From 6d102246ea02d769f28498272c98f70dcd690729 Mon Sep 17 00:00:00 2001 From: PranavPurwar Date: Tue, 26 Sep 2023 16:20:32 +0530 Subject: [PATCH] Move JAXP to its own module --- app/src/main/res/drawable/outline_redo_24.xml | 12 + .../com/google/googlejavaformat/CloseOp.java | 45 + .../googlejavaformat/CommentsHelper.java | 50 + .../java/com/google/googlejavaformat/Doc.java | 759 +++ .../google/googlejavaformat/DocBuilder.java | 114 + .../googlejavaformat/FormatterDiagnostic.java | 79 + .../googlejavaformat/FormattingError.java | 37 + .../com/google/googlejavaformat/Indent.java | 84 + .../com/google/googlejavaformat/Input.java | 147 + .../google/googlejavaformat/InputOutput.java | 119 + .../com/google/googlejavaformat/Newlines.java | 199 + .../java/com/google/googlejavaformat/Op.java | 30 + .../com/google/googlejavaformat/OpenOp.java | 51 + .../google/googlejavaformat/OpsBuilder.java | 658 +++ .../com/google/googlejavaformat/Output.java | 80 + .../java/CommandLineOptions.java | 302 ++ .../java/CommandLineOptionsParser.java | 209 + .../java/DimensionHelpers.java | 124 + .../java/FormatFileCallable.java | 118 + .../java/FormatterException.java | 58 + .../java/GoogleJavaFormatToolProvider.java | 36 + .../GoogleJavaFormatVersion.java.template | 22 + .../googlejavaformat/java/ImportOrderer.java | 483 ++ .../java/JavaCommentsHelper.java | 184 + .../java/JavaFormatterOptions.java | 89 + .../googlejavaformat/java/JavaInput.java | 670 +++ .../java/JavaInputAstVisitor.java | 3947 ++++++++++++++ .../googlejavaformat/java/JavaOutput.java | 400 ++ .../googlejavaformat/java/JavacTokens.java | 232 + .../google/googlejavaformat/java/Main.java | 279 + .../java/ModifierOrderer.java | 173 + .../java/RemoveUnusedImports.java | 358 ++ .../googlejavaformat/java/Replacement.java | 72 + .../java/SnippetFormatter.java | 215 + .../googlejavaformat/java/StringWrapper.java | 431 ++ .../google/googlejavaformat/java/Trees.java | 118 + .../java/TypeNameClassifier.java | 173 + .../googlejavaformat/java/UsageException.java | 108 + .../java/filer/FormattingFiler.java | 86 + .../java/filer/FormattingJavaFileObject.java | 94 + .../java/java17/Java17InputAstVisitor.java | 270 + .../java/javadoc/CharStream.java | 68 + .../java/javadoc/JavadocFormatter.java | 195 + .../java/javadoc/JavadocLexer.java | 557 ++ .../java/javadoc/JavadocWriter.java | 410 ++ .../java/javadoc/NestingCounter.java | 48 + .../googlejavaformat/java/javadoc/Token.java | 131 + feature/jaxp/.gitignore | 1 + feature/jaxp/build.gradle.kts | 15 + .../java_cup/internal/runtime/Scanner.java | 45 + .../sun/java_cup/internal/runtime/Symbol.java | 129 + .../java_cup/internal/runtime/lr_parser.java | 1335 +++++ .../internal/runtime/virtual_parse_stack.java | 169 + .../sun/org/apache/bcel/internal/Const.java | 3243 ++++++++++++ .../apache/bcel/internal/ExceptionConst.java | 133 + .../org/apache/bcel/internal/Repository.java | 206 + .../bcel/internal/classfile/AccessFlags.java | 217 + .../internal/classfile/AnnotationDefault.java | 96 + .../classfile/AnnotationElementValue.java | 61 + .../internal/classfile/AnnotationEntry.java | 167 + .../bcel/internal/classfile/Annotations.java | 163 + .../internal/classfile/ArrayElementValue.java | 86 + .../bcel/internal/classfile/Attribute.java | 370 ++ .../internal/classfile/AttributeReader.java | 55 + .../internal/classfile/BootstrapMethod.java | 170 + .../internal/classfile/BootstrapMethods.java | 163 + .../internal/classfile/ClassElementValue.java | 59 + .../classfile/ClassFormatException.java | 73 + .../bcel/internal/classfile/ClassParser.java | 297 ++ .../apache/bcel/internal/classfile/Code.java | 351 ++ .../internal/classfile/CodeException.java | 233 + .../bcel/internal/classfile/Constant.java | 205 + .../bcel/internal/classfile/ConstantCP.java | 144 + .../internal/classfile/ConstantClass.java | 125 + .../internal/classfile/ConstantDouble.java | 118 + .../internal/classfile/ConstantDynamic.java | 94 + .../internal/classfile/ConstantFieldref.java | 71 + .../internal/classfile/ConstantFloat.java | 119 + .../internal/classfile/ConstantInteger.java | 118 + .../classfile/ConstantInterfaceMethodref.java | 71 + .../classfile/ConstantInvokeDynamic.java | 90 + .../bcel/internal/classfile/ConstantLong.java | 118 + .../classfile/ConstantMethodHandle.java | 113 + .../classfile/ConstantMethodType.java | 102 + .../internal/classfile/ConstantMethodref.java | 71 + .../internal/classfile/ConstantModule.java | 130 + .../classfile/ConstantNameAndType.java | 143 + .../internal/classfile/ConstantObject.java | 35 + .../internal/classfile/ConstantPackage.java | 130 + .../bcel/internal/classfile/ConstantPool.java | 438 ++ .../internal/classfile/ConstantString.java | 125 + .../bcel/internal/classfile/ConstantUtf8.java | 264 + .../internal/classfile/ConstantValue.java | 161 + .../bcel/internal/classfile/Deprecated.java | 138 + .../internal/classfile/DescendingVisitor.java | 552 ++ .../bcel/internal/classfile/ElementValue.java | 178 + .../internal/classfile/ElementValuePair.java | 70 + .../bcel/internal/classfile/EmptyVisitor.java | 325 ++ .../internal/classfile/EnclosingMethod.java | 107 + .../internal/classfile/EnumElementValue.java | 72 + .../internal/classfile/ExceptionTable.java | 179 + .../apache/bcel/internal/classfile/Field.java | 198 + .../internal/classfile/FieldOrMethod.java | 265 + .../bcel/internal/classfile/InnerClass.java | 198 + .../bcel/internal/classfile/InnerClasses.java | 161 + .../bcel/internal/classfile/JavaClass.java | 864 +++ .../bcel/internal/classfile/LineNumber.java | 143 + .../internal/classfile/LineNumberTable.java | 217 + .../internal/classfile/LocalVariable.java | 282 + .../classfile/LocalVariableTable.java | 196 + .../classfile/LocalVariableTypeTable.java | 160 + .../bcel/internal/classfile/Method.java | 261 + .../internal/classfile/MethodParameter.java | 125 + .../internal/classfile/MethodParameters.java | 101 + .../bcel/internal/classfile/Module.java | 254 + .../internal/classfile/ModuleExports.java | 123 + .../internal/classfile/ModuleMainClass.java | 134 + .../bcel/internal/classfile/ModuleOpens.java | 123 + .../internal/classfile/ModulePackages.java | 166 + .../internal/classfile/ModuleProvides.java | 119 + .../internal/classfile/ModuleRequires.java | 112 + .../bcel/internal/classfile/NestHost.java | 134 + .../bcel/internal/classfile/NestMembers.java | 167 + .../apache/bcel/internal/classfile/Node.java | 30 + .../bcel/internal/classfile/PMGClass.java | 157 + .../classfile/ParameterAnnotationEntry.java | 93 + .../classfile/ParameterAnnotations.java | 125 + .../RuntimeInvisibleAnnotations.java | 61 + .../RuntimeInvisibleParameterAnnotations.java | 47 + .../classfile/RuntimeVisibleAnnotations.java | 61 + .../RuntimeVisibleParameterAnnotations.java | 47 + .../bcel/internal/classfile/Signature.java | 258 + .../classfile/SimpleElementValue.java | 183 + .../bcel/internal/classfile/SourceFile.java | 138 + .../bcel/internal/classfile/StackMap.java | 166 + .../internal/classfile/StackMapEntry.java | 419 ++ .../bcel/internal/classfile/StackMapType.java | 162 + .../bcel/internal/classfile/Synthetic.java | 145 + .../bcel/internal/classfile/Unknown.java | 164 + .../classfile/UnknownAttributeReader.java | 50 + .../bcel/internal/classfile/Utility.java | 1562 ++++++ .../bcel/internal/classfile/Visitor.java | 236 + .../bcel/internal/classfile/package.html | 30 + .../apache/bcel/internal/generic/AALOAD.java | 54 + .../apache/bcel/internal/generic/AASTORE.java | 54 + .../bcel/internal/generic/ACONST_NULL.java | 61 + .../apache/bcel/internal/generic/ALOAD.java | 60 + .../bcel/internal/generic/ANEWARRAY.java | 75 + .../apache/bcel/internal/generic/ARETURN.java | 54 + .../bcel/internal/generic/ARRAYLENGTH.java | 62 + .../apache/bcel/internal/generic/ASTORE.java | 59 + .../apache/bcel/internal/generic/ATHROW.java | 61 + .../generic/AllocationInstruction.java | 28 + .../generic/AnnotationElementValueGen.java | 77 + .../internal/generic/AnnotationEntryGen.java | 341 ++ .../generic/ArithmeticInstruction.java | 95 + .../generic/ArrayElementValueGen.java | 116 + .../internal/generic/ArrayInstruction.java | 84 + .../bcel/internal/generic/ArrayType.java | 140 + .../apache/bcel/internal/generic/BALOAD.java | 53 + .../apache/bcel/internal/generic/BASTORE.java | 53 + .../apache/bcel/internal/generic/BIPUSH.java | 105 + .../bcel/internal/generic/BREAKPOINT.java | 42 + .../bcel/internal/generic/BasicType.java | 84 + .../bcel/internal/generic/BranchHandle.java | 104 + .../internal/generic/BranchInstruction.java | 278 + .../apache/bcel/internal/generic/CALOAD.java | 54 + .../apache/bcel/internal/generic/CASTORE.java | 54 + .../bcel/internal/generic/CHECKCAST.java | 83 + .../bcel/internal/generic/CPInstruction.java | 145 + .../generic/ClassElementValueGen.java | 92 + .../bcel/internal/generic/ClassGen.java | 545 ++ .../internal/generic/ClassGenException.java | 41 + .../bcel/internal/generic/ClassObserver.java | 31 + .../internal/generic/CodeExceptionGen.java | 180 + .../internal/generic/CompoundInstruction.java | 38 + .../internal/generic/ConstantPoolGen.java | 788 +++ .../generic/ConstantPushInstruction.java | 34 + .../generic/ConversionInstruction.java | 77 + .../org/apache/bcel/internal/generic/D2F.java | 54 + .../org/apache/bcel/internal/generic/D2I.java | 54 + .../org/apache/bcel/internal/generic/D2L.java | 54 + .../apache/bcel/internal/generic/DADD.java | 56 + .../apache/bcel/internal/generic/DALOAD.java | 54 + .../apache/bcel/internal/generic/DASTORE.java | 54 + .../apache/bcel/internal/generic/DCMPG.java | 58 + .../apache/bcel/internal/generic/DCMPL.java | 58 + .../apache/bcel/internal/generic/DCONST.java | 81 + .../apache/bcel/internal/generic/DDIV.java | 56 + .../apache/bcel/internal/generic/DLOAD.java | 60 + .../apache/bcel/internal/generic/DMUL.java | 56 + .../apache/bcel/internal/generic/DNEG.java | 51 + .../apache/bcel/internal/generic/DREM.java | 56 + .../apache/bcel/internal/generic/DRETURN.java | 54 + .../apache/bcel/internal/generic/DSTORE.java | 60 + .../apache/bcel/internal/generic/DSUB.java | 56 + .../org/apache/bcel/internal/generic/DUP.java | 50 + .../apache/bcel/internal/generic/DUP2.java | 50 + .../apache/bcel/internal/generic/DUP2_X1.java | 48 + .../apache/bcel/internal/generic/DUP2_X2.java | 48 + .../apache/bcel/internal/generic/DUP_X1.java | 48 + .../apache/bcel/internal/generic/DUP_X2.java | 48 + .../internal/generic/ElementValueGen.java | 169 + .../internal/generic/ElementValuePairGen.java | 101 + .../bcel/internal/generic/EmptyVisitor.java | 755 +++ .../internal/generic/EnumElementValueGen.java | 125 + .../internal/generic/ExceptionThrower.java | 38 + .../org/apache/bcel/internal/generic/F2D.java | 54 + .../org/apache/bcel/internal/generic/F2I.java | 54 + .../org/apache/bcel/internal/generic/F2L.java | 54 + .../apache/bcel/internal/generic/FADD.java | 54 + .../apache/bcel/internal/generic/FALOAD.java | 54 + .../apache/bcel/internal/generic/FASTORE.java | 54 + .../apache/bcel/internal/generic/FCMPG.java | 58 + .../apache/bcel/internal/generic/FCMPL.java | 58 + .../apache/bcel/internal/generic/FCONST.java | 83 + .../apache/bcel/internal/generic/FDIV.java | 54 + .../apache/bcel/internal/generic/FLOAD.java | 60 + .../apache/bcel/internal/generic/FMUL.java | 54 + .../apache/bcel/internal/generic/FNEG.java | 51 + .../apache/bcel/internal/generic/FREM.java | 54 + .../apache/bcel/internal/generic/FRETURN.java | 54 + .../apache/bcel/internal/generic/FSTORE.java | 60 + .../apache/bcel/internal/generic/FSUB.java | 54 + .../bcel/internal/generic/FieldGen.java | 347 ++ .../internal/generic/FieldGenOrMethodGen.java | 177 + .../internal/generic/FieldInstruction.java | 80 + .../bcel/internal/generic/FieldObserver.java | 31 + .../bcel/internal/generic/FieldOrMethod.java | 132 + .../bcel/internal/generic/GETFIELD.java | 80 + .../bcel/internal/generic/GETSTATIC.java | 80 + .../apache/bcel/internal/generic/GOTO.java | 95 + .../apache/bcel/internal/generic/GOTO_W.java | 79 + .../internal/generic/GotoInstruction.java | 38 + .../org/apache/bcel/internal/generic/I2B.java | 54 + .../org/apache/bcel/internal/generic/I2C.java | 54 + .../org/apache/bcel/internal/generic/I2D.java | 54 + .../org/apache/bcel/internal/generic/I2F.java | 54 + .../org/apache/bcel/internal/generic/I2L.java | 54 + .../org/apache/bcel/internal/generic/I2S.java | 51 + .../apache/bcel/internal/generic/IADD.java | 54 + .../apache/bcel/internal/generic/IALOAD.java | 54 + .../apache/bcel/internal/generic/IAND.java | 51 + .../apache/bcel/internal/generic/IASTORE.java | 54 + .../apache/bcel/internal/generic/ICONST.java | 77 + .../apache/bcel/internal/generic/IDIV.java | 65 + .../apache/bcel/internal/generic/IFEQ.java | 64 + .../apache/bcel/internal/generic/IFGE.java | 64 + .../apache/bcel/internal/generic/IFGT.java | 64 + .../apache/bcel/internal/generic/IFLE.java | 64 + .../apache/bcel/internal/generic/IFLT.java | 64 + .../apache/bcel/internal/generic/IFNE.java | 64 + .../bcel/internal/generic/IFNONNULL.java | 64 + .../apache/bcel/internal/generic/IFNULL.java | 64 + .../bcel/internal/generic/IF_ACMPEQ.java | 64 + .../bcel/internal/generic/IF_ACMPNE.java | 64 + .../bcel/internal/generic/IF_ICMPEQ.java | 64 + .../bcel/internal/generic/IF_ICMPGE.java | 64 + .../bcel/internal/generic/IF_ICMPGT.java | 64 + .../bcel/internal/generic/IF_ICMPLE.java | 64 + .../bcel/internal/generic/IF_ICMPLT.java | 64 + .../bcel/internal/generic/IF_ICMPNE.java | 64 + .../apache/bcel/internal/generic/IINC.java | 163 + .../apache/bcel/internal/generic/ILOAD.java | 60 + .../apache/bcel/internal/generic/IMPDEP1.java | 43 + .../apache/bcel/internal/generic/IMPDEP2.java | 43 + .../apache/bcel/internal/generic/IMUL.java | 54 + .../apache/bcel/internal/generic/INEG.java | 51 + .../bcel/internal/generic/INSTANCEOF.java | 75 + .../bcel/internal/generic/INVOKEDYNAMIC.java | 130 + .../internal/generic/INVOKEINTERFACE.java | 129 + .../bcel/internal/generic/INVOKESPECIAL.java | 88 + .../bcel/internal/generic/INVOKESTATIC.java | 87 + .../bcel/internal/generic/INVOKEVIRTUAL.java | 87 + .../org/apache/bcel/internal/generic/IOR.java | 51 + .../apache/bcel/internal/generic/IREM.java | 65 + .../apache/bcel/internal/generic/IRETURN.java | 54 + .../apache/bcel/internal/generic/ISHL.java | 51 + .../apache/bcel/internal/generic/ISHR.java | 51 + .../apache/bcel/internal/generic/ISTORE.java | 60 + .../apache/bcel/internal/generic/ISUB.java | 54 + .../apache/bcel/internal/generic/IUSHR.java | 51 + .../apache/bcel/internal/generic/IXOR.java | 51 + .../bcel/internal/generic/IfInstruction.java | 47 + .../internal/generic/IndexedInstruction.java | 32 + .../bcel/internal/generic/Instruction.java | 601 +++ .../generic/InstructionComparator.java | 60 + .../internal/generic/InstructionConst.java | 299 ++ .../internal/generic/InstructionFactory.java | 739 +++ .../internal/generic/InstructionHandle.java | 308 ++ .../internal/generic/InstructionList.java | 1194 +++++ .../generic/InstructionListObserver.java | 31 + .../internal/generic/InstructionTargeter.java | 48 + .../internal/generic/InvokeInstruction.java | 147 + .../org/apache/bcel/internal/generic/JSR.java | 86 + .../apache/bcel/internal/generic/JSR_W.java | 79 + .../bcel/internal/generic/JsrInstruction.java | 74 + .../org/apache/bcel/internal/generic/L2D.java | 51 + .../org/apache/bcel/internal/generic/L2F.java | 51 + .../org/apache/bcel/internal/generic/L2I.java | 51 + .../apache/bcel/internal/generic/LADD.java | 53 + .../apache/bcel/internal/generic/LALOAD.java | 54 + .../apache/bcel/internal/generic/LAND.java | 53 + .../apache/bcel/internal/generic/LASTORE.java | 54 + .../apache/bcel/internal/generic/LCMP.java | 59 + .../apache/bcel/internal/generic/LCONST.java | 80 + .../org/apache/bcel/internal/generic/LDC.java | 150 + .../apache/bcel/internal/generic/LDC2_W.java | 81 + .../apache/bcel/internal/generic/LDC_W.java | 57 + .../apache/bcel/internal/generic/LDIV.java | 61 + .../apache/bcel/internal/generic/LLOAD.java | 55 + .../apache/bcel/internal/generic/LMUL.java | 53 + .../apache/bcel/internal/generic/LNEG.java | 51 + .../bcel/internal/generic/LOOKUPSWITCH.java | 101 + .../org/apache/bcel/internal/generic/LOR.java | 51 + .../apache/bcel/internal/generic/LREM.java | 59 + .../apache/bcel/internal/generic/LRETURN.java | 51 + .../apache/bcel/internal/generic/LSHL.java | 51 + .../apache/bcel/internal/generic/LSHR.java | 51 + .../apache/bcel/internal/generic/LSTORE.java | 55 + .../apache/bcel/internal/generic/LSUB.java | 53 + .../apache/bcel/internal/generic/LUSHR.java | 51 + .../apache/bcel/internal/generic/LXOR.java | 51 + .../bcel/internal/generic/LineNumberGen.java | 108 + .../bcel/internal/generic/LoadClass.java | 48 + .../internal/generic/LoadInstruction.java | 60 + .../internal/generic/LocalVariableGen.java | 236 + .../generic/LocalVariableInstruction.java | 220 + .../bcel/internal/generic/MONITORENTER.java | 56 + .../bcel/internal/generic/MONITOREXIT.java | 56 + .../bcel/internal/generic/MULTIANEWARRAY.java | 142 + .../bcel/internal/generic/MethodGen.java | 1175 +++++ .../bcel/internal/generic/MethodObserver.java | 31 + .../org/apache/bcel/internal/generic/NEW.java | 72 + .../bcel/internal/generic/NEWARRAY.java | 118 + .../org/apache/bcel/internal/generic/NOP.java | 43 + .../generic/NameSignatureInstruction.java | 67 + .../bcel/internal/generic/NamedAndTyped.java | 36 + .../bcel/internal/generic/ObjectType.java | 159 + .../org/apache/bcel/internal/generic/POP.java | 50 + .../apache/bcel/internal/generic/POP2.java | 50 + .../apache/bcel/internal/generic/PUSH.java | 200 + .../bcel/internal/generic/PUTFIELD.java | 81 + .../bcel/internal/generic/PUTSTATIC.java | 80 + .../bcel/internal/generic/PopInstruction.java | 31 + .../internal/generic/PushInstruction.java | 37 + .../org/apache/bcel/internal/generic/RET.java | 140 + .../apache/bcel/internal/generic/RETURN.java | 51 + .../bcel/internal/generic/ReferenceType.java | 264 + .../internal/generic/ReturnInstruction.java | 78 + .../internal/generic/ReturnaddressType.java | 83 + .../apache/bcel/internal/generic/SALOAD.java | 51 + .../apache/bcel/internal/generic/SASTORE.java | 51 + .../apache/bcel/internal/generic/SIPUSH.java | 103 + .../apache/bcel/internal/generic/SWAP.java | 50 + .../apache/bcel/internal/generic/SWITCH.java | 139 + .../apache/bcel/internal/generic/Select.java | 372 ++ .../generic/SimpleElementValueGen.java | 239 + .../bcel/internal/generic/StackConsumer.java | 33 + .../internal/generic/StackInstruction.java | 48 + .../bcel/internal/generic/StackProducer.java | 33 + .../internal/generic/StoreInstruction.java | 60 + .../bcel/internal/generic/TABLESWITCH.java | 109 + .../internal/generic/TargetLostException.java | 67 + .../apache/bcel/internal/generic/Type.java | 399 ++ .../internal/generic/TypedInstruction.java | 30 + .../internal/generic/UnconditionalBranch.java | 31 + .../generic/VariableLengthInstruction.java | 34 + .../apache/bcel/internal/generic/Visitor.java | 394 ++ .../apache/bcel/internal/generic/package.html | 32 + .../sun/org/apache/bcel/internal/package.html | 33 + .../org/apache/bcel/internal/util/Args.java | 148 + .../bcel/internal/util/AttributeHTML.java | 195 + .../bcel/internal/util/BCELComparator.java | 47 + .../bcel/internal/util/BCELFactory.java | 340 ++ .../apache/bcel/internal/util/BCELifier.java | 322 ++ .../bcel/internal/util/ByteSequence.java | 65 + .../apache/bcel/internal/util/Class2HTML.java | 231 + .../apache/bcel/internal/util/ClassQueue.java | 54 + .../apache/bcel/internal/util/ClassSet.java | 58 + .../apache/bcel/internal/util/ClassStack.java | 52 + .../apache/bcel/internal/util/CodeHTML.java | 565 ++ .../bcel/internal/util/ConstantHTML.java | 203 + .../bcel/internal/util/InstructionFinder.java | 392 ++ .../apache/bcel/internal/util/MethodHTML.java | 152 + .../internal/util/ModularRuntimeImage.java | 142 + .../apache/bcel/internal/util/Repository.java | 66 + .../internal/util/SyntheticRepository.java | 158 + .../apache/bcel/internal/util/package.html | 41 + .../extensions/ExpressionContext.java | 94 + .../xalan/internal/extensions/package.html | 28 + .../apache/xalan/internal/lib/ExsltBase.java | 85 + .../xalan/internal/lib/ExsltCommon.java | 107 + .../xalan/internal/lib/ExsltDatetime.java | 1120 ++++ .../xalan/internal/lib/ExsltDynamic.java | 612 +++ .../apache/xalan/internal/lib/ExsltMath.java | 389 ++ .../apache/xalan/internal/lib/ExsltSets.java | 241 + .../xalan/internal/lib/ExsltStrings.java | 325 ++ .../apache/xalan/internal/lib/Extensions.java | 268 + .../apache/xalan/internal/lib/NodeInfo.java | 248 + .../apache/xalan/internal/lib/package.html | 29 + .../xalan/internal/res/XSLMessages.java | 91 + .../internal/res/XSLTErrorResources.java | 1425 +++++ .../internal/res/XSLTErrorResources_de.java | 1425 +++++ .../internal/res/XSLTErrorResources_en.java | 32 + .../internal/res/XSLTErrorResources_es.java | 1425 +++++ .../internal/res/XSLTErrorResources_fr.java | 1425 +++++ .../internal/res/XSLTErrorResources_it.java | 1425 +++++ .../internal/res/XSLTErrorResources_ja.java | 1425 +++++ .../internal/res/XSLTErrorResources_ko.java | 1425 +++++ .../res/XSLTErrorResources_pt_BR.java | 1425 +++++ .../internal/res/XSLTErrorResources_sv.java | 1425 +++++ .../res/XSLTErrorResources_zh_CN.java | 1425 +++++ .../res/XSLTErrorResources_zh_TW.java | 1425 +++++ .../xalan/internal/res/XSLTInfo.properties | 32 + .../apache/xalan/internal/res/package.html | 28 + .../xalan/internal/templates/Constants.java | 400 ++ .../xalan/internal/templates/package.html | 15 + .../internal/utils/ConfigurationError.java | 61 + .../internal/utils/FeaturePropertyBase.java | 217 + .../xalan/internal/utils/ObjectFactory.java | 209 + .../utils/XMLSecurityPropertyManager.java | 101 + .../apache/xalan/internal/xslt/package.html | 28 + .../xalan/internal/xsltc/CollatorFactory.java | 35 + .../org/apache/xalan/internal/xsltc/DOM.java | 103 + .../apache/xalan/internal/xsltc/DOMCache.java | 56 + .../internal/xsltc/DOMEnhancedForDTM.java | 46 + .../xalan/internal/xsltc/NodeIterator.java | 84 + .../internal/xsltc/ProcessorVersion.java | 49 + .../xalan/internal/xsltc/StripFilter.java | 31 + .../apache/xalan/internal/xsltc/Translet.java | 55 + .../internal/xsltc/TransletException.java | 46 + .../xsltc/compiler/AbsoluteLocationPath.java | 128 + .../xsltc/compiler/AbsolutePathPattern.java | 140 + .../xsltc/compiler/AlternativePattern.java | 100 + .../xsltc/compiler/AncestorPattern.java | 182 + .../internal/xsltc/compiler/ApplyImports.java | 159 + .../xsltc/compiler/ApplyTemplates.java | 206 + .../internal/xsltc/compiler/ArgumentList.java | 42 + .../internal/xsltc/compiler/Attribute.java | 45 + .../internal/xsltc/compiler/AttributeSet.java | 210 + .../xsltc/compiler/AttributeValue.java | 48 + .../compiler/AttributeValueTemplate.java | 263 + .../internal/xsltc/compiler/BinOpExpr.java | 130 + .../internal/xsltc/compiler/BooleanCall.java | 56 + .../internal/xsltc/compiler/BooleanExpr.java | 79 + .../internal/xsltc/compiler/CallTemplate.java | 244 + .../internal/xsltc/compiler/CastCall.java | 99 + .../internal/xsltc/compiler/CastExpr.java | 241 + .../internal/xsltc/compiler/CeilingCall.java | 47 + .../xalan/internal/xsltc/compiler/Choose.java | 171 + .../internal/xsltc/compiler/Closure.java | 50 + .../internal/xsltc/compiler/Comment.java | 116 + .../xsltc/compiler/CompilerException.java | 54 + .../internal/xsltc/compiler/ConcatCall.java | 94 + .../internal/xsltc/compiler/Constants.java | 595 +++ .../internal/xsltc/compiler/ContainsCall.java | 106 + .../xalan/internal/xsltc/compiler/Copy.java | 157 + .../xalan/internal/xsltc/compiler/CopyOf.java | 141 + .../internal/xsltc/compiler/CurrentCall.java | 39 + .../xsltc/compiler/DecimalFormatting.java | 256 + .../internal/xsltc/compiler/DocumentCall.java | 154 + .../xsltc/compiler/ElementAvailableCall.java | 92 + .../internal/xsltc/compiler/EqualityExpr.java | 359 ++ .../internal/xsltc/compiler/Expression.java | 221 + .../internal/xsltc/compiler/Fallback.java | 79 + .../internal/xsltc/compiler/FilterExpr.java | 249 + .../xsltc/compiler/FilterParentPath.java | 174 + .../FilteredAbsoluteLocationPath.java | 125 + .../internal/xsltc/compiler/FloorCall.java | 45 + .../internal/xsltc/compiler/FlowList.java | 117 + .../internal/xsltc/compiler/ForEach.java | 199 + .../xsltc/compiler/FormatNumberCall.java | 113 + .../xsltc/compiler/FunctionAvailableCall.java | 192 + .../internal/xsltc/compiler/FunctionCall.java | 1186 +++++ .../xsltc/compiler/GenerateIdCall.java | 54 + .../internal/xsltc/compiler/IdKeyPattern.java | 127 + .../internal/xsltc/compiler/IdPattern.java | 35 + .../xalan/internal/xsltc/compiler/If.java | 110 + .../xsltc/compiler/IllegalCharException.java | 33 + .../xalan/internal/xsltc/compiler/Import.java | 166 + .../internal/xsltc/compiler/Include.java | 165 + .../internal/xsltc/compiler/Instruction.java | 50 + .../internal/xsltc/compiler/IntExpr.java | 56 + .../xalan/internal/xsltc/compiler/Key.java | 302 ++ .../internal/xsltc/compiler/KeyCall.java | 224 + .../internal/xsltc/compiler/KeyPattern.java | 34 + .../internal/xsltc/compiler/LangCall.java | 90 + .../internal/xsltc/compiler/LastCall.java | 69 + .../xsltc/compiler/LiteralAttribute.java | 157 + .../xsltc/compiler/LiteralElement.java | 509 ++ .../internal/xsltc/compiler/LiteralExpr.java | 85 + .../xsltc/compiler/LocalNameCall.java | 73 + .../xsltc/compiler/LocationPathPattern.java | 107 + .../internal/xsltc/compiler/LogicalExpr.java | 233 + .../internal/xsltc/compiler/Message.java | 168 + .../xalan/internal/xsltc/compiler/Mode.java | 1498 ++++++ .../internal/xsltc/compiler/NameBase.java | 127 + .../internal/xsltc/compiler/NameCall.java | 65 + .../xsltc/compiler/NamespaceAlias.java | 55 + .../xsltc/compiler/NamespaceUriCall.java | 66 + .../internal/xsltc/compiler/NodeTest.java | 43 + .../internal/xsltc/compiler/NotCall.java | 57 + .../xalan/internal/xsltc/compiler/Number.java | 597 +++ .../internal/xsltc/compiler/NumberCall.java | 67 + .../internal/xsltc/compiler/Otherwise.java | 53 + .../xalan/internal/xsltc/compiler/Output.java | 419 ++ .../xalan/internal/xsltc/compiler/Param.java | 256 + .../internal/xsltc/compiler/ParameterRef.java | 109 + .../xsltc/compiler/ParentLocationPath.java | 250 + .../xsltc/compiler/ParentPattern.java | 151 + .../xalan/internal/xsltc/compiler/Parser.java | 1471 ++++++ .../internal/xsltc/compiler/Pattern.java | 60 + .../internal/xsltc/compiler/PositionCall.java | 67 + .../internal/xsltc/compiler/Predicate.java | 617 +++ .../xsltc/compiler/ProcessingInstruction.java | 140 + .../ProcessingInstructionPattern.java | 158 + .../xalan/internal/xsltc/compiler/QName.java | 85 + .../internal/xsltc/compiler/RealExpr.java | 56 + .../xsltc/compiler/RelationalExpr.java | 281 + .../xsltc/compiler/RelativeLocationPath.java | 31 + .../xsltc/compiler/RelativePathPattern.java | 28 + .../internal/xsltc/compiler/RoundCall.java | 50 + .../xsltc/compiler/SimpleAttributeValue.java | 75 + .../xalan/internal/xsltc/compiler/Sort.java | 732 +++ .../internal/xsltc/compiler/SourceLoader.java | 42 + .../xsltc/compiler/StartsWithCall.java | 90 + .../xalan/internal/xsltc/compiler/Step.java | 532 ++ .../internal/xsltc/compiler/StepPattern.java | 524 ++ .../internal/xsltc/compiler/StringCall.java | 73 + .../xsltc/compiler/StringLengthCall.java | 55 + .../internal/xsltc/compiler/Stylesheet.java | 1425 +++++ .../internal/xsltc/compiler/SymbolTable.java | 297 ++ .../xsltc/compiler/SyntaxTreeNode.java | 920 ++++ .../internal/xsltc/compiler/Template.java | 341 ++ .../internal/xsltc/compiler/TestSeq.java | 283 + .../xalan/internal/xsltc/compiler/Text.java | 245 + .../xsltc/compiler/TopLevelElement.java | 100 + .../xsltc/compiler/TransletOutput.java | 149 + .../internal/xsltc/compiler/UnaryOpExpr.java | 88 + .../xsltc/compiler/UnionPathExpr.java | 146 + .../xsltc/compiler/UnparsedEntityUriCall.java | 69 + .../xsltc/compiler/UnresolvedRef.java | 102 + .../xsltc/compiler/UnsupportedElement.java | 152 + .../xsltc/compiler/UseAttributeSets.java | 113 + .../internal/xsltc/compiler/ValueOf.java | 138 + .../internal/xsltc/compiler/Variable.java | 203 + .../internal/xsltc/compiler/VariableBase.java | 301 ++ .../internal/xsltc/compiler/VariableRef.java | 95 + .../xsltc/compiler/VariableRefBase.java | 163 + .../xalan/internal/xsltc/compiler/When.java | 105 + .../internal/xsltc/compiler/Whitespace.java | 529 ++ .../internal/xsltc/compiler/WithParam.java | 253 + .../internal/xsltc/compiler/XPathLexer.java | 1621 ++++++ .../internal/xsltc/compiler/XPathParser.java | 2849 ++++++++++ .../xalan/internal/xsltc/compiler/XSLTC.java | 1026 ++++ .../internal/xsltc/compiler/XslAttribute.java | 294 ++ .../internal/xsltc/compiler/XslElement.java | 281 + .../xalan/internal/xsltc/compiler/sym.java | 100 + .../util/AttributeSetMethodGenerator.java | 76 + .../xsltc/compiler/util/BooleanType.java | 223 + .../xsltc/compiler/util/ClassGenerator.java | 142 + .../xsltc/compiler/util/CompareGenerator.java | 118 + .../xsltc/compiler/util/ErrorMessages.java | 1049 ++++ .../xsltc/compiler/util/ErrorMessages_ca.java | 861 +++ .../xsltc/compiler/util/ErrorMessages_cs.java | 861 +++ .../xsltc/compiler/util/ErrorMessages_de.java | 988 ++++ .../xsltc/compiler/util/ErrorMessages_es.java | 988 ++++ .../xsltc/compiler/util/ErrorMessages_fr.java | 988 ++++ .../xsltc/compiler/util/ErrorMessages_it.java | 988 ++++ .../xsltc/compiler/util/ErrorMessages_ja.java | 988 ++++ .../xsltc/compiler/util/ErrorMessages_ko.java | 988 ++++ .../compiler/util/ErrorMessages_pt_BR.java | 988 ++++ .../xsltc/compiler/util/ErrorMessages_sk.java | 861 +++ .../xsltc/compiler/util/ErrorMessages_sv.java | 988 ++++ .../compiler/util/ErrorMessages_zh_CN.java | 988 ++++ .../compiler/util/ErrorMessages_zh_TW.java | 988 ++++ .../xsltc/compiler/util/ErrorMsg.java | 334 ++ .../xsltc/compiler/util/FilterGenerator.java | 64 + .../internal/xsltc/compiler/util/IntType.java | 300 ++ .../xsltc/compiler/util/InternalError.java | 39 + .../compiler/util/MarkerInstruction.java | 96 + .../xsltc/compiler/util/MatchGenerator.java | 102 + .../xsltc/compiler/util/MethodGenerator.java | 2103 ++++++++ .../xsltc/compiler/util/MethodType.java | 172 + .../xsltc/compiler/util/MultiHashtable.java | 90 + .../compiler/util/NamedMethodGenerator.java | 65 + .../compiler/util/NodeCounterGenerator.java | 73 + .../xsltc/compiler/util/NodeSetType.java | 329 ++ .../util/NodeSortRecordFactGenerator.java | 47 + .../util/NodeSortRecordGenerator.java | 63 + .../xsltc/compiler/util/NodeType.java | 322 ++ .../xsltc/compiler/util/NumberType.java | 37 + .../xsltc/compiler/util/ObjectType.java | 177 + .../compiler/util/OutlineableChunkEnd.java | 69 + .../compiler/util/OutlineableChunkStart.java | 79 + .../xsltc/compiler/util/RealType.java | 341 ++ .../xsltc/compiler/util/ReferenceType.java | 375 ++ .../xsltc/compiler/util/ResultTreeType.java | 463 ++ .../compiler/util/RtMethodGenerator.java | 68 + .../xsltc/compiler/util/SlotAllocator.java | 100 + .../xsltc/compiler/util/StringStack.java | 43 + .../xsltc/compiler/util/StringType.java | 229 + .../xsltc/compiler/util/TestGenerator.java | 115 + .../internal/xsltc/compiler/util/Type.java | 297 ++ .../xsltc/compiler/util/TypeCheckError.java | 77 + .../internal/xsltc/compiler/util/Util.java | 201 + .../xsltc/compiler/util/VoidType.java | 98 + .../internal/xsltc/dom/AbsoluteIterator.java | 99 + .../xsltc/dom/AdaptiveResultTreeImpl.java | 1346 +++++ .../internal/xsltc/dom/AnyNodeCounter.java | 129 + .../xsltc/dom/ArrayNodeListIterator.java | 90 + .../xalan/internal/xsltc/dom/BitArray.java | 266 + .../xsltc/dom/CachedNodeListIterator.java | 113 + .../xsltc/dom/ClonedNodeListIterator.java | 81 + .../xsltc/dom/CollatorFactoryBase.java | 50 + .../xsltc/dom/CurrentNodeListFilter.java | 35 + .../xsltc/dom/CurrentNodeListIterator.java | 199 + .../xalan/internal/xsltc/dom/DOMAdapter.java | 464 ++ .../xalan/internal/xsltc/dom/DOMBuilder.java | 28 + .../xalan/internal/xsltc/dom/DOMWSFilter.java | 133 + .../internal/xsltc/dom/DocumentCache.java | 338 ++ .../internal/xsltc/dom/DupFilterIterator.java | 164 + .../xalan/internal/xsltc/dom/EmptyFilter.java | 32 + .../xalan/internal/xsltc/dom/ExtendedSAX.java | 35 + .../xalan/internal/xsltc/dom/Filter.java | 30 + .../internal/xsltc/dom/FilterIterator.java | 118 + .../xsltc/dom/FilteredStepIterator.java | 54 + .../xsltc/dom/ForwardPositionIterator.java | 107 + .../xalan/internal/xsltc/dom/KeyIndex.java | 914 ++++ .../internal/xsltc/dom/LoadDocument.java | 300 ++ .../internal/xsltc/dom/MatchingIterator.java | 127 + .../xalan/internal/xsltc/dom/MultiDOM.java | 720 +++ .../dom/MultiValuedNodeHeapIterator.java | 297 ++ .../xsltc/dom/MultipleNodeCounter.java | 118 + .../xalan/internal/xsltc/dom/NodeCounter.java | 414 ++ .../internal/xsltc/dom/NodeIteratorBase.java | 170 + .../internal/xsltc/dom/NodeSortRecord.java | 222 + .../xsltc/dom/NodeSortRecordFactory.java | 175 + .../xalan/internal/xsltc/dom/NthIterator.java | 115 + .../xalan/internal/xsltc/dom/SAXImpl.java | 1885 +++++++ .../xsltc/dom/SimpleResultTreeImpl.java | 1022 ++++ .../internal/xsltc/dom/SingleNodeCounter.java | 156 + .../internal/xsltc/dom/SingletonIterator.java | 92 + .../internal/xsltc/dom/SortSettings.java | 138 + .../internal/xsltc/dom/SortingIterator.java | 149 + .../internal/xsltc/dom/StepIterator.java | 138 + .../xsltc/dom/StripWhitespaceFilter.java | 32 + .../internal/xsltc/dom/UnionIterator.java | 98 + .../internal/xsltc/dom/XSLTCDTMManager.java | 447 ++ .../xsltc/runtime/AbstractTranslet.java | 820 +++ .../internal/xsltc/runtime/Attributes.java | 63 + .../internal/xsltc/runtime/BasisLibrary.java | 1692 ++++++ .../internal/xsltc/runtime/Constants.java | 51 + .../internal/xsltc/runtime/ErrorMessages.java | 285 + .../xsltc/runtime/ErrorMessages_ca.java | 232 + .../xsltc/runtime/ErrorMessages_cs.java | 232 + .../xsltc/runtime/ErrorMessages_de.java | 285 + .../xsltc/runtime/ErrorMessages_es.java | 285 + .../xsltc/runtime/ErrorMessages_fr.java | 285 + .../xsltc/runtime/ErrorMessages_it.java | 285 + .../xsltc/runtime/ErrorMessages_ja.java | 285 + .../xsltc/runtime/ErrorMessages_ko.java | 285 + .../xsltc/runtime/ErrorMessages_pt_BR.java | 285 + .../xsltc/runtime/ErrorMessages_sk.java | 232 + .../xsltc/runtime/ErrorMessages_sv.java | 285 + .../xsltc/runtime/ErrorMessages_zh_CN.java | 285 + .../xsltc/runtime/ErrorMessages_zh_TW.java | 285 + .../xsltc/runtime/InternalRuntimeError.java | 37 + .../xsltc/runtime/MessageHandler.java | 37 + .../xalan/internal/xsltc/runtime/Node.java | 38 + .../internal/xsltc/runtime/Operators.java | 58 + .../internal/xsltc/runtime/Parameter.java | 46 + .../xsltc/runtime/StringValueHandler.java | 125 + .../xsltc/runtime/output/OutputBuffer.java | 34 + .../runtime/output/StringOutputBuffer.java | 53 + .../output/TransletOutputHandlerFactory.java | 275 + .../runtime/output/WriterOutputBuffer.java | 86 + .../xalan/internal/xsltc/trax/DOM2SAX.java | 424 ++ .../xalan/internal/xsltc/trax/DOM2TO.java | 435 ++ .../internal/xsltc/trax/OutputSettings.java | 47 + .../xalan/internal/xsltc/trax/SAX2DOM.java | 335 ++ .../xsltc/trax/SAX2StAXBaseWriter.java | 265 + .../xsltc/trax/SAX2StAXEventWriter.java | 327 ++ .../xsltc/trax/SAX2StAXStreamWriter.java | 208 + .../internal/xsltc/trax/StAXEvent2SAX.java | 599 +++ .../internal/xsltc/trax/StAXStream2SAX.java | 578 ++ .../xsltc/trax/TemplatesHandlerImpl.java | 361 ++ .../internal/xsltc/trax/TemplatesImpl.java | 628 +++ .../xalan/internal/xsltc/trax/TrAXFilter.java | 119 + .../xsltc/trax/TransformerFactoryImpl.java | 1630 ++++++ .../xsltc/trax/TransformerHandlerImpl.java | 511 ++ .../internal/xsltc/trax/TransformerImpl.java | 1413 +++++ .../xalan/internal/xsltc/trax/Util.java | 235 + .../internal/xsltc/trax/XSLTCSource.java | 138 + .../internal/xsltc/util/IntegerArray.java | 226 + .../xerces/internal/dom/AbortException.java | 36 + .../apache/xerces/internal/dom/AttrImpl.java | 1241 +++++ .../xerces/internal/dom/AttrNSImpl.java | 328 ++ .../xerces/internal/dom/AttributeMap.java | 605 +++ .../xerces/internal/dom/CDATASectionImpl.java | 90 + .../internal/dom/CharacterDataImpl.java | 426 ++ .../apache/xerces/internal/dom/ChildNode.java | 149 + .../xerces/internal/dom/CommentImpl.java | 72 + .../dom/CoreDOMImplementationImpl.java | 644 +++ .../xerces/internal/dom/CoreDocumentImpl.java | 2847 ++++++++++ .../internal/dom/DOMConfigurationImpl.java | 1240 +++++ .../xerces/internal/dom/DOMErrorImpl.java | 137 + .../internal/dom/DOMImplementationImpl.java | 155 + .../dom/DOMImplementationListImpl.java | 77 + .../dom/DOMImplementationSourceImpl.java | 139 + .../xerces/internal/dom/DOMInputImpl.java | 392 ++ .../xerces/internal/dom/DOMLocatorImpl.java | 163 + .../internal/dom/DOMMessageFormatter.java | 143 + .../xerces/internal/dom/DOMNormalizer.java | 2103 ++++++++ .../xerces/internal/dom/DOMOutputImpl.java | 174 + .../internal/dom/DOMStringListImpl.java | 91 + .../dom/DOMXSImplementationSourceImpl.java | 104 + .../xerces/internal/dom/DeepNodeListImpl.java | 242 + .../xerces/internal/dom/DeferredAttrImpl.java | 146 + .../internal/dom/DeferredAttrNSImpl.java | 131 + .../dom/DeferredCDATASectionImpl.java | 110 + .../internal/dom/DeferredCommentImpl.java | 91 + .../dom/DeferredDOMImplementationImpl.java | 60 + .../internal/dom/DeferredDocumentImpl.java | 2126 ++++++++ .../dom/DeferredDocumentTypeImpl.java | 188 + .../dom/DeferredElementDefinitionImpl.java | 127 + .../internal/dom/DeferredElementImpl.java | 139 + .../internal/dom/DeferredElementNSImpl.java | 162 + .../internal/dom/DeferredEntityImpl.java | 154 + .../dom/DeferredEntityReferenceImpl.java | 156 + .../xerces/internal/dom/DeferredNode.java | 44 + .../internal/dom/DeferredNotationImpl.java | 118 + .../DeferredProcessingInstructionImpl.java | 95 + .../xerces/internal/dom/DeferredTextImpl.java | 108 + .../internal/dom/DocumentFragmentImpl.java | 156 + .../xerces/internal/dom/DocumentImpl.java | 1380 +++++ .../xerces/internal/dom/DocumentTypeImpl.java | 559 ++ .../internal/dom/ElementDefinitionImpl.java | 122 + .../xerces/internal/dom/ElementImpl.java | 1362 +++++ .../xerces/internal/dom/ElementNSImpl.java | 383 ++ .../xerces/internal/dom/EntityImpl.java | 368 ++ .../internal/dom/EntityReferenceImpl.java | 403 ++ .../apache/xerces/internal/dom/LCount.java | 47 + .../xerces/internal/dom/NamedNodeMapImpl.java | 625 +++ .../apache/xerces/internal/dom/NodeImpl.java | 2022 +++++++ .../xerces/internal/dom/NodeIteratorImpl.java | 375 ++ .../xerces/internal/dom/NodeListCache.java | 59 + .../xerces/internal/dom/NotationImpl.java | 213 + .../xerces/internal/dom/PSVIAttrNSImpl.java | 285 + .../dom/PSVIDOMImplementationImpl.java | 92 + .../xerces/internal/dom/PSVIDocumentImpl.java | 151 + .../internal/dom/PSVIElementNSImpl.java | 333 ++ .../xerces/internal/dom/ParentNode.java | 1034 ++++ .../dom/ProcessingInstructionImpl.java | 162 + .../internal/dom/RangeExceptionImpl.java | 39 + .../apache/xerces/internal/dom/RangeImpl.java | 2086 ++++++++ .../apache/xerces/internal/dom/TextImpl.java | 661 +++ .../xerces/internal/dom/TreeWalkerImpl.java | 508 ++ .../xerces/internal/dom/events/EventImpl.java | 137 + .../dom/events/MutationEventImpl.java | 113 + .../xerces/internal/impl/Constants.java | 793 +++ .../internal/impl/ExternalSubsetResolver.java | 67 + .../xerces/internal/impl/PropertyManager.java | 236 + .../internal/impl/RevalidationHandler.java | 44 + .../internal/impl/XML11DTDScannerImpl.java | 256 + .../impl/XML11DocumentScannerImpl.java | 500 ++ .../internal/impl/XML11EntityScanner.java | 1288 +++++ .../impl/XML11NSDocumentScannerImpl.java | 892 ++++ .../internal/impl/XML11NamespaceBinder.java | 66 + .../internal/impl/XMLDTDScannerImpl.java | 2191 ++++++++ .../impl/XMLDocumentFragmentScannerImpl.java | 3261 ++++++++++++ .../internal/impl/XMLDocumentScannerImpl.java | 1512 ++++++ .../internal/impl/XMLEntityDescription.java | 51 + .../internal/impl/XMLEntityHandler.java | 79 + .../internal/impl/XMLEntityManager.java | 3175 +++++++++++ .../internal/impl/XMLEntityScanner.java | 2203 ++++++++ .../internal/impl/XMLErrorReporter.java | 612 +++ .../impl/XMLNSDocumentScannerImpl.java | 648 +++ .../internal/impl/XMLNamespaceBinder.java | 848 +++ .../xerces/internal/impl/XMLScanner.java | 1550 ++++++ .../internal/impl/XMLStreamFilterImpl.java | 539 ++ .../internal/impl/XMLStreamReaderImpl.java | 1490 ++++++ .../internal/impl/XMLVersionDetector.java | 254 + .../internal/impl/dtd/BalancedDTDGrammar.java | 287 + .../xerces/internal/impl/dtd/DTDGrammar.java | 2656 ++++++++++ .../internal/impl/dtd/DTDGrammarBucket.java | 112 + .../internal/impl/dtd/XML11DTDProcessor.java | 88 + .../internal/impl/dtd/XML11DTDValidator.java | 86 + .../impl/dtd/XML11NSDTDValidator.java | 226 + .../internal/impl/dtd/XMLAttributeDecl.java | 70 + .../internal/impl/dtd/XMLContentSpec.java | 296 ++ .../internal/impl/dtd/XMLDTDDescription.java | 179 + .../internal/impl/dtd/XMLDTDLoader.java | 518 ++ .../internal/impl/dtd/XMLDTDProcessor.java | 1702 ++++++ .../internal/impl/dtd/XMLDTDValidator.java | 2000 +++++++ .../impl/dtd/XMLDTDValidatorFilter.java | 53 + .../internal/impl/dtd/XMLElementDecl.java | 101 + .../internal/impl/dtd/XMLEntityDecl.java | 118 + .../internal/impl/dtd/XMLNSDTDValidator.java | 235 + .../internal/impl/dtd/XMLNotationDecl.java | 72 + .../internal/impl/dtd/XMLSimpleType.java | 172 + .../internal/impl/dtd/models/CMAny.java | 151 + .../internal/impl/dtd/models/CMBinOp.java | 151 + .../internal/impl/dtd/models/CMLeaf.java | 145 + .../internal/impl/dtd/models/CMNode.java | 163 + .../internal/impl/dtd/models/CMStateSet.java | 303 ++ .../internal/impl/dtd/models/CMUniOp.java | 103 + .../dtd/models/ContentModelValidator.java | 48 + .../impl/dtd/models/DFAContentModel.java | 991 ++++ .../impl/dtd/models/MixedContentModel.java | 218 + .../impl/dtd/models/SimpleContentModel.java | 280 + .../xerces/internal/impl/dv/DTDDVFactory.java | 100 + .../internal/impl/dv/DVFactoryException.java | 43 + .../internal/impl/dv/DatatypeException.java | 110 + .../internal/impl/dv/DatatypeValidator.java | 46 + .../dv/InvalidDatatypeFacetException.java | 49 + .../dv/InvalidDatatypeValueException.java | 48 + .../internal/impl/dv/SchemaDVFactory.java | 149 + .../internal/impl/dv/ValidatedInfo.java | 239 + .../internal/impl/dv/ValidationContext.java | 67 + .../xerces/internal/impl/dv/XSFacets.java | 137 + .../xerces/internal/impl/dv/XSSimpleType.java | 204 + .../impl/dv/dtd/DTDDVFactoryImpl.java | 81 + .../impl/dv/dtd/ENTITYDatatypeValidator.java | 69 + .../impl/dv/dtd/IDDatatypeValidator.java | 85 + .../impl/dv/dtd/IDREFDatatypeValidator.java | 79 + .../impl/dv/dtd/ListDatatypeValidator.java | 69 + .../impl/dv/dtd/NMTOKENDatatypeValidator.java | 58 + .../dv/dtd/NOTATIONDatatypeValidator.java | 56 + .../impl/dv/dtd/StringDatatypeValidator.java | 61 + .../impl/dv/dtd/XML11DTDDVFactoryImpl.java | 79 + .../impl/dv/dtd/XML11IDDatatypeValidator.java | 87 + .../dv/dtd/XML11IDREFDatatypeValidator.java | 81 + .../dv/dtd/XML11NMTOKENDatatypeValidator.java | 60 + .../xerces/internal/impl/dv/util/Base64.java | 308 ++ .../internal/impl/dv/util/ByteListImpl.java | 112 + .../xerces/internal/impl/dv/util/HexBin.java | 116 + .../impl/dv/xs/AbstractDateTimeDV.java | 1178 +++++ .../internal/impl/dv/xs/AnyAtomicDV.java | 45 + .../internal/impl/dv/xs/AnySimpleDV.java | 47 + .../xerces/internal/impl/dv/xs/AnyURIDV.java | 172 + .../internal/impl/dv/xs/Base64BinaryDV.java | 94 + .../internal/impl/dv/xs/BaseDVFactory.java | 250 + .../impl/dv/xs/BaseSchemaDVFactory.java | 328 ++ .../xerces/internal/impl/dv/xs/BooleanDV.java | 56 + .../xerces/internal/impl/dv/xs/DateDV.java | 95 + .../internal/impl/dv/xs/DateTimeDV.java | 96 + .../xerces/internal/impl/dv/xs/DayDV.java | 119 + .../impl/dv/xs/DayTimeDurationDV.java | 64 + .../xerces/internal/impl/dv/xs/DecimalDV.java | 393 ++ .../xerces/internal/impl/dv/xs/DoubleDV.java | 260 + .../internal/impl/dv/xs/DurationDV.java | 390 ++ .../xerces/internal/impl/dv/xs/EntityDV.java | 57 + .../dv/xs/ExtendedSchemaDVFactoryImpl.java | 85 + .../xerces/internal/impl/dv/xs/FloatDV.java | 241 + .../internal/impl/dv/xs/FullDVFactory.java | 169 + .../internal/impl/dv/xs/HexBinaryDV.java | 91 + .../xerces/internal/impl/dv/xs/IDDV.java | 56 + .../xerces/internal/impl/dv/xs/IDREFDV.java | 54 + .../xerces/internal/impl/dv/xs/IntegerDV.java | 45 + .../xerces/internal/impl/dv/xs/ListDV.java | 139 + .../xerces/internal/impl/dv/xs/MonthDV.java | 168 + .../internal/impl/dv/xs/MonthDayDV.java | 131 + .../impl/dv/xs/PrecisionDecimalDV.java | 448 ++ .../xerces/internal/impl/dv/xs/QNameDV.java | 112 + .../impl/dv/xs/SchemaDVFactoryImpl.java | 77 + .../impl/dv/xs/SchemaDateTimeException.java | 40 + .../xerces/internal/impl/dv/xs/StringDV.java | 47 + .../xerces/internal/impl/dv/xs/TimeDV.java | 113 + .../internal/impl/dv/xs/TypeValidator.java | 143 + .../xerces/internal/impl/dv/xs/UnionDV.java | 48 + .../internal/impl/dv/xs/XSSimpleTypeDecl.java | 3494 +++++++++++++ .../impl/dv/xs/XSSimpleTypeDelegate.java | 223 + .../xerces/internal/impl/dv/xs/YearDV.java | 127 + .../internal/impl/dv/xs/YearMonthDV.java | 101 + .../impl/dv/xs/YearMonthDurationDV.java | 65 + .../xerces/internal/impl/io/ASCIIReader.java | 248 + .../xerces/internal/impl/io/Latin1Reader.java | 219 + .../io/MalformedByteSequenceException.java | 140 + .../xerces/internal/impl/io/UCSReader.java | 312 ++ .../xerces/internal/impl/io/UTF16Reader.java | 333 ++ .../xerces/internal/impl/io/UTF8Reader.java | 717 +++ .../internal/impl/msg/DOMMessages.properties | 85 + .../impl/msg/DOMMessages_de.properties | 93 + .../impl/msg/DOMMessages_es.properties | 93 + .../impl/msg/DOMMessages_fr.properties | 93 + .../impl/msg/DOMMessages_it.properties | 93 + .../impl/msg/DOMMessages_ja.properties | 93 + .../impl/msg/DOMMessages_ko.properties | 93 + .../impl/msg/DOMMessages_pt_BR.properties | 93 + .../impl/msg/DOMMessages_sv.properties | 93 + .../impl/msg/DOMMessages_zh_CN.properties | 93 + .../impl/msg/DOMMessages_zh_TW.properties | 93 + .../impl/msg/DatatypeMessages.properties | 45 + .../impl/msg/DatatypeMessages_de.properties | 53 + .../impl/msg/DatatypeMessages_es.properties | 53 + .../impl/msg/DatatypeMessages_fr.properties | 53 + .../impl/msg/DatatypeMessages_it.properties | 53 + .../impl/msg/DatatypeMessages_ja.properties | 53 + .../impl/msg/DatatypeMessages_ko.properties | 53 + .../msg/DatatypeMessages_pt_BR.properties | 53 + .../impl/msg/DatatypeMessages_sv.properties | 53 + .../msg/DatatypeMessages_zh_CN.properties | 53 + .../msg/DatatypeMessages_zh_TW.properties | 53 + .../msg/JAXPValidationMessages.properties | 45 + .../msg/JAXPValidationMessages_de.properties | 53 + .../msg/JAXPValidationMessages_es.properties | 53 + .../msg/JAXPValidationMessages_fr.properties | 53 + .../msg/JAXPValidationMessages_it.properties | 53 + .../msg/JAXPValidationMessages_ja.properties | 53 + .../msg/JAXPValidationMessages_ko.properties | 53 + .../JAXPValidationMessages_pt_BR.properties | 53 + .../msg/JAXPValidationMessages_sv.properties | 53 + .../JAXPValidationMessages_zh_CN.properties | 53 + .../JAXPValidationMessages_zh_TW.properties | 53 + .../internal/impl/msg/SAXMessages.properties | 51 + .../impl/msg/SAXMessages_de.properties | 59 + .../impl/msg/SAXMessages_es.properties | 59 + .../impl/msg/SAXMessages_fr.properties | 59 + .../impl/msg/SAXMessages_it.properties | 59 + .../impl/msg/SAXMessages_ja.properties | 59 + .../impl/msg/SAXMessages_ko.properties | 59 + .../impl/msg/SAXMessages_pt_BR.properties | 59 + .../impl/msg/SAXMessages_sv.properties | 59 + .../impl/msg/SAXMessages_zh_CN.properties | 59 + .../impl/msg/SAXMessages_zh_TW.properties | 59 + .../impl/msg/XIncludeMessages.properties | 53 + .../impl/msg/XIncludeMessages_de.properties | 61 + .../impl/msg/XIncludeMessages_es.properties | 61 + .../impl/msg/XIncludeMessages_fr.properties | 61 + .../impl/msg/XIncludeMessages_it.properties | 61 + .../impl/msg/XIncludeMessages_ja.properties | 61 + .../impl/msg/XIncludeMessages_ko.properties | 61 + .../msg/XIncludeMessages_pt_BR.properties | 61 + .../impl/msg/XIncludeMessages_sv.properties | 61 + .../msg/XIncludeMessages_zh_CN.properties | 61 + .../msg/XIncludeMessages_zh_TW.properties | 61 + .../impl/msg/XMLMessageFormatter.java | 121 + .../impl/msg/XMLMessageFormatter_de.java | 122 + .../impl/msg/XMLMessageFormatter_es.java | 122 + .../impl/msg/XMLMessageFormatter_fr.java | 122 + .../impl/msg/XMLMessageFormatter_it.java | 122 + .../impl/msg/XMLMessageFormatter_ja.java | 122 + .../impl/msg/XMLMessageFormatter_ko.java | 122 + .../impl/msg/XMLMessageFormatter_pt_BR.java | 122 + .../impl/msg/XMLMessageFormatter_sv.java | 122 + .../impl/msg/XMLMessageFormatter_zh_CN.java | 122 + .../impl/msg/XMLMessageFormatter_zh_TW.java | 122 + .../internal/impl/msg/XMLMessages.properties | 325 ++ .../impl/msg/XMLMessages_de.properties | 308 ++ .../impl/msg/XMLMessages_es.properties | 308 ++ .../impl/msg/XMLMessages_fr.properties | 308 ++ .../impl/msg/XMLMessages_it.properties | 308 ++ .../impl/msg/XMLMessages_ja.properties | 308 ++ .../impl/msg/XMLMessages_ko.properties | 308 ++ .../impl/msg/XMLMessages_pt_BR.properties | 308 ++ .../impl/msg/XMLMessages_sv.properties | 308 ++ .../impl/msg/XMLMessages_zh_CN.properties | 308 ++ .../impl/msg/XMLMessages_zh_TW.properties | 308 ++ .../impl/msg/XMLSchemaMessages.properties | 320 ++ .../impl/msg/XMLSchemaMessages_de.properties | 328 ++ .../impl/msg/XMLSchemaMessages_es.properties | 328 ++ .../impl/msg/XMLSchemaMessages_fr.properties | 328 ++ .../impl/msg/XMLSchemaMessages_it.properties | 328 ++ .../impl/msg/XMLSchemaMessages_ja.properties | 327 ++ .../impl/msg/XMLSchemaMessages_ko.properties | 328 ++ .../msg/XMLSchemaMessages_pt_BR.properties | 328 ++ .../impl/msg/XMLSchemaMessages_sv.properties | 328 ++ .../msg/XMLSchemaMessages_zh_CN.properties | 327 ++ .../msg/XMLSchemaMessages_zh_TW.properties | 328 ++ .../impl/msg/XMLSerializerMessages.properties | 48 + .../msg/XMLSerializerMessages_de.properties | 56 + .../msg/XMLSerializerMessages_es.properties | 56 + .../msg/XMLSerializerMessages_fr.properties | 56 + .../msg/XMLSerializerMessages_it.properties | 56 + .../msg/XMLSerializerMessages_ja.properties | 56 + .../msg/XMLSerializerMessages_ko.properties | 56 + .../XMLSerializerMessages_pt_BR.properties | 56 + .../msg/XMLSerializerMessages_sv.properties | 56 + .../XMLSerializerMessages_zh_CN.properties | 56 + .../XMLSerializerMessages_zh_TW.properties | 56 + .../impl/msg/XPointerMessages.properties | 42 + .../impl/msg/XPointerMessages_de.properties | 50 + .../impl/msg/XPointerMessages_es.properties | 50 + .../impl/msg/XPointerMessages_fr.properties | 50 + .../impl/msg/XPointerMessages_it.properties | 50 + .../impl/msg/XPointerMessages_ja.properties | 50 + .../impl/msg/XPointerMessages_ko.properties | 50 + .../msg/XPointerMessages_pt_BR.properties | 50 + .../impl/msg/XPointerMessages_sv.properties | 50 + .../msg/XPointerMessages_zh_CN.properties | 50 + .../msg/XPointerMessages_zh_TW.properties | 50 + .../ConfigurableValidationState.java | 130 + .../internal/impl/validation/EntityState.java | 50 + .../impl/validation/ValidationManager.java | 87 + .../impl/validation/ValidationState.java | 212 + .../xerces/internal/impl/xpath/XPath.java | 2027 ++++++++ .../internal/impl/xpath/XPathException.java | 62 + .../internal/impl/xpath/regex/BMPattern.java | 238 + .../impl/xpath/regex/CaseInsensitiveMap.java | 164 + .../internal/impl/xpath/regex/Match.java | 187 + .../xerces/internal/impl/xpath/regex/Op.java | 255 + .../impl/xpath/regex/ParseException.java | 56 + .../impl/xpath/regex/ParserForXMLSchema.java | 517 ++ .../internal/impl/xpath/regex/REUtil.java | 365 ++ .../internal/impl/xpath/regex/RangeToken.java | 622 +++ .../impl/xpath/regex/RegexParser.java | 1237 +++++ .../impl/xpath/regex/RegularExpression.java | 2446 +++++++++ .../internal/impl/xpath/regex/Token.java | 1583 ++++++ .../impl/xpath/regex/message.properties | 39 + .../impl/xpath/regex/message_de.properties | 64 + .../impl/xpath/regex/message_es.properties | 64 + .../impl/xpath/regex/message_fr.properties | 64 + .../impl/xpath/regex/message_it.properties | 64 + .../impl/xpath/regex/message_ja.properties | 64 + .../impl/xpath/regex/message_ko.properties | 64 + .../impl/xpath/regex/message_pt_BR.properties | 64 + .../impl/xpath/regex/message_sv.properties | 64 + .../impl/xpath/regex/message_zh_CN.properties | 64 + .../impl/xpath/regex/message_zh_TW.properties | 64 + .../internal/impl/xs/AttributePSVImpl.java | 286 + .../internal/impl/xs/ElementPSVImpl.java | 348 ++ .../internal/impl/xs/PSVIErrorList.java | 91 + .../internal/impl/xs/SchemaGrammar.java | 1696 ++++++ .../impl/xs/SchemaNamespaceSupport.java | 113 + .../internal/impl/xs/SchemaSymbols.java | 218 + .../impl/xs/SubstitutionGroupHandler.java | 362 ++ .../internal/impl/xs/XMLSchemaException.java | 55 + .../internal/impl/xs/XMLSchemaLoader.java | 1440 +++++ .../internal/impl/xs/XMLSchemaValidator.java | 4633 +++++++++++++++++ .../internal/impl/xs/XSAnnotationImpl.java | 189 + .../internal/impl/xs/XSAttributeDecl.java | 223 + .../impl/xs/XSAttributeGroupDecl.java | 402 ++ .../internal/impl/xs/XSAttributeUseImpl.java | 161 + .../internal/impl/xs/XSComplexTypeDecl.java | 735 +++ .../internal/impl/xs/XSConstraints.java | 1534 ++++++ .../internal/impl/xs/XSDDescription.java | 274 + .../internal/impl/xs/XSDeclarationPool.java | 318 ++ .../internal/impl/xs/XSElementDecl.java | 396 ++ .../internal/impl/xs/XSElementDeclHelper.java | 34 + .../internal/impl/xs/XSGrammarBucket.java | 243 + .../xerces/internal/impl/xs/XSGroupDecl.java | 111 + .../impl/xs/XSImplementationImpl.java | 120 + .../xerces/internal/impl/xs/XSLoaderImpl.java | 322 ++ .../internal/impl/xs/XSMessageFormatter.java | 95 + .../internal/impl/xs/XSModelGroupImpl.java | 246 + .../xerces/internal/impl/xs/XSModelImpl.java | 850 +++ .../internal/impl/xs/XSNotationDecl.java | 121 + .../internal/impl/xs/XSParticleDecl.java | 248 + .../internal/impl/xs/XSWildcardDecl.java | 599 +++ .../internal/impl/xs/identity/Field.java | 308 ++ .../impl/xs/identity/FieldActivator.java | 69 + .../impl/xs/identity/IdentityConstraint.java | 251 + .../internal/impl/xs/identity/KeyRef.java | 73 + .../internal/impl/xs/identity/Selector.java | 256 + .../impl/xs/identity/UniqueOrKey.java | 52 + .../internal/impl/xs/identity/ValueStore.java | 74 + .../impl/xs/identity/XPathMatcher.java | 542 ++ .../internal/impl/xs/models/CMBuilder.java | 478 ++ .../impl/xs/models/CMNodeFactory.java | 171 + .../internal/impl/xs/models/XSAllCM.java | 235 + .../internal/impl/xs/models/XSCMBinOp.java | 142 + .../internal/impl/xs/models/XSCMLeaf.java | 136 + .../impl/xs/models/XSCMRepeatingLeaf.java | 50 + .../internal/impl/xs/models/XSCMUniOp.java | 113 + .../impl/xs/models/XSCMValidator.java | 145 + .../internal/impl/xs/models/XSDFACM.java | 1275 +++++ .../internal/impl/xs/models/XSEmptyCM.java | 152 + .../internal/impl/xs/opti/AttrImpl.java | 111 + .../impl/xs/opti/DefaultDocument.java | 292 ++ .../internal/impl/xs/opti/DefaultElement.java | 152 + .../internal/impl/xs/opti/DefaultNode.java | 219 + .../internal/impl/xs/opti/DefaultText.java | 239 + .../xs/opti/DefaultXMLDocumentHandler.java | 872 ++++ .../internal/impl/xs/opti/ElementImpl.java | 274 + .../impl/xs/opti/NamedNodeMapImpl.java | 89 + .../internal/impl/xs/opti/NodeImpl.java | 88 + .../internal/impl/xs/opti/SchemaDOM.java | 461 ++ .../impl/xs/opti/SchemaDOMImplementation.java | 66 + .../impl/xs/opti/SchemaDOMParser.java | 611 +++ .../impl/xs/opti/SchemaParsingConfig.java | 1042 ++++ .../internal/impl/xs/opti/TextImpl.java | 131 + .../xs/traversers/SchemaContentHandler.java | 391 ++ .../impl/xs/traversers/StAXSchemaParser.java | 423 ++ .../impl/xs/traversers/XSAnnotationInfo.java | 74 + .../xs/traversers/XSAttributeChecker.java | 1830 +++++++ .../XSDAbstractIDConstraintTraverser.java | 194 + .../XSDAbstractParticleTraverser.java | 385 ++ .../xs/traversers/XSDAbstractTraverser.java | 1002 ++++ .../XSDAttributeGroupTraverser.java | 210 + .../xs/traversers/XSDAttributeTraverser.java | 488 ++ .../traversers/XSDComplexTypeTraverser.java | 1256 +++++ .../xs/traversers/XSDElementTraverser.java | 565 ++ .../impl/xs/traversers/XSDGroupTraverser.java | 270 + .../impl/xs/traversers/XSDHandler.java | 4434 ++++++++++++++++ .../xs/traversers/XSDKeyrefTraverser.java | 125 + .../xs/traversers/XSDNotationTraverser.java | 134 + .../xs/traversers/XSDSimpleTypeTraverser.java | 521 ++ .../traversers/XSDUniqueOrKeyTraverser.java | 102 + .../xs/traversers/XSDWildcardTraverser.java | 202 + .../impl/xs/traversers/XSDocumentInfo.java | 252 + .../impl/xs/util/LSInputListImpl.java | 125 + .../internal/impl/xs/util/ObjectListImpl.java | 118 + .../internal/impl/xs/util/ShortListImpl.java | 123 + .../internal/impl/xs/util/SimpleLocator.java | 148 + .../internal/impl/xs/util/StringListImpl.java | 166 + .../xerces/internal/impl/xs/util/XInt.java | 53 + .../internal/impl/xs/util/XIntPool.java | 44 + .../internal/impl/xs/util/XS10TypeHelper.java | 65 + .../internal/impl/xs/util/XSGrammarPool.java | 75 + .../internal/impl/xs/util/XSInputSource.java | 65 + .../impl/xs/util/XSNamedMap4Types.java | 144 + .../internal/impl/xs/util/XSNamedMapImpl.java | 300 ++ .../impl/xs/util/XSObjectListImpl.java | 267 + .../jaxp/DefaultValidationErrorHandler.java | 63 + .../jaxp/DocumentBuilderFactoryImpl.java | 253 + .../internal/jaxp/DocumentBuilderImpl.java | 416 ++ .../xerces/internal/jaxp/JAXPConstants.java | 42 + .../internal/jaxp/JAXPValidatorComponent.java | 600 +++ .../internal/jaxp/SAXParserFactoryImpl.java | 212 + .../xerces/internal/jaxp/SAXParserImpl.java | 732 +++ .../jaxp/SchemaValidatorConfiguration.java | 192 + .../jaxp/TeeXMLDocumentFilterImpl.java | 177 + .../internal/jaxp/UnparsedEntityHandler.java | 262 + .../jaxp/datatype/DatatypeFactoryImpl.java | 652 +++ .../jaxp/datatype/DurationDayTimeImpl.java | 191 + .../internal/jaxp/datatype/DurationImpl.java | 1883 +++++++ .../jaxp/datatype/DurationYearMonthImpl.java | 197 + .../datatype/XMLGregorianCalendarImpl.java | 3061 +++++++++++ .../jaxp/validation/AbstractXMLSchema.java | 109 + .../jaxp/validation/DOMDocumentHandler.java | 90 + .../jaxp/validation/DOMResultAugmentor.java | 259 + .../jaxp/validation/DOMResultBuilder.java | 371 ++ .../jaxp/validation/DOMValidatorHelper.java | 612 +++ .../validation/DraconianErrorHandler.java | 63 + .../jaxp/validation/EmptyXMLSchema.java | 73 + .../jaxp/validation/ErrorHandlerAdaptor.java | 83 + .../JAXPValidationMessageFormatter.java | 102 + .../jaxp/validation/ReadOnlyGrammarPool.java | 66 + .../jaxp/validation/SimpleXMLSchema.java | 82 + .../validation/SoftReferenceGrammarPool.java | 437 ++ .../jaxp/validation/StAXValidatorHelper.java | 117 + .../validation/StreamValidatorHelper.java | 227 + .../xerces/internal/jaxp/validation/Util.java | 78 + .../jaxp/validation/ValidatorHandlerImpl.java | 1089 ++++ .../jaxp/validation/ValidatorHelper.java | 41 + .../jaxp/validation/ValidatorImpl.java | 292 ++ .../validation/WeakReferenceXMLSchema.java | 63 + .../jaxp/validation/WrappedSAXException.java | 51 + .../internal/jaxp/validation/XMLSchema.java | 71 + .../jaxp/validation/XMLSchemaFactory.java | 643 +++ .../XMLSchemaValidatorComponentManager.java | 624 +++ .../validation/XSGrammarPoolContainer.java | 75 + .../internal/parsers/AbstractDOMParser.java | 2641 ++++++++++ .../internal/parsers/AbstractSAXParser.java | 2430 +++++++++ .../parsers/AbstractXMLDocumentParser.java | 813 +++ .../parsers/BasicParserConfiguration.java | 578 ++ .../internal/parsers/CachingParserPool.java | 431 ++ .../xerces/internal/parsers/DOMParser.java | 673 +++ .../internal/parsers/DOMParserImpl.java | 1390 +++++ .../internal/parsers/DTDConfiguration.java | 901 ++++ .../xerces/internal/parsers/DTDParser.java | 482 ++ .../IntegratedParserConfiguration.java | 252 + .../parsers/NonValidatingConfiguration.java | 826 +++ .../xerces/internal/parsers/SAXParser.java | 181 + .../parsers/SecurityConfiguration.java | 114 + .../parsers/StandardParserConfiguration.java | 417 ++ .../XIncludeAwareParserConfiguration.java | 297 ++ .../parsers/XIncludeParserConfiguration.java | 223 + .../internal/parsers/XML11Configurable.java | 31 + .../internal/parsers/XML11Configuration.java | 1607 ++++++ .../parsers/XML11DTDConfiguration.java | 1313 +++++ .../XML11NonValidatingConfiguration.java | 1209 +++++ .../internal/parsers/XMLDocumentParser.java | 79 + .../XMLGrammarCachingConfiguration.java | 312 ++ .../internal/parsers/XMLGrammarParser.java | 54 + .../internal/parsers/XMLGrammarPreparser.java | 341 ++ .../xerces/internal/parsers/XMLParser.java | 155 + .../parsers/XPointerParserConfiguration.java | 245 + .../xerces/internal/util/AttributesProxy.java | 193 + .../internal/util/AugmentationsImpl.java | 287 + .../util/DOMEntityResolverWrapper.java | 171 + .../internal/util/DOMErrorHandlerWrapper.java | 422 ++ .../xerces/internal/util/DOMInputSource.java | 77 + .../apache/xerces/internal/util/DOMUtil.java | 860 +++ .../util/DatatypeMessageFormatter.java | 104 + .../internal/util/DefaultErrorHandler.java | 117 + .../internal/util/DraconianErrorHandler.java | 51 + .../xerces/internal/util/EncodingMap.java | 981 ++++ .../internal/util/EntityResolver2Wrapper.java | 216 + .../internal/util/EntityResolverWrapper.java | 146 + .../internal/util/ErrorHandlerProxy.java | 81 + .../internal/util/ErrorHandlerWrapper.java | 233 + .../xerces/internal/util/FeatureState.java | 57 + .../xerces/internal/util/HTTPInputSource.java | 195 + .../apache/xerces/internal/util/IntStack.java | 117 + .../util/JAXPNamespaceContextWrapper.java | 147 + .../xerces/internal/util/LocatorProxy.java | 89 + .../xerces/internal/util/LocatorWrapper.java | 71 + .../internal/util/MessageFormatter.java | 61 + .../util/NamespaceContextWrapper.java | 90 + .../internal/util/NamespaceSupport.java | 444 ++ .../util/ParserConfigurationSettings.java | 338 ++ .../util/PrimeNumberSequenceGenerator.java | 45 + .../xerces/internal/util/PropertyState.java | 56 + .../apache/xerces/internal/util/SAX2XNI.java | 217 + .../xerces/internal/util/SAXInputSource.java | 166 + .../internal/util/SAXLocatorWrapper.java | 112 + .../internal/util/SAXMessageFormatter.java | 103 + .../xerces/internal/util/SecurityManager.java | 185 + .../internal/util/ShadowedSymbolTable.java | 122 + .../xerces/internal/util/StAXInputSource.java | 94 + .../internal/util/StAXLocationWrapper.java | 105 + .../apache/xerces/internal/util/Status.java | 53 + .../xerces/internal/util/SymbolHash.java | 329 ++ .../xerces/internal/util/SymbolTable.java | 467 ++ .../util/SynchronizedSymbolTable.java | 130 + .../util/TeeXMLDocumentFilterImpl.java | 178 + .../org/apache/xerces/internal/util/URI.java | 2211 ++++++++ .../xerces/internal/util/XML11Char.java | 415 ++ .../internal/util/XMLAttributesImpl.java | 1270 +++++ .../util/XMLAttributesIteratorImpl.java | 99 + .../apache/xerces/internal/util/XMLChar.java | 1065 ++++ .../internal/util/XMLDocumentFilterImpl.java | 143 + .../util/XMLEntityDescriptionImpl.java | 182 + .../xerces/internal/util/XMLErrorCode.java | 85 + .../internal/util/XMLGrammarPoolImpl.java | 367 ++ .../internal/util/XMLInputSourceAdaptor.java | 68 + .../internal/util/XMLLocatorWrapper.java | 113 + .../util/XMLResourceIdentifierImpl.java | 231 + .../xerces/internal/util/XMLStringBuffer.java | 106 + .../xerces/internal/util/XMLSymbols.java | 104 + .../internal/utils/ConfigurationError.java | 60 + .../xerces/internal/utils/ObjectFactory.java | 237 + .../internal/utils/XMLLimitAnalyzer.java | 251 + .../internal/utils/XMLSecurityManager.java | 610 +++ .../utils/XMLSecurityPropertyManager.java | 243 + .../MultipleScopeNamespaceSupport.java | 197 + .../xinclude/XInclude11TextReader.java | 64 + .../internal/xinclude/XIncludeHandler.java | 3215 ++++++++++++ .../xinclude/XIncludeMessageFormatter.java | 90 + .../xinclude/XIncludeNamespaceSupport.java | 97 + .../internal/xinclude/XIncludeTextReader.java | 553 ++ .../xerces/internal/xni/Augmentations.java | 90 + .../xerces/internal/xni/NamespaceContext.java | 179 + .../org/apache/xerces/internal/xni/QName.java | 202 + .../xerces/internal/xni/XMLAttributes.java | 399 ++ .../xni/XMLDTDContentModelHandler.java | 274 + .../xerces/internal/xni/XMLDTDHandler.java | 379 ++ .../xni/XMLDocumentFragmentHandler.java | 260 + .../internal/xni/XMLDocumentHandler.java | 297 ++ .../xerces/internal/xni/XMLLocator.java | 80 + .../internal/xni/XMLResourceIdentifier.java | 65 + .../apache/xerces/internal/xni/XMLString.java | 267 + .../xerces/internal/xni/XNIException.java | 96 + .../xerces/internal/xni/grammars/Grammar.java | 56 + .../xni/grammars/XMLDTDDescription.java | 38 + .../xni/grammars/XMLGrammarDescription.java | 60 + .../xni/grammars/XMLGrammarLoader.java | 148 + .../internal/xni/grammars/XMLGrammarPool.java | 107 + .../xni/grammars/XMLSchemaDescription.java | 139 + .../internal/xni/grammars/XSGrammar.java | 56 + .../internal/xni/parser/XMLComponent.java | 127 + .../xni/parser/XMLComponentManager.java | 90 + .../xni/parser/XMLConfigurationException.java | 99 + .../xni/parser/XMLDTDContentModelFilter.java | 36 + .../xni/parser/XMLDTDContentModelSource.java | 50 + .../internal/xni/parser/XMLDTDFilter.java | 36 + .../internal/xni/parser/XMLDTDScanner.java | 110 + .../internal/xni/parser/XMLDTDSource.java | 50 + .../xni/parser/XMLDocumentFilter.java | 37 + .../xni/parser/XMLDocumentScanner.java | 76 + .../xni/parser/XMLDocumentSource.java | 50 + .../xni/parser/XMLEntityResolver.java | 62 + .../internal/xni/parser/XMLErrorHandler.java | 107 + .../internal/xni/parser/XMLInputSource.java | 292 ++ .../xni/parser/XMLParseException.java | 182 + .../xni/parser/XMLParserConfiguration.java | 254 + .../parser/XMLPullParserConfiguration.java | 98 + .../xpointer/ElementSchemePointer.java | 869 ++++ .../internal/xpointer/ShortHandPointer.java | 296 ++ .../xpointer/XPointerErrorHandler.java | 117 + .../internal/xpointer/XPointerHandler.java | 1255 +++++ .../xpointer/XPointerMessageFormatter.java | 98 + .../internal/xpointer/XPointerPart.java | 134 + .../internal/xpointer/XPointerProcessor.java | 100 + .../xerces/internal/xs/AttributePSVI.java | 34 + .../xerces/internal/xs/ElementPSVI.java | 51 + .../apache/xerces/internal/xs/ItemPSVI.java | 229 + .../xerces/internal/xs/LSInputList.java | 51 + .../xerces/internal/xs/PSVIProvider.java | 94 + .../apache/xerces/internal/xs/ShortList.java | 61 + .../apache/xerces/internal/xs/StringList.java | 59 + .../xerces/internal/xs/XSAnnotation.java | 64 + .../internal/xs/XSAttributeDeclaration.java | 128 + .../xs/XSAttributeGroupDefinition.java | 49 + .../xerces/internal/xs/XSAttributeUse.java | 115 + .../internal/xs/XSComplexTypeDefinition.java | 117 + .../xerces/internal/xs/XSConstants.java | 346 ++ .../internal/xs/XSElementDeclaration.java | 196 + .../xerces/internal/xs/XSException.java | 57 + .../apache/xerces/internal/xs/XSFacet.java | 73 + .../xerces/internal/xs/XSIDCDefinition.java | 73 + .../xerces/internal/xs/XSImplementation.java | 52 + .../apache/xerces/internal/xs/XSLoader.java | 94 + .../apache/xerces/internal/xs/XSModel.java | 177 + .../xerces/internal/xs/XSModelGroup.java | 67 + .../internal/xs/XSModelGroupDefinition.java | 43 + .../xerces/internal/xs/XSMultiValueFacet.java | 51 + .../apache/xerces/internal/xs/XSNamedMap.java | 72 + .../xerces/internal/xs/XSNamespaceItem.java | 121 + .../internal/xs/XSNamespaceItemList.java | 50 + .../internal/xs/XSNotationDeclaration.java | 50 + .../apache/xerces/internal/xs/XSObject.java | 59 + .../xerces/internal/xs/XSObjectList.java | 50 + .../apache/xerces/internal/xs/XSParticle.java | 56 + .../internal/xs/XSSimpleTypeDefinition.java | 248 + .../org/apache/xerces/internal/xs/XSTerm.java | 31 + .../xerces/internal/xs/XSTypeDefinition.java | 106 + .../apache/xerces/internal/xs/XSValue.java | 108 + .../apache/xerces/internal/xs/XSWildcard.java | 91 + .../internal/xs/datatypes/ByteList.java | 68 + .../internal/xs/datatypes/ObjectList.java | 63 + .../internal/xs/datatypes/XSDateTime.java | 295 ++ .../internal/xs/datatypes/XSDecimal.java | 69 + .../internal/xs/datatypes/XSDouble.java | 37 + .../xerces/internal/xs/datatypes/XSFloat.java | 37 + .../xerces/internal/xs/datatypes/XSQName.java | 40 + .../xerces/internal/xs/datatypes/package.html | 309 ++ .../sun/org/apache/xml/internal/dtm/Axis.java | 221 + .../sun/org/apache/xml/internal/dtm/DTM.java | 968 ++++ .../xml/internal/dtm/DTMAxisIterator.java | 111 + .../xml/internal/dtm/DTMAxisTraverser.java | 117 + .../xml/internal/dtm/DTMDOMException.java | 55 + .../apache/xml/internal/dtm/DTMException.java | 61 + .../apache/xml/internal/dtm/DTMFilter.java | 189 + .../apache/xml/internal/dtm/DTMIterator.java | 345 ++ .../apache/xml/internal/dtm/DTMManager.java | 378 ++ .../apache/xml/internal/dtm/DTMWSFilter.java | 57 + .../xml/internal/dtm/ref/ChunkedIntArray.java | 307 ++ .../internal/dtm/ref/CoroutineManager.java | 345 ++ .../xml/internal/dtm/ref/CoroutineParser.java | 140 + .../internal/dtm/ref/CustomStringPool.java | 92 + .../internal/dtm/ref/DTMAxisIterNodeList.java | 143 + .../internal/dtm/ref/DTMAxisIteratorBase.java | 282 + .../dtm/ref/DTMChildIterNodeList.java | 120 + .../xml/internal/dtm/ref/DTMDefaultBase.java | 2363 +++++++++ .../dtm/ref/DTMDefaultBaseIterators.java | 2194 ++++++++ .../dtm/ref/DTMDefaultBaseTraversers.java | 1746 +++++++ .../xml/internal/dtm/ref/DTMDocumentImpl.java | 2414 +++++++++ .../internal/dtm/ref/DTMManagerDefault.java | 859 +++ .../xml/internal/dtm/ref/DTMNamedNodeMap.java | 301 ++ .../xml/internal/dtm/ref/DTMNodeIterator.java | 187 + .../xml/internal/dtm/ref/DTMNodeList.java | 129 + .../xml/internal/dtm/ref/DTMNodeListBase.java | 82 + .../xml/internal/dtm/ref/DTMNodeProxy.java | 2406 +++++++++ .../internal/dtm/ref/DTMSafeStringPool.java | 110 + .../xml/internal/dtm/ref/DTMStringPool.java | 192 + .../xml/internal/dtm/ref/DTMTreeWalker.java | 404 ++ .../xml/internal/dtm/ref/EmptyIterator.java | 63 + .../internal/dtm/ref/ExpandedNameTable.java | 392 ++ .../xml/internal/dtm/ref/ExtendedType.java | 146 + .../dtm/ref/IncrementalSAXSource.java | 89 + .../dtm/ref/IncrementalSAXSource_Filter.java | 811 +++ .../dtm/ref/IncrementalSAXSource_Xerces.java | 458 ++ .../xml/internal/dtm/ref/NodeLocator.java | 110 + .../xml/internal/dtm/ref/dom2dtm/DOM2DTM.java | 1765 +++++++ ...OM2DTMdefaultNamespaceDeclarationNode.java | 678 +++ .../xml/internal/dtm/ref/sax2dtm/SAX2DTM.java | 2435 +++++++++ .../internal/dtm/ref/sax2dtm/SAX2DTM2.java | 3309 ++++++++++++ .../internal/dtm/ref/sax2dtm/SAX2RTFDTM.java | 363 ++ .../xml/internal/res/XMLErrorResources.java | 452 ++ .../internal/res/XMLErrorResources_ca.java | 442 ++ .../internal/res/XMLErrorResources_cs.java | 442 ++ .../internal/res/XMLErrorResources_de.java | 452 ++ .../internal/res/XMLErrorResources_en.java | 32 + .../internal/res/XMLErrorResources_es.java | 452 ++ .../internal/res/XMLErrorResources_fr.java | 452 ++ .../internal/res/XMLErrorResources_it.java | 452 ++ .../internal/res/XMLErrorResources_ja.java | 452 ++ .../internal/res/XMLErrorResources_ko.java | 452 ++ .../internal/res/XMLErrorResources_pt_BR.java | 452 ++ .../internal/res/XMLErrorResources_sk.java | 442 ++ .../internal/res/XMLErrorResources_sv.java | 452 ++ .../internal/res/XMLErrorResources_tr.java | 442 ++ .../internal/res/XMLErrorResources_zh_CN.java | 452 ++ .../internal/res/XMLErrorResources_zh_HK.java | 38 + .../internal/res/XMLErrorResources_zh_TW.java | 452 ++ .../apache/xml/internal/res/XMLMessages.java | 158 + .../serialize/BaseMarkupSerializer.java | 1952 +++++++ .../xml/internal/serialize/DOMSerializer.java | 85 + .../internal/serialize/DOMSerializerImpl.java | 1074 ++++ .../xml/internal/serialize/ElementState.java | 113 + .../xml/internal/serialize/EncodingInfo.java | 151 + .../xml/internal/serialize/Encodings.java | 132 + .../internal/serialize/HTMLSerializer.java | 878 ++++ .../xml/internal/serialize/HTMLdtd.java | 561 ++ .../xml/internal/serialize/IndentPrinter.java | 371 ++ .../xml/internal/serialize/LineSeparator.java | 63 + .../apache/xml/internal/serialize/Method.java | 69 + .../xml/internal/serialize/OutputFormat.java | 823 +++ .../xml/internal/serialize/Printer.java | 370 ++ .../xml/internal/serialize/Serializer.java | 129 + .../internal/serialize/SerializerFactory.java | 158 + .../serialize/SerializerFactoryImpl.java | 122 + .../internal/serialize/TextSerializer.java | 396 ++ .../internal/serialize/XHTMLSerializer.java | 105 + .../internal/serialize/XML11Serializer.java | 550 ++ .../xml/internal/serialize/XMLSerializer.java | 1468 ++++++ .../serializer/AttributesImplSerializer.java | 238 + .../xml/internal/serializer/CharInfo.java | 746 +++ .../internal/serializer/DOM3Serializer.java | 117 + .../internal/serializer/DOMSerializer.java | 67 + .../xml/internal/serializer/ElemContext.java | 220 + .../xml/internal/serializer/ElemDesc.java | 179 + .../internal/serializer/EmptySerializer.java | 760 +++ .../xml/internal/serializer/EncodingInfo.java | 513 ++ .../xml/internal/serializer/Encodings.java | 581 +++ .../internal/serializer/Encodings.properties | 118 + .../serializer/ExtendedContentHandler.java | 272 + .../serializer/ExtendedLexicalHandler.java | 40 + .../serializer/HTMLEntities.properties | 314 ++ .../xml/internal/serializer/Method.java | 77 + .../serializer/NamespaceMappings.java | 324 ++ .../serializer/OutputPropertiesFactory.java | 363 ++ .../serializer/OutputPropertyUtils.java | 84 + .../serializer/SerializationHandler.java | 156 + .../xml/internal/serializer/Serializer.java | 241 + .../internal/serializer/SerializerBase.java | 1586 ++++++ .../serializer/SerializerConstants.java | 60 + .../serializer/SerializerFactory.java | 178 + .../internal/serializer/SerializerTrace.java | 154 + .../serializer/SerializerTraceWriter.java | 342 ++ .../internal/serializer/ToHTMLSAXHandler.java | 745 +++ .../xml/internal/serializer/ToHTMLStream.java | 2275 ++++++++ .../xml/internal/serializer/ToSAXHandler.java | 401 ++ .../xml/internal/serializer/ToStream.java | 3616 +++++++++++++ .../internal/serializer/ToTextSAXHandler.java | 413 ++ .../xml/internal/serializer/ToTextStream.java | 650 +++ .../internal/serializer/ToUnknownStream.java | 1215 +++++ .../internal/serializer/ToXMLSAXHandler.java | 776 +++ .../xml/internal/serializer/ToXMLStream.java | 666 +++ .../serializer/TransformStateSetter.java | 57 + .../xml/internal/serializer/TreeWalker.java | 497 ++ .../xml/internal/serializer/Version.java | 151 + .../xml/internal/serializer/WriterChain.java | 83 + .../xml/internal/serializer/WriterToASCI.java | 156 + .../serializer/WriterToUTF8Buffered.java | 507 ++ .../serializer/XMLEntities.properties | 32 + .../serializer/XSLOutputAttributes.java | 247 + .../serializer/dom3/DOM3SerializerImpl.java | 154 + .../serializer/dom3/DOM3TreeWalker.java | 2083 ++++++++ .../serializer/dom3/DOMConstants.java | 145 + .../serializer/dom3/DOMErrorHandlerImpl.java | 67 + .../serializer/dom3/DOMErrorImpl.java | 177 + .../serializer/dom3/DOMLocatorImpl.java | 181 + .../serializer/dom3/DOMOutputImpl.java | 178 + .../serializer/dom3/DOMStringListImpl.java | 101 + .../serializer/dom3/LSSerializerImpl.java | 1432 +++++ .../serializer/dom3/NamespaceSupport.java | 316 ++ .../xml/internal/serializer/package.html | 45 + .../internal/serializer/utils/BoolStack.java | 205 + .../internal/serializer/utils/Messages.java | 267 + .../xml/internal/serializer/utils/MsgKey.java | 136 + .../serializer/utils/SerializerMessages.java | 298 ++ .../utils/SerializerMessages_ca.java | 231 + .../utils/SerializerMessages_cs.java | 223 + .../utils/SerializerMessages_de.java | 298 ++ .../utils/SerializerMessages_en.java | 31 + .../utils/SerializerMessages_es.java | 298 ++ .../utils/SerializerMessages_fr.java | 298 ++ .../utils/SerializerMessages_it.java | 298 ++ .../utils/SerializerMessages_ja.java | 298 ++ .../utils/SerializerMessages_ko.java | 298 ++ .../utils/SerializerMessages_pt_BR.java | 298 ++ .../utils/SerializerMessages_sv.java | 298 ++ .../utils/SerializerMessages_zh_CN.java | 298 ++ .../utils/SerializerMessages_zh_TW.java | 298 ++ .../serializer/utils/StringToIntTable.java | 204 + .../serializer/utils/SystemIDResolver.java | 304 ++ .../xml/internal/serializer/utils/URI.java | 1671 ++++++ .../xml/internal/serializer/utils/Utils.java | 43 + .../utils/WrappedRuntimeException.java | 82 + .../apache/xml/internal/utils/AttList.java | 233 + .../apache/xml/internal/utils/BoolStack.java | 203 + .../apache/xml/internal/utils/CharKey.java | 85 + .../apache/xml/internal/utils/Constants.java | 113 + .../apache/xml/internal/utils/DOM2Helper.java | 343 ++ .../apache/xml/internal/utils/DOMBuilder.java | 787 +++ .../internal/utils/DefaultErrorHandler.java | 343 ++ .../apache/xml/internal/utils/ElemDesc.java | 193 + .../xml/internal/utils/FastStringBuffer.java | 1297 +++++ .../apache/xml/internal/utils/IntStack.java | 212 + .../apache/xml/internal/utils/IntVector.java | 420 ++ .../internal/utils/ListingErrorHandler.java | 565 ++ .../xml/internal/utils/LocaleUtility.java | 86 + .../internal/utils/MutableAttrListImpl.java | 140 + .../org/apache/xml/internal/utils/NSInfo.java | 111 + .../apache/xml/internal/utils/NameSpace.java | 60 + .../xml/internal/utils/NodeConsumer.java | 41 + .../apache/xml/internal/utils/NodeVector.java | 741 +++ .../apache/xml/internal/utils/ObjectPool.java | 176 + .../xml/internal/utils/ObjectStack.java | 216 + .../xml/internal/utils/ObjectVector.java | 432 ++ .../xml/internal/utils/PrefixResolver.java | 73 + .../internal/utils/PrefixResolverDefault.java | 146 + .../org/apache/xml/internal/utils/QName.java | 708 +++ .../internal/utils/RawCharacterHandler.java | 43 + .../xml/internal/utils/SAXSourceLocator.java | 171 + .../apache/xml/internal/utils/SafeThread.java | 68 + .../utils/SerializableLocatorImpl.java | 226 + .../internal/utils/StopParseException.java | 41 + .../xml/internal/utils/StringBufferPool.java | 61 + .../xml/internal/utils/StringComparable.java | 214 + .../xml/internal/utils/StringToIntTable.java | 197 + .../internal/utils/StringToStringTable.java | 243 + .../utils/StringToStringTableVector.java | 200 + .../xml/internal/utils/StringVector.java | 224 + .../internal/utils/StylesheetPIHandler.java | 341 ++ .../utils/SuballocatedByteVector.java | 499 ++ .../internal/utils/SuballocatedIntVector.java | 558 ++ .../xml/internal/utils/SystemIDResolver.java | 297 ++ .../utils/ThreadControllerWrapper.java | 90 + .../apache/xml/internal/utils/TreeWalker.java | 462 ++ .../org/apache/xml/internal/utils/Trie.java | 206 + .../org/apache/xml/internal/utils/URI.java | 1692 ++++++ .../apache/xml/internal/utils/UnImplNode.java | 2056 ++++++++ .../utils/WrappedRuntimeException.java | 75 + .../internal/utils/WrongParserException.java | 41 + .../apache/xml/internal/utils/XML11Char.java | 433 ++ .../apache/xml/internal/utils/XMLChar.java | 667 +++ .../utils/XMLCharacterRecognizer.java | 110 + .../xml/internal/utils/XMLReaderManager.java | 268 + .../apache/xml/internal/utils/XMLString.java | 690 +++ .../xml/internal/utils/XMLStringDefault.java | 819 +++ .../xml/internal/utils/XMLStringFactory.java | 72 + .../utils/XMLStringFactoryDefault.java | 85 + .../apache/xml/internal/utils/package.html | 29 + .../internal/utils/res/CharArrayWrapper.java | 43 + .../internal/utils/res/IntArrayWrapper.java | 43 + .../internal/utils/res/LongArrayWrapper.java | 43 + .../utils/res/StringArrayWrapper.java | 43 + .../internal/utils/res/XResourceBundle.java | 74 + .../utils/res/XResourceBundleBase.java | 51 + .../xml/internal/utils/res/XResources_de.java | 75 + .../xml/internal/utils/res/XResources_en.java | 75 + .../xml/internal/utils/res/XResources_es.java | 75 + .../xml/internal/utils/res/XResources_fr.java | 75 + .../xml/internal/utils/res/XResources_it.java | 75 + .../utils/res/XResources_ja_JP_A.java | 88 + .../utils/res/XResources_ja_JP_HA.java | 88 + .../utils/res/XResources_ja_JP_HI.java | 89 + .../utils/res/XResources_ja_JP_I.java | 88 + .../xml/internal/utils/res/XResources_ko.java | 82 + .../xml/internal/utils/res/XResources_sv.java | 75 + .../internal/utils/res/XResources_zh_CN.java | 82 + .../internal/utils/res/XResources_zh_TW.java | 82 + .../sun/org/apache/xpath/internal/Arg.java | 266 + .../apache/xpath/internal/CachedXPathAPI.java | 337 ++ .../org/apache/xpath/internal/Expression.java | 591 +++ .../apache/xpath/internal/ExpressionNode.java | 52 + .../xpath/internal/ExpressionOwner.java | 45 + .../xpath/internal/ExtensionsProvider.java | 60 + .../org/apache/xpath/internal/FoundIndex.java | 38 + .../org/apache/xpath/internal/NodeSet.java | 1371 +++++ .../org/apache/xpath/internal/NodeSetDTM.java | 1248 +++++ .../org/apache/xpath/internal/SourceTree.java | 53 + .../apache/xpath/internal/VariableStack.java | 519 ++ .../WhitespaceStrippingElementMatcher.java | 55 + .../sun/org/apache/xpath/internal/XPath.java | 642 +++ .../org/apache/xpath/internal/XPathAPI.java | 285 + .../apache/xpath/internal/XPathContext.java | 1297 +++++ .../apache/xpath/internal/XPathException.java | 328 ++ .../apache/xpath/internal/XPathFactory.java | 51 + .../internal/XPathProcessorException.java | 55 + .../apache/xpath/internal/XPathVisitable.java | 42 + .../apache/xpath/internal/XPathVisitor.java | 203 + .../internal/axes/AttributeIterator.java | 76 + .../xpath/internal/axes/AxesWalker.java | 591 +++ .../internal/axes/BasicTestIterator.java | 226 + .../xpath/internal/axes/ChildIterator.java | 122 + .../internal/axes/ChildTestIterator.java | 179 + .../xpath/internal/axes/ContextNodeList.java | 137 + .../internal/axes/DescendantIterator.java | 382 ++ .../internal/axes/FilterExprIterator.java | 219 + .../axes/FilterExprIteratorSimple.java | 318 ++ .../xpath/internal/axes/FilterExprWalker.java | 354 ++ .../axes/HasPositionalPredChecker.java | 124 + .../xpath/internal/axes/IteratorPool.java | 120 + .../xpath/internal/axes/LocPathIterator.java | 1027 ++++ .../internal/axes/MatchPatternIterator.java | 333 ++ .../xpath/internal/axes/NodeSequence.java | 961 ++++ .../xpath/internal/axes/OneStepIterator.java | 346 ++ .../internal/axes/OneStepIteratorForward.java | 173 + .../xpath/internal/axes/PathComponent.java | 36 + .../internal/axes/PredicatedNodeTest.java | 653 +++ .../xpath/internal/axes/RTFIterator.java | 42 + .../internal/axes/ReverseAxesWalker.java | 248 + .../axes/SelfIteratorNoPredicate.java | 129 + .../xpath/internal/axes/SubContextList.java | 53 + .../internal/axes/UnionChildIterator.java | 154 + .../internal/axes/UnionPathIterator.java | 580 +++ .../xpath/internal/axes/WalkerFactory.java | 1829 +++++++ .../xpath/internal/axes/WalkingIterator.java | 367 ++ .../internal/axes/WalkingIteratorSorted.java | 217 + .../apache/xpath/internal/axes/package.html | 29 + .../xpath/internal/compiler/Compiler.java | 1297 +++++ .../xpath/internal/compiler/FuncLoader.java | 108 + .../internal/compiler/FunctionTable.java | 423 ++ .../xpath/internal/compiler/Keywords.java | 397 ++ .../apache/xpath/internal/compiler/Lexer.java | 753 +++ .../xpath/internal/compiler/OpCodes.java | 633 +++ .../apache/xpath/internal/compiler/OpMap.java | 457 ++ .../xpath/internal/compiler/OpMapVector.java | 116 + .../xpath/internal/compiler/PsuedoNames.java | 60 + .../apache/xpath/internal/compiler/Token.java | 77 + .../xpath/internal/compiler/XPathDumper.java | 32 + .../xpath/internal/compiler/XPathParser.java | 2375 +++++++++ .../xpath/internal/compiler/package.html | 28 + .../xpath/internal/functions/FuncBoolean.java | 49 + .../xpath/internal/functions/FuncCeiling.java | 48 + .../xpath/internal/functions/FuncConcat.java | 91 + .../internal/functions/FuncContains.java | 58 + .../xpath/internal/functions/FuncCount.java | 65 + .../xpath/internal/functions/FuncCurrent.java | 84 + .../internal/functions/FuncDoclocation.java | 70 + .../functions/FuncExtElementAvailable.java | 98 + .../internal/functions/FuncExtFunction.java | 342 ++ .../functions/FuncExtFunctionAvailable.java | 105 + .../xpath/internal/functions/FuncFalse.java | 59 + .../xpath/internal/functions/FuncFloor.java | 48 + .../internal/functions/FuncGenerateId.java | 63 + .../xpath/internal/functions/FuncHere.java | 111 + .../xpath/internal/functions/FuncId.java | 152 + .../xpath/internal/functions/FuncLang.java | 83 + .../xpath/internal/functions/FuncLast.java | 109 + .../internal/functions/FuncLocalPart.java | 58 + .../internal/functions/FuncNamespace.java | 79 + .../functions/FuncNormalizeSpace.java | 87 + .../xpath/internal/functions/FuncNot.java | 48 + .../xpath/internal/functions/FuncNumber.java | 48 + .../internal/functions/FuncPosition.java | 137 + .../xpath/internal/functions/FuncQname.java | 64 + .../xpath/internal/functions/FuncRound.java | 53 + .../internal/functions/FuncStartsWith.java | 49 + .../xpath/internal/functions/FuncString.java | 48 + .../internal/functions/FuncStringLength.java | 48 + .../internal/functions/FuncSubstring.java | 125 + .../functions/FuncSubstringAfter.java | 56 + .../functions/FuncSubstringBefore.java | 54 + .../xpath/internal/functions/FuncSum.java | 66 + .../functions/FuncSystemProperty.java | 180 + .../internal/functions/FuncTranslate.java | 89 + .../xpath/internal/functions/FuncTrue.java | 59 + .../functions/FuncUnparsedEntityURI.java | 56 + .../xpath/internal/functions/Function.java | 145 + .../internal/functions/Function2Args.java | 187 + .../internal/functions/Function3Args.java | 186 + .../internal/functions/FunctionDef1Arg.java | 168 + .../internal/functions/FunctionMultiArgs.java | 239 + .../internal/functions/FunctionOneArg.java | 177 + .../functions/WrongNumberArgsException.java | 44 + .../xpath/internal/functions/package.html | 31 + .../internal/jaxp/JAXPExtensionsProvider.java | 209 + .../internal/jaxp/JAXPPrefixResolver.java | 128 + .../internal/jaxp/JAXPVariableStack.java | 74 + .../internal/jaxp/XPathExpressionImpl.java | 168 + .../xpath/internal/jaxp/XPathFactoryImpl.java | 320 ++ .../apache/xpath/internal/jaxp/XPathImpl.java | 244 + .../xpath/internal/jaxp/XPathImplUtil.java | 271 + .../xpath/internal/jaxp/XPathNodesImpl.java | 93 + .../xpath/internal/jaxp/XPathResultImpl.java | 205 + .../xpath/internal/objects/DTMXRTreeFrag.java | 61 + .../xpath/internal/objects/XBoolean.java | 168 + .../internal/objects/XBooleanStatic.java | 70 + .../objects/XMLStringFactoryImpl.java | 102 + .../xpath/internal/objects/XNodeSet.java | 971 ++++ .../internal/objects/XNodeSetForDOM.java | 129 + .../apache/xpath/internal/objects/XNull.java | 131 + .../xpath/internal/objects/XNumber.java | 437 ++ .../xpath/internal/objects/XObject.java | 760 +++ .../internal/objects/XObjectFactory.java | 162 + .../xpath/internal/objects/XRTreeFrag.java | 302 ++ .../objects/XRTreeFragSelectWrapper.java | 158 + .../xpath/internal/objects/XString.java | 1123 ++++ .../internal/objects/XStringForChars.java | 217 + .../xpath/internal/objects/XStringForFSB.java | 987 ++++ .../xpath/internal/objects/package.html | 29 + .../apache/xpath/internal/operations/And.java | 76 + .../xpath/internal/operations/Bool.java | 69 + .../apache/xpath/internal/operations/Div.java | 68 + .../xpath/internal/operations/Equals.java | 75 + .../apache/xpath/internal/operations/Gt.java | 50 + .../apache/xpath/internal/operations/Gte.java | 51 + .../apache/xpath/internal/operations/Lt.java | 50 + .../apache/xpath/internal/operations/Lte.java | 50 + .../xpath/internal/operations/Minus.java | 69 + .../apache/xpath/internal/operations/Mod.java | 68 + .../xpath/internal/operations/Mult.java | 67 + .../apache/xpath/internal/operations/Neg.java | 66 + .../xpath/internal/operations/NotEquals.java | 50 + .../xpath/internal/operations/Number.java | 70 + .../xpath/internal/operations/Operation.java | 216 + .../apache/xpath/internal/operations/Or.java | 76 + .../xpath/internal/operations/Plus.java | 68 + .../apache/xpath/internal/operations/Quo.java | 53 + .../xpath/internal/operations/String.java | 48 + .../internal/operations/UnaryOperation.java | 167 + .../xpath/internal/operations/Variable.java | 398 ++ .../operations/VariableSafeAbsRef.java | 74 + .../xpath/internal/operations/package.html | 28 + .../org/apache/xpath/internal/package.html | 29 + .../patterns/ContextMatchStepPattern.java | 181 + .../internal/patterns/FunctionPattern.java | 251 + .../xpath/internal/patterns/NodeTest.java | 696 +++ .../internal/patterns/NodeTestFilter.java | 40 + .../xpath/internal/patterns/StepPattern.java | 1056 ++++ .../xpath/internal/patterns/UnionPattern.java | 221 + .../xpath/internal/patterns/package.html | 28 + .../internal/res/XPATHErrorResources.java | 958 ++++ .../internal/res/XPATHErrorResources_de.java | 942 ++++ .../internal/res/XPATHErrorResources_en.java | 32 + .../internal/res/XPATHErrorResources_es.java | 942 ++++ .../internal/res/XPATHErrorResources_fr.java | 942 ++++ .../internal/res/XPATHErrorResources_it.java | 942 ++++ .../internal/res/XPATHErrorResources_ja.java | 952 ++++ .../internal/res/XPATHErrorResources_ko.java | 942 ++++ .../res/XPATHErrorResources_pt_BR.java | 942 ++++ .../internal/res/XPATHErrorResources_sv.java | 942 ++++ .../res/XPATHErrorResources_zh_CN.java | 952 ++++ .../res/XPATHErrorResources_zh_TW.java | 942 ++++ .../xpath/internal/res/XPATHMessages.java | 147 + .../apache/xpath/internal/res/package.html | 32 + .../com/sun/xml/internal/stream/Entity.java | 476 ++ .../internal/stream/EventFilterSupport.java | 103 + .../stream/StaxEntityResolverWrapper.java | 85 + .../internal/stream/StaxErrorReporter.java | 187 + .../internal/stream/StaxXMLInputSource.java | 83 + .../internal/stream/XMLBufferListener.java | 50 + .../xml/internal/stream/XMLEntityReader.java | 303 ++ .../xml/internal/stream/XMLEntityStorage.java | 615 +++ .../internal/stream/XMLEventReaderImpl.java | 288 + .../internal/stream/XMLInputFactoryImpl.java | 305 ++ .../internal/stream/XMLOutputFactoryImpl.java | 220 + .../internal/stream/dtd/DTDGrammarUtil.java | 494 ++ .../stream/dtd/nonvalidating/DTDGrammar.java | 880 ++++ .../dtd/nonvalidating/XMLAttributeDecl.java | 63 + .../dtd/nonvalidating/XMLElementDecl.java | 84 + .../dtd/nonvalidating/XMLNotationDecl.java | 72 + .../dtd/nonvalidating/XMLSimpleType.java | 162 + .../internal/stream/events/AttributeImpl.java | 161 + .../stream/events/CharacterEvent.java | 196 + .../internal/stream/events/CommentEvent.java | 76 + .../xml/internal/stream/events/DTDEvent.java | 112 + .../internal/stream/events/DummyEvent.java | 258 + .../stream/events/EndDocumentEvent.java | 61 + .../stream/events/EndElementEvent.java | 127 + .../stream/events/EntityDeclarationImpl.java | 145 + .../stream/events/EntityReferenceEvent.java | 80 + .../internal/stream/events/LocationImpl.java | 84 + .../internal/stream/events/NamedEvent.java | 83 + .../internal/stream/events/NamespaceImpl.java | 101 + .../events/NotationDeclarationImpl.java | 95 + .../events/ProcessingInstructionEvent.java | 101 + .../stream/events/StartDocumentEvent.java | 173 + .../stream/events/StartElementEvent.java | 248 + .../stream/events/XMLEventAllocatorImpl.java | 271 + .../stream/events/XMLEventFactoryImpl.java | 245 + .../internal/stream/util/BufferAllocator.java | 121 + .../stream/util/ReadOnlyIterator.java | 64 + .../util/ThreadLocalBufferAllocator.java | 57 + .../writers/UTF8OutputStreamWriter.java | 149 + .../stream/writers/WriterUtility.java | 253 + .../stream/writers/XMLDOMWriterImpl.java | 717 +++ .../stream/writers/XMLEventWriterImpl.java | 300 ++ .../stream/writers/XMLOutputSource.java | 45 + .../stream/writers/XMLStreamWriterBase.java | 47 + .../stream/writers/XMLStreamWriterImpl.java | 2247 ++++++++ .../internal/stream/writers/XMLWriter.java | 260 + .../src/main/java/javax/xml/XMLConstants.java | 418 ++ .../java/javax/xml/catalog/AltCatalog.java | 88 + .../java/javax/xml/catalog/BaseEntry.java | 236 + .../main/java/javax/xml/catalog/Catalog.java | 155 + .../java/javax/xml/catalog/CatalogEntry.java | 50 + .../javax/xml/catalog/CatalogException.java | 61 + .../javax/xml/catalog/CatalogFeatures.java | 683 +++ .../java/javax/xml/catalog/CatalogImpl.java | 472 ++ .../javax/xml/catalog/CatalogManager.java | 122 + .../javax/xml/catalog/CatalogMessages.java | 194 + .../xml/catalog/CatalogMessages.properties | 57 + .../xml/catalog/CatalogMessages_de.properties | 57 + .../xml/catalog/CatalogMessages_es.properties | 57 + .../xml/catalog/CatalogMessages_fr.properties | 57 + .../xml/catalog/CatalogMessages_it.properties | 57 + .../xml/catalog/CatalogMessages_ja.properties | 57 + .../xml/catalog/CatalogMessages_ko.properties | 57 + .../catalog/CatalogMessages_pt_BR.properties | 57 + .../xml/catalog/CatalogMessages_sv.properties | 57 + .../catalog/CatalogMessages_zh_CN.properties | 57 + .../catalog/CatalogMessages_zh_TW.properties | 57 + .../java/javax/xml/catalog/CatalogReader.java | 262 + .../javax/xml/catalog/CatalogResolver.java | 238 + .../xml/catalog/CatalogResolverImpl.java | 349 ++ .../javax/xml/catalog/DelegatePublic.java | 97 + .../javax/xml/catalog/DelegateSystem.java | 97 + .../java/javax/xml/catalog/DelegateUri.java | 97 + .../java/javax/xml/catalog/GroupEntry.java | 555 ++ .../java/javax/xml/catalog/NextCatalog.java | 48 + .../java/javax/xml/catalog/Normalizer.java | 177 + .../java/javax/xml/catalog/PublicEntry.java | 91 + .../java/javax/xml/catalog/RewriteSystem.java | 124 + .../java/javax/xml/catalog/RewriteUri.java | 120 + .../java/javax/xml/catalog/SystemEntry.java | 97 + .../java/javax/xml/catalog/SystemSuffix.java | 112 + .../main/java/javax/xml/catalog/UriEntry.java | 95 + .../java/javax/xml/catalog/UriSuffix.java | 107 + .../src/main/java/javax/xml/catalog/Util.java | 286 + .../java/javax/xml/catalog/package-info.java | 71 + .../DatatypeConfigurationException.java | 80 + .../javax/xml/datatype/DatatypeConstants.java | 274 + .../javax/xml/datatype/DatatypeFactory.java | 1061 ++++ .../java/javax/xml/datatype/Duration.java | 982 ++++ .../javax/xml/datatype/FactoryFinder.java | 308 ++ .../xml/datatype/XMLGregorianCalendar.java | 1063 ++++ .../java/javax/xml/datatype/package-info.java | 162 + .../javax/xml/namespace/NamespaceContext.java | 272 + .../main/java/javax/xml/namespace/QName.java | 457 ++ .../javax/xml/namespace/package-info.java | 49 + .../src/main/java/javax/xml/package-info.java | 34 + .../javax/xml/parsers/DocumentBuilder.java | 349 ++ .../xml/parsers/DocumentBuilderFactory.java | 662 +++ .../parsers/FactoryConfigurationError.java | 135 + .../java/javax/xml/parsers/FactoryFinder.java | 312 ++ .../parsers/ParserConfigurationException.java | 57 + .../java/javax/xml/parsers/SAXParser.java | 557 ++ .../javax/xml/parsers/SAXParserFactory.java | 499 ++ .../java/javax/xml/parsers/package-info.java | 36 + .../java/javax/xml/stream/EventFilter.java | 47 + .../xml/stream/FactoryConfigurationError.java | 126 + .../java/javax/xml/stream/FactoryFinder.java | 373 ++ .../main/java/javax/xml/stream/Location.java | 74 + .../java/javax/xml/stream/StreamFilter.java | 48 + .../javax/xml/stream/XMLEventFactory.java | 463 ++ .../java/javax/xml/stream/XMLEventReader.java | 113 + .../java/javax/xml/stream/XMLEventWriter.java | 250 + .../javax/xml/stream/XMLInputFactory.java | 526 ++ .../javax/xml/stream/XMLOutputFactory.java | 365 ++ .../java/javax/xml/stream/XMLReporter.java | 51 + .../java/javax/xml/stream/XMLResolver.java | 57 + .../javax/xml/stream/XMLStreamConstants.java | 128 + .../javax/xml/stream/XMLStreamException.java | 135 + .../javax/xml/stream/XMLStreamReader.java | 717 +++ .../javax/xml/stream/XMLStreamWriter.java | 523 ++ .../javax/xml/stream/events/Attribute.java | 68 + .../javax/xml/stream/events/Characters.java | 77 + .../java/javax/xml/stream/events/Comment.java | 43 + .../java/javax/xml/stream/events/DTD.java | 75 + .../javax/xml/stream/events/EndDocument.java | 39 + .../javax/xml/stream/events/EndElement.java | 56 + .../xml/stream/events/EntityDeclaration.java | 77 + .../xml/stream/events/EntityReference.java | 60 + .../javax/xml/stream/events/Namespace.java | 59 + .../stream/events/NotationDeclaration.java | 58 + .../stream/events/ProcessingInstruction.java | 49 + .../xml/stream/events/StartDocument.java | 73 + .../javax/xml/stream/events/StartElement.java | 112 + .../javax/xml/stream/events/XMLEvent.java | 190 + .../javax/xml/stream/events/package-info.java | 32 + .../java/javax/xml/stream/package-info.java | 51 + .../xml/stream/util/EventReaderDelegate.java | 128 + .../xml/stream/util/StreamReaderDelegate.java | 283 + .../xml/stream/util/XMLEventAllocator.java | 82 + .../xml/stream/util/XMLEventConsumer.java | 56 + .../javax/xml/stream/util/package-info.java | 32 + .../javax/xml/transform/ErrorListener.java | 129 + .../javax/xml/transform/FactoryFinder.java | 299 ++ .../java/javax/xml/transform/OutputKeys.java | 201 + .../main/java/javax/xml/transform/Result.java | 87 + .../main/java/javax/xml/transform/Source.java | 68 + .../javax/xml/transform/SourceLocator.java | 98 + .../java/javax/xml/transform/Templates.java | 84 + .../java/javax/xml/transform/Transformer.java | 340 ++ .../TransformerConfigurationException.java | 106 + .../xml/transform/TransformerException.java | 374 ++ .../xml/transform/TransformerFactory.java | 397 ++ .../TransformerFactoryConfigurationError.java | 132 + .../java/javax/xml/transform/URIResolver.java | 52 + .../javax/xml/transform/dom/DOMLocator.java | 51 + .../javax/xml/transform/dom/DOMResult.java | 369 ++ .../javax/xml/transform/dom/DOMSource.java | 157 + .../javax/xml/transform/dom/package-info.java | 61 + .../java/javax/xml/transform/overview.html | 291 ++ .../javax/xml/transform/package-info.java | 209 + .../javax/xml/transform/sax/SAXResult.java | 145 + .../javax/xml/transform/sax/SAXSource.java | 229 + .../transform/sax/SAXTransformerFactory.java | 152 + .../xml/transform/sax/TemplatesHandler.java | 70 + .../xml/transform/sax/TransformerHandler.java | 78 + .../javax/xml/transform/sax/package-info.java | 88 + .../javax/xml/transform/stax/StAXResult.java | 183 + .../javax/xml/transform/stax/StAXSource.java | 250 + .../xml/transform/stax/package-info.java | 45 + .../xml/transform/stream/StreamResult.java | 203 + .../xml/transform/stream/StreamSource.java | 342 ++ .../xml/transform/stream/package-info.java | 56 + .../java/javax/xml/validation/Schema.java | 104 + .../javax/xml/validation/SchemaFactory.java | 774 +++ .../SchemaFactoryConfigurationError.java | 80 + .../xml/validation/SchemaFactoryFinder.java | 365 ++ .../xml/validation/SchemaFactoryLoader.java | 68 + .../xml/validation/TypeInfoProvider.java | 197 + .../java/javax/xml/validation/Validator.java | 522 ++ .../xml/validation/ValidatorHandler.java | 485 ++ .../javax/xml/validation/package-info.java | 133 + .../src/main/java/javax/xml/xpath/XPath.java | 510 ++ .../java/javax/xml/xpath/XPathConstants.java | 84 + .../xml/xpath/XPathEvaluationResult.java | 142 + .../java/javax/xml/xpath/XPathException.java | 178 + .../java/javax/xml/xpath/XPathExpression.java | 398 ++ .../xml/xpath/XPathExpressionException.java | 74 + .../java/javax/xml/xpath/XPathFactory.java | 372 ++ .../XPathFactoryConfigurationException.java | 75 + .../javax/xml/xpath/XPathFactoryFinder.java | 360 ++ .../java/javax/xml/xpath/XPathFunction.java | 56 + .../xml/xpath/XPathFunctionException.java | 72 + .../xml/xpath/XPathFunctionResolver.java | 66 + .../main/java/javax/xml/xpath/XPathNodes.java | 65 + .../xml/xpath/XPathVariableResolver.java | 58 + .../java/javax/xml/xpath/package-info.java | 416 ++ .../jdk/xml/internal/ErrorHandlerProxy.java | 51 + .../java/jdk/xml/internal/JdkConstants.java | 392 ++ .../java/jdk/xml/internal/JdkProperty.java | 277 + .../java/jdk/xml/internal/JdkXmlFeatures.java | 422 ++ .../java/jdk/xml/internal/JdkXmlUtils.java | 422 ++ .../jdk/xml/internal/SecuritySupport.java | 469 ++ .../xml/internal/TransformErrorListener.java | 78 + .../src/main/java/jdk/xml/internal/Utils.java | 57 + .../jdk/xml/internal/XMLLimitAnalyzer.java | 248 + .../jdk/xml/internal/XMLSecurityManager.java | 633 +++ feature/jaxp/src/main/java/module-info.java | 927 ++++ .../jaxp/src/main/java/org/w3c/dom/Attr.java | 309 ++ .../main/java/org/w3c/dom/CDATASection.java | 83 + .../main/java/org/w3c/dom/CharacterData.java | 182 + .../src/main/java/org/w3c/dom/Comment.java | 59 + .../java/org/w3c/dom/DOMConfiguration.java | 442 ++ .../src/main/java/org/w3c/dom/DOMError.java | 116 + .../java/org/w3c/dom/DOMErrorHandler.java | 74 + .../main/java/org/w3c/dom/DOMException.java | 162 + .../java/org/w3c/dom/DOMImplementation.java | 165 + .../org/w3c/dom/DOMImplementationList.java | 72 + .../org/w3c/dom/DOMImplementationSource.java | 88 + .../src/main/java/org/w3c/dom/DOMLocator.java | 87 + .../main/java/org/w3c/dom/DOMStringList.java | 79 + .../src/main/java/org/w3c/dom/Document.java | 854 +++ .../java/org/w3c/dom/DocumentFragment.java | 82 + .../main/java/org/w3c/dom/DocumentType.java | 112 + .../src/main/java/org/w3c/dom/Element.java | 468 ++ .../java/org/w3c/dom/ElementTraversal.java | 103 + .../src/main/java/org/w3c/dom/Entity.java | 119 + .../java/org/w3c/dom/EntityReference.java | 72 + .../src/main/java/org/w3c/dom/NameList.java | 97 + .../main/java/org/w3c/dom/NamedNodeMap.java | 212 + .../jaxp/src/main/java/org/w3c/dom/Node.java | 968 ++++ .../src/main/java/org/w3c/dom/NodeList.java | 70 + .../src/main/java/org/w3c/dom/Notation.java | 69 + .../org/w3c/dom/ProcessingInstruction.java | 80 + .../jaxp/src/main/java/org/w3c/dom/Text.java | 187 + .../src/main/java/org/w3c/dom/TypeInfo.java | 214 + .../java/org/w3c/dom/UserDataHandler.java | 101 + .../bootstrap/DOMImplementationRegistry.java | 403 ++ .../org/w3c/dom/bootstrap/package-info.java | 32 + .../org/w3c/dom/events/DocumentEvent.java | 85 + .../main/java/org/w3c/dom/events/Event.java | 170 + .../org/w3c/dom/events/EventException.java | 67 + .../org/w3c/dom/events/EventListener.java | 70 + .../java/org/w3c/dom/events/EventTarget.java | 131 + .../java/org/w3c/dom/events/MouseEvent.java | 185 + .../org/w3c/dom/events/MutationEvent.java | 137 + .../main/java/org/w3c/dom/events/UIEvent.java | 87 + .../java/org/w3c/dom/events/package-info.java | 42 + .../org/w3c/dom/ls/DOMImplementationLS.java | 156 + .../main/java/org/w3c/dom/ls/LSException.java | 80 + .../src/main/java/org/w3c/dom/ls/LSInput.java | 249 + .../main/java/org/w3c/dom/ls/LSLoadEvent.java | 66 + .../main/java/org/w3c/dom/ls/LSOutput.java | 137 + .../main/java/org/w3c/dom/ls/LSParser.java | 520 ++ .../java/org/w3c/dom/ls/LSParserFilter.java | 204 + .../java/org/w3c/dom/ls/LSProgressEvent.java | 79 + .../org/w3c/dom/ls/LSResourceResolver.java | 112 + .../java/org/w3c/dom/ls/LSSerializer.java | 492 ++ .../org/w3c/dom/ls/LSSerializerFilter.java | 94 + .../java/org/w3c/dom/ls/package-info.java | 39 + .../main/java/org/w3c/dom/package-info.java | 49 + .../org/w3c/dom/ranges/DocumentRange.java | 62 + .../main/java/org/w3c/dom/ranges/Range.java | 445 ++ .../org/w3c/dom/ranges/RangeException.java | 70 + .../java/org/w3c/dom/ranges/package-info.java | 37 + .../w3c/dom/traversal/DocumentTraversal.java | 122 + .../org/w3c/dom/traversal/NodeFilter.java | 173 + .../org/w3c/dom/traversal/NodeIterator.java | 138 + .../org/w3c/dom/traversal/TreeWalker.java | 208 + .../org/w3c/dom/traversal/package-info.java | 36 + .../java/org/w3c/dom/views/AbstractView.java | 56 + .../java/org/w3c/dom/views/DocumentView.java | 59 + .../java/org/w3c/dom/views/package-info.java | 37 + .../main/java/org/xml/sax/AttributeList.java | 206 + .../src/main/java/org/xml/sax/Attributes.java | 268 + .../main/java/org/xml/sax/ContentHandler.java | 449 ++ .../src/main/java/org/xml/sax/DTDHandler.java | 129 + .../java/org/xml/sax/DocumentHandler.java | 245 + .../main/java/org/xml/sax/EntityResolver.java | 131 + .../main/java/org/xml/sax/ErrorHandler.java | 149 + .../main/java/org/xml/sax/HandlerBase.java | 385 ++ .../main/java/org/xml/sax/InputSource.java | 399 ++ .../src/main/java/org/xml/sax/Locator.java | 148 + .../src/main/java/org/xml/sax/Parser.java | 222 + .../main/java/org/xml/sax/SAXException.java | 230 + .../xml/sax/SAXNotRecognizedException.java | 66 + .../org/xml/sax/SAXNotSupportedException.java | 66 + .../java/org/xml/sax/SAXParseException.java | 301 ++ .../src/main/java/org/xml/sax/XMLFilter.java | 76 + .../src/main/java/org/xml/sax/XMLReader.java | 416 ++ .../java/org/xml/sax/ext/Attributes2.java | 146 + .../java/org/xml/sax/ext/Attributes2Impl.java | 322 ++ .../java/org/xml/sax/ext/DeclHandler.java | 158 + .../java/org/xml/sax/ext/DefaultHandler2.java | 144 + .../java/org/xml/sax/ext/EntityResolver2.java | 208 + .../java/org/xml/sax/ext/LexicalHandler.java | 224 + .../main/java/org/xml/sax/ext/Locator2.java | 89 + .../java/org/xml/sax/ext/Locator2Impl.java | 115 + .../java/org/xml/sax/ext/package-info.java | 73 + .../xml/sax/helpers/AttributeListImpl.java | 325 ++ .../org/xml/sax/helpers/AttributesImpl.java | 628 +++ .../org/xml/sax/helpers/DefaultHandler.java | 498 ++ .../java/org/xml/sax/helpers/LocatorImpl.java | 226 + .../org/xml/sax/helpers/NamespaceSupport.java | 841 +++ .../java/org/xml/sax/helpers/NewInstance.java | 89 + .../org/xml/sax/helpers/ParserAdapter.java | 1058 ++++ .../org/xml/sax/helpers/ParserFactory.java | 137 + .../org/xml/sax/helpers/XMLFilterImpl.java | 725 +++ .../org/xml/sax/helpers/XMLReaderAdapter.java | 550 ++ .../org/xml/sax/helpers/XMLReaderFactory.java | 262 + .../org/xml/sax/helpers/package-info.java | 38 + .../main/java/org/xml/sax/package-info.java | 333 ++ feature/the-unsafe/.gitignore | 1 + feature/the-unsafe/build.gradle.kts | 15 + .../src/main/java/sun/misc/Unsafe.java | 609 +++ 2048 files changed, 584166 insertions(+) create mode 100644 app/src/main/res/drawable/outline_redo_24.xml create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CloseOp.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CommentsHelper.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Doc.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/DocBuilder.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormatterDiagnostic.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormattingError.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Indent.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Input.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/InputOutput.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Newlines.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Op.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpenOp.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpsBuilder.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Output.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptions.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptionsParser.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatFileCallable.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProvider.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaOutput.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Replacement.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/TypeNameClassifier.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/UsageException.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/CharStream.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocFormatter.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocLexer.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/NestingCounter.java create mode 100644 feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/Token.java create mode 100644 feature/jaxp/.gitignore create mode 100644 feature/jaxp/build.gradle.kts create mode 100644 feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Scanner.java create mode 100644 feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Symbol.java create mode 100644 feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/lr_parser.java create mode 100644 feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/virtual_parse_stack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Const.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/ExceptionConst.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Repository.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Annotations.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Attribute.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Code.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/CodeException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Constant.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantString.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Deprecated.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Field.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClass.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/JavaClass.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumber.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Method.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Module.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestHost.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestMembers.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Node.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/PMGClass.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Signature.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SourceFile.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMap.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Synthetic.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Unknown.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Utility.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Visitor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARETURN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ATHROW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BIPUSH.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BasicType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchHandle.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CPInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGenException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassObserver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2F.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2I.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2L.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DADD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPG.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCONST.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DDIV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DLOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DMUL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DNEG.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DREM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DRETURN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSUB.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X1.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X2.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2D.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2I.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2L.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FADD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPG.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCONST.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FDIV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FLOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FMUL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FNEG.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FREM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FRETURN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSUB.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldObserver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETFIELD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO_W.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2B.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2C.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2D.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2F.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2L.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2S.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IADD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IAND.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ICONST.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IDIV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFEQ.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGT.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLT.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNULL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IINC.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ILOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMUL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INEG.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IOR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IREM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IRETURN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISUB.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IUSHR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IXOR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IfInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Instruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionConst.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR_W.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2D.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2F.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2I.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LADD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LAND.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCMP.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCONST.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC2_W.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC_W.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDIV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LLOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LMUL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LNEG.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LREM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LRETURN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHL.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSUB.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LUSHR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LXOR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadClass.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodObserver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NOP.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ObjectType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP2.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUSH.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PopInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PushInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RET.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RETURN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReferenceType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SALOAD.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SASTORE.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SIPUSH.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWAP.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWITCH.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Select.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackConsumer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackProducer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TargetLostException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Type.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Visitor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Args.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/AttributeHTML.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELComparator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELifier.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ByteSequence.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Class2HTML.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassQueue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassSet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/CodeHTML.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ConstantHTML.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/InstructionFinder.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/MethodHTML.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Repository.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/ExpressionContext.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltCommon.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDynamic.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltMath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltSets.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/Extensions.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/NodeInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLMessages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_en.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTInfo.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/Constants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xslt/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/CollatorFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMCache.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMEnhancedForDTM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/NodeIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/ProcessorVersion.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/StripFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/Translet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/TransletException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsoluteLocationPath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsolutePathPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AlternativePattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AncestorPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ArgumentList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Attribute.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CeilingCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Closure.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Comment.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CompilerException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ConcatCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ContainsCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Copy.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CopyOf.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CurrentCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DecimalFormatting.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ElementAvailableCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/EqualityExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Expression.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Fallback.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterParentPath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilteredAbsoluteLocationPath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FloorCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FlowList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FormatNumberCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/GenerateIdCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdKeyPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/If.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IllegalCharException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Instruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IntExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LangCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LastCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralAttribute.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocalNameCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocationPathPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/NameBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/NameCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/NamespaceAlias.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/NamespaceUriCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/NodeTest.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/NotCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Number.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/NumberCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Otherwise.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Output.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Param.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ParameterRef.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ParentLocationPath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ParentPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Pattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/PositionCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Predicate.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ProcessingInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ProcessingInstructionPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/QName.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/RealExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/RelationalExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/RelativeLocationPath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/RelativePathPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/RoundCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/SimpleAttributeValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/SourceLoader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/StartsWithCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Step.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/StepPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/StringCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/StringLengthCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Text.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/TopLevelElement.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/TransletOutput.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/UnaryOpExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/UnionPathExpr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/UnparsedEntityUriCall.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/UnresolvedRef.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/UnsupportedElement.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/UseAttributeSets.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ValueOf.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Variable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableRef.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableRefBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/When.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Whitespace.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/XPathLexer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/XPathParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/XslAttribute.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/sym.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/AttributeSetMethodGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/BooleanType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ClassGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/CompareGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ca.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_cs.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ja.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_pt_BR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_sk.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/FilterGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/IntType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/InternalError.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MarkerInstruction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MatchGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MultiHashtable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NamedMethodGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NodeCounterGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NodeSetType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NodeSortRecordFactGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NodeSortRecordGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NodeType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NumberType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ObjectType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/OutlineableChunkEnd.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/OutlineableChunkStart.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/RealType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ReferenceType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ResultTreeType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/RtMethodGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/SlotAllocator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/StringStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/StringType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/TestGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Type.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/TypeCheckError.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/util/VoidType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/AbsoluteIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/AnyNodeCounter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/ArrayNodeListIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/BitArray.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/CachedNodeListIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/ClonedNodeListIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/CollatorFactoryBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/CurrentNodeListFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/CurrentNodeListIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/DOMBuilder.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/DOMWSFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/DupFilterIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/EmptyFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/ExtendedSAX.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/Filter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/FilterIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/FilteredStepIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/ForwardPositionIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/LoadDocument.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/MatchingIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/MultiValuedNodeHeapIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/MultipleNodeCounter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/NodeCounter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/NodeIteratorBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecordFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/NthIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/SingleNodeCounter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/SingletonIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/SortSettings.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/SortingIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/StepIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/StripWhitespaceFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/UnionIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/dom/XSLTCDTMManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/Attributes.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/Constants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_ca.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_cs.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_ja.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_pt_BR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_sk.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/InternalRuntimeError.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/MessageHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/Node.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/Operators.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/Parameter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/output/OutputBuffer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/output/StringOutputBuffer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/output/TransletOutputHandlerFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2TO.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/OutputSettings.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2StAXBaseWriter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2StAXEventWriter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2StAXStreamWriter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/StAXEvent2SAX.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/StAXStream2SAX.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/TrAXFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerHandlerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/trax/XSLTCSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/util/IntegerArray.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/AbortException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/AttrImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/AttributeMap.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/CDATASectionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/CharacterDataImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/ChildNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/CommentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMErrorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMImplementationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMImplementationListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMImplementationSourceImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMInputImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMLocatorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMOutputImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMStringListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DOMXSImplementationSourceImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeepNodeListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredAttrImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredAttrNSImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredCDATASectionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredCommentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredDOMImplementationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredDocumentTypeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredElementDefinitionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredElementImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredElementNSImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredEntityImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredEntityReferenceImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredNotationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredProcessingInstructionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DeferredTextImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DocumentFragmentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/ElementDefinitionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/ElementImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/EntityImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/EntityReferenceImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/LCount.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/NodeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/NodeIteratorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/NodeListCache.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/NotationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/PSVIAttrNSImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/PSVIDOMImplementationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/PSVIDocumentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/ParentNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/ProcessingInstructionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/RangeExceptionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/RangeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/TextImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/TreeWalkerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/events/EventImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/dom/events/MutationEventImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/Constants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/ExternalSubsetResolver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/PropertyManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/RevalidationHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XML11NamespaceBinder.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLEntityDescription.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLEntityHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLScanner.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLStreamFilterImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammarBucket.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XML11DTDProcessor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XML11DTDValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XML11NSDTDValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLAttributeDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLContentSpec.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidatorFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLElementDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLEntityDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLNSDTDValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLNotationDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/XMLSimpleType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/CMAny.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/CMBinOp.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/CMLeaf.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/CMNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/CMStateSet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/CMUniOp.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/ContentModelValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/MixedContentModel.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dtd/models/SimpleContentModel.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/DVFactoryException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/DatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/InvalidDatatypeFacetException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/InvalidDatatypeValueException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/XSFacets.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/XSSimpleType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/DTDDVFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/ENTITYDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/IDDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/IDREFDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/ListDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/NMTOKENDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/NOTATIONDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/StringDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11DTDDVFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11IDDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11IDREFDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11NMTOKENDatatypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/util/Base64.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/util/HexBin.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/AnyAtomicDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/AnySimpleDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/AnyURIDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/BooleanDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/DecimalDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/EntityDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/FullDVFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/IDDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/IDREFDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/IntegerDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/QNameDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDateTimeException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/StringDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/TypeValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/UnionDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/io/ASCIIReader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/io/Latin1Reader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/io/MalformedByteSequenceException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/io/UCSReader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/io/UTF16Reader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/io/UTF8Reader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/validation/ConfigurableValidationState.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/validation/EntityState.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/validation/ValidationManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/XPathException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/BMPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/Match.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/Op.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParseException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/REUtil.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_de.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_es.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_fr.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_it.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_ja.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_ko.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_sv.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xpath/regex/message_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/AttributePSVImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/ElementPSVImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/PSVIErrorList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/SchemaNamespaceSupport.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/SchemaSymbols.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSAnnotationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSElementDeclHelper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSImplementationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/FieldActivator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/IdentityConstraint.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/KeyRef.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/UniqueOrKey.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/ValueStore.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/identity/XPathMatcher.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMBinOp.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMLeaf.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMUniOp.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/DefaultDocument.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/DefaultElement.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/DefaultNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/DefaultText.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/DefaultXMLDocumentHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/NamedNodeMapImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/NodeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/opti/TextImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/SchemaContentHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAnnotationInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/SimpleLocator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XInt.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XIntPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XS10TypeHelper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/DefaultValidationErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/JAXPConstants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/JAXPValidatorComponent.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/TeeXMLDocumentFilterImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/DOMDocumentHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/DOMResultAugmentor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/DOMResultBuilder.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/DraconianErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/ErrorHandlerAdaptor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/ReadOnlyGrammarPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/SimpleXMLSchema.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/SoftReferenceGrammarPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/StAXValidatorHelper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/Util.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHelper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/WeakReferenceXMLSchema.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/WrappedSAXException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/AbstractXMLDocumentParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/CachingParserPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/DOMParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/DTDParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/IntegratedParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/SAXParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XIncludeParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XML11Configurable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XMLParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/parsers/XPointerParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/AttributesProxy.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/DOMEntityResolverWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/DOMErrorHandlerWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/DOMInputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/DOMUtil.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/DefaultErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/DraconianErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/EncodingMap.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/EntityResolver2Wrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/EntityResolverWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/ErrorHandlerProxy.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/ErrorHandlerWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/FeatureState.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/HTTPInputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/IntStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/LocatorProxy.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/LocatorWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/MessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/NamespaceContextWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/NamespaceSupport.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/PrimeNumberSequenceGenerator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/PropertyState.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SAX2XNI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SAXInputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SAXLocatorWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SecurityManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/ShadowedSymbolTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/StAXInputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/Status.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SymbolHash.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SymbolTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/SynchronizedSymbolTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/TeeXMLDocumentFilterImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/URI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XML11Char.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLAttributesIteratorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLChar.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLDocumentFilterImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLEntityDescriptionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLErrorCode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLGrammarPoolImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLInputSourceAdaptor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLLocatorWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLResourceIdentifierImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLStringBuffer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/util/XMLSymbols.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/utils/ConfigurationError.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/utils/XMLSecurityPropertyManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xinclude/MultipleScopeNamespaceSupport.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xinclude/XInclude11TextReader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xinclude/XIncludeNamespaceSupport.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/Augmentations.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/NamespaceContext.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/QName.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLAttributes.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLDTDContentModelHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLDTDHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLDocumentFragmentHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLDocumentHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLLocator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLResourceIdentifier.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XMLString.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/XNIException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/grammars/Grammar.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/grammars/XMLDTDDescription.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/grammars/XMLGrammarDescription.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/grammars/XMLGrammarLoader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/grammars/XMLGrammarPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/grammars/XMLSchemaDescription.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/grammars/XSGrammar.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLComponent.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDContentModelFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDContentModelSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDScanner.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDocumentFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDocumentScanner.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLDocumentSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLEntityResolver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLInputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLParseException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xni/parser/XMLPullParserConfiguration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xpointer/ShortHandPointer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xpointer/XPointerErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xpointer/XPointerPart.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xpointer/XPointerProcessor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/AttributePSVI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/ElementPSVI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/ItemPSVI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/LSInputList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/PSVIProvider.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/ShortList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/StringList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSAnnotation.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSAttributeDeclaration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSAttributeGroupDefinition.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSAttributeUse.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSComplexTypeDefinition.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSConstants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSElementDeclaration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSFacet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSIDCDefinition.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSImplementation.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSLoader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSModel.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSModelGroup.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSModelGroupDefinition.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSMultiValueFacet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSNamedMap.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSNamespaceItem.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSNamespaceItemList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSNotationDeclaration.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSObject.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSObjectList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSParticle.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSSimpleTypeDefinition.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSTerm.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSTypeDefinition.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSValue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/XSWildcard.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/XSDateTime.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/XSDecimal.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/XSDouble.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/XSFloat.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/XSQName.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xerces/internal/xs/datatypes/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/Axis.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMAxisIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMAxisTraverser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMDOMException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/DTMWSFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/ChunkedIntArray.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/CoroutineManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/CoroutineParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/CustomStringPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMAxisIterNodeList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMAxisIteratorBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMChildIterNodeList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBaseIterators.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBaseTraversers.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMDocumentImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMNamedNodeMap.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeListBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMSafeStringPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMStringPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/DTMTreeWalker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/EmptyIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/ExpandedNameTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/ExtendedType.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Filter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Xerces.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/NodeLocator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/dom2dtm/DOM2DTM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2RTFDTM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_ca.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_cs.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_en.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_ja.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_pt_BR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_sk.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_tr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_zh_HK.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLErrorResources_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/res/XMLMessages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/DOMSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/ElementState.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/Encodings.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/HTMLSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/IndentPrinter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/LineSeparator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/Method.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/OutputFormat.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/Printer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/Serializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/SerializerFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/TextSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/XHTMLSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/XML11Serializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/AttributesImplSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/CharInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/DOM3Serializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/DOMSerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ElemContext.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ElemDesc.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/Encodings.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/Encodings.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ExtendedContentHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ExtendedLexicalHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/HTMLEntities.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/Method.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/NamespaceMappings.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/OutputPropertyUtils.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/Serializer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/SerializerBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/SerializerConstants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/SerializerTrace.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/SerializerTraceWriter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToHTMLSAXHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToSAXHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToStream.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToTextSAXHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToTextStream.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToXMLSAXHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/TransformStateSetter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/TreeWalker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/Version.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/WriterChain.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/WriterToASCI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/WriterToUTF8Buffered.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/XMLEntities.properties create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/XSLOutputAttributes.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOM3SerializerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOM3TreeWalker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOMConstants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorHandlerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOMLocatorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOMOutputImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/DOMStringListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/dom3/NamespaceSupport.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/BoolStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/Messages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/MsgKey.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ca.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_cs.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_en.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ja.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_pt_BR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/StringToIntTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/SystemIDResolver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/URI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/Utils.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/serializer/utils/WrappedRuntimeException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/AttList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/BoolStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/CharKey.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/Constants.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/DOM2Helper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/DOMBuilder.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/DefaultErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/ElemDesc.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/FastStringBuffer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/IntStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/IntVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/LocaleUtility.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/MutableAttrListImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/NSInfo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/NameSpace.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/NodeConsumer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/NodeVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/ObjectPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/ObjectStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/ObjectVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/PrefixResolver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/PrefixResolverDefault.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/QName.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/RawCharacterHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/SAXSourceLocator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/SafeThread.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/SerializableLocatorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StopParseException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StringBufferPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StringComparable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StringToIntTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StringToStringTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StringToStringTableVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StringVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/StylesheetPIHandler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/SuballocatedByteVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/SuballocatedIntVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/SystemIDResolver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/ThreadControllerWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/TreeWalker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/Trie.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/URI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/UnImplNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/WrappedRuntimeException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/WrongParserException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XML11Char.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XMLChar.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XMLCharacterRecognizer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XMLString.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XMLStringDefault.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XMLStringFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/XMLStringFactoryDefault.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/CharArrayWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/IntArrayWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/LongArrayWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/StringArrayWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResourceBundle.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResourceBundleBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_en.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_ja_JP_A.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_ja_JP_HA.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_ja_JP_HI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_ja_JP_I.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xml/internal/utils/res/XResources_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/Arg.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/CachedXPathAPI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/Expression.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/ExpressionNode.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/ExpressionOwner.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/ExtensionsProvider.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/FoundIndex.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/NodeSet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/NodeSetDTM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/SourceTree.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/VariableStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/WhitespaceStrippingElementMatcher.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPath.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPathAPI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPathContext.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPathException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPathFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPathProcessorException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPathVisitable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/XPathVisitor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/AttributeIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/AxesWalker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/BasicTestIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/ChildIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/ChildTestIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/ContextNodeList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/DescendantIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/FilterExprIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/FilterExprIteratorSimple.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/FilterExprWalker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/HasPositionalPredChecker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/IteratorPool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/LocPathIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/MatchPatternIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/NodeSequence.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/OneStepIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/OneStepIteratorForward.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/PathComponent.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/PredicatedNodeTest.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/RTFIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/ReverseAxesWalker.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/SelfIteratorNoPredicate.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/SubContextList.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/UnionChildIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/UnionPathIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/WalkingIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/WalkingIteratorSorted.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/axes/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/Compiler.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/FuncLoader.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/Keywords.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/Lexer.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/OpCodes.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/OpMap.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/OpMapVector.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/PsuedoNames.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/Token.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/XPathDumper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/XPathParser.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/compiler/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncBoolean.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncCeiling.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncConcat.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncContains.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncCount.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncCurrent.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncDoclocation.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncExtElementAvailable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncExtFunction.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncExtFunctionAvailable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncFalse.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncFloor.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncGenerateId.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncHere.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncId.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncLang.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncLast.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncLocalPart.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncNamespace.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncNormalizeSpace.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncNot.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncNumber.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncPosition.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncQname.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncRound.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncStartsWith.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncString.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncStringLength.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncSubstring.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncSubstringAfter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncSubstringBefore.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncSum.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncSystemProperty.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncTranslate.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncTrue.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FuncUnparsedEntityURI.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/Function.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/Function2Args.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/Function3Args.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FunctionDef1Arg.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FunctionMultiArgs.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/FunctionOneArg.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/WrongNumberArgsException.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/functions/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/JAXPPrefixResolver.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/JAXPVariableStack.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/XPathImplUtil.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/XPathNodesImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/jaxp/XPathResultImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/DTMXRTreeFrag.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XBoolean.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XBooleanStatic.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XMLStringFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XNodeSet.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XNodeSetForDOM.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XNull.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XNumber.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XObject.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XObjectFactory.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XRTreeFrag.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XRTreeFragSelectWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XString.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XStringForChars.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/XStringForFSB.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/objects/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/And.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Bool.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Div.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Equals.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Gt.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Gte.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Lt.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Lte.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Minus.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Mod.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Mult.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Neg.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/NotEquals.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Number.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Operation.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Or.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Plus.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Quo.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/String.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/UnaryOperation.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/Variable.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/VariableSafeAbsRef.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/operations/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/patterns/ContextMatchStepPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/patterns/FunctionPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/patterns/NodeTest.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/patterns/NodeTestFilter.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/patterns/StepPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/patterns/UnionPattern.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/patterns/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_en.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_es.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_fr.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_it.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ja.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ko.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_pt_BR.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_sv.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_zh_CN.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_zh_TW.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/XPATHMessages.java create mode 100644 feature/jaxp/src/main/java/com/sun/org/apache/xpath/internal/res/package.html create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/Entity.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/EventFilterSupport.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/StaxErrorReporter.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/StaxXMLInputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/XMLBufferListener.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/XMLEntityReader.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/XMLEntityStorage.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/XMLEventReaderImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/XMLInputFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/XMLOutputFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/dtd/nonvalidating/DTDGrammar.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/dtd/nonvalidating/XMLAttributeDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/dtd/nonvalidating/XMLElementDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/dtd/nonvalidating/XMLNotationDecl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/dtd/nonvalidating/XMLSimpleType.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/AttributeImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/CharacterEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/CommentEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/DTDEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/DummyEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/EndDocumentEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/EndElementEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/EntityDeclarationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/EntityReferenceEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/LocationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/NamedEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/NamespaceImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/NotationDeclarationImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/ProcessingInstructionEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/StartDocumentEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/StartElementEvent.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/XMLEventAllocatorImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/events/XMLEventFactoryImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/util/BufferAllocator.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/util/ReadOnlyIterator.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/util/ThreadLocalBufferAllocator.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/UTF8OutputStreamWriter.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/WriterUtility.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/XMLEventWriterImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/XMLOutputSource.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/XMLStreamWriterBase.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java create mode 100644 feature/jaxp/src/main/java/com/sun/xml/internal/stream/writers/XMLWriter.java create mode 100644 feature/jaxp/src/main/java/javax/xml/XMLConstants.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/AltCatalog.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/BaseEntry.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/Catalog.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogEntry.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogFeatures.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogImpl.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogManager.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_de.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_es.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_fr.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_it.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_ja.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_ko.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_pt_BR.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_sv.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_zh_CN.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogMessages_zh_TW.properties create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogReader.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogResolver.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/CatalogResolverImpl.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/DelegatePublic.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/DelegateSystem.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/DelegateUri.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/GroupEntry.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/NextCatalog.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/Normalizer.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/PublicEntry.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/RewriteSystem.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/RewriteUri.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/SystemEntry.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/SystemSuffix.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/UriEntry.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/UriSuffix.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/Util.java create mode 100644 feature/jaxp/src/main/java/javax/xml/catalog/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/datatype/DatatypeConfigurationException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/datatype/DatatypeConstants.java create mode 100644 feature/jaxp/src/main/java/javax/xml/datatype/DatatypeFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/datatype/Duration.java create mode 100644 feature/jaxp/src/main/java/javax/xml/datatype/FactoryFinder.java create mode 100644 feature/jaxp/src/main/java/javax/xml/datatype/XMLGregorianCalendar.java create mode 100644 feature/jaxp/src/main/java/javax/xml/datatype/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/namespace/NamespaceContext.java create mode 100644 feature/jaxp/src/main/java/javax/xml/namespace/QName.java create mode 100644 feature/jaxp/src/main/java/javax/xml/namespace/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/DocumentBuilder.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/FactoryConfigurationError.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/FactoryFinder.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/ParserConfigurationException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/SAXParser.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/SAXParserFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/parsers/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/EventFilter.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/FactoryConfigurationError.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/FactoryFinder.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/Location.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/StreamFilter.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLEventFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLEventReader.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLEventWriter.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLInputFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLOutputFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLReporter.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLResolver.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLStreamConstants.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLStreamException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLStreamReader.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/XMLStreamWriter.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/Attribute.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/Characters.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/Comment.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/DTD.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/EndDocument.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/EndElement.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/EntityDeclaration.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/EntityReference.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/Namespace.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/NotationDeclaration.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/ProcessingInstruction.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/StartDocument.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/StartElement.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/XMLEvent.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/events/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/util/EventReaderDelegate.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/util/StreamReaderDelegate.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/util/XMLEventAllocator.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/util/XMLEventConsumer.java create mode 100644 feature/jaxp/src/main/java/javax/xml/stream/util/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/ErrorListener.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/FactoryFinder.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/OutputKeys.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/Result.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/Source.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/SourceLocator.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/Templates.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/Transformer.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/TransformerConfigurationException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/TransformerException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/TransformerFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/TransformerFactoryConfigurationError.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/URIResolver.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/dom/DOMLocator.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/dom/DOMResult.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/dom/DOMSource.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/dom/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/overview.html create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/sax/SAXResult.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/sax/SAXSource.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/sax/SAXTransformerFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/sax/TemplatesHandler.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/sax/TransformerHandler.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/sax/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/stax/StAXResult.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/stax/StAXSource.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/stax/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/stream/StreamResult.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/stream/StreamSource.java create mode 100644 feature/jaxp/src/main/java/javax/xml/transform/stream/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/Schema.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/SchemaFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/SchemaFactoryConfigurationError.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/SchemaFactoryFinder.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/SchemaFactoryLoader.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/TypeInfoProvider.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/Validator.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/ValidatorHandler.java create mode 100644 feature/jaxp/src/main/java/javax/xml/validation/package-info.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPath.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathConstants.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathEvaluationResult.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathExpression.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathExpressionException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathFactory.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathFactoryConfigurationException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathFactoryFinder.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathFunction.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathFunctionException.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathFunctionResolver.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathNodes.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/XPathVariableResolver.java create mode 100644 feature/jaxp/src/main/java/javax/xml/xpath/package-info.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/ErrorHandlerProxy.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/JdkConstants.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/JdkProperty.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/JdkXmlFeatures.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/JdkXmlUtils.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/SecuritySupport.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/TransformErrorListener.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/Utils.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/XMLLimitAnalyzer.java create mode 100644 feature/jaxp/src/main/java/jdk/xml/internal/XMLSecurityManager.java create mode 100644 feature/jaxp/src/main/java/module-info.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Attr.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/CDATASection.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/CharacterData.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Comment.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMConfiguration.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMError.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMErrorHandler.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMException.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMImplementation.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMImplementationList.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMImplementationSource.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMLocator.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DOMStringList.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Document.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DocumentFragment.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/DocumentType.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Element.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ElementTraversal.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Entity.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/EntityReference.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/NameList.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/NamedNodeMap.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Node.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/NodeList.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Notation.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ProcessingInstruction.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/Text.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/TypeInfo.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/UserDataHandler.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/bootstrap/DOMImplementationRegistry.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/bootstrap/package-info.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/DocumentEvent.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/Event.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/EventException.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/EventListener.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/EventTarget.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/MouseEvent.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/MutationEvent.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/UIEvent.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/events/package-info.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/DOMImplementationLS.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSException.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSInput.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSLoadEvent.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSOutput.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSParser.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSParserFilter.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSProgressEvent.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSResourceResolver.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSSerializer.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/LSSerializerFilter.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ls/package-info.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/package-info.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ranges/DocumentRange.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ranges/Range.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ranges/RangeException.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/ranges/package-info.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/traversal/DocumentTraversal.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/traversal/NodeFilter.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/traversal/NodeIterator.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/traversal/TreeWalker.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/traversal/package-info.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/views/AbstractView.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/views/DocumentView.java create mode 100644 feature/jaxp/src/main/java/org/w3c/dom/views/package-info.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/AttributeList.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/Attributes.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ContentHandler.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/DTDHandler.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/DocumentHandler.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/EntityResolver.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ErrorHandler.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/HandlerBase.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/InputSource.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/Locator.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/Parser.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/SAXException.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/SAXNotRecognizedException.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/SAXNotSupportedException.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/SAXParseException.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/XMLFilter.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/XMLReader.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/Attributes2.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/Attributes2Impl.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/DeclHandler.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/DefaultHandler2.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/EntityResolver2.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/LexicalHandler.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/Locator2.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/Locator2Impl.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/ext/package-info.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/AttributeListImpl.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/AttributesImpl.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/DefaultHandler.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/LocatorImpl.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/NamespaceSupport.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/NewInstance.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/ParserAdapter.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/ParserFactory.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/XMLFilterImpl.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/XMLReaderAdapter.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/helpers/package-info.java create mode 100644 feature/jaxp/src/main/java/org/xml/sax/package-info.java create mode 100644 feature/the-unsafe/.gitignore create mode 100644 feature/the-unsafe/build.gradle.kts create mode 100644 feature/the-unsafe/src/main/java/sun/misc/Unsafe.java diff --git a/app/src/main/res/drawable/outline_redo_24.xml b/app/src/main/res/drawable/outline_redo_24.xml new file mode 100644 index 000000000..5301f06c5 --- /dev/null +++ b/app/src/main/res/drawable/outline_redo_24.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CloseOp.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CloseOp.java new file mode 100644 index 000000000..59e7e5a28 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CloseOp.java @@ -0,0 +1,45 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.MoreObjects; + +/** + * A {@code CloseOp} closes a level. It is an {@link Op} in the sequence of {@link Op}s generated by + * {@link OpsBuilder}. When the sequence is turned into a {@link Doc} by {@link DocBuilder}, ranges + * delimited by {@link OpenOp}-{@code CloseOp} pairs turn into nested {@link Doc.Level}s. + */ +public enum CloseOp implements Op { + CLOSE; + + /** + * Make a {@code CloseOp}, returning a singleton since they are all the same. + * + * @return the singleton {@code CloseOp} + */ + public static Op make() { + return CLOSE; + } + + @Override + public void add(DocBuilder builder) { + builder.close(); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CommentsHelper.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CommentsHelper.java new file mode 100644 index 000000000..1e33003b0 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/CommentsHelper.java @@ -0,0 +1,50 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.googlejavaformat.Input.Tok; +import java.util.Optional; +import java.util.regex.Pattern; + +/** + * Rewrite comments. This interface is implemented by {@link + * com.google.googlejavaformat.java.JavaCommentsHelper JavaCommentsHelper}. + */ +public interface CommentsHelper { + /** + * Try to rewrite comments, returning rewritten text. + * + * @param tok the comment's tok + * @param maxWidth the line length for the output + * @param column0 the current column + * @return the rewritten comment + */ + String rewrite(Input.Tok tok, int maxWidth, int column0); + + static Optional reformatParameterComment(Tok tok) { + if (!tok.isSlashStarComment()) { + return Optional.empty(); + } + var match = PARAMETER_COMMENT.matcher(tok.getOriginalText()); + if (!match.matches()) { + return Optional.empty(); + } + return Optional.of(String.format("/* %s= */", match.group(1))); + } + + Pattern PARAMETER_COMMENT = + Pattern.compile( + "/\\*\\s*(\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*(\\Q...\\E)?)\\s*=\\s*\\*/"); +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Doc.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Doc.java new file mode 100644 index 000000000..cab688558 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Doc.java @@ -0,0 +1,759 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import static com.google.common.collect.Iterables.getLast; +import static com.google.googlejavaformat.CommentsHelper.reformatParameterComment; +import static java.lang.Math.max; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.DiscreteDomain; +import com.google.common.collect.Iterators; +import com.google.common.collect.Range; +import com.google.googlejavaformat.Output.BreakTag; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * {@link com.google.googlejavaformat.java.JavaInputAstVisitor JavaInputAstVisitor} outputs a + * sequence of {@link Op}s using {@link OpsBuilder}. This linear sequence is then transformed by + * {@link DocBuilder} into a tree-structured {@code Doc}. The top-level {@code Doc} is a {@link + * Level}, which contains a sequence of {@code Doc}s, including other {@link Level}s. Leaf {@code + * Doc}s are {@link Token}s, representing language-level tokens; {@link Tok}s, which may also + * represent non-token {@link Input.Tok}s, including comments and other white-space; {@link Space}s, + * representing single spaces; and {@link Break}s, which represent optional line-breaks. + */ +public abstract class Doc { + /** + * Each {@link Break} in a {@link Level} is either {@link FillMode#UNIFIED} or {@link + * FillMode#INDEPENDENT}. + */ + public enum FillMode { + /** + * If a {@link Level} will not fit on one line, all of its {@code UNIFIED} {@link Break}s will + * be broken. + */ + UNIFIED, + + /** + * If a {@link Level} will not fit on one line, its {@code INDEPENDENT} {@link Break}s will be + * broken independently of each other, to fill in the {@link Level}. + */ + INDEPENDENT, + + /** + * A {@code FORCED} {@link Break} will always be broken, and a {@link Level} it appears in will + * not fit on one line. + */ + FORCED + } + + /** State for writing. */ + public static final class State { + final int lastIndent; + final int indent; + final int column; + final boolean mustBreak; + + State(int lastIndent, int indent, int column, boolean mustBreak) { + this.lastIndent = lastIndent; + this.indent = indent; + this.column = column; + this.mustBreak = mustBreak; + } + + public State(int indent0, int column0) { + this(indent0, indent0, column0, false); + } + + State withColumn(int column) { + return new State(lastIndent, indent, column, mustBreak); + } + + State withMustBreak(boolean mustBreak) { + return new State(lastIndent, indent, column, mustBreak); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("lastIndent", lastIndent) + .add("indent", indent) + .add("column", column) + .add("mustBreak", mustBreak) + .toString(); + } + } + + private static final Range EMPTY_RANGE = Range.closedOpen(-1, -1); + private static final DiscreteDomain INTEGERS = DiscreteDomain.integers(); + + // Memoized width; Float.POSITIVE_INFINITY if contains forced breaks. + private final Supplier width = Suppliers.memoize(this::computeWidth); + + // Memoized flat; not defined (and never computed) if contains forced breaks. + private final Supplier flat = Suppliers.memoize(this::computeFlat); + + // Memoized Range. + private final Supplier> range = Suppliers.memoize(this::computeRange); + + /** + * Return the width of a {@code Doc}, or {@code Float.POSITIVE_INFINITY} if it must be broken. + * + * @return the width + */ + final float getWidth() { + return width.get(); + } + + /** + * Return a {@code Doc}'s flat-string value; not defined (and never called) if the (@code Doc} + * contains forced breaks. + * + * @return the flat-string value + */ + final String getFlat() { + return flat.get(); + } + + /** + * Return the {@link Range} of a {@code Doc}. + * + * @return the {@code Doc}'s {@link Range} + */ + final Range range() { + return range.get(); + } + + /** + * Compute the {@code Doc}'s width. + * + * @return the width, or {@code Float.POSITIVE_INFINITY} if it must be broken + */ + abstract float computeWidth(); + + /** + * Compute the {@code Doc}'s flat value. Not defined (and never called) if contains forced breaks. + * + * @return the flat value + */ + abstract String computeFlat(); + + /** + * Compute the {@code Doc}'s {@link Range} of {@link Input.Token}s. + * + * @return the {@link Range} + */ + abstract Range computeRange(); + + /** + * Make breaking decisions for a {@code Doc}. + * + * @param maxWidth the maximum line width + * @param state the current output state + * @return the new output state + */ + public abstract State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state); + + /** Write a {@code Doc} to an {@link Output}, after breaking decisions have been made. */ + public abstract void write(Output output); + + /** A {@code Level} inside a {@link Doc}. */ + static final class Level extends Doc { + private final Indent plusIndent; // The extra indent following breaks. + private final List docs = new ArrayList<>(); // The elements of the level. + + private Level(Indent plusIndent) { + this.plusIndent = plusIndent; + } + + /** + * Factory method for {@code Level}s. + * + * @param plusIndent the extra indent inside the {@code Level} + * @return the new {@code Level} + */ + static Level make(Indent plusIndent) { + return new Level(plusIndent); + } + + /** + * Add a {@link Doc} to the {@code Level}. + * + * @param doc the {@link Doc} to add + */ + void add(Doc doc) { + docs.add(doc); + } + + @Override + float computeWidth() { + float thisWidth = 0.0F; + for (Doc doc : docs) { + thisWidth += doc.getWidth(); + } + return thisWidth; + } + + @Override + String computeFlat() { + StringBuilder builder = new StringBuilder(); + for (Doc doc : docs) { + builder.append(doc.getFlat()); + } + return builder.toString(); + } + + @Override + Range computeRange() { + Range docRange = EMPTY_RANGE; + for (Doc doc : docs) { + docRange = union(docRange, doc.range()); + } + return docRange; + } + + // State that needs to be preserved between calculating breaks and + // writing output. + // TODO(cushon): represent phases as separate immutable data. + + /** True if the entire {@link Level} fits on one line. */ + boolean oneLine = false; + + /** + * Groups of {@link Doc}s that are children of the current {@link Level}, separated by {@link + * Break}s. + */ + List> splits = new ArrayList<>(); + + /** {@link Break}s between {@link Doc}s in the current {@link Level}. */ + List breaks = new ArrayList<>(); + + @Override + public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state) { + float thisWidth = getWidth(); + if (state.column + thisWidth <= maxWidth) { + oneLine = true; + return state.withColumn(state.column + (int) thisWidth); + } + State broken = + computeBroken( + commentsHelper, maxWidth, new State(state.indent + plusIndent.eval(), state.column)); + return state.withColumn(broken.column); + } + + private static void splitByBreaks(List docs, List> splits, List breaks) { + splits.clear(); + breaks.clear(); + splits.add(new ArrayList<>()); + for (Doc doc : docs) { + if (doc instanceof Break) { + breaks.add((Break) doc); + splits.add(new ArrayList<>()); + } else { + getLast(splits).add(doc); + } + } + } + + /** Compute breaks for a {@link Level} that spans multiple lines. */ + private State computeBroken(CommentsHelper commentsHelper, int maxWidth, State state) { + splitByBreaks(docs, splits, breaks); + + state = + computeBreakAndSplit( + commentsHelper, maxWidth, state, /* optBreakDoc= */ Optional.empty(), splits.get(0)); + + // Handle following breaks and split. + for (int i = 0; i < breaks.size(); i++) { + state = + computeBreakAndSplit( + commentsHelper, maxWidth, state, Optional.of(breaks.get(i)), splits.get(i + 1)); + } + return state; + } + + /** Lay out a Break-separated group of Docs in the current Level. */ + private static State computeBreakAndSplit( + CommentsHelper commentsHelper, + int maxWidth, + State state, + Optional optBreakDoc, + List split) { + float breakWidth = optBreakDoc.isPresent() ? optBreakDoc.get().getWidth() : 0.0F; + float splitWidth = getWidth(split); + boolean shouldBreak = + (optBreakDoc.isPresent() && optBreakDoc.get().fillMode == FillMode.UNIFIED) + || state.mustBreak + || state.column + breakWidth + splitWidth > maxWidth; + + if (optBreakDoc.isPresent()) { + state = optBreakDoc.get().computeBreaks(state, state.lastIndent, shouldBreak); + } + boolean enoughRoom = state.column + splitWidth <= maxWidth; + state = computeSplit(commentsHelper, maxWidth, split, state.withMustBreak(false)); + if (!enoughRoom) { + state = state.withMustBreak(true); // Break after, too. + } + return state; + } + + private static State computeSplit( + CommentsHelper commentsHelper, int maxWidth, List docs, State state) { + for (Doc doc : docs) { + state = doc.computeBreaks(commentsHelper, maxWidth, state); + } + return state; + } + + @Override + public void write(Output output) { + if (oneLine) { + output.append(getFlat(), range()); // This is defined because width is finite. + } else { + writeFilled(output); + } + } + + private void writeFilled(Output output) { + // Handle first split. + for (Doc doc : splits.get(0)) { + doc.write(output); + } + // Handle following breaks and split. + for (int i = 0; i < breaks.size(); i++) { + breaks.get(i).write(output); + for (Doc doc : splits.get(i + 1)) { + doc.write(output); + } + } + } + + /** + * Get the width of a sequence of {@link Doc}s. + * + * @param docs the {@link Doc}s + * @return the width, or {@code Float.POSITIVE_INFINITY} if any {@link Doc} must be broken + */ + static float getWidth(List docs) { + float width = 0.0F; + for (Doc doc : docs) { + width += doc.getWidth(); + } + return width; + } + + private static Range union(Range x, Range y) { + return x.isEmpty() ? y : y.isEmpty() ? x : x.span(y).canonical(INTEGERS); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("plusIndent", plusIndent) + .add("docs", docs) + .toString(); + } + } + + /** A leaf {@link Doc} for a token. */ + public static final class Token extends Doc implements Op { + /** Is a Token a real token, or imaginary (e.g., a token generated incorrectly, or an EOF)? */ + public enum RealOrImaginary { + REAL, + IMAGINARY; + + boolean isReal() { + return this == REAL; + } + } + + private final Input.Token token; + private final RealOrImaginary realOrImaginary; + private final Indent plusIndentCommentsBefore; + private final Optional breakAndIndentTrailingComment; + + private Token( + Input.Token token, + RealOrImaginary realOrImaginary, + Indent plusIndentCommentsBefore, + Optional breakAndIndentTrailingComment) { + this.token = token; + this.realOrImaginary = realOrImaginary; + this.plusIndentCommentsBefore = plusIndentCommentsBefore; + this.breakAndIndentTrailingComment = breakAndIndentTrailingComment; + } + + /** + * How much extra to indent comments before the {@code Token}. + * + * @return the extra indent + */ + Indent getPlusIndentCommentsBefore() { + return plusIndentCommentsBefore; + } + + /** Force a line break and indent trailing javadoc or block comments. */ + Optional breakAndIndentTrailingComment() { + return breakAndIndentTrailingComment; + } + + /** + * Make a {@code Token}. + * + * @param token the {@link Input.Token} to wrap + * @param realOrImaginary did this {@link Input.Token} appear in the input, or was it generated + * incorrectly? + * @param plusIndentCommentsBefore extra {@code plusIndent} for comments just before this token + * @return the new {@code Token} + */ + static Op make( + Input.Token token, + Doc.Token.RealOrImaginary realOrImaginary, + Indent plusIndentCommentsBefore, + Optional breakAndIndentTrailingComment) { + return new Token( + token, realOrImaginary, plusIndentCommentsBefore, breakAndIndentTrailingComment); + } + + /** + * Return the wrapped {@link Input.Token}. + * + * @return the {@link Input.Token} + */ + Input.Token getToken() { + return token; + } + + /** + * Is the token good? That is, does it match an {@link Input.Token}? + * + * @return whether the @code Token} is good + */ + RealOrImaginary realOrImaginary() { + return realOrImaginary; + } + + @Override + public void add(DocBuilder builder) { + builder.add(this); + } + + @Override + float computeWidth() { + return token.getTok().length(); + } + + @Override + String computeFlat() { + return token.getTok().getOriginalText(); + } + + @Override + Range computeRange() { + return Range.singleton(token.getTok().getIndex()).canonical(INTEGERS); + } + + @Override + public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state) { + String text = token.getTok().getOriginalText(); + return state.withColumn(state.column + text.length()); + } + + @Override + public void write(Output output) { + String text = token.getTok().getOriginalText(); + output.append(text, range()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("token", token) + .add("realOrImaginary", realOrImaginary) + .add("plusIndentCommentsBefore", plusIndentCommentsBefore) + .toString(); + } + } + + /** A Leaf node in a {@link Doc} for a non-breaking space. */ + static final class Space extends Doc implements Op { + private static final Space SPACE = new Space(); + + private Space() {} + + /** + * Factor method for {@code Space}. + * + * @return the new {@code Space} + */ + static Space make() { + return SPACE; + } + + @Override + public void add(DocBuilder builder) { + builder.add(this); + } + + @Override + float computeWidth() { + return 1.0F; + } + + @Override + String computeFlat() { + return " "; + } + + @Override + Range computeRange() { + return EMPTY_RANGE; + } + + @Override + public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state) { + return state.withColumn(state.column + 1); + } + + @Override + public void write(Output output) { + output.append(" ", range()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).toString(); + } + } + + /** A leaf node in a {@link Doc} for an optional break. */ + public static final class Break extends Doc implements Op { + private final FillMode fillMode; + private final String flat; + private final Indent plusIndent; + private final Optional optTag; + + private Break(FillMode fillMode, String flat, Indent plusIndent, Optional optTag) { + this.fillMode = fillMode; + this.flat = flat; + this.plusIndent = plusIndent; + this.optTag = optTag; + } + + /** + * Make a {@code Break}. + * + * @param fillMode the {@link FillMode} + * @param flat the text when not broken + * @param plusIndent extra indent if taken + * @return the new {@code Break} + */ + public static Break make(FillMode fillMode, String flat, Indent plusIndent) { + return new Break(fillMode, flat, plusIndent, /* optTag= */ Optional.empty()); + } + + /** + * Make a {@code Break}. + * + * @param fillMode the {@link FillMode} + * @param flat the text when not broken + * @param plusIndent extra indent if taken + * @param optTag an optional tag for remembering whether the break was taken + * @return the new {@code Break} + */ + public static Break make( + FillMode fillMode, String flat, Indent plusIndent, Optional optTag) { + return new Break(fillMode, flat, plusIndent, optTag); + } + + /** + * Make a forced {@code Break}. + * + * @return the new forced {@code Break} + */ + public static Break makeForced() { + return make(FillMode.FORCED, "", Indent.Const.ZERO); + } + + /** + * Return the {@code Break}'s extra indent. + * + * @return the extra indent + */ + int getPlusIndent() { + return plusIndent.eval(); + } + + /** + * Is the {@code Break} forced? + * + * @return whether the {@code Break} is forced + */ + boolean isForced() { + return fillMode == FillMode.FORCED; + } + + @Override + public void add(DocBuilder builder) { + builder.breakDoc(this); + } + + @Override + float computeWidth() { + return isForced() ? Float.POSITIVE_INFINITY : (float) flat.length(); + } + + @Override + String computeFlat() { + return flat; + } + + @Override + Range computeRange() { + return EMPTY_RANGE; + } + + /** Was this break taken? */ + boolean broken; + + /** New indent after this break. */ + int newIndent; + + public State computeBreaks(State state, int lastIndent, boolean broken) { + if (optTag.isPresent()) { + optTag.get().recordBroken(broken); + } + + if (broken) { + this.broken = true; + this.newIndent = max(lastIndent + plusIndent.eval(), 0); + return state.withColumn(newIndent); + } else { + this.broken = false; + this.newIndent = -1; + return state.withColumn(state.column + flat.length()); + } + } + + @Override + public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state) { + // Updating the state for {@link Break}s requires deciding if the break + // should be taken. + // TODO(cushon): this hierarchy is wrong, create a separate interface + // for unbreakable Docs? + throw new UnsupportedOperationException("Did you mean computeBreaks(State, int, boolean)?"); + } + + @Override + public void write(Output output) { + if (broken) { + output.append("\n", EMPTY_RANGE); + output.indent(newIndent); + } else { + output.append(flat, range()); + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("fillMode", fillMode) + .add("flat", flat) + .add("plusIndent", plusIndent) + .add("optTag", optTag) + .toString(); + } + } + + /** A leaf node in a {@link Doc} for a non-token. */ + static final class Tok extends Doc implements Op { + private final Input.Tok tok; + + private Tok(Input.Tok tok) { + this.tok = tok; + } + + /** + * Factory method for a {@code Tok}. + * + * @param tok the {@link Input.Tok} to wrap + * @return the new {@code Tok} + */ + static Tok make(Input.Tok tok) { + return new Tok(tok); + } + + @Override + public void add(DocBuilder builder) { + builder.add(this); + } + + @Override + float computeWidth() { + int idx = Newlines.firstBreak(tok.getOriginalText()); + // only count the first line of multi-line block comments + if (tok.isComment()) { + if (idx > 0) { + return idx; + } else if (tok.isSlashSlashComment() && !tok.getOriginalText().startsWith("// ")) { + // Account for line comments with missing spaces, see computeFlat. + return tok.length() + 1; + } else { + return reformatParameterComment(tok).map(String::length).orElse(tok.length()); + } + } + return idx != -1 ? Float.POSITIVE_INFINITY : (float) tok.length(); + } + + @Override + String computeFlat() { + // TODO(cushon): commentsHelper.rewrite doesn't get called for spans that fit in a single + // line. That's fine for multi-line comment reflowing, but problematic for adding missing + // spaces in line comments. + if (tok.isSlashSlashComment() && !tok.getOriginalText().startsWith("// ")) { + return "// " + tok.getOriginalText().substring("//".length()); + } + return reformatParameterComment(tok).orElse(tok.getOriginalText()); + } + + @Override + Range computeRange() { + return Range.singleton(tok.getIndex()).canonical(INTEGERS); + } + + String text; + + @Override + public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state) { + text = commentsHelper.rewrite(tok, maxWidth, state.column); + int firstLineLength = text.length() - Iterators.getLast(Newlines.lineOffsetIterator(text)); + return state.withColumn(state.column + firstLineLength); + } + + @Override + public void write(Output output) { + output.append(text, range()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("tok", tok).toString(); + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/DocBuilder.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/DocBuilder.java new file mode 100644 index 000000000..31cc798a9 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/DocBuilder.java @@ -0,0 +1,114 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.MoreObjects; +import java.util.ArrayDeque; +import java.util.List; + +/** A {@code DocBuilder} converts a sequence of {@link Op}s into a {@link Doc}. */ +public final class DocBuilder { + private final Doc.Level base = Doc.Level.make(Indent.Const.ZERO); + private final ArrayDeque stack = new ArrayDeque<>(); + + /** + * A possibly earlier {@link Doc.Level} for appending text, à la Philip Wadler. + * + *

Processing {@link Doc}s presents a subtle problem. Suppose we have a {@link Doc} for to an + * assignment node, {@code a = b}, with an optional {@link Doc.Break} following the {@code =}. + * Suppose we have 5 characters to write it, so that we think we don't need the break. + * Unfortunately, this {@link Doc} lies in an expression statement {@link Doc} for the statement + * {@code a = b;} and this statement does not fit in 3 characters. This is why many formatters + * sometimes emit lines that are too long, or cheat by using a narrower line length to avoid such + * problems. + * + *

One solution to this problem is not to decide whether a {@link Doc.Level} should be broken + * until later (in this case, after the semicolon has been seen). A simpler approach is to rewrite + * the {@link Doc} as here, so that the semicolon moves inside the inner {@link Doc}, and we can + * decide whether to break that {@link Doc} without seeing later text. + */ + private Doc.Level appendLevel = base; + + /** Start to build a {@code DocBuilder}. */ + public DocBuilder() { + stack.addLast(base); + } + + /** + * Add a list of {@link Op}s to the {@link OpsBuilder}. + * + * @param ops the {@link Op}s + * @return the {@link OpsBuilder} + */ + public DocBuilder withOps(List ops) { + for (Op op : ops) { + op.add(this); // These operations call the operations below to build the doc. + } + return this; + } + + /** + * Open a new {@link Doc.Level}. + * + * @param plusIndent the extra indent for the {@link Doc.Level} + */ + void open(Indent plusIndent) { + Doc.Level level = Doc.Level.make(plusIndent); + stack.addLast(level); + } + + /** Close the current {@link Doc.Level}. */ + void close() { + Doc.Level top = stack.removeLast(); + stack.peekLast().add(top); + } + + /** + * Add a {@link Doc} to the current {@link Doc.Level}. + * + * @param doc the {@link Doc} + */ + void add(Doc doc) { + appendLevel.add(doc); + } + + /** + * Add a {@link Doc.Break} to the current {@link Doc.Level}. + * + * @param breakDoc the {@link Doc.Break} + */ + void breakDoc(Doc.Break breakDoc) { + appendLevel = stack.peekLast(); + appendLevel.add(breakDoc); + } + + /** + * Return the {@link Doc}. + * + * @return the {@link Doc} + */ + public Doc build() { + return base; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("base", base) + .add("stack", stack) + .add("appendLevel", appendLevel) + .toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormatterDiagnostic.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormatterDiagnostic.java new file mode 100644 index 000000000..be7f8a6ca --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormatterDiagnostic.java @@ -0,0 +1,79 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +/** An error that prevented formatting from succeeding. */ +public class FormatterDiagnostic { + private final int lineNumber; + private final String message; + private final int column; + + public static FormatterDiagnostic create(String message) { + return new FormatterDiagnostic(-1, -1, message); + } + + public static FormatterDiagnostic create(int lineNumber, int column, String message) { + checkArgument(lineNumber >= 0); + checkArgument(column >= 0); + checkNotNull(message); + return new FormatterDiagnostic(lineNumber, column, message); + } + + private FormatterDiagnostic(int lineNumber, int column, String message) { + this.lineNumber = lineNumber; + this.column = column; + this.message = message; + } + + /** + * Returns the line number on which the error occurred, or {@code -1} if the error does not have a + * line number. + */ + public int line() { + return lineNumber; + } + + /** + * Returns the 0-indexed column number on which the error occurred, or {@code -1} if the error + * does not have a column. + */ + public int column() { + return column; + } + + /** Returns a description of the problem that prevented formatting from succeeding. */ + public String message() { + return message; + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + if (lineNumber >= 0) { + sb.append(lineNumber).append(':'); + } + if (column >= 0) { + // internal column numbers are 0-based, but diagnostics use 1-based indexing by convention + sb.append(column + 1).append(':'); + } + if (lineNumber >= 0 || column >= 0) { + sb.append(' '); + } + sb.append("error: ").append(message); + return sb.toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormattingError.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormattingError.java new file mode 100644 index 000000000..50381d0cd --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/FormattingError.java @@ -0,0 +1,37 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableList; + +/** An unchecked formatting error. */ +public class FormattingError extends Error { + + private final ImmutableList diagnostics; + + public FormattingError(FormatterDiagnostic diagnostic) { + this(ImmutableList.of(diagnostic)); + } + + public FormattingError(Iterable diagnostics) { + super(Joiner.on("\n").join(diagnostics) + "\n"); + this.diagnostics = ImmutableList.copyOf(diagnostics); + } + + public ImmutableList diagnostics() { + return diagnostics; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Indent.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Indent.java new file mode 100644 index 000000000..44b56cdd6 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Indent.java @@ -0,0 +1,84 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.MoreObjects; +import com.google.googlejavaformat.Output.BreakTag; + +/** + * An indent for a {@link Doc.Level} or {@link Doc.Break}. The indent is either a constant {@code + * int}, or a conditional expression whose value depends on whether or not a {@link Doc.Break} has + * been broken. + */ +public abstract class Indent { + + abstract int eval(); + + /** A constant function, returning a constant indent. */ + public static final class Const extends Indent { + private final int n; + + public static final Const ZERO = new Const(+0); + + private Const(int n) { + this.n = n; + } + + public static Const make(int n, int indentMultiplier) { + return new Const(n * indentMultiplier); + } + + @Override + int eval() { + return n; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("n", n).toString(); + } + } + + /** A conditional function, whose value depends on whether a break was taken. */ + public static final class If extends Indent { + private final BreakTag condition; + private final Indent thenIndent; + private final Indent elseIndent; + + private If(BreakTag condition, Indent thenIndent, Indent elseIndent) { + this.condition = condition; + this.thenIndent = thenIndent; + this.elseIndent = elseIndent; + } + + public static If make(BreakTag condition, Indent thenIndent, Indent elseIndent) { + return new If(condition, thenIndent, elseIndent); + } + + @Override + int eval() { + return (condition.wasBreakTaken() ? thenIndent : elseIndent).eval(); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("condition", condition) + .add("thenIndent", thenIndent) + .add("elseIndent", elseIndent) + .toString(); + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Input.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Input.java new file mode 100644 index 000000000..66a392190 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Input.java @@ -0,0 +1,147 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableRangeMap; + +/** An input to the formatter. */ +public abstract class Input extends InputOutput { + /** + * A {@code Tok} ("tock") is a token, or a comment, or a newline, or a maximal string of blanks. A + * token {@code Tok} underlies a {@link Token}, and each other {@code Tok} is attached to a single + * {@code Token}. Tokens and comments have indices; white space {@code Tok}s do not. + */ + public interface Tok { + /** + * Return the {@code Tok}'s index. + * + * @return its index + */ + int getIndex(); + + /** + * Return the {@code Tok}'s {@code 0}-based position. + * + * @return its position + */ + int getPosition(); + + /** + * Return the {@code Tok}'s {@code 0}-based column number. + * + * @return its column number + */ + int getColumn(); + + /** The {@code Tok}'s text. */ + String getText(); + + /** The {@code Tok}'s original text (before processing escapes). */ + String getOriginalText(); + + /** The length of the {@code Tok}'s original text. */ + int length(); + + /** Is the {@code Tok} a newline? */ + boolean isNewline(); + + /** Is the {@code Tok} a "//" comment? */ + boolean isSlashSlashComment(); + + /** Is the {@code Tok} a "/*" comment? */ + boolean isSlashStarComment(); + + /** Is the {@code Tok} a javadoc comment? */ + boolean isJavadocComment(); + + /** Is the {@code Tok} a comment? */ + boolean isComment(); + } + + /** A {@code Token} is a language-level token. */ + public interface Token { + /** + * Get the token's {@link Tok}. + * + * @return the token's {@link Tok} + */ + Tok getTok(); + + /** + * Get the earlier {@link Tok}s assigned to this {@code Token}. + * + * @return the earlier {@link Tok}s assigned to this {@code Token} + */ + ImmutableList getToksBefore(); + + /** + * Get the later {@link Tok}s assigned to this {@code Token}. + * + * @return the later {@link Tok}s assigned to this {@code Token} + */ + ImmutableList getToksAfter(); + } + + /** + * Get the input tokens. + * + * @return the input tokens + */ + public abstract ImmutableList getTokens(); + + /** A map from [start, end] position ranges to {@link Token}s. */ + public abstract ImmutableRangeMap getPositionTokenMap(); + + public abstract ImmutableMap getPositionToColumnMap(); + + public abstract String getText(); + + /** + * Get the number of toks. + * + * @return the number of toks, excluding the EOF tok + */ + public abstract int getkN(); + + /** + * Get the Token by index. + * + * @param k the Tok index + */ + public abstract Token getToken(int k); + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("super", super.toString()).toString(); + } + + /** Converts a character offset in the input to a line number. */ + public abstract int getLineNumber(int inputPosition); + + /** Converts a character offset in the input to a 0-based column number. */ + public abstract int getColumnNumber(int inputPosition); + + /** + * Construct a diagnostic. Populates the input filename, and converts character offsets to + * numbers. + */ + public FormatterDiagnostic createDiagnostic(int inputPosition, String message) { + return FormatterDiagnostic.create( + getLineNumber(inputPosition), getColumnNumber(inputPosition), message); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/InputOutput.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/InputOutput.java new file mode 100644 index 000000000..46dc70bbc --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/InputOutput.java @@ -0,0 +1,119 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.collect.DiscreteDomain; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Range; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** This interface defines methods common to an {@link Input} or an {@link Output}. */ +public abstract class InputOutput { + private ImmutableList lines = ImmutableList.of(); + + protected static final Range EMPTY_RANGE = Range.closedOpen(-1, -1); + private static final DiscreteDomain INTEGERS = DiscreteDomain.integers(); + + /** Set the lines. */ + protected final void setLines(ImmutableList lines) { + this.lines = lines; + } + + /** + * Get the line count. + * + * @return the line count + */ + public final int getLineCount() { + return lines.size(); + } + + /** + * Get a line. + * + * @param lineI the line number + * @return the line + */ + public final String getLine(int lineI) { + return lines.get(lineI); + } + + /** The {@link Range}s of the tokens or comments lying on each line, in any part. */ + protected final List> ranges = new ArrayList<>(); + + private static void addToRanges(List> ranges, int i, int k) { + while (ranges.size() <= i) { + ranges.add(EMPTY_RANGE); + } + Range oldValue = ranges.get(i); + ranges.set(i, Range.closedOpen(oldValue.isEmpty() ? k : oldValue.lowerEndpoint(), k + 1)); + } + + protected final void computeRanges(List toks) { + int lineI = 0; + for (Input.Tok tok : toks) { + String txt = tok.getOriginalText(); + int lineI0 = lineI; + lineI += Newlines.count(txt); + int k = tok.getIndex(); + if (k >= 0) { + for (int i = lineI0; i <= lineI; i++) { + addToRanges(ranges, i, k); + } + } + } + } + + /** + * Given an {@code InputOutput}, compute the map from tok indices to line ranges. + * + * @param put the {@code InputOutput} + * @return the map from {@code com.google.googlejavaformat.java.JavaInput.Tok} indices to line + * ranges in this {@code put} + */ + public static Map> makeKToIJ(InputOutput put) { + Map> map = new HashMap<>(); + int ijN = put.getLineCount(); + for (int ij = 0; ij <= ijN; ij++) { + Range range = put.getRanges(ij).canonical(INTEGERS); + for (int k = range.lowerEndpoint(); k < range.upperEndpoint(); k++) { + if (map.containsKey(k)) { + map.put(k, Range.closedOpen(map.get(k).lowerEndpoint(), ij + 1)); + } else { + map.put(k, Range.closedOpen(ij, ij + 1)); + } + } + } + return map; + } + + /** + * Get the {@link Range} of {@link Input.Tok}s lying in any part on a line. + * + * @param lineI the line number + * @return the {@link Range} of {@link Input.Tok}s on the specified line + */ + public final Range getRanges(int lineI) { + return 0 <= lineI && lineI < ranges.size() ? ranges.get(lineI) : EMPTY_RANGE; + } + + @Override + public String toString() { + return "InputOutput{" + "lines=" + lines + ", ranges=" + ranges + '}'; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Newlines.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Newlines.java new file mode 100644 index 000000000..dbb82d3c5 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Newlines.java @@ -0,0 +1,199 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.CharMatcher; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** Platform-independent newline handling. */ +public class Newlines { + + /** Returns the number of line breaks in the input. */ + public static int count(String input) { + return Iterators.size(lineOffsetIterator(input)) - 1; + } + + /** Returns the index of the first break in the input, or {@code -1}. */ + public static int firstBreak(String input) { + Iterator it = lineOffsetIterator(input); + it.next(); + return it.hasNext() ? it.next() : -1; + } + + private static final ImmutableSet BREAKS = ImmutableSet.of("\r\n", "\n", "\r"); + + /** Returns true if the entire input string is a recognized line break. */ + public static boolean isNewline(String input) { + return BREAKS.contains(input); + } + + /** Returns the length of the newline sequence at the current offset, or {@code -1}. */ + public static int hasNewlineAt(String input, int idx) { + for (String b : BREAKS) { + if (input.startsWith(b, idx)) { + return b.length(); + } + } + return -1; + } + + /** + * Returns the terminating line break in the input, or {@code null} if the input does not end in a + * break. + */ + public static String getLineEnding(String input) { + for (String b : BREAKS) { + if (input.endsWith(b)) { + return b; + } + } + return null; + } + + /** + * Returns the first line separator in the text, or {@code "\n"} if the text does not contain a + * single line separator. + */ + public static String guessLineSeparator(String text) { + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + switch (c) { + case '\r': + if (i + 1 < text.length() && text.charAt(i + 1) == '\n') { + return "\r\n"; + } + return "\r"; + case '\n': + return "\n"; + default: + break; + } + } + return "\n"; + } + + /** Returns true if the input contains any line breaks. */ + public static boolean containsBreaks(String text) { + return CharMatcher.anyOf("\n\r").matchesAnyOf(text); + } + + /** Returns an iterator over the start offsets of lines in the input. */ + public static Iterator lineOffsetIterator(String input) { + return new LineOffsetIterator(input); + } + + /** Returns an iterator over lines in the input, including trailing whitespace. */ + public static Iterator lineIterator(String input) { + return new LineIterator(input); + } + + private static class LineOffsetIterator implements Iterator { + + private int curr = 0; + private int idx = 0; + private final String input; + + private LineOffsetIterator(String input) { + this.input = input; + } + + @Override + public boolean hasNext() { + return curr != -1; + } + + @Override + public Integer next() { + if (curr == -1) { + throw new NoSuchElementException(); + } + int result = curr; + advance(); + return result; + } + + private void advance() { + for (; idx < input.length(); idx++) { + char c = input.charAt(idx); + switch (c) { + case '\r': + if (idx + 1 < input.length() && input.charAt(idx + 1) == '\n') { + idx++; + } + // falls through + case '\n': + idx++; + curr = idx; + return; + default: + break; + } + } + curr = -1; + } + + @Override + public void remove() { + throw new UnsupportedOperationException("remove"); + } + } + + private static class LineIterator implements Iterator { + + int idx; + String curr; + + private final String input; + private final Iterator indices; + + private LineIterator(String input) { + this.input = input; + this.indices = lineOffsetIterator(input); + idx = indices.next(); // read leading 0 + } + + private void advance() { + int last = idx; + if (indices.hasNext()) { + idx = indices.next(); + } else if (hasNext()) { + // no terminal line break + idx = input.length(); + } else { + throw new NoSuchElementException(); + } + curr = input.substring(last, idx); + } + + @Override + public boolean hasNext() { + return idx < input.length(); + } + + @Override + public String next() { + advance(); + return curr; + } + + @Override + public void remove() { + throw new UnsupportedOperationException("remove"); + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Op.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Op.java new file mode 100644 index 000000000..a48454179 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Op.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +/** + * An {@code Op} is a member of the sequence of formatting operations emitted by {@link OpsBuilder} + * and transformed by {@link DocBuilder} into a {@link Doc}. Leaf subclasses of {@link Doc} + * implement {@code Op}; {@link Doc.Level} is the only non-leaf, and is represented by paired {@link + * OpenOp}-{@link CloseOp} {@code Op}s. + */ +public interface Op { + /** + * Add an {@code Op} to a {@link DocBuilder}. + * + * @param builder the {@link DocBuilder} + */ + void add(DocBuilder builder); +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpenOp.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpenOp.java new file mode 100644 index 000000000..649820131 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpenOp.java @@ -0,0 +1,51 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.MoreObjects; + +/** + * An {@code OpenOp} opens a level. It is an {@link Op} in the sequence of {@link Op}s generated by + * {@link OpsBuilder}. When the sequence is turned into a {@link Doc} by {@link DocBuilder}, {@link + * Input.Tok}s delimited by {@code OpenOp}-{@link CloseOp} pairs turn into nested {@link + * Doc.Level}s. + */ +public final class OpenOp implements Op { + private final Indent plusIndent; + + private OpenOp(Indent plusIndent) { + this.plusIndent = plusIndent; + } + + /** + * Make an ordinary {@code OpenOp}. + * + * @param plusIndent the indent for breaks at this level + * @return the {@code OpenOp} + */ + public static Op make(Indent plusIndent) { + return new OpenOp(plusIndent); + } + + @Override + public void add(DocBuilder builder) { + builder.open(plusIndent); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("plusIndent", plusIndent).toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpsBuilder.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpsBuilder.java new file mode 100644 index 000000000..a45e83b9e --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/OpsBuilder.java @@ -0,0 +1,658 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import static java.lang.Math.max; +import static java.lang.Math.min; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; +import com.google.googlejavaformat.Indent.Const; +import com.google.googlejavaformat.Input.Tok; +import com.google.googlejavaformat.Input.Token; +import com.google.googlejavaformat.Output.BreakTag; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * An {@code OpsBuilder} creates a list of {@link Op}s, which is turned into a {@link Doc} by {@link + * DocBuilder}. + */ +public final class OpsBuilder { + + /** @return the actual size of the AST node at position, including comments. */ + public int actualSize(int position, int length) { + Token startToken = input.getPositionTokenMap().get(position); + int start = startToken.getTok().getPosition(); + for (Tok tok : startToken.getToksBefore()) { + if (tok.isComment()) { + start = min(start, tok.getPosition()); + } + } + Token endToken = input.getPositionTokenMap().get(position + length - 1); + int end = endToken.getTok().getPosition() + endToken.getTok().length(); + for (Tok tok : endToken.getToksAfter()) { + if (tok.isComment()) { + end = max(end, tok.getPosition() + tok.length()); + } + } + return end - start; + } + + /** @return the start column of the token at {@code position}, including leading comments. */ + public Integer actualStartColumn(int position) { + Token startToken = input.getPositionTokenMap().get(position); + int start = startToken.getTok().getPosition(); + int line0 = input.getLineNumber(start); + for (Tok tok : startToken.getToksBefore()) { + if (line0 != input.getLineNumber(tok.getPosition())) { + return start; + } + if (tok.isComment()) { + start = min(start, tok.getPosition()); + } + } + return start; + } + + /** A request to add or remove a blank line in the output. */ + public abstract static class BlankLineWanted { + + /** Always emit a blank line. */ + public static final BlankLineWanted YES = new SimpleBlankLine(Optional.of(true)); + + /** Never emit a blank line. */ + public static final BlankLineWanted NO = new SimpleBlankLine(Optional.of(false)); + + /** + * Explicitly preserve blank lines from the input (e.g. before the first member in a class + * declaration). Overrides conditional blank lines. + */ + public static final BlankLineWanted PRESERVE = + new SimpleBlankLine(/* wanted= */ Optional.empty()); + + /** Is the blank line wanted? */ + public abstract Optional wanted(); + + /** Merge this blank line request with another. */ + public abstract BlankLineWanted merge(BlankLineWanted wanted); + + /** Emit a blank line if the given break is taken. */ + public static BlankLineWanted conditional(BreakTag breakTag) { + return new ConditionalBlankLine(ImmutableList.of(breakTag)); + } + + private static final class SimpleBlankLine extends BlankLineWanted { + private final Optional wanted; + + SimpleBlankLine(Optional wanted) { + this.wanted = wanted; + } + + @Override + public Optional wanted() { + return wanted; + } + + @Override + public BlankLineWanted merge(BlankLineWanted other) { + return this; + } + } + + private static final class ConditionalBlankLine extends BlankLineWanted { + + private final ImmutableList tags; + + ConditionalBlankLine(Iterable tags) { + this.tags = ImmutableList.copyOf(tags); + } + + @Override + public Optional wanted() { + for (BreakTag tag : tags) { + if (tag.wasBreakTaken()) { + return Optional.of(true); + } + } + return Optional.empty(); + } + + @Override + public BlankLineWanted merge(BlankLineWanted other) { + if (!(other instanceof ConditionalBlankLine)) { + return other; + } + return new ConditionalBlankLine( + Iterables.concat(this.tags, ((ConditionalBlankLine) other).tags)); + } + } + } + + private final Input input; + private final List ops = new ArrayList<>(); + private final Output output; + private static final Indent.Const ZERO = Indent.Const.ZERO; + + private int tokenI = 0; + private int inputPosition = Integer.MIN_VALUE; + + /** The number of unclosed open ops in the input stream. */ + int depth = 0; + + /** Add an {@link Op}, and record open/close ops for later validation of unclosed levels. */ + public final void add(Op op) { + if (op instanceof OpenOp) { + depth++; + } else if (op instanceof CloseOp) { + depth--; + if (depth < 0) { + throw new AssertionError(); + } + } + ops.add(op); + } + + /** Add a list of {@link Op}s. */ + public final void addAll(List ops) { + for (Op op : ops) { + add(op); + } + } + + /** + * The {@code OpsBuilder} constructor. + * + * @param input the {@link Input}, used for retrieve information from the AST + * @param output the {@link Output}, used here only to record blank-line information + */ + public OpsBuilder(Input input, Output output) { + this.input = input; + this.output = output; + } + + /** Get the {@code OpsBuilder}'s {@link Input}. */ + public final Input getInput() { + return input; + } + + /** Returns the number of unclosed open ops in the input stream. */ + public int depth() { + return depth; + } + + /** + * Checks that all open ops in the op stream have matching close ops. + * + * @throws FormattingError if any ops were unclosed + */ + public void checkClosed(int previous) { + if (depth != previous) { + throw new FormattingError(diagnostic(String.format("saw %d unclosed ops", depth))); + } + } + + /** Create a {@link FormatterDiagnostic} at the current position. */ + public FormatterDiagnostic diagnostic(String message) { + return input.createDiagnostic(inputPosition, message); + } + + /** + * Sync to position in the input. If we've skipped outputting any tokens that were present in the + * input tokens, output them here and optionally complain. + * + * @param inputPosition the {@code 0}-based input position + */ + public final void sync(int inputPosition) { + if (inputPosition > this.inputPosition) { + ImmutableList tokens = input.getTokens(); + int tokensN = tokens.size(); + this.inputPosition = inputPosition; + if (tokenI < tokensN && inputPosition > tokens.get(tokenI).getTok().getPosition()) { + // Found a missing input token. Insert it and mark it missing (usually not good). + Input.Token token = tokens.get(tokenI++); + throw new FormattingError( + diagnostic(String.format("did not generate token \"%s\"", token.getTok().getText()))); + } + } + } + + /** Output any remaining tokens from the input stream (e.g. terminal whitespace). */ + public final void drain() { + int inputPosition = input.getText().length() + 1; + if (inputPosition > this.inputPosition) { + ImmutableList tokens = input.getTokens(); + int tokensN = tokens.size(); + while (tokenI < tokensN && inputPosition > tokens.get(tokenI).getTok().getPosition()) { + Input.Token token = tokens.get(tokenI++); + add( + Doc.Token.make( + token, + Doc.Token.RealOrImaginary.IMAGINARY, + ZERO, + /* breakAndIndentTrailingComment= */ Optional.empty())); + } + } + this.inputPosition = inputPosition; + checkClosed(0); + } + + /** + * Open a new level by emitting an {@link OpenOp}. + * + * @param plusIndent the extra indent for the new level + */ + public final void open(Indent plusIndent) { + add(OpenOp.make(plusIndent)); + } + + /** Close the current level, by emitting a {@link CloseOp}. */ + public final void close() { + add(CloseOp.make()); + } + + /** Return the text of the next {@link Input.Token}, or absent if there is none. */ + public final Optional peekToken() { + return peekToken(0); + } + + /** Return the text of an upcoming {@link Input.Token}, or absent if there is none. */ + public final Optional peekToken(int skip) { + ImmutableList tokens = input.getTokens(); + int idx = tokenI + skip; + return idx < tokens.size() + ? Optional.of(tokens.get(idx).getTok().getOriginalText()) + : Optional.empty(); + } + + /** + * Returns the {@link Input.Tok}s starting at the current source position, which are satisfied by + * the given predicate. + */ + public ImmutableList peekTokens(int startPosition, Predicate predicate) { + ImmutableList tokens = input.getTokens(); + Preconditions.checkState( + tokens.get(tokenI).getTok().getPosition() == startPosition, + "Expected the current token to be at position %s, found: %s", + startPosition, + tokens.get(tokenI)); + ImmutableList.Builder result = ImmutableList.builder(); + for (int idx = tokenI; idx < tokens.size(); idx++) { + Tok tok = tokens.get(idx).getTok(); + if (!predicate.apply(tok)) { + break; + } + result.add(tok); + } + return result.build(); + } + + /** + * Emit an optional token iff it exists on the input. This is used to emit tokens whose existence + * has been lost in the AST. + * + * @param token the optional token + */ + public final void guessToken(String token) { + token( + token, + Doc.Token.RealOrImaginary.IMAGINARY, + ZERO, + /* breakAndIndentTrailingComment= */ Optional.empty()); + } + + public final void token( + String token, + Doc.Token.RealOrImaginary realOrImaginary, + Indent plusIndentCommentsBefore, + Optional breakAndIndentTrailingComment) { + ImmutableList tokens = input.getTokens(); + if (token.equals(peekToken().orElse(null))) { // Found the input token. Output it. + add( + Doc.Token.make( + tokens.get(tokenI++), + Doc.Token.RealOrImaginary.REAL, + plusIndentCommentsBefore, + breakAndIndentTrailingComment)); + } else { + /* + * Generated a "bad" token, which doesn't exist on the input. Drop it, and complain unless + * (for example) we're guessing at an optional token. + */ + if (realOrImaginary.isReal()) { + throw new FormattingError( + diagnostic( + String.format( + "expected token: '%s'; generated %s instead", + peekToken().orElse(null), token))); + } + } + } + + /** + * Emit a single- or multi-character op by breaking it into single-character {@link Doc.Token}s. + * + * @param op the operator to emit + */ + public final void op(String op) { + int opN = op.length(); + for (int i = 0; i < opN; i++) { + token( + op.substring(i, i + 1), + Doc.Token.RealOrImaginary.REAL, + ZERO, + /* breakAndIndentTrailingComment= */ Optional.empty()); + } + } + + /** Emit a {@link Doc.Space}. */ + public final void space() { + add(Doc.Space.make()); + } + + /** Emit a {@link Doc.Break}. */ + public final void breakOp() { + breakOp(Doc.FillMode.UNIFIED, "", ZERO); + } + + /** + * Emit a {@link Doc.Break}. + * + * @param plusIndent extra indent if taken + */ + public final void breakOp(Indent plusIndent) { + breakOp(Doc.FillMode.UNIFIED, "", plusIndent); + } + + /** Emit a filled {@link Doc.Break}. */ + public final void breakToFill() { + breakOp(Doc.FillMode.INDEPENDENT, "", ZERO); + } + + /** Emit a forced {@link Doc.Break}. */ + public final void forcedBreak() { + breakOp(Doc.FillMode.FORCED, "", ZERO); + } + + /** + * Emit a forced {@link Doc.Break}. + * + * @param plusIndent extra indent if taken + */ + public final void forcedBreak(Indent plusIndent) { + breakOp(Doc.FillMode.FORCED, "", plusIndent); + } + + /** + * Emit a {@link Doc.Break}, with a specified {@code flat} value (e.g., {@code " "}). + * + * @param flat the {@link Doc.Break} when not broken + */ + public final void breakOp(String flat) { + breakOp(Doc.FillMode.UNIFIED, flat, ZERO); + } + + /** + * Emit a {@link Doc.Break}, with a specified {@code flat} value (e.g., {@code " "}). + * + * @param flat the {@link Doc.Break} when not broken + */ + public final void breakToFill(String flat) { + breakOp(Doc.FillMode.INDEPENDENT, flat, ZERO); + } + + /** + * Emit a generic {@link Doc.Break}. + * + * @param fillMode the {@link Doc.FillMode} + * @param flat the {@link Doc.Break} when not broken + * @param plusIndent extra indent if taken + */ + public final void breakOp(Doc.FillMode fillMode, String flat, Indent plusIndent) { + breakOp(fillMode, flat, plusIndent, /* optionalTag= */ Optional.empty()); + } + + /** + * Emit a generic {@link Doc.Break}. + * + * @param fillMode the {@link Doc.FillMode} + * @param flat the {@link Doc.Break} when not broken + * @param plusIndent extra indent if taken + * @param optionalTag an optional tag for remembering whether the break was taken + */ + public final void breakOp( + Doc.FillMode fillMode, String flat, Indent plusIndent, Optional optionalTag) { + add(Doc.Break.make(fillMode, flat, plusIndent, optionalTag)); + } + + private int lastPartialFormatBoundary = -1; + + /** + * Make the boundary of a region that can be partially formatted. The boundary will be included in + * the following region, e.g.: [[boundary0, boundary1), [boundary1, boundary2), ...]. + */ + public void markForPartialFormat() { + if (lastPartialFormatBoundary == -1) { + lastPartialFormatBoundary = tokenI; + return; + } + if (tokenI == lastPartialFormatBoundary) { + return; + } + Token start = input.getTokens().get(lastPartialFormatBoundary); + Token end = input.getTokens().get(tokenI - 1); + output.markForPartialFormat(start, end); + lastPartialFormatBoundary = tokenI; + } + + /** + * Force or suppress a blank line here in the output. + * + * @param wanted whether to force ({@code true}) or suppress {@code false}) the blank line + */ + public final void blankLineWanted(BlankLineWanted wanted) { + output.blankLine(getI(input.getTokens().get(tokenI)), wanted); + } + + private static int getI(Input.Token token) { + for (Input.Tok tok : token.getToksBefore()) { + if (tok.getIndex() >= 0) { + return tok.getIndex(); + } + } + return token.getTok().getIndex(); + } + + private static final Doc.Space SPACE = Doc.Space.make(); + + /** + * Build a list of {@link Op}s from the {@code OpsBuilder}. + * + * @return the list of {@link Op}s + */ + public final ImmutableList build() { + markForPartialFormat(); + // Rewrite the ops to insert comments. + Multimap tokOps = ArrayListMultimap.create(); + int opsN = ops.size(); + for (int i = 0; i < opsN; i++) { + Op op = ops.get(i); + if (op instanceof Doc.Token) { + /* + * Token ops can have associated non-tokens, including comments, which we need to insert. + * They can also cause line breaks, so we insert them before or after the current level, + * when possible. + */ + Doc.Token tokenOp = (Doc.Token) op; + Input.Token token = tokenOp.getToken(); + int j = i; // Where to insert toksBefore before. + while (0 < j && ops.get(j - 1) instanceof OpenOp) { + --j; + } + int k = i; // Where to insert toksAfter after. + while (k + 1 < opsN && ops.get(k + 1) instanceof CloseOp) { + ++k; + } + if (tokenOp.realOrImaginary().isReal()) { + /* + * Regular input token. Copy out toksBefore before token, and toksAfter after it. Insert + * this token's toksBefore at position j. + */ + int newlines = 0; // Count of newlines in a row. + boolean space = false; // Do we need an extra space after a previous "/*" comment? + boolean lastWasComment = false; // Was the last thing we output a comment? + boolean allowBlankAfterLastComment = false; + for (Input.Tok tokBefore : token.getToksBefore()) { + if (tokBefore.isNewline()) { + newlines++; + } else if (tokBefore.isComment()) { + tokOps.put( + j, + Doc.Break.make( + tokBefore.isSlashSlashComment() ? Doc.FillMode.FORCED : Doc.FillMode.UNIFIED, + "", + tokenOp.getPlusIndentCommentsBefore())); + tokOps.putAll(j, makeComment(tokBefore)); + space = tokBefore.isSlashStarComment(); + newlines = 0; + lastWasComment = true; + if (tokBefore.isJavadocComment()) { + tokOps.put(j, Doc.Break.makeForced()); + } + allowBlankAfterLastComment = + tokBefore.isSlashSlashComment() + || (tokBefore.isSlashStarComment() && !tokBefore.isJavadocComment()); + } + } + if (allowBlankAfterLastComment && newlines > 1) { + // Force a line break after two newlines in a row following a line or block comment + output.blankLine(token.getTok().getIndex(), BlankLineWanted.YES); + } + if (lastWasComment && newlines > 0) { + tokOps.put(j, Doc.Break.makeForced()); + } else if (space) { + tokOps.put(j, SPACE); + } + // Now we've seen the Token; output the toksAfter. + for (Input.Tok tokAfter : token.getToksAfter()) { + if (tokAfter.isComment()) { + boolean breakAfter = + tokAfter.isJavadocComment() + || (tokAfter.isSlashStarComment() + && tokenOp.breakAndIndentTrailingComment().isPresent()); + if (breakAfter) { + tokOps.put( + k + 1, + Doc.Break.make( + Doc.FillMode.FORCED, + "", + tokenOp.breakAndIndentTrailingComment().orElse(Const.ZERO))); + } else { + tokOps.put(k + 1, SPACE); + } + tokOps.putAll(k + 1, makeComment(tokAfter)); + if (breakAfter) { + tokOps.put(k + 1, Doc.Break.make(Doc.FillMode.FORCED, "", ZERO)); + } + } + } + } else { + /* + * This input token was mistakenly not generated for output. As no whitespace or comments + * were generated (presumably), copy all input non-tokens literally, even spaces and + * newlines. + */ + int newlines = 0; + boolean lastWasComment = false; + for (Input.Tok tokBefore : token.getToksBefore()) { + if (tokBefore.isNewline()) { + newlines++; + } else if (tokBefore.isComment()) { + newlines = 0; + lastWasComment = tokBefore.isComment(); + } + if (lastWasComment && newlines > 0) { + tokOps.put(j, Doc.Break.makeForced()); + } + tokOps.put(j, Doc.Tok.make(tokBefore)); + } + for (Input.Tok tokAfter : token.getToksAfter()) { + tokOps.put(k + 1, Doc.Tok.make(tokAfter)); + } + } + } + } + /* + * Construct new list of ops, splicing in the comments. If a comment is inserted immediately + * before a space, suppress the space. + */ + ImmutableList.Builder newOps = ImmutableList.builder(); + boolean afterForcedBreak = false; // Was the last Op a forced break? If so, suppress spaces. + for (int i = 0; i < opsN; i++) { + for (Op op : tokOps.get(i)) { + if (!(afterForcedBreak && op instanceof Doc.Space)) { + newOps.add(op); + afterForcedBreak = isForcedBreak(op); + } + } + Op op = ops.get(i); + if (afterForcedBreak + && (op instanceof Doc.Space + || (op instanceof Doc.Break + && ((Doc.Break) op).getPlusIndent() == 0 + && " ".equals(((Doc) op).getFlat())))) { + continue; + } + newOps.add(op); + if (!(op instanceof OpenOp)) { + afterForcedBreak = isForcedBreak(op); + } + } + for (Op op : tokOps.get(opsN)) { + if (!(afterForcedBreak && op instanceof Doc.Space)) { + newOps.add(op); + afterForcedBreak = isForcedBreak(op); + } + } + return newOps.build(); + } + + private static boolean isForcedBreak(Op op) { + return op instanceof Doc.Break && ((Doc.Break) op).isForced(); + } + + private static List makeComment(Input.Tok comment) { + return comment.isSlashStarComment() + ? ImmutableList.of(Doc.Tok.make(comment)) + : ImmutableList.of(Doc.Tok.make(comment), Doc.Break.makeForced()); + } + + @Override + public final String toString() { + return MoreObjects.toStringHelper(this) + .add("input", input) + .add("ops", ops) + .add("output", output) + .add("tokenI", tokenI) + .add("inputPosition", inputPosition) + .toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Output.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Output.java new file mode 100644 index 000000000..ea039fa83 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/Output.java @@ -0,0 +1,80 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat; + +import com.google.common.base.MoreObjects; +import com.google.common.collect.Range; +import com.google.googlejavaformat.OpsBuilder.BlankLineWanted; +import java.util.Optional; + +/** An output from the formatter. */ +public abstract class Output extends InputOutput { + /** Unique identifier for a break. */ + public static final class BreakTag { + + Optional taken = Optional.empty(); + + public void recordBroken(boolean broken) { + // TODO(cushon): enforce invariants. + // Currently we rely on setting Breaks multiple times, e.g. when deciding + // whether a Level should be flowed. Using separate data structures + // instead of mutation or adding an explicit 'reset' step would allow + // a useful invariant to be enforced here. + taken = Optional.of(broken); + } + + public boolean wasBreakTaken() { + return taken.orElse(false); + } + } + + /** + * Indent by outputting {@code indent} spaces. + * + * @param indent the current indent + */ + public abstract void indent(int indent); + + /** + * Output a string. + * + * @param text the string + * @param range the {@link Range} corresponding to the string + */ + public abstract void append(String text, Range range); + + /** + * A blank line is or is not wanted here. + * + * @param k the {@link Input.Tok} index + * @param wanted whether a blank line is wanted here + */ + public abstract void blankLine(int k, BlankLineWanted wanted); + + /** Marks a region that can be partially formatted. */ + public abstract void markForPartialFormat(Input.Token start, Input.Token end); + + /** + * Get the {@link CommentsHelper}. + * + * @return the {@link CommentsHelper} + */ + public abstract CommentsHelper getCommentsHelper(); + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("super", super.toString()).toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptions.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptions.java new file mode 100644 index 000000000..5a233284a --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptions.java @@ -0,0 +1,302 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableRangeSet; +import java.util.Optional; + +/** + * Command line options for google-java-format. + * + *

google-java-format doesn't depend on AutoValue, to allow AutoValue to depend on + * google-java-format. + */ +final class CommandLineOptions { + + private final ImmutableList files; + private final boolean inPlace; + private final ImmutableRangeSet lines; + private final ImmutableList offsets; + private final ImmutableList lengths; + private final boolean aosp; + private final boolean version; + private final boolean help; + private final boolean stdin; + private final boolean fixImportsOnly; + private final boolean sortImports; + private final boolean removeUnusedImports; + private final boolean dryRun; + private final boolean setExitIfChanged; + private final Optional assumeFilename; + private final boolean reflowLongStrings; + private final boolean formatJavadoc; + + CommandLineOptions( + ImmutableList files, + boolean inPlace, + ImmutableRangeSet lines, + ImmutableList offsets, + ImmutableList lengths, + boolean aosp, + boolean version, + boolean help, + boolean stdin, + boolean fixImportsOnly, + boolean sortImports, + boolean removeUnusedImports, + boolean dryRun, + boolean setExitIfChanged, + Optional assumeFilename, + boolean reflowLongStrings, + boolean formatJavadoc) { + this.files = files; + this.inPlace = inPlace; + this.lines = lines; + this.offsets = offsets; + this.lengths = lengths; + this.aosp = aosp; + this.version = version; + this.help = help; + this.stdin = stdin; + this.fixImportsOnly = fixImportsOnly; + this.sortImports = sortImports; + this.removeUnusedImports = removeUnusedImports; + this.dryRun = dryRun; + this.setExitIfChanged = setExitIfChanged; + this.assumeFilename = assumeFilename; + this.reflowLongStrings = reflowLongStrings; + this.formatJavadoc = formatJavadoc; + } + + /** The files to format. */ + ImmutableList files() { + return files; + } + + /** Format files in place. */ + boolean inPlace() { + return inPlace; + } + + /** Line ranges to format. */ + ImmutableRangeSet lines() { + return lines; + } + + /** Character offsets for partial formatting, paired with {@code lengths}. */ + ImmutableList offsets() { + return offsets; + } + + /** Partial formatting region lengths, paired with {@code offsets}. */ + ImmutableList lengths() { + return lengths; + } + + /** Use AOSP style instead of Google Style (4-space indentation). */ + boolean aosp() { + return aosp; + } + + /** Print the version. */ + boolean version() { + return version; + } + + /** Print usage information. */ + boolean help() { + return help; + } + + /** Format input from stdin. */ + boolean stdin() { + return stdin; + } + + /** Fix imports, but do no formatting. */ + boolean fixImportsOnly() { + return fixImportsOnly; + } + + /** Sort imports. */ + boolean sortImports() { + return sortImports; + } + + /** Remove unused imports. */ + boolean removeUnusedImports() { + return removeUnusedImports; + } + + /** + * Print the paths of the files whose contents would change if the formatter were run normally. + */ + boolean dryRun() { + return dryRun; + } + + /** Return exit code 1 if there are any formatting changes. */ + boolean setExitIfChanged() { + return setExitIfChanged; + } + + /** Return the name to use for diagnostics when formatting standard input. */ + Optional assumeFilename() { + return assumeFilename; + } + + boolean reflowLongStrings() { + return reflowLongStrings; + } + + /** Returns true if partial formatting was selected. */ + boolean isSelection() { + return !lines().isEmpty() || !offsets().isEmpty() || !lengths().isEmpty(); + } + + boolean formatJavadoc() { + return formatJavadoc; + } + + static Builder builder() { + return new Builder(); + } + + static class Builder { + + private final ImmutableList.Builder files = ImmutableList.builder(); + private final ImmutableRangeSet.Builder lines = ImmutableRangeSet.builder(); + private final ImmutableList.Builder offsets = ImmutableList.builder(); + private final ImmutableList.Builder lengths = ImmutableList.builder(); + private boolean inPlace = false; + private boolean aosp = false; + private boolean version = false; + private boolean help = false; + private boolean stdin = false; + private boolean fixImportsOnly = false; + private boolean sortImports = true; + private boolean removeUnusedImports = true; + private boolean dryRun = false; + private boolean setExitIfChanged = false; + private Optional assumeFilename = Optional.empty(); + private boolean reflowLongStrings = true; + private boolean formatJavadoc = true; + + ImmutableList.Builder filesBuilder() { + return files; + } + + Builder inPlace(boolean inPlace) { + this.inPlace = inPlace; + return this; + } + + ImmutableRangeSet.Builder linesBuilder() { + return lines; + } + + Builder addOffset(Integer offset) { + offsets.add(offset); + return this; + } + + Builder addLength(Integer length) { + lengths.add(length); + return this; + } + + Builder aosp(boolean aosp) { + this.aosp = aosp; + return this; + } + + Builder version(boolean version) { + this.version = version; + return this; + } + + Builder help(boolean help) { + this.help = help; + return this; + } + + Builder stdin(boolean stdin) { + this.stdin = stdin; + return this; + } + + Builder fixImportsOnly(boolean fixImportsOnly) { + this.fixImportsOnly = fixImportsOnly; + return this; + } + + Builder sortImports(boolean sortImports) { + this.sortImports = sortImports; + return this; + } + + Builder removeUnusedImports(boolean removeUnusedImports) { + this.removeUnusedImports = removeUnusedImports; + return this; + } + + Builder dryRun(boolean dryRun) { + this.dryRun = dryRun; + return this; + } + + Builder setExitIfChanged(boolean setExitIfChanged) { + this.setExitIfChanged = setExitIfChanged; + return this; + } + + Builder assumeFilename(String assumeFilename) { + this.assumeFilename = Optional.of(assumeFilename); + return this; + } + + Builder reflowLongStrings(boolean reflowLongStrings) { + this.reflowLongStrings = reflowLongStrings; + return this; + } + + Builder formatJavadoc(boolean formatJavadoc) { + this.formatJavadoc = formatJavadoc; + return this; + } + + CommandLineOptions build() { + return new CommandLineOptions( + files.build(), + inPlace, + lines.build(), + offsets.build(), + lengths.build(), + aosp, + version, + help, + stdin, + fixImportsOnly, + sortImports, + removeUnusedImports, + dryRun, + setExitIfChanged, + assumeFilename, + reflowLongStrings, + formatJavadoc); + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptionsParser.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptionsParser.java new file mode 100644 index 000000000..f7c3dec95 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/CommandLineOptionsParser.java @@ -0,0 +1,209 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableRangeSet; +import com.google.common.collect.Range; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** A parser for {@link CommandLineOptions}. */ +final class CommandLineOptionsParser { + + private static final Splitter COMMA_SPLITTER = Splitter.on(','); + private static final Splitter COLON_SPLITTER = Splitter.on(':'); + private static final Splitter ARG_SPLITTER = + Splitter.on(CharMatcher.breakingWhitespace()).omitEmptyStrings().trimResults(); + + /** Parses {@link CommandLineOptions}. */ + static CommandLineOptions parse(Iterable options) { + CommandLineOptions.Builder optionsBuilder = CommandLineOptions.builder(); + List expandedOptions = new ArrayList<>(); + expandParamsFiles(options, expandedOptions); + Iterator it = expandedOptions.iterator(); + while (it.hasNext()) { + String option = it.next(); + if (!option.startsWith("-")) { + optionsBuilder.filesBuilder().add(option).addAll(it); + break; + } + String flag; + String value; + int idx = option.indexOf('='); + if (idx >= 0) { + flag = option.substring(0, idx); + value = option.substring(idx + 1); + } else { + flag = option; + value = null; + } + // NOTE: update usage information in UsageException when new flags are added + switch (flag) { + case "-i": + case "-r": + case "-replace": + case "--replace": + optionsBuilder.inPlace(true); + break; + case "--lines": + case "-lines": + case "--line": + case "-line": + parseRangeSet(optionsBuilder.linesBuilder(), getValue(flag, it, value)); + break; + case "--offset": + case "-offset": + optionsBuilder.addOffset(parseInteger(it, flag, value)); + break; + case "--length": + case "-length": + optionsBuilder.addLength(parseInteger(it, flag, value)); + break; + case "--aosp": + case "-aosp": + case "-a": + optionsBuilder.aosp(true); + break; + case "--version": + case "-version": + case "-v": + optionsBuilder.version(true); + break; + case "--help": + case "-help": + case "-h": + optionsBuilder.help(true); + break; + case "--fix-imports-only": + optionsBuilder.fixImportsOnly(true); + break; + case "--skip-sorting-imports": + optionsBuilder.sortImports(false); + break; + case "--skip-removing-unused-imports": + optionsBuilder.removeUnusedImports(false); + break; + case "--skip-reflowing-long-strings": + optionsBuilder.reflowLongStrings(false); + break; + case "--skip-javadoc-formatting": + optionsBuilder.formatJavadoc(false); + break; + case "-": + optionsBuilder.stdin(true); + break; + case "-n": + case "--dry-run": + optionsBuilder.dryRun(true); + break; + case "--set-exit-if-changed": + optionsBuilder.setExitIfChanged(true); + break; + case "-assume-filename": + case "--assume-filename": + optionsBuilder.assumeFilename(getValue(flag, it, value)); + break; + default: + throw new IllegalArgumentException("unexpected flag: " + flag); + } + } + return optionsBuilder.build(); + } + + private static Integer parseInteger(Iterator it, String flag, String value) { + try { + return Integer.valueOf(getValue(flag, it, value)); + } catch (NumberFormatException e) { + throw new IllegalArgumentException( + String.format("invalid integer value for %s: %s", flag, value), e); + } + } + + private static String getValue(String flag, Iterator it, String value) { + if (value != null) { + return value; + } + if (!it.hasNext()) { + throw new IllegalArgumentException("required value was not provided for: " + flag); + } + return it.next(); + } + + /** + * Parse multiple --lines flags, like {"1:12,14,20:36", "40:45,50"}. Multiple ranges can be given + * with multiple --lines flags or separated by commas. A single line can be set by a single + * number. Line numbers are {@code 1}-based, but are converted to the {@code 0}-based numbering + * used internally by google-java-format. + */ + private static void parseRangeSet(ImmutableRangeSet.Builder result, String ranges) { + for (String range : COMMA_SPLITTER.split(ranges)) { + result.add(parseRange(range)); + } + } + + /** + * Parse a range, as in "1:12" or "42". Line numbers provided are {@code 1}-based, but are + * converted here to {@code 0}-based. + */ + private static Range parseRange(String arg) { + List args = COLON_SPLITTER.splitToList(arg); + switch (args.size()) { + case 1: + int line = Integer.parseInt(args.get(0)) - 1; + return Range.closedOpen(line, line + 1); + case 2: + int line0 = Integer.parseInt(args.get(0)) - 1; + int line1 = Integer.parseInt(args.get(1)) - 1; + return Range.closedOpen(line0, line1 + 1); + default: + throw new IllegalArgumentException(arg); + } + } + + /** + * Pre-processes an argument list, expanding arguments of the form {@code @filename} by reading + * the content of the file and appending whitespace-delimited options to {@code arguments}. + */ + private static void expandParamsFiles(Iterable args, List expanded) { + for (String arg : args) { + if (arg.isEmpty()) { + continue; + } + if (!arg.startsWith("@")) { + expanded.add(arg); + } else if (arg.startsWith("@@")) { + expanded.add(arg.substring(1)); + } else { + Path path = Paths.get(arg.substring(1)); + try { + String sequence = new String(Files.readAllBytes(path), UTF_8); + expandParamsFiles(ARG_SPLITTER.split(sequence), expanded); + } catch (IOException e) { + throw new UncheckedIOException(path + ": could not read file: " + e.getMessage(), e); + } + } + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java new file mode 100644 index 000000000..4bd19bee3 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java @@ -0,0 +1,124 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import com.google.common.collect.ImmutableList; +import com.sun.source.tree.AnnotatedTypeTree; +import com.sun.source.tree.AnnotationTree; +import com.sun.source.tree.ArrayTypeTree; +import com.sun.source.tree.Tree; +import com.sun.tools.javac.tree.JCTree; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.List; + +/** + * Utilities for working with array dimensions. + * + *

javac's parser does not preserve concrete syntax for mixed-notation arrays, so we have to + * re-lex the input to extra it. + * + *

For example, {@code int [] a;} cannot be distinguished from {@code int [] a [];} in the AST. + */ +class DimensionHelpers { + + /** The array dimension specifiers (including any type annotations) associated with a type. */ + static class TypeWithDims { + final Tree node; + final ImmutableList> dims; + + public TypeWithDims(Tree node, ImmutableList> dims) { + this.node = node; + this.dims = dims; + } + } + + enum SortedDims { + YES, + NO + } + + /** Returns a (possibly re-ordered) {@link TypeWithDims} for the given type. */ + static TypeWithDims extractDims(Tree node, SortedDims sorted) { + Deque> builder = new ArrayDeque<>(); + node = extractDims(builder, node); + Iterable> dims; + if (sorted == SortedDims.YES) { + dims = reorderBySourcePosition(builder); + } else { + dims = builder; + } + return new TypeWithDims(node, ImmutableList.copyOf(dims)); + } + + /** + * Rotate the list of dimension specifiers until all dimensions with type annotations appear in + * source order. + * + *

javac reorders dimension specifiers in method declarations with mixed-array notation, which + * means that any type annotations don't appear in source order. + * + *

For example, the type of {@code int @A [] f() @B [] {}} is parsed as {@code @B [] @A []}. + * + *

This doesn't handle cases with un-annotated dimension specifiers, so the formatting logic + * checks the token stream to figure out which side of the method name they appear on. + */ + private static Iterable> reorderBySourcePosition( + Deque> dims) { + int lastAnnotation = -1; + int lastPos = -1; + int idx = 0; + for (List dim : dims) { + if (!dim.isEmpty()) { + int pos = ((JCTree) dim.get(0)).getStartPosition(); + if (pos < lastPos) { + List> list = new ArrayList<>(dims); + Collections.rotate(list, -(lastAnnotation + 1)); + return list; + } + lastPos = pos; + lastAnnotation = idx; + } + idx++; + } + return dims; + } + + /** + * Accumulates a flattened list of array dimensions specifiers with type annotations, and returns + * the base type. + * + *

Given {@code int @A @B [][] @C []}, adds {@code [[@A, @B], [@C]]} to dims and returns {@code + * int}. + */ + private static Tree extractDims(Deque> dims, Tree node) { + switch (node.getKind()) { + case ARRAY_TYPE: + return extractDims(dims, ((ArrayTypeTree) node).getType()); + case ANNOTATED_TYPE: + AnnotatedTypeTree annotatedTypeTree = (AnnotatedTypeTree) node; + if (annotatedTypeTree.getUnderlyingType().getKind() != Tree.Kind.ARRAY_TYPE) { + return node; + } + node = extractDims(dims, annotatedTypeTree.getUnderlyingType()); + dims.addFirst(ImmutableList.copyOf(annotatedTypeTree.getAnnotations())); + return node; + default: + return node; + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatFileCallable.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatFileCallable.java new file mode 100644 index 000000000..3d68a23f3 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatFileCallable.java @@ -0,0 +1,118 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeSet; +import java.nio.file.Path; +import java.util.concurrent.Callable; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** + * Encapsulates information about a file to be formatted, including which parts of the file to + * format. + */ +class FormatFileCallable implements Callable { + + @AutoValue + abstract static class Result { + abstract @Nullable Path path(); + + abstract String input(); + + abstract @Nullable String output(); + + boolean changed() { + return !input().equals(output()); + } + + abstract @Nullable FormatterException exception(); + + static Result create( + @Nullable Path path, + String input, + @Nullable String output, + @Nullable FormatterException exception) { + return new AutoValue_FormatFileCallable_Result(path, input, output, exception); + } + } + + private final Path path; + private final String input; + private final CommandLineOptions parameters; + private final JavaFormatterOptions options; + + public FormatFileCallable( + CommandLineOptions parameters, Path path, String input, JavaFormatterOptions options) { + this.path = path; + this.input = input; + this.parameters = parameters; + this.options = options; + } + + @Override + public Result call() { + try { + if (parameters.fixImportsOnly()) { + return Result.create(path, input, fixImports(input), /* exception= */ null); + } + + Formatter formatter = new Formatter(options); + String formatted = formatter.formatSource(input, characterRanges(input).asRanges()); + formatted = fixImports(formatted); + if (parameters.reflowLongStrings()) { + formatted = StringWrapper.wrap(Formatter.MAX_LINE_LENGTH, formatted, formatter); + } + return Result.create(path, input, formatted, /* exception= */ null); + } catch (FormatterException e) { + return Result.create(path, input, /* output= */ null, e); + } + } + + private String fixImports(String input) throws FormatterException { + if (parameters.removeUnusedImports()) { + input = RemoveUnusedImports.removeUnusedImports(input); + } + if (parameters.sortImports()) { + input = ImportOrderer.reorderImports(input, options.style()); + } + return input; + } + + private RangeSet characterRanges(String input) { + final RangeSet characterRanges = TreeRangeSet.create(); + + if (parameters.lines().isEmpty() && parameters.offsets().isEmpty()) { + characterRanges.add(Range.closedOpen(0, input.length())); + return characterRanges; + } + + characterRanges.addAll(Formatter.lineRangesToCharRanges(input, parameters.lines())); + + for (int i = 0; i < parameters.offsets().size(); i++) { + Integer length = parameters.lengths().get(i); + if (length == 0) { + // 0 stands for "format the line under the cursor" + length = 1; + } + characterRanges.add( + Range.closedOpen(parameters.offsets().get(i), parameters.offsets().get(i) + length)); + } + + return characterRanges; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java new file mode 100644 index 000000000..808916c2c --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java @@ -0,0 +1,58 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static java.util.Locale.ENGLISH; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.googlejavaformat.FormatterDiagnostic; +import java.util.List; +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; + +/** Checked exception class for formatter errors. */ +public final class FormatterException extends Exception { + + private final ImmutableList diagnostics; + + public FormatterException(String message) { + this(FormatterDiagnostic.create(message)); + } + + public FormatterException(FormatterDiagnostic diagnostic) { + this(ImmutableList.of(diagnostic)); + } + + public FormatterException(Iterable diagnostics) { + super(diagnostics.iterator().next().toString()); + this.diagnostics = ImmutableList.copyOf(diagnostics); + } + + public List diagnostics() { + return diagnostics; + } + + public static FormatterException fromJavacDiagnostics( + Iterable> diagnostics) { + return new FormatterException( + Iterables.transform(diagnostics, FormatterException::toFormatterDiagnostic)); + } + + private static FormatterDiagnostic toFormatterDiagnostic(Diagnostic input) { + return FormatterDiagnostic.create( + (int) input.getLineNumber(), (int) input.getColumnNumber(), input.getMessage(ENGLISH)); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProvider.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProvider.java new file mode 100644 index 000000000..0b39b2d60 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProvider.java @@ -0,0 +1,36 @@ +/* + * Copyright 2021 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import java.io.PrintWriter; +import java.util.spi.ToolProvider; + +/** Provide a way to be invoked without necessarily starting a new VM. */ +public class GoogleJavaFormatToolProvider implements ToolProvider { + @Override + public String name() { + return "google-java-format"; + } + + @Override + public int run(PrintWriter out, PrintWriter err, String... args) { + try { + return Main.main(out, err, args); + } catch (RuntimeException e) { + err.print(e.getMessage()); + return -1; // pass non-zero value back indicating an error has happened + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template new file mode 100644 index 000000000..88706fbf1 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template @@ -0,0 +1,22 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +class GoogleJavaFormatVersion { + + static String version() { + return "%VERSION%"; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java new file mode 100644 index 000000000..dcbaea172 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java @@ -0,0 +1,483 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.googlejavaformat.java; + +import static com.google.common.collect.Iterables.getLast; +import static com.google.common.primitives.Booleans.trueFirst; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Preconditions; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; +import com.google.googlejavaformat.Newlines; +import com.google.googlejavaformat.java.JavaFormatterOptions.Style; +import com.google.googlejavaformat.java.JavaInput.Tok; +import com.sun.tools.javac.parser.Tokens.TokenKind; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.function.BiFunction; +import java.util.stream.Stream; + +/** Orders imports in Java source code. */ +public class ImportOrderer { + + private static final Splitter DOT_SPLITTER = Splitter.on('.'); + + /** + * Reorder the inputs in {@code text}, a complete Java program. On success, another complete Java + * program is returned, which is the same as the original except the imports are in order. + * + * @throws FormatterException if the input could not be parsed. + */ + public static String reorderImports(String text, Style style) throws FormatterException { + ImmutableList toks = JavaInput.buildToks(text, CLASS_START); + return new ImportOrderer(text, toks, style).reorderImports(); + } + + /** + * Reorder the inputs in {@code text}, a complete Java program, in Google style. On success, + * another complete Java program is returned, which is the same as the original except the imports + * are in order. + * + * @deprecated Use {@link #reorderImports(String, Style)} instead + * @throws FormatterException if the input could not be parsed. + */ + @Deprecated + public static String reorderImports(String text) throws FormatterException { + return reorderImports(text, Style.GOOGLE); + } + + private String reorderImports() throws FormatterException { + int firstImportStart; + Optional maybeFirstImport = findIdentifier(0, IMPORT_OR_CLASS_START); + if (!maybeFirstImport.isPresent() || !tokenAt(maybeFirstImport.get()).equals("import")) { + // No imports, so nothing to do. + return text; + } + firstImportStart = maybeFirstImport.get(); + int unindentedFirstImportStart = unindent(firstImportStart); + + ImportsAndIndex imports = scanImports(firstImportStart); + int afterLastImport = imports.index; + + // Make sure there are no more imports before the next class (etc) definition. + Optional maybeLaterImport = findIdentifier(afterLastImport, IMPORT_OR_CLASS_START); + if (maybeLaterImport.isPresent() && tokenAt(maybeLaterImport.get()).equals("import")) { + throw new FormatterException("Imports not contiguous (perhaps a comment separates them?)"); + } + + StringBuilder result = new StringBuilder(); + String prefix = tokString(0, unindentedFirstImportStart); + result.append(prefix); + if (!prefix.isEmpty() && Newlines.getLineEnding(prefix) == null) { + result.append(lineSeparator).append(lineSeparator); + } + result.append(reorderedImportsString(imports.imports)); + + List tail = new ArrayList<>(); + tail.add(CharMatcher.whitespace().trimLeadingFrom(tokString(afterLastImport, toks.size()))); + if (!toks.isEmpty()) { + Tok lastTok = getLast(toks); + int tailStart = lastTok.getPosition() + lastTok.length(); + tail.add(text.substring(tailStart)); + } + if (tail.stream().anyMatch(s -> !s.isEmpty())) { + result.append(lineSeparator); + tail.forEach(result::append); + } + + return result.toString(); + } + + /** + * {@link TokenKind}s that indicate the start of a type definition. We use this to avoid scanning + * the whole file, since we know that imports must precede any type definition. + */ + private static final ImmutableSet CLASS_START = + ImmutableSet.of(TokenKind.CLASS, TokenKind.INTERFACE, TokenKind.ENUM); + + /** + * We use this set to find the first import, and again to check that there are no imports after + * the place we stopped gathering them. An annotation definition ({@code @interface}) is two + * tokens, the second which is {@code interface}, so we don't need a separate entry for that. + */ + private static final ImmutableSet IMPORT_OR_CLASS_START = + ImmutableSet.of("import", "class", "interface", "enum"); + + /** + * A {@link Comparator} that orders {@link Import}s by Google Style, defined at + * https://google.github.io/styleguide/javaguide.html#s3.3.3-import-ordering-and-spacing. + */ + private static final Comparator GOOGLE_IMPORT_COMPARATOR = + Comparator.comparing(Import::isStatic, trueFirst()).thenComparing(Import::imported); + + /** + * A {@link Comparator} that orders {@link Import}s by AOSP Style, defined at + * https://source.android.com/setup/contribute/code-style#order-import-statements and implemented + * in IntelliJ at + * https://android.googlesource.com/platform/development/+/master/ide/intellij/codestyles/AndroidStyle.xml. + */ + private static final Comparator AOSP_IMPORT_COMPARATOR = + Comparator.comparing(Import::isStatic, trueFirst()) + .thenComparing(Import::isAndroid, trueFirst()) + .thenComparing(Import::isThirdParty, trueFirst()) + .thenComparing(Import::isJava, trueFirst()) + .thenComparing(Import::imported); + + /** + * Determines whether to insert a blank line between the {@code prev} and {@code curr} {@link + * Import}s based on Google style. + */ + private static boolean shouldInsertBlankLineGoogle(Import prev, Import curr) { + return prev.isStatic() && !curr.isStatic(); + } + + /** + * Determines whether to insert a blank line between the {@code prev} and {@code curr} {@link + * Import}s based on AOSP style. + */ + private static boolean shouldInsertBlankLineAosp(Import prev, Import curr) { + if (prev.isStatic() && !curr.isStatic()) { + return true; + } + // insert blank line between "com.android" from "com.anythingelse" + if (prev.isAndroid() && !curr.isAndroid()) { + return true; + } + return !prev.topLevel().equals(curr.topLevel()); + } + + private final String text; + private final ImmutableList toks; + private final String lineSeparator; + private final Comparator importComparator; + private final BiFunction shouldInsertBlankLineFn; + + private ImportOrderer(String text, ImmutableList toks, Style style) { + this.text = text; + this.toks = toks; + this.lineSeparator = Newlines.guessLineSeparator(text); + if (style.equals(Style.GOOGLE)) { + this.importComparator = GOOGLE_IMPORT_COMPARATOR; + this.shouldInsertBlankLineFn = ImportOrderer::shouldInsertBlankLineGoogle; + } else if (style.equals(Style.AOSP)) { + this.importComparator = AOSP_IMPORT_COMPARATOR; + this.shouldInsertBlankLineFn = ImportOrderer::shouldInsertBlankLineAosp; + } else { + throw new IllegalArgumentException("Unsupported code style: " + style); + } + } + + /** An import statement. */ + class Import { + private final String imported; + private final boolean isStatic; + private final String trailing; + + Import(String imported, String trailing, boolean isStatic) { + this.imported = imported; + this.trailing = trailing; + this.isStatic = isStatic; + } + + /** The name being imported, for example {@code java.util.List}. */ + String imported() { + return imported; + } + + /** True if this is {@code import static}. */ + boolean isStatic() { + return isStatic; + } + + /** The top-level package of the import. */ + String topLevel() { + return DOT_SPLITTER.split(imported()).iterator().next(); + } + + /** True if this is an Android import per AOSP style. */ + boolean isAndroid() { + return Stream.of("android.", "androidx.", "dalvik.", "libcore.", "com.android.") + .anyMatch(imported::startsWith); + } + + /** True if this is a Java import per AOSP style. */ + boolean isJava() { + switch (topLevel()) { + case "java": + case "javax": + return true; + default: + return false; + } + } + + /** + * The {@code //} comment lines after the final {@code ;}, up to and including the line + * terminator of the last one. Note: In case two imports were separated by a space (which is + * disallowed by the style guide), the trailing whitespace of the first import does not include + * a line terminator. + */ + String trailing() { + return trailing; + } + + /** True if this is a third-party import per AOSP style. */ + public boolean isThirdParty() { + return !(isAndroid() || isJava()); + } + + // One or multiple lines, the import itself and following comments, including the line + // terminator. + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("import "); + if (isStatic()) { + sb.append("static "); + } + sb.append(imported()).append(';'); + if (trailing().trim().isEmpty()) { + sb.append(lineSeparator); + } else { + sb.append(trailing()); + } + return sb.toString(); + } + } + + private String tokString(int start, int end) { + StringBuilder sb = new StringBuilder(); + for (int i = start; i < end; i++) { + sb.append(toks.get(i).getOriginalText()); + } + return sb.toString(); + } + + private static class ImportsAndIndex { + final ImmutableSortedSet imports; + final int index; + + ImportsAndIndex(ImmutableSortedSet imports, int index) { + this.imports = imports; + this.index = index; + } + } + + /** + * Scans a sequence of import lines. The parsing uses this approximate grammar: + * + *

{@code
+   *  -> ( | )*
+   *  -> "import"  ("static" )?
+   *     ("." )* ("." "*")? ? ";"
+   *    ? ? ( )*
+   * }
+ * + * @param i the index to start parsing at. + * @return the result of parsing the imports. + * @throws FormatterException if imports could not parsed according to the grammar. + */ + private ImportsAndIndex scanImports(int i) throws FormatterException { + int afterLastImport = i; + ImmutableSortedSet.Builder imports = ImmutableSortedSet.orderedBy(importComparator); + // JavaInput.buildToks appends a zero-width EOF token after all tokens. It won't match any + // of our tests here and protects us from running off the end of the toks list. Since it is + // zero-width it doesn't matter if we include it in our string concatenation at the end. + while (i < toks.size() && tokenAt(i).equals("import")) { + i++; + if (isSpaceToken(i)) { + i++; + } + boolean isStatic = tokenAt(i).equals("static"); + if (isStatic) { + i++; + if (isSpaceToken(i)) { + i++; + } + } + if (!isIdentifierToken(i)) { + throw new FormatterException("Unexpected token after import: " + tokenAt(i)); + } + StringAndIndex imported = scanImported(i); + String importedName = imported.string; + i = imported.index; + if (isSpaceToken(i)) { + i++; + } + if (!tokenAt(i).equals(";")) { + throw new FormatterException("Expected ; after import"); + } + while (tokenAt(i).equals(";")) { + // Extra semicolons are not allowed by the JLS but are accepted by javac. + i++; + } + StringBuilder trailing = new StringBuilder(); + if (isSpaceToken(i)) { + trailing.append(tokenAt(i)); + i++; + } + if (isNewlineToken(i)) { + trailing.append(tokenAt(i)); + i++; + } + // Gather (if any) all single line comments and accompanied line terminators following this + // import + while (isSlashSlashCommentToken(i)) { + trailing.append(tokenAt(i)); + i++; + if (isNewlineToken(i)) { + trailing.append(tokenAt(i)); + i++; + } + } + while (tokenAt(i).equals(";")) { + // Extra semicolons are not allowed by the JLS but are accepted by javac. + i++; + } + imports.add(new Import(importedName, trailing.toString(), isStatic)); + // Remember the position just after the import we just saw, before skipping blank lines. + // If the next thing after the blank lines is not another import then we don't want to + // include those blank lines in the text to be replaced. + afterLastImport = i; + while (isNewlineToken(i) || isSpaceToken(i)) { + i++; + } + } + return new ImportsAndIndex(imports.build(), afterLastImport); + } + + // Produces the sorted output based on the imports we have scanned. + private String reorderedImportsString(ImmutableSortedSet imports) { + Preconditions.checkArgument(!imports.isEmpty(), "imports"); + + // Pretend that the first import was preceded by another import of the same kind, so we don't + // insert a newline there. + Import prevImport = imports.iterator().next(); + + StringBuilder sb = new StringBuilder(); + for (Import currImport : imports) { + if (shouldInsertBlankLineFn.apply(prevImport, currImport)) { + // Blank line between static and non-static imports. + sb.append(lineSeparator); + } + sb.append(currImport); + prevImport = currImport; + } + return sb.toString(); + } + + private static class StringAndIndex { + private final String string; + private final int index; + + StringAndIndex(String string, int index) { + this.string = string; + this.index = index; + } + } + + /** + * Scans the imported thing, the dot-separated name that comes after import [static] and before + * the semicolon. We don't allow spaces inside the dot-separated name. Wildcard imports are + * supported: if the input is {@code import java.util.*;} then the returned string will be {@code + * java.util.*}. + * + * @param start the index of the start of the identifier. If the import is {@code import + * java.util.List;} then this index points to the token {@code java}. + * @return the parsed import ({@code java.util.List} in the example) and the index of the first + * token after the imported thing ({@code ;} in the example). + * @throws FormatterException if the imported name could not be parsed. + */ + private StringAndIndex scanImported(int start) throws FormatterException { + int i = start; + StringBuilder imported = new StringBuilder(); + // At the start of each iteration of this loop, i points to an identifier. + // On exit from the loop, i points to a token after an identifier or after *. + while (true) { + Preconditions.checkState(isIdentifierToken(i)); + imported.append(tokenAt(i)); + i++; + if (!tokenAt(i).equals(".")) { + return new StringAndIndex(imported.toString(), i); + } + imported.append('.'); + i++; + if (tokenAt(i).equals("*")) { + imported.append('*'); + return new StringAndIndex(imported.toString(), i + 1); + } else if (!isIdentifierToken(i)) { + throw new FormatterException("Could not parse imported name, at: " + tokenAt(i)); + } + } + } + + /** + * Returns the index of the first place where one of the given identifiers occurs, or {@code + * Optional.empty()} if there is none. + * + * @param start the index to start looking at + * @param identifiers the identifiers to look for + */ + private Optional findIdentifier(int start, ImmutableSet identifiers) { + for (int i = start; i < toks.size(); i++) { + if (isIdentifierToken(i)) { + String id = tokenAt(i); + if (identifiers.contains(id)) { + return Optional.of(i); + } + } + } + return Optional.empty(); + } + + /** Returns the given token, or the preceding token if it is a whitespace token. */ + private int unindent(int i) { + if (i > 0 && isSpaceToken(i - 1)) { + return i - 1; + } else { + return i; + } + } + + private String tokenAt(int i) { + return toks.get(i).getOriginalText(); + } + + private boolean isIdentifierToken(int i) { + String s = tokenAt(i); + return !s.isEmpty() && Character.isJavaIdentifierStart(s.codePointAt(0)); + } + + private boolean isSpaceToken(int i) { + String s = tokenAt(i); + if (s.isEmpty()) { + return false; + } else { + return " \t\f".indexOf(s.codePointAt(0)) >= 0; + } + } + + private boolean isSlashSlashCommentToken(int i) { + return toks.get(i).isSlashSlashComment(); + } + + private boolean isNewlineToken(int i) { + return toks.get(i).isNewline(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java new file mode 100644 index 000000000..d34ecc43f --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java @@ -0,0 +1,184 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Strings; +import com.google.googlejavaformat.CommentsHelper; +import com.google.googlejavaformat.Input.Tok; +import com.google.googlejavaformat.Newlines; +import com.google.googlejavaformat.java.javadoc.JavadocFormatter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** {@code JavaCommentsHelper} extends {@link CommentsHelper} to rewrite Java comments. */ +public final class JavaCommentsHelper implements CommentsHelper { + + private final String lineSeparator; + private final JavaFormatterOptions options; + + public JavaCommentsHelper(String lineSeparator, JavaFormatterOptions options) { + this.lineSeparator = lineSeparator; + this.options = options; + } + + @Override + public String rewrite(Tok tok, int maxWidth, int column0) { + if (!tok.isComment()) { + return tok.getOriginalText(); + } + String text = tok.getOriginalText(); + if (tok.isJavadocComment() && options.formatJavadoc()) { + text = JavadocFormatter.formatJavadoc(text, column0); + } + List lines = new ArrayList<>(); + Iterator it = Newlines.lineIterator(text); + while (it.hasNext()) { + lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next())); + } + if (tok.isSlashSlashComment()) { + return indentLineComments(lines, column0); + } + return CommentsHelper.reformatParameterComment(tok) + .orElseGet( + () -> + javadocShaped(lines) + ? indentJavadoc(lines, column0) + : preserveIndentation(lines, column0)); + } + + // For non-javadoc-shaped block comments, shift the entire block to the correct + // column, but do not adjust relative indentation. + private String preserveIndentation(List lines, int column0) { + StringBuilder builder = new StringBuilder(); + + // find the leftmost non-whitespace character in all trailing lines + int startCol = -1; + for (int i = 1; i < lines.size(); i++) { + int lineIdx = CharMatcher.whitespace().negate().indexIn(lines.get(i)); + if (lineIdx >= 0 && (startCol == -1 || lineIdx < startCol)) { + startCol = lineIdx; + } + } + + // output the first line at the current column + builder.append(lines.get(0)); + + // output all trailing lines with plausible indentation + for (int i = 1; i < lines.size(); ++i) { + builder.append(lineSeparator).append(Strings.repeat(" ", column0)); + // check that startCol is valid index, e.g. for blank lines + if (lines.get(i).length() >= startCol) { + builder.append(lines.get(i).substring(startCol)); + } else { + builder.append(lines.get(i)); + } + } + return builder.toString(); + } + + // Wraps and re-indents line comments. + private String indentLineComments(List lines, int column0) { + lines = wrapLineComments(lines, column0); + StringBuilder builder = new StringBuilder(); + builder.append(lines.get(0).trim()); + String indentString = Strings.repeat(" ", column0); + for (int i = 1; i < lines.size(); ++i) { + builder.append(lineSeparator).append(indentString).append(lines.get(i).trim()); + } + return builder.toString(); + } + + // Preserve special `//noinspection` and `//$NON-NLS-x$` comments used by IDEs, which cannot + // contain leading spaces. + private static final Pattern LINE_COMMENT_MISSING_SPACE_PREFIX = + Pattern.compile("^(//+)(?!noinspection|\\$NON-NLS-\\d+\\$)[^\\s/]"); + + private List wrapLineComments(List lines, int column0) { + List result = new ArrayList<>(); + for (String line : lines) { + // Add missing leading spaces to line comments: `//foo` -> `// foo`. + Matcher matcher = LINE_COMMENT_MISSING_SPACE_PREFIX.matcher(line); + if (matcher.find()) { + int length = matcher.group(1).length(); + line = Strings.repeat("/", length) + " " + line.substring(length); + } + if (line.startsWith("// MOE:")) { + // don't wrap comments for https://github.com/google/MOE + result.add(line); + continue; + } + while (line.length() + column0 > Formatter.MAX_LINE_LENGTH) { + int idx = Formatter.MAX_LINE_LENGTH - column0; + // only break on whitespace characters, and ignore the leading `// ` + while (idx >= 2 && !CharMatcher.whitespace().matches(line.charAt(idx))) { + idx--; + } + if (idx <= 2) { + break; + } + result.add(line.substring(0, idx)); + line = "//" + line.substring(idx); + } + result.add(line); + } + return result; + } + + // Remove leading whitespace (trailing was already removed), and re-indent. + // Add a +1 indent before '*', and add the '*' if necessary. + private String indentJavadoc(List lines, int column0) { + StringBuilder builder = new StringBuilder(); + builder.append(lines.get(0).trim()); + int indent = column0 + 1; + String indentString = Strings.repeat(" ", indent); + for (int i = 1; i < lines.size(); ++i) { + builder.append(lineSeparator).append(indentString); + String line = lines.get(i).trim(); + if (!line.startsWith("*")) { + builder.append("* "); + } + builder.append(line); + } + return builder.toString(); + } + + // Returns true if the comment looks like javadoc + private static boolean javadocShaped(List lines) { + Iterator it = lines.iterator(); + if (!it.hasNext()) { + return false; + } + String first = it.next().trim(); + // if it's actually javadoc, we're done + if (first.startsWith("/**")) { + return true; + } + // if it's a block comment, check all trailing lines for '*' + if (!first.startsWith("/*")) { + return false; + } + while (it.hasNext()) { + if (!it.next().trim().startsWith("*")) { + return false; + } + } + return true; + } +} + diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java new file mode 100644 index 000000000..67c13d0b3 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java @@ -0,0 +1,89 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.Immutable; + +/** + * Options for a google-java-format invocation. + * + *

Like gofmt, the google-java-format CLI exposes no configuration options (aside from + * {@code --aosp}). + * + *

The goal of google-java-format is to provide consistent formatting, and to free developers + * from arguments over style choices. It is an explicit non-goal to support developers' individual + * preferences, and in fact it would work directly against our primary goals. + */ +@Immutable +@AutoValue +public abstract class JavaFormatterOptions { + + public enum Style { + /** The default Google Java Style configuration. */ + GOOGLE(1), + + /** The AOSP-compliant configuration. */ + AOSP(2); + + private final int indentationMultiplier; + + Style(int indentationMultiplier) { + this.indentationMultiplier = indentationMultiplier; + } + + int indentationMultiplier() { + return indentationMultiplier; + } + } + + /** Returns the multiplier for the unit of indent. */ + public int indentationMultiplier() { + return style().indentationMultiplier(); + } + + public abstract boolean formatJavadoc(); + + public abstract boolean reorderModifiers(); + + /** Returns the code style. */ + public abstract Style style(); + + /** Returns the default formatting options. */ + public static JavaFormatterOptions defaultOptions() { + return builder().build(); + } + + /** Returns a builder for {@link JavaFormatterOptions}. */ + public static Builder builder() { + return new AutoValue_JavaFormatterOptions.Builder() + .style(Style.GOOGLE) + .formatJavadoc(true) + .reorderModifiers(true); + } + + /** A builder for {@link JavaFormatterOptions}. */ + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder style(Style style); + + public abstract Builder formatJavadoc(boolean formatJavadoc); + + public abstract Builder reorderModifiers(boolean reorderModifiers); + + public abstract JavaFormatterOptions build(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java new file mode 100644 index 000000000..eee210e20 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java @@ -0,0 +1,670 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.getLast; +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Verify; +import com.google.common.collect.DiscreteDomain; +import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableRangeMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeSet; +import com.google.googlejavaformat.Input; +import com.google.googlejavaformat.Newlines; +import com.google.googlejavaformat.java.JavacTokens.RawTok; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.parser.Tokens.TokenKind; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Log.DeferredDiagnosticHandler; +import com.sun.tools.javac.util.Options; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.DiagnosticListener; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import javax.tools.JavaFileObject.Kind; +import javax.tools.SimpleJavaFileObject; + +/** {@code JavaInput} extends {@link Input} to represent a Java input document. */ +public final class JavaInput extends Input { + /** + * A {@code JavaInput} is a sequence of {@link Tok}s that cover the Java input. A {@link Tok} is + * either a token (if {@code isToken()}), or a non-token, which is a comment (if {@code + * isComment()}) or a newline (if {@code isNewline()}) or a maximal sequence of other whitespace + * characters (if {@code isSpaces()}). Each {@link Tok} contains a sequence of characters, an + * index (sequential starting at {@code 0} for tokens and comments, else {@code -1}), and a + * ({@code 0}-origin) position in the input. The concatenation of the texts of all the {@link + * Tok}s equals the input. Each Input ends with a token EOF {@link Tok}, with empty text. + * + *

A {@code /*} comment possibly contains newlines; a {@code //} comment does not contain the + * terminating newline character, but is followed by a newline {@link Tok}. + */ + static final class Tok implements Input.Tok { + private final int index; + private final String originalText; + private final String text; + private final int position; + private final int columnI; + private final boolean isToken; + private final TokenKind kind; + + /** + * The {@code Tok} constructor. + * + * @param index its index + * @param originalText its original text, before removing Unicode escapes + * @param text its text after removing Unicode escapes + * @param position its {@code 0}-origin position in the input + * @param columnI its {@code 0}-origin column number in the input + * @param isToken whether the {@code Tok} is a token + * @param kind the token kind + */ + Tok( + int index, + String originalText, + String text, + int position, + int columnI, + boolean isToken, + TokenKind kind) { + this.index = index; + this.originalText = originalText; + this.text = text; + this.position = position; + this.columnI = columnI; + this.isToken = isToken; + this.kind = kind; + } + + @Override + public int getIndex() { + return index; + } + + @Override + public String getText() { + return text; + } + + @Override + public String getOriginalText() { + return originalText; + } + + @Override + public int length() { + return originalText.length(); + } + + @Override + public int getPosition() { + return position; + } + + @Override + public int getColumn() { + return columnI; + } + + boolean isToken() { + return isToken; + } + + @Override + public boolean isNewline() { + return Newlines.isNewline(text); + } + + @Override + public boolean isSlashSlashComment() { + return text.startsWith("//"); + } + + @Override + public boolean isSlashStarComment() { + return text.startsWith("/*"); + } + + @Override + public boolean isJavadocComment() { + // comments like `/***` are also javadoc, but their formatting probably won't be improved + // by the javadoc formatter + return text.startsWith("/**") && text.charAt("/**".length()) != '*' && text.length() > 4; + } + + @Override + public boolean isComment() { + return isSlashSlashComment() || isSlashStarComment(); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("index", index) + .add("text", text) + .add("position", position) + .add("columnI", columnI) + .add("isToken", isToken) + .toString(); + } + + public TokenKind kind() { + return kind; + } + } + + /** + * A {@link Token} contains a token {@link Tok} and its associated non-tokens; each non-token + * {@link Tok} belongs to one {@link Token}. Each {@link Token} has an immutable list of its + * non-tokens that appear before it, and another list of its non-tokens that appear after it. The + * concatenation of the texts of all the {@link Token}s' {@link Tok}s, each preceded by the texts + * of its {@code toksBefore} and followed by the texts of its {@code toksAfter}, equals the input. + */ + static final class Token implements Input.Token { + private final Tok tok; + private final ImmutableList toksBefore; + private final ImmutableList toksAfter; + + /** + * Token constructor. + * + * @param toksBefore the earlier non-token {link Tok}s assigned to this {@code Token} + * @param tok this token {@link Tok} + * @param toksAfter the later non-token {link Tok}s assigned to this {@code Token} + */ + Token(List toksBefore, Tok tok, List toksAfter) { + this.toksBefore = ImmutableList.copyOf(toksBefore); + this.tok = tok; + this.toksAfter = ImmutableList.copyOf(toksAfter); + } + + /** + * Get the token's {@link Tok}. + * + * @return the token's {@link Tok} + */ + @Override + public Tok getTok() { + return tok; + } + + /** + * Get the earlier {@link Tok}s assigned to this {@code Token}. + * + * @return the earlier {@link Tok}s assigned to this {@code Token} + */ + @Override + public ImmutableList getToksBefore() { + return toksBefore; + } + + /** + * Get the later {@link Tok}s assigned to this {@code Token}. + * + * @return the later {@link Tok}s assigned to this {@code Token} + */ + @Override + public ImmutableList getToksAfter() { + return toksAfter; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("tok", tok) + .add("toksBefore", toksBefore) + .add("toksAfter", toksAfter) + .toString(); + } + } + + private final String text; // The input. + private int kN; // The number of numbered toks (tokens or comments), excluding the EOF. + + /* + * The following lists record the sequential indices of the {@code Tok}s on each input line. (Only + * tokens and comments have sequential indices.) Tokens and {@code //} comments lie on just one + * line; {@code /*} comments can lie on multiple lines. These data structures (along with + * equivalent ones for the formatted output) let us compute correspondences between the input and + * output. + */ + + private final ImmutableMap positionToColumnMap; // Map Tok position to column. + private final ImmutableList tokens; // The Tokens for this input. + private final ImmutableRangeMap positionTokenMap; // Map position to Token. + + /** Map from Tok index to the associated Token. */ + private final Token[] kToToken; + + /** + * Input constructor. + * + * @param text the input text + * @throws FormatterException if the input cannot be parsed + */ + public JavaInput(String text) throws FormatterException { + this.text = checkNotNull(text); + setLines(ImmutableList.copyOf(Newlines.lineIterator(text))); + ImmutableList toks = buildToks(text); + positionToColumnMap = makePositionToColumnMap(toks); + tokens = buildTokens(toks); + ImmutableRangeMap.Builder tokenLocations = ImmutableRangeMap.builder(); + for (Token token : tokens) { + Input.Tok end = JavaOutput.endTok(token); + int upper = end.getPosition(); + if (!end.getText().isEmpty()) { + upper += end.length() - 1; + } + tokenLocations.put(Range.closed(JavaOutput.startTok(token).getPosition(), upper), token); + } + positionTokenMap = tokenLocations.build(); + + // adjust kN for EOF + kToToken = new Token[kN + 1]; + for (Token token : tokens) { + for (Input.Tok tok : token.getToksBefore()) { + if (tok.getIndex() < 0) { + continue; + } + kToToken[tok.getIndex()] = token; + } + kToToken[token.getTok().getIndex()] = token; + for (Input.Tok tok : token.getToksAfter()) { + if (tok.getIndex() < 0) { + continue; + } + kToToken[tok.getIndex()] = token; + } + } + } + + private static ImmutableMap makePositionToColumnMap(List toks) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (Tok tok : toks) { + builder.put(tok.getPosition(), tok.getColumn()); + } + return builder.buildOrThrow(); + } + + /** + * Get the input text. + * + * @return the input text + */ + @Override + public String getText() { + return text; + } + + @Override + public ImmutableMap getPositionToColumnMap() { + return positionToColumnMap; + } + + /** Lex the input and build the list of toks. */ + private ImmutableList buildToks(String text) throws FormatterException { + ImmutableList toks = buildToks(text, ImmutableSet.of()); + kN = getLast(toks).getIndex(); + computeRanges(toks); + return toks; + } + + /** + * Lex the input and build the list of toks. + * + * @param text the text to be lexed. + * @param stopTokens a set of tokens which should cause lexing to stop. If one of these is found, + * the returned list will include tokens up to but not including that token. + */ + static ImmutableList buildToks(String text, ImmutableSet stopTokens) + throws FormatterException { + stopTokens = ImmutableSet.builder().addAll(stopTokens).add(TokenKind.EOF).build(); + Context context = new Context(); + Options.instance(context).put("--enable-preview", "true"); + JavaFileManager fileManager = new JavacFileManager(context, false, UTF_8); + context.put(JavaFileManager.class, fileManager); + DiagnosticCollector diagnosticCollector = new DiagnosticCollector<>(); + context.put(DiagnosticListener.class, diagnosticCollector); + Log log = Log.instance(context); + log.useSource( + new SimpleJavaFileObject(URI.create("Source.java"), Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return text; + } + }); + DeferredDiagnosticHandler diagnostics = new DeferredDiagnosticHandler(log); + ImmutableList rawToks = JavacTokens.getTokens(text, context, stopTokens); + if (diagnostics.getDiagnostics().stream().anyMatch(d -> d.getKind() == Diagnostic.Kind.ERROR)) { + return ImmutableList.of(new Tok(0, "", "", 0, 0, true, null)); // EOF + } + int kN = 0; + List toks = new ArrayList<>(); + int charI = 0; + int columnI = 0; + for (RawTok t : rawToks) { + if (stopTokens.contains(t.kind())) { + break; + } + int charI0 = t.pos(); + // Get string, possibly with Unicode escapes. + String originalTokText = text.substring(charI0, t.endPos()); + String tokText = + t.kind() == TokenKind.STRINGLITERAL + ? t.stringVal() // Unicode escapes removed. + : originalTokText; + char tokText0 = tokText.charAt(0); // The token's first character. + final boolean isToken; // Is this tok a token? + final boolean isNumbered; // Is this tok numbered? (tokens and comments) + String extraNewline = null; // Extra newline at end? + List strings = new ArrayList<>(); + if (Character.isWhitespace(tokText0)) { + isToken = false; + isNumbered = false; + Iterator it = Newlines.lineIterator(originalTokText); + while (it.hasNext()) { + String line = it.next(); + String newline = Newlines.getLineEnding(line); + if (newline != null) { + String spaces = line.substring(0, line.length() - newline.length()); + if (!spaces.isEmpty()) { + strings.add(spaces); + } + strings.add(newline); + } else if (!line.isEmpty()) { + strings.add(line); + } + } + } else if (tokText.startsWith("'") || tokText.startsWith("\"")) { + isToken = true; + isNumbered = true; + strings.add(originalTokText); + } else if (tokText.startsWith("//") || tokText.startsWith("/*")) { + // For compatibility with an earlier lexer, the newline after a // comment is its own tok. + if (tokText.startsWith("//") + && (originalTokText.endsWith("\n") || originalTokText.endsWith("\r"))) { + extraNewline = Newlines.getLineEnding(originalTokText); + tokText = tokText.substring(0, tokText.length() - extraNewline.length()); + originalTokText = + originalTokText.substring(0, originalTokText.length() - extraNewline.length()); + } + isToken = false; + isNumbered = true; + strings.add(originalTokText); + } else if (Character.isJavaIdentifierStart(tokText0) + || Character.isDigit(tokText0) + || (tokText0 == '.' && tokText.length() > 1 && Character.isDigit(tokText.charAt(1)))) { + // Identifier, keyword, or numeric literal (a dot may begin a number, as in .2D). + isToken = true; + isNumbered = true; + strings.add(tokText); + } else { + // Other tokens ("+" or "++" or ">>" are broken into one-character toks, because ">>" + // cannot be lexed without syntactic knowledge. This implementation fails if the token + // contains Unicode escapes. + isToken = true; + isNumbered = true; + for (char c : tokText.toCharArray()) { + strings.add(String.valueOf(c)); + } + } + if (strings.size() == 1) { + toks.add( + new Tok( + isNumbered ? kN++ : -1, + originalTokText, + tokText, + charI, + columnI, + isToken, + t.kind())); + charI += originalTokText.length(); + columnI = updateColumn(columnI, originalTokText); + + } else { + if (strings.size() != 1 && !tokText.equals(originalTokText)) { + throw new FormatterException( + "Unicode escapes not allowed in whitespace or multi-character operators"); + } + for (String str : strings) { + toks.add(new Tok(isNumbered ? kN++ : -1, str, str, charI, columnI, isToken, null)); + charI += str.length(); + columnI = updateColumn(columnI, originalTokText); + } + } + if (extraNewline != null) { + toks.add(new Tok(-1, extraNewline, extraNewline, charI, columnI, false, null)); + columnI = 0; + charI += extraNewline.length(); + } + } + toks.add(new Tok(kN, "", "", charI, columnI, true, null)); // EOF tok. + return ImmutableList.copyOf(toks); + } + + private static int updateColumn(int columnI, String originalTokText) { + Integer last = Iterators.getLast(Newlines.lineOffsetIterator(originalTokText)); + if (last > 0) { + columnI = originalTokText.length() - last; + } else { + columnI += originalTokText.length(); + } + return columnI; + } + + private static ImmutableList buildTokens(List toks) { + ImmutableList.Builder tokens = ImmutableList.builder(); + int k = 0; + int kN = toks.size(); + + // Remaining non-tokens before the token go here. + ImmutableList.Builder toksBefore = ImmutableList.builder(); + + OUTERMOST: + while (k < kN) { + while (!toks.get(k).isToken()) { + Tok tok = toks.get(k++); + toksBefore.add(tok); + if (isParamComment(tok)) { + while (toks.get(k).isNewline()) { + // drop newlines after parameter comments + k++; + } + } + } + Tok tok = toks.get(k++); + + // Non-tokens starting on the same line go here too. + ImmutableList.Builder toksAfter = ImmutableList.builder(); + OUTER: + while (k < kN && !toks.get(k).isToken()) { + // Don't attach inline comments to certain leading tokens, e.g. for `f(/*flag1=*/true). + // + // Attaching inline comments to the right token is hard, and this barely + // scratches the surface. But it's enough to do a better job with parameter + // name comments. + // + // TODO(cushon): find a better strategy. + if (toks.get(k).isSlashStarComment()) { + switch (tok.getText()) { + case "(": + case "<": + case ".": + break OUTER; + default: + break; + } + } + if (toks.get(k).isJavadocComment()) { + switch (tok.getText()) { + case ";": + break OUTER; + default: + break; + } + } + if (isParamComment(toks.get(k))) { + tokens.add(new Token(toksBefore.build(), tok, toksAfter.build())); + toksBefore = ImmutableList.builder().add(toks.get(k++)); + // drop newlines after parameter comments + while (toks.get(k).isNewline()) { + k++; + } + continue OUTERMOST; + } + Tok nonTokenAfter = toks.get(k++); + toksAfter.add(nonTokenAfter); + if (Newlines.containsBreaks(nonTokenAfter.getText())) { + break; + } + } + tokens.add(new Token(toksBefore.build(), tok, toksAfter.build())); + toksBefore = ImmutableList.builder(); + } + return tokens.build(); + } + + private static boolean isParamComment(Tok tok) { + return tok.isSlashStarComment() + && tok.getText().matches("\\/\\*[A-Za-z0-9\\s_\\-]+=\\s*\\*\\/"); + } + + /** + * Convert from a character range to a token range. + * + * @param characterRange the {@code 0}-based {@link Range} of characters + * @return the {@code 0}-based {@link Range} of tokens + * @throws FormatterException if the upper endpoint of the range is outside the file + */ + Range characterRangeToTokenRange(Range characterRange) + throws FormatterException { + if (characterRange.upperEndpoint() > text.length()) { + throw new FormatterException( + String.format( + "error: invalid length %d, offset + length (%d) is outside the file", + characterRange.upperEndpoint() - characterRange.lowerEndpoint(), + characterRange.upperEndpoint())); + } + // empty range stands for "format the line under the cursor" + Range nonEmptyRange = + characterRange.isEmpty() + ? Range.closedOpen(characterRange.lowerEndpoint(), characterRange.lowerEndpoint() + 1) + : characterRange; + ImmutableCollection enclosed = + getPositionTokenMap().subRangeMap(nonEmptyRange).asMapOfRanges().values(); + if (enclosed.isEmpty()) { + return EMPTY_RANGE; + } + return Range.closedOpen( + enclosed.iterator().next().getTok().getIndex(), getLast(enclosed).getTok().getIndex() + 1); + } + + /** + * Get the number of toks. + * + * @return the number of toks, excluding the EOF tok + */ + @Override + public int getkN() { + return kN; + } + + /** + * Get the Token by index. + * + * @param k the Tok index + */ + @Override + public Token getToken(int k) { + return kToToken[k]; + } + + /** + * Get the input tokens. + * + * @return the input tokens + */ + @Override + public ImmutableList getTokens() { + return tokens; + } + + /** + * Get the navigable map from position to {@link Token}. Used to look for tokens following a given + * one, and to implement the --offset and --length flags to reformat a character range in the + * input file. + * + * @return the navigable map from position to {@link Token} + */ + @Override + public ImmutableRangeMap getPositionTokenMap() { + return positionTokenMap; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("tokens", tokens) + .add("super", super.toString()) + .toString(); + } + + private JCCompilationUnit unit; + + @Override + public int getLineNumber(int inputPosition) { + Verify.verifyNotNull(unit, "Expected compilation unit to be set."); + return unit.getLineMap().getLineNumber(inputPosition); + } + + @Override + public int getColumnNumber(int inputPosition) { + Verify.verifyNotNull(unit, "Expected compilation unit to be set."); + return unit.getLineMap().getColumnNumber(inputPosition); + } + + // TODO(cushon): refactor JavaInput so the CompilationUnit can be passed into + // the constructor. + public void setCompilationUnit(JCCompilationUnit unit) { + this.unit = unit; + } + + public RangeSet characterRangesToTokenRanges(Collection> characterRanges) + throws FormatterException { + RangeSet tokenRangeSet = TreeRangeSet.create(); + for (Range characterRange : characterRanges) { + tokenRangeSet.add( + characterRangeToTokenRange(characterRange.canonical(DiscreteDomain.integers()))); + } + return tokenRangeSet; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java new file mode 100644 index 000000000..89c944c5b --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java @@ -0,0 +1,3947 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static com.google.common.collect.Iterables.getLast; +import static com.google.common.collect.Iterables.getOnlyElement; +import static com.google.googlejavaformat.Doc.FillMode.INDEPENDENT; +import static com.google.googlejavaformat.Doc.FillMode.UNIFIED; +import static com.google.googlejavaformat.Indent.If.make; +import static com.google.googlejavaformat.OpsBuilder.BlankLineWanted.PRESERVE; +import static com.google.googlejavaformat.OpsBuilder.BlankLineWanted.YES; +import static com.google.googlejavaformat.java.Trees.getEndPosition; +import static com.google.googlejavaformat.java.Trees.getLength; +import static com.google.googlejavaformat.java.Trees.getMethodName; +import static com.google.googlejavaformat.java.Trees.getSourceForNode; +import static com.google.googlejavaformat.java.Trees.getStartPosition; +import static com.google.googlejavaformat.java.Trees.operatorName; +import static com.google.googlejavaformat.java.Trees.precedence; +import static com.google.googlejavaformat.java.Trees.skipParen; +import static com.sun.source.tree.Tree.Kind.ANNOTATION; +import static com.sun.source.tree.Tree.Kind.ARRAY_ACCESS; +import static com.sun.source.tree.Tree.Kind.ASSIGNMENT; +import static com.sun.source.tree.Tree.Kind.BLOCK; +import static com.sun.source.tree.Tree.Kind.EXTENDS_WILDCARD; +import static com.sun.source.tree.Tree.Kind.IF; +import static com.sun.source.tree.Tree.Kind.METHOD_INVOCATION; +import static com.sun.source.tree.Tree.Kind.NEW_ARRAY; +import static com.sun.source.tree.Tree.Kind.NEW_CLASS; +import static com.sun.source.tree.Tree.Kind.STRING_LITERAL; +import static com.sun.source.tree.Tree.Kind.UNION_TYPE; +import static com.sun.source.tree.Tree.Kind.VARIABLE; +import static java.util.stream.Collectors.toList; + +import com.google.auto.value.AutoOneOf; +import com.google.auto.value.AutoValue; +import com.google.common.base.MoreObjects; +import com.google.common.base.Predicate; +import com.google.common.base.Throwables; +import com.google.common.base.Verify; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSetMultimap; +import com.google.common.collect.ImmutableSortedSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Iterators; +import com.google.common.collect.Multiset; +import com.google.common.collect.PeekingIterator; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.Streams; +import com.google.common.collect.TreeRangeSet; +import com.google.errorprone.annotations.CheckReturnValue; +import com.google.googlejavaformat.CloseOp; +import com.google.googlejavaformat.Doc; +import com.google.googlejavaformat.Doc.FillMode; +import com.google.googlejavaformat.FormattingError; +import com.google.googlejavaformat.Indent; +import com.google.googlejavaformat.Input; +import com.google.googlejavaformat.Op; +import com.google.googlejavaformat.OpenOp; +import com.google.googlejavaformat.OpsBuilder; +import com.google.googlejavaformat.OpsBuilder.BlankLineWanted; +import com.google.googlejavaformat.Output.BreakTag; +import com.google.googlejavaformat.java.DimensionHelpers.SortedDims; +import com.google.googlejavaformat.java.DimensionHelpers.TypeWithDims; +import com.sun.source.tree.AnnotatedTypeTree; +import com.sun.source.tree.AnnotationTree; +import com.sun.source.tree.ArrayAccessTree; +import com.sun.source.tree.ArrayTypeTree; +import com.sun.source.tree.AssertTree; +import com.sun.source.tree.AssignmentTree; +import com.sun.source.tree.BinaryTree; +import com.sun.source.tree.BlockTree; +import com.sun.source.tree.BreakTree; +import com.sun.source.tree.CaseTree; +import com.sun.source.tree.CatchTree; +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.CompoundAssignmentTree; +import com.sun.source.tree.ConditionalExpressionTree; +import com.sun.source.tree.ContinueTree; +import com.sun.source.tree.DirectiveTree; +import com.sun.source.tree.DoWhileLoopTree; +import com.sun.source.tree.EmptyStatementTree; +import com.sun.source.tree.EnhancedForLoopTree; +import com.sun.source.tree.ExportsTree; +import com.sun.source.tree.ExpressionStatementTree; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.ForLoopTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.IfTree; +import com.sun.source.tree.ImportTree; +import com.sun.source.tree.InstanceOfTree; +import com.sun.source.tree.IntersectionTypeTree; +import com.sun.source.tree.LabeledStatementTree; +import com.sun.source.tree.LambdaExpressionTree; +import com.sun.source.tree.LiteralTree; +import com.sun.source.tree.MemberReferenceTree; +import com.sun.source.tree.MemberSelectTree; +import com.sun.source.tree.MethodInvocationTree; +import com.sun.source.tree.MethodTree; +import com.sun.source.tree.ModifiersTree; +import com.sun.source.tree.ModuleTree; +import com.sun.source.tree.NewArrayTree; +import com.sun.source.tree.NewClassTree; +import com.sun.source.tree.OpensTree; +import com.sun.source.tree.ParameterizedTypeTree; +import com.sun.source.tree.ParenthesizedTree; +import com.sun.source.tree.PrimitiveTypeTree; +import com.sun.source.tree.ProvidesTree; +import com.sun.source.tree.RequiresTree; +import com.sun.source.tree.ReturnTree; +import com.sun.source.tree.StatementTree; +import com.sun.source.tree.SwitchTree; +import com.sun.source.tree.SynchronizedTree; +import com.sun.source.tree.ThrowTree; +import com.sun.source.tree.Tree; +import com.sun.source.tree.TryTree; +import com.sun.source.tree.TypeCastTree; +import com.sun.source.tree.TypeParameterTree; +import com.sun.source.tree.UnaryTree; +import com.sun.source.tree.UnionTypeTree; +import com.sun.source.tree.UsesTree; +import com.sun.source.tree.VariableTree; +import com.sun.source.tree.WhileLoopTree; +import com.sun.source.tree.WildcardTree; +import com.sun.source.util.TreePath; +import com.sun.source.util.TreePathScanner; +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.TreeScanner; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.Deque; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import javax.lang.model.element.Name; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** + * An AST visitor that builds a stream of {@link Op}s to format from the given {@link + * CompilationUnitTree}. + */ +public class JavaInputAstVisitor extends TreePathScanner { + + /** Direction for Annotations (usually VERTICAL). */ + protected enum Direction { + VERTICAL, + HORIZONTAL; + + boolean isVertical() { + return this == VERTICAL; + } + } + + /** Whether to break or not. */ + protected enum BreakOrNot { + YES, + NO; + + boolean isYes() { + return this == YES; + } + } + + /** Whether to collapse empty blocks. */ + protected enum CollapseEmptyOrNot { + YES, + NO; + + static CollapseEmptyOrNot valueOf(boolean b) { + return b ? YES : NO; + } + + boolean isYes() { + return this == YES; + } + } + + /** Whether to allow leading blank lines in blocks. */ + protected enum AllowLeadingBlankLine { + YES, + NO; + + static AllowLeadingBlankLine valueOf(boolean b) { + return b ? YES : NO; + } + } + + /** Whether to allow trailing blank lines in blocks. */ + protected enum AllowTrailingBlankLine { + YES, + NO; + + static AllowTrailingBlankLine valueOf(boolean b) { + return b ? YES : NO; + } + } + + /** Whether to include braces. */ + protected enum BracesOrNot { + YES, + NO; + + boolean isYes() { + return this == YES; + } + } + + /** Whether or not to include dimensions. */ + enum DimensionsOrNot { + YES, + NO; + + boolean isYes() { + return this == YES; + } + } + + /** Whether or not the declaration is Varargs. */ + enum VarArgsOrNot { + YES, + NO; + + static VarArgsOrNot valueOf(boolean b) { + return b ? YES : NO; + } + + boolean isYes() { + return this == YES; + } + + static VarArgsOrNot fromVariable(VariableTree node) { + return valueOf((((JCTree.JCVariableDecl) node).mods.flags & Flags.VARARGS) == Flags.VARARGS); + } + } + + /** Whether the formal parameter declaration is a receiver. */ + enum ReceiverParameter { + YES, + NO; + + boolean isYes() { + return this == YES; + } + } + + /** Whether these declarations are the first in the block. */ + protected enum FirstDeclarationsOrNot { + YES, + NO; + + boolean isYes() { + return this == YES; + } + } + + // TODO(cushon): generalize this + private static final ImmutableMultimap TYPE_ANNOTATIONS = typeAnnotations(); + + private static ImmutableSetMultimap typeAnnotations() { + ImmutableSetMultimap.Builder result = ImmutableSetMultimap.builder(); + for (String annotation : + ImmutableList.of( + "org.jspecify.annotations.NonNull", + "org.jspecify.annotations.Nullable", + "org.jspecify.nullness.Nullable", + "org.checkerframework.checker.nullness.qual.NonNull", + "org.checkerframework.checker.nullness.qual.Nullable")) { + String simpleName = annotation.substring(annotation.lastIndexOf('.') + 1); + result.put(simpleName, annotation); + } + return result.build(); + } + + protected final OpsBuilder builder; + + protected static final Indent.Const ZERO = Indent.Const.ZERO; + protected final int indentMultiplier; + protected final Indent.Const minusTwo; + protected final Indent.Const minusFour; + protected final Indent.Const plusTwo; + protected final Indent.Const plusFour; + + private final Set typeAnnotationSimpleNames = new HashSet<>(); + + private static final ImmutableList breakList(Optional breakTag) { + return ImmutableList.of(Doc.Break.make(Doc.FillMode.UNIFIED, " ", ZERO, breakTag)); + } + + private static final ImmutableList breakFillList(Optional breakTag) { + return ImmutableList.of( + OpenOp.make(ZERO), + Doc.Break.make(Doc.FillMode.INDEPENDENT, " ", ZERO, breakTag), + CloseOp.make()); + } + + private static final ImmutableList forceBreakList(Optional breakTag) { + return ImmutableList.of(Doc.Break.make(FillMode.FORCED, "", Indent.Const.ZERO, breakTag)); + } + + /** + * Allow multi-line filling (of array initializers, argument lists, and boolean expressions) for + * items with length less than or equal to this threshold. + */ + private static final int MAX_ITEM_LENGTH_FOR_FILLING = 10; + + /** + * The {@code Visitor} constructor. + * + * @param builder the {@link OpsBuilder} + */ + public JavaInputAstVisitor(OpsBuilder builder, int indentMultiplier) { + this.builder = builder; + this.indentMultiplier = indentMultiplier; + minusTwo = Indent.Const.make(-2, indentMultiplier); + minusFour = Indent.Const.make(-4, indentMultiplier); + plusTwo = Indent.Const.make(+2, indentMultiplier); + plusFour = Indent.Const.make(+4, indentMultiplier); + } + + /** A record of whether we have visited into an expression. */ + private final Deque inExpression = new ArrayDeque<>(ImmutableList.of(false)); + + private boolean inExpression() { + return inExpression.peekLast(); + } + + @Override + public Void scan(Tree tree, Void unused) { + inExpression.addLast(tree instanceof ExpressionTree || inExpression.peekLast()); + int previous = builder.depth(); + try { + super.scan(tree, null); + } catch (FormattingError e) { + throw e; + } catch (Throwable t) { + throw new FormattingError(builder.diagnostic(Throwables.getStackTraceAsString(t))); + } finally { + inExpression.removeLast(); + } + builder.checkClosed(previous); + return null; + } + + @Override + public Void visitCompilationUnit(CompilationUnitTree node, Void unused) { + boolean first = true; + if (node.getPackageName() != null) { + markForPartialFormat(); + visitPackage(node.getPackageName(), node.getPackageAnnotations()); + builder.forcedBreak(); + first = false; + } + dropEmptyDeclarations(); + if (!node.getImports().isEmpty()) { + if (!first) { + builder.blankLineWanted(BlankLineWanted.YES); + } + for (ImportTree importDeclaration : node.getImports()) { + markForPartialFormat(); + builder.blankLineWanted(PRESERVE); + scan(importDeclaration, null); + builder.forcedBreak(); + } + first = false; + } + dropEmptyDeclarations(); + for (Tree type : node.getTypeDecls()) { + if (type.getKind() == Tree.Kind.IMPORT) { + // javac treats extra semicolons in the import list as type declarations + // TODO(cushon): remove this if https://bugs.openjdk.java.net/browse/JDK-8027682 is fixed + continue; + } + if (!first) { + builder.blankLineWanted(BlankLineWanted.YES); + } + markForPartialFormat(); + scan(type, null); + builder.forcedBreak(); + first = false; + dropEmptyDeclarations(); + } + handleModule(first, node); + // set a partial format marker at EOF to make sure we can format the entire file + markForPartialFormat(); + return null; + } + + protected void handleModule(boolean first, CompilationUnitTree node) {} + + /** Skips over extra semi-colons at the top-level, or in a class member declaration lists. */ + protected void dropEmptyDeclarations() { + if (builder.peekToken().equals(Optional.of(";"))) { + while (builder.peekToken().equals(Optional.of(";"))) { + builder.forcedBreak(); + markForPartialFormat(); + token(";"); + } + } + } + + @Override + public Void visitClass(ClassTree tree, Void unused) { + switch (tree.getKind()) { + case ANNOTATION_TYPE: + visitAnnotationType(tree); + break; + case CLASS: + case INTERFACE: + visitClassDeclaration(tree); + break; + case ENUM: + visitEnumDeclaration(tree); + break; + default: + throw new AssertionError(tree.getKind()); + } + return null; + } + + public void visitAnnotationType(ClassTree node) { + sync(node); + builder.open(ZERO); + typeDeclarationModifiers(node.getModifiers()); + builder.open(ZERO); + token("@"); + token("interface"); + builder.breakOp(" "); + visit(node.getSimpleName()); + builder.close(); + builder.close(); + if (node.getMembers() == null) { + builder.open(plusFour); + token(";"); + builder.close(); + } else { + addBodyDeclarations(node.getMembers(), BracesOrNot.YES, FirstDeclarationsOrNot.YES); + } + builder.guessToken(";"); + } + + @Override + public Void visitArrayAccess(ArrayAccessTree node, Void unused) { + sync(node); + visitDot(node); + return null; + } + + @Override + public Void visitNewArray(NewArrayTree node, Void unused) { + if (node.getType() != null) { + builder.open(plusFour); + token("new"); + builder.space(); + + TypeWithDims extractedDims = DimensionHelpers.extractDims(node.getType(), SortedDims.YES); + Tree base = extractedDims.node; + + Deque dimExpressions = new ArrayDeque<>(node.getDimensions()); + + Deque> annotations = new ArrayDeque<>(); + annotations.add(ImmutableList.copyOf(node.getAnnotations())); + annotations.addAll(node.getDimAnnotations()); + annotations.addAll(extractedDims.dims); + + scan(base, null); + builder.open(ZERO); + maybeAddDims(dimExpressions, annotations); + builder.close(); + builder.close(); + } + if (node.getInitializers() != null) { + if (node.getType() != null) { + builder.space(); + } + visitArrayInitializer(node.getInitializers()); + } + return null; + } + + public boolean visitArrayInitializer(List expressions) { + int cols; + if (expressions.isEmpty()) { + tokenBreakTrailingComment("{", plusTwo); + if (builder.peekToken().equals(Optional.of(","))) { + token(","); + } + token("}", plusTwo); + } else if ((cols = argumentsAreTabular(expressions)) != -1) { + builder.open(plusTwo); + token("{"); + builder.forcedBreak(); + boolean first = true; + for (Iterable row : Iterables.partition(expressions, cols)) { + if (!first) { + builder.forcedBreak(); + } + builder.open(row.iterator().next().getKind() == NEW_ARRAY || cols == 1 ? ZERO : plusFour); + boolean firstInRow = true; + for (ExpressionTree item : row) { + if (!firstInRow) { + token(","); + builder.breakToFill(" "); + } + scan(item, null); + firstInRow = false; + } + builder.guessToken(","); + builder.close(); + first = false; + } + builder.breakOp(minusTwo); + builder.close(); + token("}", plusTwo); + } else { + // Special-case the formatting of array initializers inside annotations + // to more eagerly use a one-per-line layout. + boolean inMemberValuePair = false; + // walk up past the enclosing NewArrayTree (and maybe an enclosing AssignmentTree) + TreePath path = getCurrentPath(); + for (int i = 0; i < 2; i++) { + if (path == null) { + break; + } + if (path.getLeaf().getKind() == ANNOTATION) { + inMemberValuePair = true; + break; + } + path = path.getParentPath(); + } + boolean shortItems = hasOnlyShortItems(expressions); + boolean allowFilledElementsOnOwnLine = shortItems || !inMemberValuePair; + + builder.open(plusTwo); + tokenBreakTrailingComment("{", plusTwo); + boolean hasTrailingComma = hasTrailingToken(builder.getInput(), expressions, ","); + builder.breakOp(hasTrailingComma ? FillMode.FORCED : FillMode.UNIFIED, "", ZERO); + if (allowFilledElementsOnOwnLine) { + builder.open(ZERO); + } + boolean first = true; + FillMode fillMode = shortItems ? FillMode.INDEPENDENT : FillMode.UNIFIED; + for (ExpressionTree expression : expressions) { + if (!first) { + token(","); + builder.breakOp(fillMode, " ", ZERO); + } + scan(expression, null); + first = false; + } + builder.guessToken(","); + if (allowFilledElementsOnOwnLine) { + builder.close(); + } + builder.breakOp(minusTwo); + builder.close(); + token("}", plusTwo); + } + return false; + } + + private boolean hasOnlyShortItems(List expressions) { + for (ExpressionTree expression : expressions) { + int startPosition = getStartPosition(expression); + if (builder.actualSize( + startPosition, getEndPosition(expression, getCurrentPath()) - startPosition) + >= MAX_ITEM_LENGTH_FOR_FILLING) { + return false; + } + } + return true; + } + + @Override + public Void visitArrayType(ArrayTypeTree node, Void unused) { + sync(node); + visitAnnotatedArrayType(node); + return null; + } + + private void visitAnnotatedArrayType(Tree node) { + TypeWithDims extractedDims = DimensionHelpers.extractDims(node, SortedDims.YES); + builder.open(plusFour); + scan(extractedDims.node, null); + Deque> dims = new ArrayDeque<>(extractedDims.dims); + maybeAddDims(dims); + Verify.verify(dims.isEmpty()); + builder.close(); + } + + @Override + public Void visitAssert(AssertTree node, Void unused) { + sync(node); + builder.open(ZERO); + token("assert"); + builder.space(); + builder.open(node.getDetail() == null ? ZERO : plusFour); + scan(node.getCondition(), null); + if (node.getDetail() != null) { + builder.breakOp(" "); + token(":"); + builder.space(); + scan(node.getDetail(), null); + } + builder.close(); + builder.close(); + token(";"); + return null; + } + + @Override + public Void visitAssignment(AssignmentTree node, Void unused) { + sync(node); + builder.open(plusFour); + scan(node.getVariable(), null); + builder.space(); + splitToken(operatorName(node)); + builder.breakOp(" "); + scan(node.getExpression(), null); + builder.close(); + return null; + } + + @Override + public Void visitBlock(BlockTree node, Void unused) { + visitBlock(node, CollapseEmptyOrNot.NO, AllowLeadingBlankLine.NO, AllowTrailingBlankLine.NO); + return null; + } + + @Override + public Void visitCompoundAssignment(CompoundAssignmentTree node, Void unused) { + sync(node); + builder.open(plusFour); + scan(node.getVariable(), null); + builder.space(); + splitToken(operatorName(node)); + builder.breakOp(" "); + scan(node.getExpression(), null); + builder.close(); + return null; + } + + @Override + public Void visitBreak(BreakTree node, Void unused) { + sync(node); + builder.open(plusFour); + token("break"); + if (node.getLabel() != null) { + builder.breakOp(" "); + visit(node.getLabel()); + } + builder.close(); + token(";"); + return null; + } + + @Override + public Void visitTypeCast(TypeCastTree node, Void unused) { + sync(node); + builder.open(plusFour); + token("("); + scan(node.getType(), null); + token(")"); + builder.breakOp(" "); + scan(node.getExpression(), null); + builder.close(); + return null; + } + + @Override + public Void visitNewClass(NewClassTree node, Void unused) { + sync(node); + builder.open(ZERO); + if (node.getEnclosingExpression() != null) { + scan(node.getEnclosingExpression(), null); + builder.breakOp(); + token("."); + } + token("new"); + builder.space(); + addTypeArguments(node.getTypeArguments(), plusFour); + if (node.getClassBody() != null) { + List annotations = + visitModifiers( + node.getClassBody().getModifiers(), Direction.HORIZONTAL, Optional.empty()); + visitAnnotations(annotations, BreakOrNot.NO, BreakOrNot.YES); + } + scan(node.getIdentifier(), null); + addArguments(node.getArguments(), plusFour); + builder.close(); + if (node.getClassBody() != null) { + addBodyDeclarations( + node.getClassBody().getMembers(), BracesOrNot.YES, FirstDeclarationsOrNot.YES); + } + return null; + } + + @Override + public Void visitConditionalExpression(ConditionalExpressionTree node, Void unused) { + sync(node); + builder.open(plusFour); + scan(node.getCondition(), null); + builder.breakOp(" "); + token("?"); + builder.space(); + scan(node.getTrueExpression(), null); + builder.breakOp(" "); + token(":"); + builder.space(); + scan(node.getFalseExpression(), null); + builder.close(); + return null; + } + + @Override + public Void visitContinue(ContinueTree node, Void unused) { + sync(node); + builder.open(plusFour); + token("continue"); + if (node.getLabel() != null) { + builder.breakOp(" "); + visit(node.getLabel()); + } + token(";"); + builder.close(); + return null; + } + + @Override + public Void visitDoWhileLoop(DoWhileLoopTree node, Void unused) { + sync(node); + token("do"); + visitStatement( + node.getStatement(), + CollapseEmptyOrNot.YES, + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.YES); + if (node.getStatement().getKind() == BLOCK) { + builder.space(); + } else { + builder.breakOp(" "); + } + token("while"); + builder.space(); + token("("); + scan(skipParen(node.getCondition()), null); + token(")"); + token(";"); + return null; + } + + @Override + public Void visitEmptyStatement(EmptyStatementTree node, Void unused) { + sync(node); + dropEmptyDeclarations(); + return null; + } + + @Override + public Void visitEnhancedForLoop(EnhancedForLoopTree node, Void unused) { + sync(node); + builder.open(ZERO); + token("for"); + builder.space(); + token("("); + builder.open(ZERO); + visitToDeclare( + DeclarationKind.NONE, + Direction.HORIZONTAL, + node.getVariable(), + Optional.of(node.getExpression()), + ":", + /* trailing= */ Optional.empty()); + builder.close(); + token(")"); + builder.close(); + visitStatement( + node.getStatement(), + CollapseEmptyOrNot.YES, + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.NO); + return null; + } + + private void visitEnumConstantDeclaration(VariableTree enumConstant) { + for (AnnotationTree annotation : enumConstant.getModifiers().getAnnotations()) { + scan(annotation, null); + builder.forcedBreak(); + } + visit(enumConstant.getName()); + NewClassTree init = ((NewClassTree) enumConstant.getInitializer()); + if (init.getArguments().isEmpty()) { + builder.guessToken("("); + builder.guessToken(")"); + } else { + addArguments(init.getArguments(), plusFour); + } + if (init.getClassBody() != null) { + addBodyDeclarations( + init.getClassBody().getMembers(), BracesOrNot.YES, FirstDeclarationsOrNot.YES); + } + } + + public boolean visitEnumDeclaration(ClassTree node) { + sync(node); + builder.open(ZERO); + typeDeclarationModifiers(node.getModifiers()); + builder.open(plusFour); + token("enum"); + builder.breakOp(" "); + visit(node.getSimpleName()); + builder.close(); + builder.close(); + if (!node.getImplementsClause().isEmpty()) { + builder.open(plusFour); + builder.breakOp(" "); + builder.open(plusFour); + token("implements"); + builder.breakOp(" "); + builder.open(ZERO); + boolean first = true; + for (Tree superInterfaceType : node.getImplementsClause()) { + if (!first) { + token(","); + builder.breakToFill(" "); + } + scan(superInterfaceType, null); + first = false; + } + builder.close(); + builder.close(); + builder.close(); + } + builder.space(); + tokenBreakTrailingComment("{", plusTwo); + ArrayList enumConstants = new ArrayList<>(); + ArrayList members = new ArrayList<>(); + for (Tree member : node.getMembers()) { + if (member instanceof JCTree.JCVariableDecl) { + JCTree.JCVariableDecl variableDecl = (JCTree.JCVariableDecl) member; + if ((variableDecl.mods.flags & Flags.ENUM) == Flags.ENUM) { + enumConstants.add(variableDecl); + continue; + } + } + members.add(member); + } + if (enumConstants.isEmpty() && members.isEmpty()) { + if (builder.peekToken().equals(Optional.of(";"))) { + builder.open(plusTwo); + builder.forcedBreak(); + token(";"); + builder.forcedBreak(); + dropEmptyDeclarations(); + builder.close(); + builder.open(ZERO); + builder.forcedBreak(); + builder.blankLineWanted(BlankLineWanted.NO); + token("}", plusTwo); + builder.close(); + } else { + builder.open(ZERO); + builder.blankLineWanted(BlankLineWanted.NO); + token("}"); + builder.close(); + } + } else { + builder.open(plusTwo); + builder.blankLineWanted(BlankLineWanted.NO); + builder.forcedBreak(); + builder.open(ZERO); + boolean first = true; + for (VariableTree enumConstant : enumConstants) { + if (!first) { + token(","); + builder.forcedBreak(); + builder.blankLineWanted(BlankLineWanted.PRESERVE); + } + markForPartialFormat(); + visitEnumConstantDeclaration(enumConstant); + first = false; + } + if (builder.peekToken().orElse("").equals(",")) { + token(","); + builder.forcedBreak(); // The ";" goes on its own line. + } + builder.close(); + builder.close(); + if (builder.peekToken().equals(Optional.of(";"))) { + builder.open(plusTwo); + token(";"); + builder.forcedBreak(); + dropEmptyDeclarations(); + builder.close(); + } + builder.open(ZERO); + addBodyDeclarations(members, BracesOrNot.NO, FirstDeclarationsOrNot.NO); + builder.forcedBreak(); + builder.blankLineWanted(BlankLineWanted.NO); + token("}", plusTwo); + builder.close(); + } + builder.guessToken(";"); + return false; + } + + @Override + public Void visitMemberReference(MemberReferenceTree node, Void unused) { + sync(node); + builder.open(plusFour); + scan(node.getQualifierExpression(), null); + builder.breakOp(); + builder.op("::"); + addTypeArguments(node.getTypeArguments(), plusFour); + switch (node.getMode()) { + case INVOKE: + visit(node.getName()); + break; + case NEW: + token("new"); + break; + default: + throw new AssertionError(node.getMode()); + } + builder.close(); + return null; + } + + @Override + public Void visitExpressionStatement(ExpressionStatementTree node, Void unused) { + sync(node); + scan(node.getExpression(), null); + token(";"); + return null; + } + + @Override + public Void visitVariable(VariableTree node, Void unused) { + sync(node); + visitVariables( + ImmutableList.of(node), + DeclarationKind.NONE, + fieldAnnotationDirection(node.getModifiers())); + return null; + } + + void visitVariables( + List fragments, + DeclarationKind declarationKind, + Direction annotationDirection) { + if (fragments.size() == 1) { + VariableTree fragment = fragments.get(0); + declareOne( + declarationKind, + annotationDirection, + Optional.of(fragment.getModifiers()), + fragment.getType(), + /* name= */ fragment.getName(), + "", + "=", + Optional.ofNullable(fragment.getInitializer()), + Optional.of(";"), + /* receiverExpression= */ Optional.empty(), + Optional.ofNullable(variableFragmentDims(true, 0, fragment.getType()))); + + } else { + declareMany(fragments, annotationDirection); + } + } + + private static TypeWithDims variableFragmentDims(boolean first, int leadingDims, Tree type) { + if (type == null) { + return null; + } + if (first) { + return DimensionHelpers.extractDims(type, SortedDims.YES); + } + TypeWithDims dims = DimensionHelpers.extractDims(type, SortedDims.NO); + return new TypeWithDims( + null, leadingDims > 0 ? dims.dims.subList(0, dims.dims.size() - leadingDims) : dims.dims); + } + + @Override + public Void visitForLoop(ForLoopTree node, Void unused) { + sync(node); + token("for"); + builder.space(); + token("("); + builder.open(plusFour); + builder.open( + node.getInitializer().size() > 1 + && node.getInitializer().get(0).getKind() == Tree.Kind.EXPRESSION_STATEMENT + ? plusFour + : ZERO); + if (!node.getInitializer().isEmpty()) { + if (node.getInitializer().get(0).getKind() == VARIABLE) { + PeekingIterator it = + Iterators.peekingIterator(node.getInitializer().iterator()); + visitVariables( + variableFragments(it, it.next()), DeclarationKind.NONE, Direction.HORIZONTAL); + } else { + boolean first = true; + builder.open(ZERO); + for (StatementTree t : node.getInitializer()) { + if (!first) { + token(","); + builder.breakOp(" "); + } + scan(((ExpressionStatementTree) t).getExpression(), null); + first = false; + } + token(";"); + builder.close(); + } + } else { + token(";"); + } + builder.close(); + builder.breakOp(" "); + if (node.getCondition() != null) { + scan(node.getCondition(), null); + } + token(";"); + if (!node.getUpdate().isEmpty()) { + builder.breakOp(" "); + builder.open(node.getUpdate().size() <= 1 ? ZERO : plusFour); + boolean firstUpdater = true; + for (ExpressionStatementTree updater : node.getUpdate()) { + if (!firstUpdater) { + token(","); + builder.breakToFill(" "); + } + scan(updater.getExpression(), null); + firstUpdater = false; + } + builder.guessToken(";"); + builder.close(); + } else { + builder.space(); + } + builder.close(); + token(")"); + visitStatement( + node.getStatement(), + CollapseEmptyOrNot.YES, + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.NO); + return null; + } + + @Override + public Void visitIf(IfTree node, Void unused) { + sync(node); + // Collapse chains of else-ifs. + List expressions = new ArrayList<>(); + List statements = new ArrayList<>(); + while (true) { + expressions.add(node.getCondition()); + statements.add(node.getThenStatement()); + if (node.getElseStatement() != null && node.getElseStatement().getKind() == IF) { + node = (IfTree) node.getElseStatement(); + } else { + break; + } + } + builder.open(ZERO); + boolean first = true; + boolean followingBlock = false; + int expressionsN = expressions.size(); + for (int i = 0; i < expressionsN; i++) { + if (!first) { + if (followingBlock) { + builder.space(); + } else { + builder.forcedBreak(); + } + token("else"); + builder.space(); + } + token("if"); + builder.space(); + token("("); + scan(skipParen(expressions.get(i)), null); + token(")"); + // An empty block can collapse to "{}" if there are no if/else or else clauses + boolean onlyClause = expressionsN == 1 && node.getElseStatement() == null; + // Trailing blank lines are permitted if this isn't the last clause + boolean trailingClauses = i < expressionsN - 1 || node.getElseStatement() != null; + visitStatement( + statements.get(i), + CollapseEmptyOrNot.valueOf(onlyClause), + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.valueOf(trailingClauses)); + followingBlock = statements.get(i).getKind() == BLOCK; + first = false; + } + if (node.getElseStatement() != null) { + if (followingBlock) { + builder.space(); + } else { + builder.forcedBreak(); + } + token("else"); + visitStatement( + node.getElseStatement(), + CollapseEmptyOrNot.NO, + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.NO); + } + builder.close(); + return null; + } + + @Override + public Void visitImport(ImportTree node, Void unused) { + checkForTypeAnnotation(node); + sync(node); + token("import"); + builder.space(); + if (node.isStatic()) { + token("static"); + builder.space(); + } + visitName(node.getQualifiedIdentifier()); + token(";"); + // TODO(cushon): remove this if https://bugs.openjdk.java.net/browse/JDK-8027682 is fixed + dropEmptyDeclarations(); + return null; + } + + private void checkForTypeAnnotation(ImportTree node) { + Name simpleName = getSimpleName(node); + Collection wellKnownAnnotations = TYPE_ANNOTATIONS.get(simpleName.toString()); + if (!wellKnownAnnotations.isEmpty() + && wellKnownAnnotations.contains(node.getQualifiedIdentifier().toString())) { + typeAnnotationSimpleNames.add(simpleName); + } + } + + private static Name getSimpleName(ImportTree importTree) { + return importTree.getQualifiedIdentifier() instanceof IdentifierTree + ? ((IdentifierTree) importTree.getQualifiedIdentifier()).getName() + : ((MemberSelectTree) importTree.getQualifiedIdentifier()).getIdentifier(); + } + + @Override + public Void visitBinary(BinaryTree node, Void unused) { + sync(node); + /* + * Collect together all operators with same precedence to clean up indentation. + */ + List operands = new ArrayList<>(); + List operators = new ArrayList<>(); + walkInfix(precedence(node), node, operands, operators); + FillMode fillMode = hasOnlyShortItems(operands) ? INDEPENDENT : UNIFIED; + builder.open(plusFour); + scan(operands.get(0), null); + int operatorsN = operators.size(); + for (int i = 0; i < operatorsN; i++) { + builder.breakOp(fillMode, " ", ZERO); + builder.op(operators.get(i)); + builder.space(); + scan(operands.get(i + 1), null); + } + builder.close(); + return null; + } + + @Override + public Void visitInstanceOf(InstanceOfTree node, Void unused) { + sync(node); + builder.open(plusFour); + scan(node.getExpression(), null); + builder.breakOp(" "); + builder.open(ZERO); + token("instanceof"); + builder.breakOp(" "); + scan(node.getType(), null); + builder.close(); + builder.close(); + return null; + } + + @Override + public Void visitIntersectionType(IntersectionTypeTree node, Void unused) { + sync(node); + builder.open(plusFour); + boolean first = true; + for (Tree type : node.getBounds()) { + if (!first) { + builder.breakToFill(" "); + token("&"); + builder.space(); + } + scan(type, null); + first = false; + } + builder.close(); + return null; + } + + @Override + public Void visitLabeledStatement(LabeledStatementTree node, Void unused) { + sync(node); + builder.open(ZERO); + visit(node.getLabel()); + token(":"); + builder.forcedBreak(); + builder.close(); + scan(node.getStatement(), null); + return null; + } + + @Override + public Void visitLambdaExpression(LambdaExpressionTree node, Void unused) { + sync(node); + boolean statementBody = node.getBodyKind() == LambdaExpressionTree.BodyKind.STATEMENT; + boolean parens = builder.peekToken().equals(Optional.of("(")); + builder.open(parens ? plusFour : ZERO); + if (parens) { + token("("); + } + boolean first = true; + for (VariableTree parameter : node.getParameters()) { + if (!first) { + token(","); + builder.breakOp(" "); + } + visitVariables( + ImmutableList.of(parameter), + DeclarationKind.NONE, + fieldAnnotationDirection(parameter.getModifiers())); + first = false; + } + if (parens) { + token(")"); + } + builder.close(); + builder.space(); + builder.op("->"); + builder.open(statementBody ? ZERO : plusFour); + if (statementBody) { + builder.space(); + } else { + builder.breakOp(" "); + } + if (node.getBody().getKind() == Tree.Kind.BLOCK) { + visitBlock( + (BlockTree) node.getBody(), + CollapseEmptyOrNot.YES, + AllowLeadingBlankLine.NO, + AllowTrailingBlankLine.NO); + } else { + scan(node.getBody(), null); + } + builder.close(); + return null; + } + + @Override + public Void visitAnnotation(AnnotationTree node, Void unused) { + sync(node); + + if (visitSingleMemberAnnotation(node)) { + return null; + } + + builder.open(ZERO); + token("@"); + scan(node.getAnnotationType(), null); + if (!node.getArguments().isEmpty()) { + builder.open(plusFour); + token("("); + builder.breakOp(); + boolean first = true; + + // Format the member value pairs one-per-line if any of them are + // initialized with arrays. + boolean hasArrayInitializer = + Iterables.any(node.getArguments(), JavaInputAstVisitor::isArrayValue); + for (ExpressionTree argument : node.getArguments()) { + if (!first) { + token(","); + if (hasArrayInitializer) { + builder.forcedBreak(); + } else { + builder.breakOp(" "); + } + } + if (argument instanceof AssignmentTree) { + visitAnnotationArgument((AssignmentTree) argument); + } else { + scan(argument, null); + } + first = false; + } + token(")"); + builder.close(); + builder.close(); + return null; + + } else if (builder.peekToken().equals(Optional.of("("))) { + token("("); + token(")"); + } + builder.close(); + return null; + } + + private static boolean isArrayValue(ExpressionTree argument) { + if (!(argument instanceof AssignmentTree)) { + return false; + } + ExpressionTree expression = ((AssignmentTree) argument).getExpression(); + return expression instanceof NewArrayTree && ((NewArrayTree) expression).getType() == null; + } + + public void visitAnnotationArgument(AssignmentTree node) { + boolean isArrayInitializer = node.getExpression().getKind() == NEW_ARRAY; + sync(node); + builder.open(isArrayInitializer ? ZERO : plusFour); + scan(node.getVariable(), null); + builder.space(); + token("="); + if (isArrayInitializer) { + builder.space(); + } else { + builder.breakOp(" "); + } + scan(node.getExpression(), null); + builder.close(); + } + + @Override + public Void visitAnnotatedType(AnnotatedTypeTree node, Void unused) { + sync(node); + ExpressionTree base = node.getUnderlyingType(); + if (base instanceof MemberSelectTree) { + MemberSelectTree selectTree = (MemberSelectTree) base; + scan(selectTree.getExpression(), null); + token("."); + visitAnnotations(node.getAnnotations(), BreakOrNot.NO, BreakOrNot.NO); + builder.breakToFill(" "); + visit(selectTree.getIdentifier()); + } else if (base instanceof ArrayTypeTree) { + visitAnnotatedArrayType(node); + } else { + visitAnnotations(node.getAnnotations(), BreakOrNot.NO, BreakOrNot.NO); + builder.breakToFill(" "); + scan(base, null); + } + return null; + } + + // TODO(cushon): Use Flags if/when we drop support for Java 11 + + protected static final long COMPACT_RECORD_CONSTRUCTOR = 1L << 51; + + protected static final long RECORD = 1L << 61; + + @Override + public Void visitMethod(MethodTree node, Void unused) { + sync(node); + List annotations = node.getModifiers().getAnnotations(); + List returnTypeAnnotations = ImmutableList.of(); + + boolean isRecordConstructor = + (((JCMethodDecl) node).mods.flags & COMPACT_RECORD_CONSTRUCTOR) + == COMPACT_RECORD_CONSTRUCTOR; + + if (!node.getTypeParameters().isEmpty() && !annotations.isEmpty()) { + int typeParameterStart = getStartPosition(node.getTypeParameters().get(0)); + for (int i = 0; i < annotations.size(); i++) { + if (getStartPosition(annotations.get(i)) > typeParameterStart) { + returnTypeAnnotations = annotations.subList(i, annotations.size()); + annotations = annotations.subList(0, i); + break; + } + } + } + List typeAnnotations = + visitModifiers( + node.getModifiers(), + annotations, + Direction.VERTICAL, + /* declarationAnnotationBreak= */ Optional.empty()); + + Tree baseReturnType = null; + Deque> dims = null; + if (node.getReturnType() != null) { + TypeWithDims extractedDims = + DimensionHelpers.extractDims(node.getReturnType(), SortedDims.YES); + baseReturnType = extractedDims.node; + dims = new ArrayDeque<>(extractedDims.dims); + } else { + verticalAnnotations(typeAnnotations); + typeAnnotations = ImmutableList.of(); + } + + builder.open(plusFour); + BreakTag breakBeforeName = genSym(); + BreakTag breakBeforeType = genSym(); + builder.open(ZERO); + { + boolean first = true; + if (!typeAnnotations.isEmpty()) { + visitAnnotations(typeAnnotations, BreakOrNot.NO, BreakOrNot.NO); + first = false; + } + if (!node.getTypeParameters().isEmpty()) { + if (!first) { + builder.breakToFill(" "); + } + token("<"); + typeParametersRest(node.getTypeParameters(), plusFour); + if (!returnTypeAnnotations.isEmpty()) { + builder.breakToFill(" "); + visitAnnotations(returnTypeAnnotations, BreakOrNot.NO, BreakOrNot.NO); + } + first = false; + } + + boolean openedNameAndTypeScope = false; + // constructor-like declarations that don't match the name of the enclosing class are + // parsed as method declarations with a null return type + if (baseReturnType != null) { + if (!first) { + builder.breakOp(INDEPENDENT, " ", ZERO, Optional.of(breakBeforeType)); + } else { + first = false; + } + if (!openedNameAndTypeScope) { + builder.open(make(breakBeforeType, plusFour, ZERO)); + openedNameAndTypeScope = true; + } + scan(baseReturnType, null); + maybeAddDims(dims); + } + if (!first) { + builder.breakOp(Doc.FillMode.INDEPENDENT, " ", ZERO, Optional.of(breakBeforeName)); + } else { + first = false; + } + if (!openedNameAndTypeScope) { + builder.open(ZERO); + openedNameAndTypeScope = true; + } + String name = node.getName().toString(); + if (name.equals("")) { + name = builder.peekToken().get(); + } + token(name); + if (!isRecordConstructor) { + token("("); + } + // end of name and type scope + builder.close(); + } + builder.close(); + + builder.open(Indent.If.make(breakBeforeName, plusFour, ZERO)); + builder.open(Indent.If.make(breakBeforeType, plusFour, ZERO)); + builder.open(ZERO); + { + if (!isRecordConstructor) { + if (!node.getParameters().isEmpty() || node.getReceiverParameter() != null) { + // Break before args. + builder.breakToFill(""); + visitFormals(Optional.ofNullable(node.getReceiverParameter()), node.getParameters()); + } + token(")"); + } + if (dims != null) { + maybeAddDims(dims); + } + if (!node.getThrows().isEmpty()) { + builder.breakToFill(" "); + builder.open(plusFour); + { + visitThrowsClause(node.getThrows()); + } + builder.close(); + } + if (node.getDefaultValue() != null) { + builder.space(); + token("default"); + if (node.getDefaultValue().getKind() == Tree.Kind.NEW_ARRAY) { + builder.open(minusFour); + { + builder.space(); + scan(node.getDefaultValue(), null); + } + builder.close(); + } else { + builder.open(ZERO); + { + builder.breakToFill(" "); + scan(node.getDefaultValue(), null); + } + builder.close(); + } + } + } + builder.close(); + builder.close(); + builder.close(); + if (node.getBody() == null) { + token(";"); + } else { + builder.space(); + builder.token("{", Doc.Token.RealOrImaginary.REAL, plusTwo, Optional.of(plusTwo)); + } + builder.close(); + + if (node.getBody() != null) { + methodBody(node); + } + + return null; + } + + private void methodBody(MethodTree node) { + if (node.getBody().getStatements().isEmpty()) { + builder.blankLineWanted(BlankLineWanted.NO); + } else { + builder.open(plusTwo); + builder.forcedBreak(); + builder.blankLineWanted(BlankLineWanted.PRESERVE); + visitStatements(node.getBody().getStatements()); + builder.close(); + builder.forcedBreak(); + builder.blankLineWanted(BlankLineWanted.NO); + markForPartialFormat(); + } + token("}", plusTwo); + } + + @Override + public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { + sync(node); + if (handleLogStatement(node)) { + return null; + } + visitDot(node); + return null; + } + + /** + * Special-cases log statements, to output: + * + *

{@code
+   * logger.atInfo().log(
+   *     "Number of foos: %d, foos.size());
+   * }
+ * + *

Instead of: + * + *

{@code
+   * logger
+   *     .atInfo()
+   *     .log(
+   *         "Number of foos: %d, foos.size());
+   * }
+ */ + private boolean handleLogStatement(MethodInvocationTree node) { + if (!getMethodName(node).contentEquals("log")) { + return false; + } + Deque parts = new ArrayDeque<>(); + ExpressionTree curr = node; + while (curr instanceof MethodInvocationTree) { + MethodInvocationTree method = (MethodInvocationTree) curr; + parts.addFirst(method); + if (!LOG_METHODS.contains(getMethodName(method).toString())) { + return false; + } + curr = Trees.getMethodReceiver(method); + } + if (!(curr instanceof IdentifierTree)) { + return false; + } + parts.addFirst(curr); + visitDotWithPrefix( + ImmutableList.copyOf(parts), false, ImmutableList.of(parts.size() - 1), INDEPENDENT); + return true; + } + + static final ImmutableSet LOG_METHODS = + ImmutableSet.of( + "at", + "atConfig", + "atDebug", + "atFine", + "atFiner", + "atFinest", + "atInfo", + "atMostEvery", + "atSevere", + "atWarning", + "every", + "log", + "logVarargs", + "perUnique", + "withCause", + "withStackTrace"); + + private static List handleStream(List parts) { + return indexes( + parts.stream(), + p -> { + if (!(p instanceof MethodInvocationTree)) { + return false; + } + Name name = getMethodName((MethodInvocationTree) p); + return Stream.of("stream", "parallelStream", "toBuilder") + .anyMatch(name::contentEquals); + }) + .collect(toList()); + } + + private static Stream indexes(Stream stream, Predicate predicate) { + return Streams.mapWithIndex(stream, (x, i) -> predicate.apply(x) ? i : -1).filter(x -> x != -1); + } + + @Override + public Void visitMemberSelect(MemberSelectTree node, Void unused) { + sync(node); + visitDot(node); + return null; + } + + @Override + public Void visitLiteral(LiteralTree node, Void unused) { + sync(node); + String sourceForNode = getSourceForNode(node, getCurrentPath()); + if (isUnaryMinusLiteral(sourceForNode)) { + token("-"); + sourceForNode = sourceForNode.substring(1).trim(); + } + token(sourceForNode); + return null; + } + + // A negative numeric literal -n is usually represented as unary minus on n, + // but that doesn't work for integer or long MIN_VALUE. The parser works + // around that by representing it directly as a signed literal (with no + // unary minus), but the lexer still expects two tokens. + private static boolean isUnaryMinusLiteral(String literalTreeSource) { + return literalTreeSource.startsWith("-"); + } + + private void visitPackage( + ExpressionTree packageName, List packageAnnotations) { + if (!packageAnnotations.isEmpty()) { + for (AnnotationTree annotation : packageAnnotations) { + builder.forcedBreak(); + scan(annotation, null); + } + builder.forcedBreak(); + } + builder.open(plusFour); + token("package"); + builder.space(); + visitName(packageName); + builder.close(); + token(";"); + } + + @Override + public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) { + sync(node); + if (node.getTypeArguments().isEmpty()) { + scan(node.getType(), null); + token("<"); + token(">"); + } else { + builder.open(plusFour); + scan(node.getType(), null); + token("<"); + builder.breakOp(); + builder.open(ZERO); + boolean first = true; + for (Tree typeArgument : node.getTypeArguments()) { + if (!first) { + token(","); + builder.breakOp(" "); + } + scan(typeArgument, null); + first = false; + } + builder.close(); + builder.close(); + token(">"); + } + return null; + } + + @Override + public Void visitParenthesized(ParenthesizedTree node, Void unused) { + token("("); + scan(node.getExpression(), null); + token(")"); + return null; + } + + @Override + public Void visitUnary(UnaryTree node, Void unused) { + sync(node); + String operatorName = operatorName(node); + if (((JCTree) node).getTag().isPostUnaryOp()) { + scan(node.getExpression(), null); + splitToken(operatorName); + } else { + splitToken(operatorName); + if (ambiguousUnaryOperator(node, operatorName)) { + builder.space(); + } + scan(node.getExpression(), null); + } + return null; + } + + private void splitToken(String operatorName) { + for (int i = 0; i < operatorName.length(); i++) { + token(String.valueOf(operatorName.charAt(i))); + } + } + + private boolean ambiguousUnaryOperator(UnaryTree node, String operatorName) { + switch (node.getKind()) { + case UNARY_MINUS: + case UNARY_PLUS: + break; + default: + return false; + } + JCTree.Tag tag = unaryTag(node.getExpression()); + if (tag == null) { + return false; + } + if (tag.isPostUnaryOp()) { + return false; + } + if (!operatorName(node).startsWith(operatorName)) { + return false; + } + return true; + } + + private JCTree.Tag unaryTag(ExpressionTree expression) { + if (expression instanceof UnaryTree) { + return ((JCTree) expression).getTag(); + } + if (expression instanceof LiteralTree + && isUnaryMinusLiteral(getSourceForNode(expression, getCurrentPath()))) { + return JCTree.Tag.MINUS; + } + return null; + } + + @Override + public Void visitPrimitiveType(PrimitiveTypeTree node, Void unused) { + sync(node); + switch (node.getPrimitiveTypeKind()) { + case BOOLEAN: + token("boolean"); + break; + case BYTE: + token("byte"); + break; + case SHORT: + token("short"); + break; + case INT: + token("int"); + break; + case LONG: + token("long"); + break; + case CHAR: + token("char"); + break; + case FLOAT: + token("float"); + break; + case DOUBLE: + token("double"); + break; + case VOID: + token("void"); + break; + default: + throw new AssertionError(node.getPrimitiveTypeKind()); + } + return null; + } + + public boolean visit(Name name) { + token(name.toString()); + return false; + } + + @Override + public Void visitReturn(ReturnTree node, Void unused) { + sync(node); + token("return"); + if (node.getExpression() != null) { + builder.space(); + scan(node.getExpression(), null); + } + token(";"); + return null; + } + + // TODO(cushon): is this worth special-casing? + boolean visitSingleMemberAnnotation(AnnotationTree node) { + if (node.getArguments().size() != 1) { + return false; + } + ExpressionTree value = getOnlyElement(node.getArguments()); + if (value.getKind() == ASSIGNMENT) { + return false; + } + boolean isArrayInitializer = value.getKind() == NEW_ARRAY; + builder.open(isArrayInitializer ? ZERO : plusFour); + token("@"); + scan(node.getAnnotationType(), null); + token("("); + if (!isArrayInitializer) { + builder.breakOp(); + } + scan(value, null); + builder.close(); + token(")"); + return true; + } + + @Override + public Void visitCase(CaseTree node, Void unused) { + sync(node); + markForPartialFormat(); + builder.forcedBreak(); + if (node.getExpression() == null) { + token("default", plusTwo); + token(":"); + } else { + token("case", plusTwo); + builder.space(); + scan(node.getExpression(), null); + token(":"); + } + builder.open(plusTwo); + visitStatements(node.getStatements()); + builder.close(); + return null; + } + + @Override + public Void visitSwitch(SwitchTree node, Void unused) { + sync(node); + visitSwitch(node.getExpression(), node.getCases()); + return null; + } + + protected void visitSwitch(ExpressionTree expression, List cases) { + token("switch"); + builder.space(); + token("("); + scan(skipParen(expression), null); + token(")"); + builder.space(); + tokenBreakTrailingComment("{", plusTwo); + builder.blankLineWanted(BlankLineWanted.NO); + builder.open(plusTwo); + boolean first = true; + for (CaseTree caseTree : cases) { + if (!first) { + builder.blankLineWanted(BlankLineWanted.PRESERVE); + } + scan(caseTree, null); + first = false; + } + builder.close(); + builder.forcedBreak(); + builder.blankLineWanted(BlankLineWanted.NO); + token("}", plusFour); + } + + @Override + public Void visitSynchronized(SynchronizedTree node, Void unused) { + sync(node); + token("synchronized"); + builder.space(); + token("("); + builder.open(plusFour); + builder.breakOp(); + scan(skipParen(node.getExpression()), null); + builder.close(); + token(")"); + builder.space(); + scan(node.getBlock(), null); + return null; + } + + @Override + public Void visitThrow(ThrowTree node, Void unused) { + sync(node); + token("throw"); + builder.space(); + scan(node.getExpression(), null); + token(";"); + return null; + } + + @Override + public Void visitTry(TryTree node, Void unused) { + sync(node); + builder.open(ZERO); + token("try"); + builder.space(); + if (!node.getResources().isEmpty()) { + token("("); + builder.open(node.getResources().size() > 1 ? plusFour : ZERO); + boolean first = true; + for (Tree resource : node.getResources()) { + if (!first) { + builder.forcedBreak(); + } + if (resource instanceof VariableTree) { + VariableTree variableTree = (VariableTree) resource; + declareOne( + DeclarationKind.PARAMETER, + fieldAnnotationDirection(variableTree.getModifiers()), + Optional.of(variableTree.getModifiers()), + variableTree.getType(), + /* name= */ variableTree.getName(), + "", + "=", + Optional.ofNullable(variableTree.getInitializer()), + /* trailing= */ Optional.empty(), + /* receiverExpression= */ Optional.empty(), + /* typeWithDims= */ Optional.empty()); + } else { + // TODO(cushon): think harder about what to do with `try (resource1; resource2) {}` + scan(resource, null); + } + if (builder.peekToken().equals(Optional.of(";"))) { + token(";"); + builder.space(); + } + first = false; + } + if (builder.peekToken().equals(Optional.of(";"))) { + token(";"); + builder.space(); + } + token(")"); + builder.close(); + builder.space(); + } + // An empty try-with-resources body can collapse to "{}" if there are no trailing catch or + // finally blocks. + boolean trailingClauses = !node.getCatches().isEmpty() || node.getFinallyBlock() != null; + visitBlock( + node.getBlock(), + CollapseEmptyOrNot.valueOf(!trailingClauses), + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.valueOf(trailingClauses)); + for (int i = 0; i < node.getCatches().size(); i++) { + CatchTree catchClause = node.getCatches().get(i); + trailingClauses = i < node.getCatches().size() - 1 || node.getFinallyBlock() != null; + visitCatchClause(catchClause, AllowTrailingBlankLine.valueOf(trailingClauses)); + } + if (node.getFinallyBlock() != null) { + builder.space(); + token("finally"); + builder.space(); + visitBlock( + node.getFinallyBlock(), + CollapseEmptyOrNot.NO, + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.NO); + } + builder.close(); + return null; + } + + public void visitClassDeclaration(ClassTree node) { + sync(node); + typeDeclarationModifiers(node.getModifiers()); + List permitsTypes = getPermitsClause(node); + boolean hasSuperclassType = node.getExtendsClause() != null; + boolean hasSuperInterfaceTypes = !node.getImplementsClause().isEmpty(); + boolean hasPermitsTypes = !permitsTypes.isEmpty(); + token(node.getKind() == Tree.Kind.INTERFACE ? "interface" : "class"); + builder.space(); + visit(node.getSimpleName()); + if (!node.getTypeParameters().isEmpty()) { + token("<"); + } + builder.open(plusFour); + { + if (!node.getTypeParameters().isEmpty()) { + typeParametersRest( + node.getTypeParameters(), + hasSuperclassType || hasSuperInterfaceTypes || hasPermitsTypes ? plusFour : ZERO); + } + if (hasSuperclassType) { + builder.breakToFill(" "); + token("extends"); + builder.space(); + scan(node.getExtendsClause(), null); + } + classDeclarationTypeList( + node.getKind() == Tree.Kind.INTERFACE ? "extends" : "implements", + node.getImplementsClause()); + classDeclarationTypeList("permits", permitsTypes); + } + builder.close(); + if (node.getMembers() == null) { + token(";"); + } else { + addBodyDeclarations(node.getMembers(), BracesOrNot.YES, FirstDeclarationsOrNot.YES); + } + dropEmptyDeclarations(); + } + + @Override + public Void visitTypeParameter(TypeParameterTree node, Void unused) { + sync(node); + builder.open(ZERO); + visitAnnotations(node.getAnnotations(), BreakOrNot.NO, BreakOrNot.YES); + visit(node.getName()); + if (!node.getBounds().isEmpty()) { + builder.space(); + token("extends"); + builder.open(plusFour); + builder.breakOp(" "); + builder.open(plusFour); + boolean first = true; + for (Tree typeBound : node.getBounds()) { + if (!first) { + builder.breakToFill(" "); + token("&"); + builder.space(); + } + scan(typeBound, null); + first = false; + } + builder.close(); + builder.close(); + } + builder.close(); + return null; + } + + @Override + public Void visitUnionType(UnionTypeTree node, Void unused) { + throw new IllegalStateException("expected manual descent into union types"); + } + + @Override + public Void visitWhileLoop(WhileLoopTree node, Void unused) { + sync(node); + token("while"); + builder.space(); + token("("); + scan(skipParen(node.getCondition()), null); + token(")"); + visitStatement( + node.getStatement(), + CollapseEmptyOrNot.YES, + AllowLeadingBlankLine.YES, + AllowTrailingBlankLine.NO); + return null; + } + + @Override + public Void visitWildcard(WildcardTree node, Void unused) { + sync(node); + builder.open(ZERO); + token("?"); + if (node.getBound() != null) { + builder.open(plusFour); + builder.space(); + token(node.getKind() == EXTENDS_WILDCARD ? "extends" : "super"); + builder.breakOp(" "); + scan(node.getBound(), null); + builder.close(); + } + builder.close(); + return null; + } + + // Helper methods. + + /** Helper method for annotations. */ + protected void visitAnnotations( + List annotations, BreakOrNot breakBefore, BreakOrNot breakAfter) { + if (!annotations.isEmpty()) { + if (breakBefore.isYes()) { + builder.breakToFill(" "); + } + boolean first = true; + for (AnnotationTree annotation : annotations) { + if (!first) { + builder.breakToFill(" "); + } + scan(annotation, null); + first = false; + } + if (breakAfter.isYes()) { + builder.breakToFill(" "); + } + } + } + + void verticalAnnotations(List annotations) { + for (AnnotationTree annotation : annotations) { + builder.forcedBreak(); + scan(annotation, null); + builder.forcedBreak(); + } + } + + /** Helper method for blocks. */ + protected void visitBlock( + BlockTree node, + CollapseEmptyOrNot collapseEmptyOrNot, + AllowLeadingBlankLine allowLeadingBlankLine, + AllowTrailingBlankLine allowTrailingBlankLine) { + sync(node); + if (node.isStatic()) { + token("static"); + builder.space(); + } + if (collapseEmptyOrNot.isYes() && node.getStatements().isEmpty()) { + if (builder.peekToken().equals(Optional.of(";"))) { + // TODO(cushon): is this needed? + token(";"); + } else { + tokenBreakTrailingComment("{", plusTwo); + builder.blankLineWanted(BlankLineWanted.NO); + token("}", plusTwo); + } + } else { + builder.open(ZERO); + builder.open(plusTwo); + tokenBreakTrailingComment("{", plusTwo); + if (allowLeadingBlankLine == AllowLeadingBlankLine.NO) { + builder.blankLineWanted(BlankLineWanted.NO); + } else { + builder.blankLineWanted(BlankLineWanted.PRESERVE); + } + visitStatements(node.getStatements()); + builder.close(); + builder.forcedBreak(); + builder.close(); + if (allowTrailingBlankLine == AllowTrailingBlankLine.NO) { + builder.blankLineWanted(BlankLineWanted.NO); + } else { + builder.blankLineWanted(BlankLineWanted.PRESERVE); + } + markForPartialFormat(); + token("}", plusTwo); + } + } + + /** Helper method for statements. */ + private void visitStatement( + StatementTree node, + CollapseEmptyOrNot collapseEmptyOrNot, + AllowLeadingBlankLine allowLeadingBlank, + AllowTrailingBlankLine allowTrailingBlank) { + sync(node); + switch (node.getKind()) { + case BLOCK: + builder.space(); + visitBlock((BlockTree) node, collapseEmptyOrNot, allowLeadingBlank, allowTrailingBlank); + break; + default: + builder.open(plusTwo); + builder.breakOp(" "); + scan(node, null); + builder.close(); + } + } + + protected void visitStatements(List statements) { + boolean first = true; + PeekingIterator it = Iterators.peekingIterator(statements.iterator()); + dropEmptyDeclarations(); + while (it.hasNext()) { + StatementTree tree = it.next(); + builder.forcedBreak(); + if (!first) { + builder.blankLineWanted(BlankLineWanted.PRESERVE); + } + markForPartialFormat(); + first = false; + List fragments = variableFragments(it, tree); + if (!fragments.isEmpty()) { + visitVariables( + fragments, + DeclarationKind.NONE, + canLocalHaveHorizontalAnnotations(fragments.get(0).getModifiers())); + } else { + scan(tree, null); + } + } + } + + protected void typeDeclarationModifiers(ModifiersTree modifiers) { + List typeAnnotations = + visitModifiers( + modifiers, Direction.VERTICAL, /* declarationAnnotationBreak= */ Optional.empty()); + verticalAnnotations(typeAnnotations); + } + + /** Output combined modifiers and annotations and the trailing break. */ + void visitAndBreakModifiers( + ModifiersTree modifiers, + Direction annotationDirection, + Optional declarationAnnotationBreak) { + List typeAnnotations = + visitModifiers(modifiers, annotationDirection, declarationAnnotationBreak); + visitAnnotations(typeAnnotations, BreakOrNot.NO, BreakOrNot.YES); + } + + @Override + public Void visitModifiers(ModifiersTree node, Void unused) { + throw new IllegalStateException("expected manual descent into modifiers"); + } + + /** Output combined modifiers and annotations and returns the trailing break. */ + @CheckReturnValue + protected ImmutableList visitModifiers( + ModifiersTree modifiersTree, + Direction annotationsDirection, + Optional declarationAnnotationBreak) { + return visitModifiers( + modifiersTree, + modifiersTree.getAnnotations(), + annotationsDirection, + declarationAnnotationBreak); + } + + @CheckReturnValue + protected ImmutableList visitModifiers( + ModifiersTree modifiersTree, + List annotationTrees, + Direction annotationsDirection, + Optional declarationAnnotationBreak) { + DeclarationModifiersAndTypeAnnotations splitModifiers = + splitModifiers(modifiersTree, annotationTrees); + return visitModifiers(splitModifiers, annotationsDirection, declarationAnnotationBreak); + } + + @CheckReturnValue + private ImmutableList visitModifiers( + DeclarationModifiersAndTypeAnnotations splitModifiers, + Direction annotationsDirection, + Optional declarationAnnotationBreak) { + if (splitModifiers.declarationModifiers().isEmpty()) { + return splitModifiers.typeAnnotations(); + } + Deque declarationModifiers = + new ArrayDeque<>(splitModifiers.declarationModifiers()); + builder.open(ZERO); + boolean first = true; + boolean lastWasAnnotation = false; + while (!declarationModifiers.isEmpty() && !declarationModifiers.peekFirst().isModifier()) { + if (!first) { + builder.addAll( + annotationsDirection.isVertical() + ? forceBreakList(declarationAnnotationBreak) + : breakList(declarationAnnotationBreak)); + } + formatAnnotationOrModifier(declarationModifiers); + first = false; + lastWasAnnotation = true; + } + builder.close(); + ImmutableList trailingBreak = + annotationsDirection.isVertical() + ? forceBreakList(declarationAnnotationBreak) + : breakList(declarationAnnotationBreak); + if (declarationModifiers.isEmpty()) { + builder.addAll(trailingBreak); + return splitModifiers.typeAnnotations(); + } + if (lastWasAnnotation) { + builder.addAll(trailingBreak); + } + + builder.open(ZERO); + first = true; + while (!declarationModifiers.isEmpty()) { + if (!first) { + builder.addAll(breakFillList(Optional.empty())); + } + formatAnnotationOrModifier(declarationModifiers); + first = false; + } + builder.close(); + builder.addAll(breakFillList(Optional.empty())); + return splitModifiers.typeAnnotations(); + } + + /** Represents an annotation or a modifier in a {@link ModifiersTree}. */ + @AutoOneOf(AnnotationOrModifier.Kind.class) + abstract static class AnnotationOrModifier implements Comparable { + enum Kind { + MODIFIER, + ANNOTATION + } + + abstract Kind getKind(); + + abstract AnnotationTree annotation(); + + abstract Input.Tok modifier(); + + static AnnotationOrModifier ofModifier(Input.Tok m) { + return AutoOneOf_JavaInputAstVisitor_AnnotationOrModifier.modifier(m); + } + + static AnnotationOrModifier ofAnnotation(AnnotationTree a) { + return AutoOneOf_JavaInputAstVisitor_AnnotationOrModifier.annotation(a); + } + + boolean isModifier() { + return getKind().equals(Kind.MODIFIER); + } + + boolean isAnnotation() { + return getKind().equals(Kind.ANNOTATION); + } + + int position() { + switch (getKind()) { + case MODIFIER: + return modifier().getPosition(); + case ANNOTATION: + return getStartPosition(annotation()); + } + throw new AssertionError(); + } + + private static final Comparator COMPARATOR = + Comparator.comparingInt(AnnotationOrModifier::position); + + @Override + public int compareTo(AnnotationOrModifier o) { + return COMPARATOR.compare(this, o); + } + } + + /** + * The modifiers annotations for a declaration, grouped in to a prefix that contains all of the + * declaration annotations and modifiers, and a suffix of type annotations. + * + *

For examples like {@code @Deprecated public @Nullable Foo foo();}, this allows us to format + * {@code @Deprecated public} as declaration modifiers, and {@code @Nullable} as a type annotation + * on the return type. + */ + @AutoValue + abstract static class DeclarationModifiersAndTypeAnnotations { + abstract ImmutableList declarationModifiers(); + + abstract ImmutableList typeAnnotations(); + + static DeclarationModifiersAndTypeAnnotations create( + ImmutableList declarationModifiers, + ImmutableList typeAnnotations) { + return new AutoValue_JavaInputAstVisitor_DeclarationModifiersAndTypeAnnotations( + declarationModifiers, typeAnnotations); + } + + static DeclarationModifiersAndTypeAnnotations empty() { + return create(ImmutableList.of(), ImmutableList.of()); + } + + boolean hasDeclarationAnnotation() { + return declarationModifiers().stream().anyMatch(AnnotationOrModifier::isAnnotation); + } + } + + /** + * Examines the token stream to convert the modifiers for a declaration into a {@link + * DeclarationModifiersAndTypeAnnotations}. + */ + DeclarationModifiersAndTypeAnnotations splitModifiers( + ModifiersTree modifiersTree, List annotations) { + if (annotations.isEmpty() && !isModifier(builder.peekToken().get())) { + return DeclarationModifiersAndTypeAnnotations.empty(); + } + RangeSet annotationRanges = TreeRangeSet.create(); + for (AnnotationTree annotationTree : annotations) { + annotationRanges.add( + Range.closedOpen( + getStartPosition(annotationTree), getEndPosition(annotationTree, getCurrentPath()))); + } + ImmutableList toks = + builder.peekTokens( + getStartPosition(modifiersTree), + (Input.Tok tok) -> + // ModifiersTree end position information isn't reliable, so scan tokens as long as + // we're seeing annotations or modifiers + annotationRanges.contains(tok.getPosition()) || isModifier(tok.getText())); + ImmutableList modifiers = + ImmutableList.copyOf( + Streams.concat( + toks.stream() + // reject tokens from inside AnnotationTrees, we only want modifiers + .filter(t -> !annotationRanges.contains(t.getPosition())) + .map(AnnotationOrModifier::ofModifier), + annotations.stream().map(AnnotationOrModifier::ofAnnotation)) + .sorted() + .collect(toList())); + // Take a suffix of annotations that are well-known type annotations, and which appear after any + // declaration annotations or modifiers + ImmutableList.Builder typeAnnotations = ImmutableList.builder(); + int idx = modifiers.size() - 1; + while (idx >= 0) { + AnnotationOrModifier modifier = modifiers.get(idx); + if (!modifier.isAnnotation() || !isTypeAnnotation(modifier.annotation())) { + break; + } + typeAnnotations.add(modifier.annotation()); + idx--; + } + return DeclarationModifiersAndTypeAnnotations.create( + modifiers.subList(0, idx + 1), typeAnnotations.build().reverse()); + } + + private void formatAnnotationOrModifier(Deque modifiers) { + AnnotationOrModifier modifier = modifiers.removeFirst(); + switch (modifier.getKind()) { + case MODIFIER: + token(modifier.modifier().getText()); + if (modifier.modifier().getText().equals("non")) { + token(modifiers.removeFirst().modifier().getText()); + token(modifiers.removeFirst().modifier().getText()); + } + break; + case ANNOTATION: + scan(modifier.annotation(), null); + break; + } + } + + boolean isTypeAnnotation(AnnotationTree annotationTree) { + Tree annotationType = annotationTree.getAnnotationType(); + if (!(annotationType instanceof IdentifierTree)) { + return false; + } + return typeAnnotationSimpleNames.contains(((IdentifierTree) annotationType).getName()); + } + + private static boolean isModifier(String token) { + switch (token) { + case "public": + case "protected": + case "private": + case "abstract": + case "static": + case "final": + case "transient": + case "volatile": + case "synchronized": + case "native": + case "strictfp": + case "default": + case "sealed": + case "non": + case "-": + return true; + default: + return false; + } + } + + @Override + public Void visitCatch(CatchTree node, Void unused) { + throw new IllegalStateException("expected manual descent into catch trees"); + } + + /** Helper method for {@link CatchTree}s. */ + private void visitCatchClause(CatchTree node, AllowTrailingBlankLine allowTrailingBlankLine) { + sync(node); + builder.space(); + token("catch"); + builder.space(); + token("("); + builder.open(plusFour); + VariableTree ex = node.getParameter(); + if (ex.getType().getKind() == UNION_TYPE) { + builder.open(ZERO); + visitUnionType(ex); + builder.close(); + } else { + // TODO(cushon): don't break after here for consistency with for, while, etc. + builder.breakToFill(); + builder.open(ZERO); + scan(ex, null); + builder.close(); + } + builder.close(); + token(")"); + builder.space(); + visitBlock( + node.getBlock(), CollapseEmptyOrNot.NO, AllowLeadingBlankLine.YES, allowTrailingBlankLine); + } + + /** Formats a union type declaration in a catch clause. */ + private void visitUnionType(VariableTree declaration) { + UnionTypeTree type = (UnionTypeTree) declaration.getType(); + builder.open(ZERO); + sync(declaration); + visitAndBreakModifiers( + declaration.getModifiers(), + Direction.HORIZONTAL, + /* declarationAnnotationBreak= */ Optional.empty()); + List union = type.getTypeAlternatives(); + boolean first = true; + for (int i = 0; i < union.size() - 1; i++) { + if (!first) { + builder.breakOp(" "); + token("|"); + builder.space(); + } else { + first = false; + } + scan(union.get(i), null); + } + builder.breakOp(" "); + token("|"); + builder.space(); + Tree last = union.get(union.size() - 1); + declareOne( + DeclarationKind.NONE, + Direction.HORIZONTAL, + /* modifiers= */ Optional.empty(), + last, + /* name= */ declaration.getName(), + /* op= */ "", + "=", + Optional.ofNullable(declaration.getInitializer()), + /* trailing= */ Optional.empty(), + /* receiverExpression= */ Optional.empty(), + /* typeWithDims= */ Optional.empty()); + builder.close(); + } + + /** Accumulate the operands and operators. */ + private static void walkInfix( + int precedence, + ExpressionTree expression, + List operands, + List operators) { + if (expression instanceof BinaryTree) { + BinaryTree binaryTree = (BinaryTree) expression; + if (precedence(binaryTree) == precedence) { + walkInfix(precedence, binaryTree.getLeftOperand(), operands, operators); + operators.add(operatorName(expression)); + walkInfix(precedence, binaryTree.getRightOperand(), operands, operators); + } else { + operands.add(expression); + } + } else { + operands.add(expression); + } + } + + protected void visitFormals( + Optional receiver, List parameters) { + if (!receiver.isPresent() && parameters.isEmpty()) { + return; + } + builder.open(ZERO); + boolean first = true; + if (receiver.isPresent()) { + // TODO(user): Use builders. + declareOne( + DeclarationKind.PARAMETER, + Direction.HORIZONTAL, + Optional.of(receiver.get().getModifiers()), + receiver.get().getType(), + /* name= */ receiver.get().getName(), + "", + "", + /* initializer= */ Optional.empty(), + !parameters.isEmpty() ? Optional.of(",") : Optional.empty(), + Optional.of(receiver.get().getNameExpression()), + /* typeWithDims= */ Optional.empty()); + first = false; + } + for (int i = 0; i < parameters.size(); i++) { + VariableTree parameter = parameters.get(i); + if (!first) { + builder.breakOp(" "); + } + visitToDeclare( + DeclarationKind.PARAMETER, + Direction.HORIZONTAL, + parameter, + /* initializer= */ Optional.empty(), + "=", + i < parameters.size() - 1 ? Optional.of(",") : /* a= */ Optional.empty()); + first = false; + } + builder.close(); + } + + // /** Helper method for {@link MethodDeclaration}s. */ + private void visitThrowsClause(List thrownExceptionTypes) { + token("throws"); + builder.breakToFill(" "); + boolean first = true; + for (ExpressionTree thrownExceptionType : thrownExceptionTypes) { + if (!first) { + token(","); + builder.breakOp(" "); + } + scan(thrownExceptionType, null); + first = false; + } + } + + @Override + public Void visitIdentifier(IdentifierTree node, Void unused) { + sync(node); + token(node.getName().toString()); + return null; + } + + @Override + public Void visitModule(ModuleTree node, Void unused) { + for (AnnotationTree annotation : node.getAnnotations()) { + scan(annotation, null); + builder.forcedBreak(); + } + if (node.getModuleType() == ModuleTree.ModuleKind.OPEN) { + token("open"); + builder.space(); + } + token("module"); + builder.space(); + scan(node.getName(), null); + builder.space(); + if (node.getDirectives().isEmpty()) { + tokenBreakTrailingComment("{", plusTwo); + builder.blankLineWanted(BlankLineWanted.NO); + token("}", plusTwo); + } else { + builder.open(plusTwo); + token("{"); + builder.forcedBreak(); + Optional previousDirective = Optional.empty(); + for (DirectiveTree directiveTree : node.getDirectives()) { + markForPartialFormat(); + builder.blankLineWanted( + previousDirective.map(k -> !k.equals(directiveTree.getKind())).orElse(false) + ? BlankLineWanted.YES + : BlankLineWanted.NO); + builder.forcedBreak(); + scan(directiveTree, null); + previousDirective = Optional.of(directiveTree.getKind()); + } + builder.close(); + builder.forcedBreak(); + token("}"); + } + return null; + } + + private void visitDirective( + String name, + String separator, + ExpressionTree nameExpression, + @Nullable List items) { + token(name); + builder.space(); + scan(nameExpression, null); + if (items != null) { + builder.open(plusFour); + builder.space(); + token(separator); + builder.forcedBreak(); + boolean first = true; + for (ExpressionTree item : items) { + if (!first) { + token(","); + builder.forcedBreak(); + } + scan(item, null); + first = false; + } + token(";"); + builder.close(); + } else { + token(";"); + } + } + + @Override + public Void visitExports(ExportsTree node, Void unused) { + visitDirective("exports", "to", node.getPackageName(), node.getModuleNames()); + return null; + } + + @Override + public Void visitOpens(OpensTree node, Void unused) { + visitDirective("opens", "to", node.getPackageName(), node.getModuleNames()); + return null; + } + + @Override + public Void visitProvides(ProvidesTree node, Void unused) { + visitDirective("provides", "with", node.getServiceName(), node.getImplementationNames()); + return null; + } + + @Override + public Void visitRequires(RequiresTree node, Void unused) { + token("requires"); + builder.space(); + while (true) { + if (builder.peekToken().equals(Optional.of("static"))) { + token("static"); + builder.space(); + } else if (builder.peekToken().equals(Optional.of("transitive"))) { + token("transitive"); + builder.space(); + } else { + break; + } + } + scan(node.getModuleName(), null); + token(";"); + return null; + } + + @Override + public Void visitUses(UsesTree node, Void unused) { + token("uses"); + builder.space(); + scan(node.getServiceName(), null); + token(";"); + return null; + } + + /** Helper method for import declarations, names, and qualified names. */ + private void visitName(Tree node) { + Deque stack = new ArrayDeque<>(); + for (; node instanceof MemberSelectTree; node = ((MemberSelectTree) node).getExpression()) { + stack.addFirst(((MemberSelectTree) node).getIdentifier()); + } + stack.addFirst(((IdentifierTree) node).getName()); + boolean first = true; + for (Name name : stack) { + if (!first) { + token("."); + } + token(name.toString()); + first = false; + } + } + + private void visitToDeclare( + DeclarationKind kind, + Direction annotationsDirection, + VariableTree node, + Optional initializer, + String equals, + Optional trailing) { + sync(node); + Optional typeWithDims; + Tree type; + if (node.getType() != null) { + TypeWithDims extractedDims = DimensionHelpers.extractDims(node.getType(), SortedDims.YES); + typeWithDims = Optional.of(extractedDims); + type = extractedDims.node; + } else { + typeWithDims = Optional.empty(); + type = null; + } + declareOne( + kind, + annotationsDirection, + Optional.of(node.getModifiers()), + type, + node.getName(), + "", + equals, + initializer, + trailing, + /* receiverExpression= */ Optional.empty(), + typeWithDims); + } + + /** Does not omit the leading {@code "<"}, which should be associated with the type name. */ + protected void typeParametersRest( + List typeParameters, Indent plusIndent) { + builder.open(plusIndent); + builder.breakOp(); + builder.open(ZERO); + boolean first = true; + for (TypeParameterTree typeParameter : typeParameters) { + if (!first) { + token(","); + builder.breakOp(" "); + } + scan(typeParameter, null); + first = false; + } + token(">"); + builder.close(); + builder.close(); + } + + /** Collapse chains of {@code .} operators, across multiple {@link ASTNode} types. */ + + /** + * Output a "." node. + * + * @param node0 the "." node + */ + void visitDot(ExpressionTree node0) { + ExpressionTree node = node0; + + // collect a flattened list of "."-separated items + // e.g. ImmutableList.builder().add(1).build() -> [ImmutableList, builder(), add(1), build()] + Deque stack = new ArrayDeque<>(); + LOOP: + do { + stack.addFirst(node); + if (node.getKind() == ARRAY_ACCESS) { + node = getArrayBase(node); + } + switch (node.getKind()) { + case MEMBER_SELECT: + node = ((MemberSelectTree) node).getExpression(); + break; + case METHOD_INVOCATION: + node = getMethodReceiver((MethodInvocationTree) node); + break; + case IDENTIFIER: + node = null; + break LOOP; + default: + // If the dot chain starts with a primary expression + // (e.g. a class instance creation, or a conditional expression) + // then remove it from the list and deal with it first. + node = stack.removeFirst(); + break LOOP; + } + } while (node != null); + List items = new ArrayList<>(stack); + + boolean needDot = false; + + // The dot chain started with a primary expression: output it normally, and indent + // the rest of the chain +4. + if (node != null) { + // Exception: if it's an anonymous class declaration, we don't need to + // break and indent after the trailing '}'. + if (node.getKind() == NEW_CLASS && ((NewClassTree) node).getClassBody() != null) { + builder.open(ZERO); + scan(getArrayBase(node), null); + token("."); + } else { + builder.open(plusFour); + scan(getArrayBase(node), null); + builder.breakOp(); + needDot = true; + } + formatArrayIndices(getArrayIndices(node)); + if (stack.isEmpty()) { + builder.close(); + return; + } + } + + Set prefixes = new LinkedHashSet<>(); + + // Check if the dot chain has a prefix that looks like a type name, so we can + // treat the type name-shaped part as a single syntactic unit. + TypeNameClassifier.typePrefixLength(simpleNames(stack)).ifPresent(prefixes::add); + + int invocationCount = 0; + int firstInvocationIndex = -1; + { + for (int i = 0; i < items.size(); i++) { + ExpressionTree expression = items.get(i); + if (expression.getKind() == METHOD_INVOCATION) { + if (i > 0 || node != null) { + // we only want dereference invocations + invocationCount++; + } + if (firstInvocationIndex < 0) { + firstInvocationIndex = i; + } + } + } + } + + // If there's only one invocation, treat leading field accesses as a single + // unit. In the normal case we want to preserve the alignment of subsequent + // method calls, and would emit e.g.: + // + // myField + // .foo() + // .bar(); + // + // But if there's no 'bar()' to worry about the alignment of we prefer: + // + // myField.foo(); + // + // to: + // + // myField + // .foo(); + // + if (invocationCount == 1 && firstInvocationIndex > 0) { + prefixes.add(firstInvocationIndex); + } + + if (prefixes.isEmpty() && items.get(0) instanceof IdentifierTree) { + switch (((IdentifierTree) items.get(0)).getName().toString()) { + case "this": + case "super": + prefixes.add(1); + break; + default: + break; + } + } + + List streamPrefixes = handleStream(items); + streamPrefixes.forEach(x -> prefixes.add(x.intValue())); + if (!prefixes.isEmpty()) { + visitDotWithPrefix( + items, needDot, prefixes, streamPrefixes.isEmpty() ? INDEPENDENT : UNIFIED); + } else { + visitRegularDot(items, needDot); + } + + if (node != null) { + builder.close(); + } + } + + /** + * Output a "regular" chain of dereferences, possibly in builder-style. Break before every dot. + * + * @param items in the chain + * @param needDot whether a leading dot is needed + */ + private void visitRegularDot(List items, boolean needDot) { + boolean trailingDereferences = items.size() > 1; + boolean needDot0 = needDot; + if (!needDot0) { + builder.open(plusFour); + } + // don't break after the first element if it is every small, unless the + // chain starts with another expression + int minLength = indentMultiplier * 4; + int length = needDot0 ? minLength : 0; + for (ExpressionTree e : items) { + if (needDot) { + if (length > minLength) { + builder.breakOp(FillMode.UNIFIED, "", ZERO); + } + token("."); + length++; + } + if (!fillFirstArgument(e, items, trailingDereferences ? ZERO : minusFour)) { + BreakTag tyargTag = genSym(); + dotExpressionUpToArgs(e, Optional.of(tyargTag)); + Indent tyargIndent = Indent.If.make(tyargTag, plusFour, ZERO); + dotExpressionArgsAndParen( + e, tyargIndent, (trailingDereferences || needDot) ? plusFour : ZERO); + } + length += getLength(e, getCurrentPath()); + needDot = true; + } + if (!needDot0) { + builder.close(); + } + } + + // avoid formattings like: + // + // when( + // something + // .happens()) + // .thenReturn(result); + // + private boolean fillFirstArgument(ExpressionTree e, List items, Indent indent) { + // is there a trailing dereference? + if (items.size() < 2) { + return false; + } + // don't special-case calls nested inside expressions + if (e.getKind() != METHOD_INVOCATION) { + return false; + } + MethodInvocationTree methodInvocation = (MethodInvocationTree) e; + Name name = getMethodName(methodInvocation); + if (!(methodInvocation.getMethodSelect() instanceof IdentifierTree) + || name.length() > 4 + || !methodInvocation.getTypeArguments().isEmpty() + || methodInvocation.getArguments().size() != 1) { + return false; + } + builder.open(ZERO); + builder.open(indent); + visit(name); + token("("); + ExpressionTree arg = getOnlyElement(methodInvocation.getArguments()); + scan(arg, null); + builder.close(); + token(")"); + builder.close(); + return true; + } + + /** + * Output a chain of dereferences where some prefix should be treated as a single syntactic unit, + * either because it looks like a type name or because there is only a single method invocation in + * the chain. + * + * @param items in the chain + * @param needDot whether a leading dot is needed + * @param prefixes the terminal indices of 'prefixes' of the expression that should be treated as + * a syntactic unit + */ + private void visitDotWithPrefix( + List items, + boolean needDot, + Collection prefixes, + FillMode prefixFillMode) { + // Are there method invocations or field accesses after the prefix? + boolean trailingDereferences = !prefixes.isEmpty() && getLast(prefixes) < items.size() - 1; + + builder.open(plusFour); + for (int times = 0; times < prefixes.size(); times++) { + builder.open(ZERO); + } + + Deque unconsumedPrefixes = new ArrayDeque<>(ImmutableSortedSet.copyOf(prefixes)); + BreakTag nameTag = genSym(); + for (int i = 0; i < items.size(); i++) { + ExpressionTree e = items.get(i); + if (needDot) { + FillMode fillMode; + if (!unconsumedPrefixes.isEmpty() && i <= unconsumedPrefixes.peekFirst()) { + fillMode = prefixFillMode; + } else { + fillMode = FillMode.UNIFIED; + } + + builder.breakOp(fillMode, "", ZERO, Optional.of(nameTag)); + token("."); + } + BreakTag tyargTag = genSym(); + dotExpressionUpToArgs(e, Optional.of(tyargTag)); + if (!unconsumedPrefixes.isEmpty() && i == unconsumedPrefixes.peekFirst()) { + builder.close(); + unconsumedPrefixes.removeFirst(); + } + + Indent tyargIndent = Indent.If.make(tyargTag, plusFour, ZERO); + Indent argsIndent = Indent.If.make(nameTag, plusFour, trailingDereferences ? plusFour : ZERO); + dotExpressionArgsAndParen(e, tyargIndent, argsIndent); + + needDot = true; + } + + builder.close(); + } + + /** Returns the simple names of expressions in a "." chain. */ + private static ImmutableList simpleNames(Deque stack) { + ImmutableList.Builder simpleNames = ImmutableList.builder(); + OUTER: + for (ExpressionTree expression : stack) { + boolean isArray = expression.getKind() == ARRAY_ACCESS; + expression = getArrayBase(expression); + switch (expression.getKind()) { + case MEMBER_SELECT: + simpleNames.add(((MemberSelectTree) expression).getIdentifier().toString()); + break; + case IDENTIFIER: + simpleNames.add(((IdentifierTree) expression).getName().toString()); + break; + case METHOD_INVOCATION: + simpleNames.add(getMethodName((MethodInvocationTree) expression).toString()); + break OUTER; + default: + break OUTER; + } + if (isArray) { + break OUTER; + } + } + return simpleNames.build(); + } + + private void dotExpressionUpToArgs(ExpressionTree expression, Optional tyargTag) { + expression = getArrayBase(expression); + switch (expression.getKind()) { + case MEMBER_SELECT: + MemberSelectTree fieldAccess = (MemberSelectTree) expression; + visit(fieldAccess.getIdentifier()); + break; + case METHOD_INVOCATION: + MethodInvocationTree methodInvocation = (MethodInvocationTree) expression; + if (!methodInvocation.getTypeArguments().isEmpty()) { + builder.open(plusFour); + addTypeArguments(methodInvocation.getTypeArguments(), ZERO); + // TODO(user): Should indent the name -4. + builder.breakOp(Doc.FillMode.UNIFIED, "", ZERO, tyargTag); + builder.close(); + } + visit(getMethodName(methodInvocation)); + break; + case IDENTIFIER: + visit(((IdentifierTree) expression).getName()); + break; + default: + scan(expression, null); + break; + } + } + + /** + * Returns the base expression of an erray access, e.g. given {@code foo[0][0]} returns {@code + * foo}. + */ + private static ExpressionTree getArrayBase(ExpressionTree node) { + while (node instanceof ArrayAccessTree) { + node = ((ArrayAccessTree) node).getExpression(); + } + return node; + } + + private static ExpressionTree getMethodReceiver(MethodInvocationTree methodInvocation) { + ExpressionTree select = methodInvocation.getMethodSelect(); + return select instanceof MemberSelectTree ? ((MemberSelectTree) select).getExpression() : null; + } + + private void dotExpressionArgsAndParen( + ExpressionTree expression, Indent tyargIndent, Indent indent) { + Deque indices = getArrayIndices(expression); + expression = getArrayBase(expression); + switch (expression.getKind()) { + case METHOD_INVOCATION: + builder.open(tyargIndent); + MethodInvocationTree methodInvocation = (MethodInvocationTree) expression; + addArguments(methodInvocation.getArguments(), indent); + builder.close(); + break; + default: + break; + } + formatArrayIndices(indices); + } + + /** Lays out one or more array indices. Does not output the expression for the array itself. */ + private void formatArrayIndices(Deque indices) { + if (indices.isEmpty()) { + return; + } + builder.open(ZERO); + do { + token("["); + builder.breakToFill(); + scan(indices.removeLast(), null); + token("]"); + } while (!indices.isEmpty()); + builder.close(); + } + + /** + * Returns all array indices for the given expression, e.g. given {@code foo[0][0]} returns the + * expressions for {@code [0][0]}. + */ + private static Deque getArrayIndices(ExpressionTree expression) { + Deque indices = new ArrayDeque<>(); + while (expression instanceof ArrayAccessTree) { + ArrayAccessTree array = (ArrayAccessTree) expression; + indices.addLast(array.getIndex()); + expression = array.getExpression(); + } + return indices; + } + + /** Helper methods for method invocations. */ + void addTypeArguments(List typeArguments, Indent plusIndent) { + if (typeArguments == null || typeArguments.isEmpty()) { + return; + } + token("<"); + builder.open(plusIndent); + boolean first = true; + for (Tree typeArgument : typeArguments) { + if (!first) { + token(","); + builder.breakToFill(" "); + } + scan(typeArgument, null); + first = false; + } + builder.close(); + token(">"); + } + + /** + * Add arguments to a method invocation, etc. The arguments indented {@code plusFour}, filled, + * from the current indent. The arguments may be output two at a time if they seem to be arguments + * to a map constructor, etc. + * + * @param arguments the arguments + * @param plusIndent the extra indent for the arguments + */ + void addArguments(List arguments, Indent plusIndent) { + builder.open(plusIndent); + token("("); + if (!arguments.isEmpty()) { + if (arguments.size() % 2 == 0 && argumentsAreTabular(arguments) == 2) { + builder.forcedBreak(); + builder.open(ZERO); + boolean first = true; + for (int i = 0; i < arguments.size() - 1; i += 2) { + ExpressionTree argument0 = arguments.get(i); + ExpressionTree argument1 = arguments.get(i + 1); + if (!first) { + token(","); + builder.forcedBreak(); + } + builder.open(plusFour); + scan(argument0, null); + token(","); + builder.breakOp(" "); + scan(argument1, null); + builder.close(); + first = false; + } + builder.close(); + } else if (isFormatMethod(arguments)) { + builder.breakOp(); + builder.open(ZERO); + scan(arguments.get(0), null); + token(","); + builder.breakOp(" "); + builder.open(ZERO); + argList(arguments.subList(1, arguments.size())); + builder.close(); + builder.close(); + } else { + builder.breakOp(); + argList(arguments); + } + } + token(")"); + builder.close(); + } + + private void argList(List arguments) { + builder.open(ZERO); + boolean first = true; + FillMode fillMode = hasOnlyShortItems(arguments) ? FillMode.INDEPENDENT : FillMode.UNIFIED; + for (ExpressionTree argument : arguments) { + if (!first) { + token(","); + builder.breakOp(fillMode, " ", ZERO); + } + scan(argument, null); + first = false; + } + builder.close(); + } + + /** + * Identifies String formatting methods like {@link String#format} which we prefer to format as: + * + *

{@code
+   * String.format(
+   *     "the format string: %s %s %s",
+   *     arg, arg, arg);
+   * }
+ * + *

And not: + * + *

{@code
+   * String.format(
+   *     "the format string: %s %s %s",
+   *     arg,
+   *     arg,
+   *     arg);
+   * }
+ */ + private boolean isFormatMethod(List arguments) { + if (arguments.size() < 2) { + return false; + } + return isStringConcat(arguments.get(0)); + } + + private static final Pattern FORMAT_SPECIFIER = Pattern.compile("%|\\{[0-9]\\}"); + + private boolean isStringConcat(ExpressionTree first) { + final boolean[] stringLiteral = {true}; + final boolean[] formatString = {false}; + new TreeScanner() { + @Override + public void scan(JCTree tree) { + if (tree == null) { + return; + } + switch (tree.getKind()) { + case STRING_LITERAL: + break; + case PLUS: + super.scan(tree); + break; + default: + stringLiteral[0] = false; + break; + } + if (tree.getKind() == STRING_LITERAL) { + Object value = ((LiteralTree) tree).getValue(); + if (value instanceof String && FORMAT_SPECIFIER.matcher(value.toString()).find()) { + formatString[0] = true; + } + } + } + }.scan((JCTree) first); + return stringLiteral[0] && formatString[0]; + } + + /** Returns the number of columns if the arguments arg laid out in a grid, or else {@code -1}. */ + private int argumentsAreTabular(List arguments) { + if (arguments.isEmpty()) { + return -1; + } + List> rows = new ArrayList<>(); + PeekingIterator it = Iterators.peekingIterator(arguments.iterator()); + int start0 = actualColumn(it.peek()); + { + List row = new ArrayList<>(); + row.add(it.next()); + while (it.hasNext() && actualColumn(it.peek()) > start0) { + row.add(it.next()); + } + if (!it.hasNext()) { + return -1; + } + if (rowLength(row) <= 1) { + return -1; + } + rows.add(row); + } + while (it.hasNext()) { + List row = new ArrayList<>(); + int start = actualColumn(it.peek()); + if (start != start0) { + return -1; + } + row.add(it.next()); + while (it.hasNext() && actualColumn(it.peek()) > start0) { + row.add(it.next()); + } + rows.add(row); + } + int size0 = rows.get(0).size(); + if (!expressionsAreParallel(rows, 0, rows.size())) { + return -1; + } + for (int i = 1; i < size0; i++) { + if (!expressionsAreParallel(rows, i, rows.size() / 2 + 1)) { + return -1; + } + } + // if there are only two rows, they must be the same length + if (rows.size() == 2) { + if (size0 == rows.get(1).size()) { + return size0; + } + return -1; + } + // allow a ragged trailing row for >= 3 columns + for (int i = 1; i < rows.size() - 1; i++) { + if (size0 != rows.get(i).size()) { + return -1; + } + } + if (size0 < getLast(rows).size()) { + return -1; + } + return size0; + } + + static int rowLength(List row) { + int size = 0; + for (ExpressionTree tree : row) { + if (tree.getKind() != NEW_ARRAY) { + size++; + continue; + } + NewArrayTree array = (NewArrayTree) tree; + if (array.getInitializers() == null) { + size++; + continue; + } + size += rowLength(array.getInitializers()); + } + return size; + } + + private Integer actualColumn(ExpressionTree expression) { + Map positionToColumnMap = builder.getInput().getPositionToColumnMap(); + return positionToColumnMap.get(builder.actualStartColumn(getStartPosition(expression))); + } + + /** Returns true if {@code atLeastM} of the expressions in the given column are the same kind. */ + private static boolean expressionsAreParallel( + List> rows, int column, int atLeastM) { + Multiset nodeTypes = HashMultiset.create(); + for (List row : rows) { + if (column >= row.size()) { + continue; + } + // Treat UnaryTree expressions as their underlying type for the comparison (so, for example + // -ve and +ve numeric literals are considered the same). + if (row.get(column) instanceof UnaryTree) { + nodeTypes.add(((UnaryTree) row.get(column)).getExpression().getKind()); + } else { + nodeTypes.add(row.get(column).getKind()); + } + } + for (Multiset.Entry nodeType : nodeTypes.entrySet()) { + if (nodeType.getCount() >= atLeastM) { + return true; + } + } + return false; + } + + // General helper functions. + + enum DeclarationKind { + NONE, + FIELD, + PARAMETER + } + + /** Declare one variable or variable-like thing. */ + int declareOne( + DeclarationKind kind, + Direction annotationsDirection, + Optional modifiers, + Tree type, + Name name, + String op, + String equals, + Optional initializer, + Optional trailing, + Optional receiverExpression, + Optional typeWithDims) { + + BreakTag typeBreak = genSym(); + BreakTag verticalAnnotationBreak = genSym(); + + // If the node is a field declaration, try to output any declaration + // annotations in-line. If the entire declaration doesn't fit on a single + // line, fall back to one-per-line. + boolean isField = kind == DeclarationKind.FIELD; + + if (isField) { + builder.blankLineWanted(BlankLineWanted.conditional(verticalAnnotationBreak)); + } + + Deque> dims = + new ArrayDeque<>(typeWithDims.isPresent() ? typeWithDims.get().dims : ImmutableList.of()); + int baseDims = 0; + + // preprocess to separate declaration annotations + modifiers, type annotations + + DeclarationModifiersAndTypeAnnotations declarationAndTypeModifiers = + modifiers + .map(m -> splitModifiers(m, m.getAnnotations())) + .orElse(DeclarationModifiersAndTypeAnnotations.empty()); + builder.open( + kind == DeclarationKind.PARAMETER && declarationAndTypeModifiers.hasDeclarationAnnotation() + ? plusFour + : ZERO); + { + List annotations = + visitModifiers( + declarationAndTypeModifiers, + annotationsDirection, + Optional.of(verticalAnnotationBreak)); + boolean isVar = + builder.peekToken().get().equals("var") + && (!name.contentEquals("var") || builder.peekToken(1).get().equals("var")); + boolean hasType = type != null || isVar; + builder.open(hasType ? plusFour : ZERO); + { + builder.open(ZERO); + { + builder.open(ZERO); + { + visitAnnotations(annotations, BreakOrNot.NO, BreakOrNot.YES); + if (typeWithDims.isPresent() && typeWithDims.get().node != null) { + scan(typeWithDims.get().node, null); + int totalDims = dims.size(); + builder.open(plusFour); + maybeAddDims(dims); + builder.close(); + baseDims = totalDims - dims.size(); + } else if (isVar) { + token("var"); + } else { + scan(type, null); + } + } + builder.close(); + + if (hasType) { + builder.breakOp(Doc.FillMode.INDEPENDENT, " ", ZERO, Optional.of(typeBreak)); + } + + // conditionally ident the name and initializer +4 if the type spans + // multiple lines + builder.open(Indent.If.make(typeBreak, plusFour, ZERO)); + if (receiverExpression.isPresent()) { + scan(receiverExpression.get(), null); + } else { + visit(name); + } + builder.op(op); + } + maybeAddDims(dims); + builder.close(); + } + builder.close(); + + if (initializer.isPresent()) { + builder.space(); + token(equals); + if (initializer.get().getKind() == Tree.Kind.NEW_ARRAY + && ((NewArrayTree) initializer.get()).getType() == null) { + builder.open(minusFour); + builder.space(); + initializer.get().accept(this, null); + builder.close(); + } else { + builder.open(Indent.If.make(typeBreak, plusFour, ZERO)); + { + builder.breakToFill(" "); + scan(initializer.get(), null); + } + builder.close(); + } + } + if (trailing.isPresent() && builder.peekToken().equals(trailing)) { + builder.guessToken(trailing.get()); + } + + // end of conditional name and initializer indent + builder.close(); + } + builder.close(); + + if (isField) { + builder.blankLineWanted(BlankLineWanted.conditional(verticalAnnotationBreak)); + } + + return baseDims; + } + + private void maybeAddDims(Deque> annotations) { + maybeAddDims(new ArrayDeque<>(), annotations); + } + + /** + * The compiler does not always preserve the concrete syntax of annotated array dimensions, and + * mixed-notation array dimensions. Use look-ahead to preserve the original syntax. + * + *

It is assumed that any number of regular dimension specifiers ({@code []} with no + * annotations) may be present in the input. + * + * @param dimExpressions an ordered list of dimension expressions (e.g. the {@code 0} in {@code + * new int[0]} + * @param annotations an ordered list of type annotations grouped by dimension (e.g. {@code + * [[@A, @B], [@C]]} for {@code int @A [] @B @C []} + */ + private void maybeAddDims( + Deque dimExpressions, Deque> annotations) { + boolean lastWasAnnotation = false; + while (builder.peekToken().isPresent()) { + switch (builder.peekToken().get()) { + case "@": + if (annotations.isEmpty()) { + return; + } + List dimAnnotations = annotations.removeFirst(); + if (dimAnnotations.isEmpty()) { + continue; + } + builder.breakToFill(" "); + visitAnnotations(dimAnnotations, BreakOrNot.NO, BreakOrNot.NO); + lastWasAnnotation = true; + break; + case "[": + if (lastWasAnnotation) { + builder.breakToFill(" "); + } else { + builder.breakToFill(); + } + token("["); + if (!builder.peekToken().get().equals("]")) { + scan(dimExpressions.removeFirst(), null); + } + token("]"); + lastWasAnnotation = false; + break; + case ".": + if (!builder.peekToken().get().equals(".") || !builder.peekToken(1).get().equals(".")) { + return; + } + if (lastWasAnnotation) { + builder.breakToFill(" "); + } else { + builder.breakToFill(); + } + builder.op("..."); + lastWasAnnotation = false; + break; + default: + return; + } + } + } + + private void declareMany(List fragments, Direction annotationDirection) { + builder.open(ZERO); + + ModifiersTree modifiers = fragments.get(0).getModifiers(); + Tree type = fragments.get(0).getType(); + + visitAndBreakModifiers( + modifiers, annotationDirection, /* declarationAnnotationBreak= */ Optional.empty()); + builder.open(plusFour); + builder.open(ZERO); + TypeWithDims extractedDims = DimensionHelpers.extractDims(type, SortedDims.YES); + Deque> dims = new ArrayDeque<>(extractedDims.dims); + scan(extractedDims.node, null); + int baseDims = dims.size(); + maybeAddDims(dims); + baseDims = baseDims - dims.size(); + boolean first = true; + for (VariableTree fragment : fragments) { + if (!first) { + token(","); + } + TypeWithDims fragmentDims = variableFragmentDims(first, baseDims, fragment.getType()); + dims = new ArrayDeque<>(fragmentDims.dims); + builder.breakOp(" "); + builder.open(ZERO); + maybeAddDims(dims); + visit(fragment.getName()); + maybeAddDims(dims); + ExpressionTree initializer = fragment.getInitializer(); + if (initializer != null) { + builder.space(); + token("="); + builder.open(plusFour); + builder.breakOp(" "); + scan(initializer, null); + builder.close(); + } + builder.close(); + if (first) { + builder.close(); + } + first = false; + } + builder.close(); + token(";"); + builder.close(); + } + + /** Add a list of declarations. */ + protected void addBodyDeclarations( + List bodyDeclarations, BracesOrNot braces, FirstDeclarationsOrNot first0) { + if (bodyDeclarations.isEmpty()) { + if (braces.isYes()) { + builder.space(); + tokenBreakTrailingComment("{", plusTwo); + builder.blankLineWanted(BlankLineWanted.NO); + builder.open(ZERO); + token("}", plusTwo); + builder.close(); + } + } else { + if (braces.isYes()) { + builder.space(); + tokenBreakTrailingComment("{", plusTwo); + builder.open(ZERO); + } + builder.open(plusTwo); + boolean first = first0.isYes(); + boolean lastOneGotBlankLineBefore = false; + PeekingIterator it = Iterators.peekingIterator(bodyDeclarations.iterator()); + while (it.hasNext()) { + Tree bodyDeclaration = it.next(); + dropEmptyDeclarations(); + builder.forcedBreak(); + boolean thisOneGetsBlankLineBefore = + bodyDeclaration.getKind() != VARIABLE || hasJavaDoc(bodyDeclaration); + if (first) { + builder.blankLineWanted(PRESERVE); + } else if (!first && (thisOneGetsBlankLineBefore || lastOneGotBlankLineBefore)) { + builder.blankLineWanted(YES); + } + markForPartialFormat(); + + if (bodyDeclaration.getKind() == VARIABLE) { + visitVariables( + variableFragments(it, bodyDeclaration), + DeclarationKind.FIELD, + fieldAnnotationDirection(((VariableTree) bodyDeclaration).getModifiers())); + } else { + scan(bodyDeclaration, null); + } + first = false; + lastOneGotBlankLineBefore = thisOneGetsBlankLineBefore; + } + dropEmptyDeclarations(); + builder.forcedBreak(); + builder.close(); + builder.forcedBreak(); + markForPartialFormat(); + if (braces.isYes()) { + builder.blankLineWanted(BlankLineWanted.NO); + token("}", plusTwo); + builder.close(); + } + } + } + + /** Gets the permits clause for the given node. This is only available in Java 15 and later. */ + protected List getPermitsClause(ClassTree node) { + return ImmutableList.of(); + } + + private void classDeclarationTypeList(String token, List types) { + if (types.isEmpty()) { + return; + } + builder.breakToFill(" "); + builder.open(types.size() > 1 ? plusFour : ZERO); + token(token); + builder.space(); + boolean first = true; + for (Tree type : types) { + if (!first) { + token(","); + builder.breakOp(" "); + } + scan(type, null); + first = false; + } + builder.close(); + } + + /** + * The parser expands multi-variable declarations into separate single-variable declarations. All + * of the fragments in the original declaration have the same start position, so we use that as a + * signal to collect them and preserve the multi-variable declaration in the output. + * + *

e.g. {@code int x, y;} is parsed as {@code int x; int y;}. + */ + private static List variableFragments( + PeekingIterator it, Tree first) { + List fragments = new ArrayList<>(); + if (first.getKind() == VARIABLE) { + int start = getStartPosition(first); + fragments.add((VariableTree) first); + while (it.hasNext() + && it.peek().getKind() == VARIABLE + && getStartPosition(it.peek()) == start) { + fragments.add((VariableTree) it.next()); + } + } + return fragments; + } + + /** Does this declaration have javadoc preceding it? */ + private boolean hasJavaDoc(Tree bodyDeclaration) { + int position = ((JCTree) bodyDeclaration).getStartPosition(); + Input.Token token = builder.getInput().getPositionTokenMap().get(position); + if (token != null) { + for (Input.Tok tok : token.getToksBefore()) { + if (tok.getText().startsWith("/**")) { + return true; + } + } + } + return false; + } + + private static Optional getNextToken(Input input, int position) { + return Optional.ofNullable(input.getPositionTokenMap().get(position)); + } + + /** Does this list of trees end with the specified token? */ + private boolean hasTrailingToken(Input input, List nodes, String token) { + if (nodes.isEmpty()) { + return false; + } + Tree lastNode = getLast(nodes); + Optional nextToken = + getNextToken(input, getEndPosition(lastNode, getCurrentPath())); + return nextToken.isPresent() && nextToken.get().getTok().getText().equals(token); + } + + /** + * Can a local with a set of modifiers be declared with horizontal annotations? This is currently + * true if there is at most one parameterless annotation, and no others. + * + * @param modifiers the list of {@link ModifiersTree}s + * @return whether the local can be declared with horizontal annotations + */ + private static Direction canLocalHaveHorizontalAnnotations(ModifiersTree modifiers) { + int parameterlessAnnotations = 0; + for (AnnotationTree annotation : modifiers.getAnnotations()) { + if (annotation.getArguments().isEmpty()) { + parameterlessAnnotations++; + } + } + return parameterlessAnnotations <= 1 + && parameterlessAnnotations == modifiers.getAnnotations().size() + ? Direction.HORIZONTAL + : Direction.VERTICAL; + } + + /** + * Should a field with a set of modifiers be declared with horizontal annotations? This is + * currently true if all annotations are parameterless annotations. + */ + private static Direction fieldAnnotationDirection(ModifiersTree modifiers) { + for (AnnotationTree annotation : modifiers.getAnnotations()) { + if (!annotation.getArguments().isEmpty()) { + return Direction.VERTICAL; + } + } + return Direction.HORIZONTAL; + } + + /** + * Emit a {@link Doc.Token}. + * + * @param token the {@link String} to wrap in a {@link Doc.Token} + */ + protected final void token(String token) { + builder.token( + token, + Doc.Token.RealOrImaginary.REAL, + ZERO, + /* breakAndIndentTrailingComment= */ Optional.empty()); + } + + /** + * Emit a {@link Doc.Token}. + * + * @param token the {@link String} to wrap in a {@link Doc.Token} + * @param plusIndentCommentsBefore extra indent for comments before this token + */ + protected final void token(String token, Indent plusIndentCommentsBefore) { + builder.token( + token, + Doc.Token.RealOrImaginary.REAL, + plusIndentCommentsBefore, + /* breakAndIndentTrailingComment= */ Optional.empty()); + } + + /** Emit a {@link Doc.Token}, and breaks and indents trailing javadoc or block comments. */ + final void tokenBreakTrailingComment(String token, Indent breakAndIndentTrailingComment) { + builder.token( + token, Doc.Token.RealOrImaginary.REAL, ZERO, Optional.of(breakAndIndentTrailingComment)); + } + + protected void markForPartialFormat() { + if (!inExpression()) { + builder.markForPartialFormat(); + } + } + + /** + * Sync to position in the input. If we've skipped outputting any tokens that were present in the + * input tokens, output them here and complain. + * + * @param node the ASTNode holding the input position + */ + protected final void sync(Tree node) { + builder.sync(((JCTree) node).getStartPosition()); + } + + final BreakTag genSym() { + return new BreakTag(); + } + + @Override + public final String toString() { + return MoreObjects.toStringHelper(this).add("builder", builder).toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaOutput.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaOutput.java new file mode 100644 index 000000000..656b65c83 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaOutput.java @@ -0,0 +1,400 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static java.lang.Math.min; +import static java.util.Comparator.comparing; + +import com.google.common.base.CharMatcher; +import com.google.common.base.MoreObjects; +import com.google.common.base.Strings; +import com.google.common.collect.DiscreteDomain; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeSet; +import com.google.googlejavaformat.CommentsHelper; +import com.google.googlejavaformat.Input; +import com.google.googlejavaformat.Input.Token; +import com.google.googlejavaformat.Newlines; +import com.google.googlejavaformat.OpsBuilder.BlankLineWanted; +import com.google.googlejavaformat.Output; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/* + * Throughout this file, {@code i} is an index for input lines, {@code j} is an index for output + * lines, {@code ij} is an index into either input or output lines, and {@code k} is an index for + * toks. + */ + +/** + * {@code JavaOutput} extends {@link Output Output} to represent a Java output document. It includes + * methods to emit the output document. + */ +public final class JavaOutput extends Output { + private final String lineSeparator; + private final Input javaInput; // Used to follow along while emitting the output. + private final CommentsHelper commentsHelper; // Used to re-flow comments. + private final Map blankLines = new HashMap<>(); // Info on blank lines. + private final RangeSet partialFormatRanges = TreeRangeSet.create(); + + private final List mutableLines = new ArrayList<>(); + private final int kN; // The number of tokens or comments in the input, excluding the EOF. + private int iLine = 0; // Closest corresponding line number on input. + private int lastK = -1; // Last {@link Tok} index output. + private int newlinesPending = 0; + private StringBuilder lineBuilder = new StringBuilder(); + private StringBuilder spacesPending = new StringBuilder(); + + /** + * {@code JavaOutput} constructor. + * + * @param javaInput the {@link Input}, used to match up blank lines in the output + * @param commentsHelper the {@link CommentsHelper}, used to rewrite comments + */ + public JavaOutput(String lineSeparator, Input javaInput, CommentsHelper commentsHelper) { + this.lineSeparator = lineSeparator; + this.javaInput = javaInput; + this.commentsHelper = commentsHelper; + kN = javaInput.getkN(); + } + + @Override + public void blankLine(int k, BlankLineWanted wanted) { + if (blankLines.containsKey(k)) { + blankLines.put(k, blankLines.get(k).merge(wanted)); + } else { + blankLines.put(k, wanted); + } + } + + @Override + public void markForPartialFormat(Token start, Token end) { + int lo = JavaOutput.startTok(start).getIndex(); + int hi = JavaOutput.endTok(end).getIndex(); + partialFormatRanges.add(Range.closed(lo, hi)); + } + + // TODO(user): Add invariant. + @Override + public void append(String text, Range range) { + if (!range.isEmpty()) { + boolean sawNewlines = false; + // Skip over input line we've passed. + int iN = javaInput.getLineCount(); + while (iLine < iN + && (javaInput.getRanges(iLine).isEmpty() + || javaInput.getRanges(iLine).upperEndpoint() <= range.lowerEndpoint())) { + if (javaInput.getRanges(iLine).isEmpty()) { + // Skipped over a blank line. + sawNewlines = true; + } + ++iLine; + } + /* + * Output blank line if we've called {@link OpsBuilder#blankLine}{@code (true)} here, or if + * there's a blank line here and it's a comment. + */ + BlankLineWanted wanted = blankLines.getOrDefault(lastK, BlankLineWanted.NO); + if ((sawNewlines && isComment(text)) || wanted.wanted().orElse(sawNewlines)) { + ++newlinesPending; + } + } + if (Newlines.isNewline(text)) { + /* + * Don't update range information, and swallow extra newlines. The case below for '\n' is for + * block comments. + */ + if (newlinesPending == 0) { + ++newlinesPending; + } + spacesPending = new StringBuilder(); + } else { + boolean rangesSet = false; + int textN = text.length(); + for (int i = 0; i < textN; i++) { + char c = text.charAt(i); + switch (c) { + case ' ': + spacesPending.append(' '); + break; + case '\t': + spacesPending.append('\t'); + break; + case '\r': + if (i + 1 < text.length() && text.charAt(i + 1) == '\n') { + i++; + } + // falls through + case '\n': + spacesPending = new StringBuilder(); + ++newlinesPending; + break; + default: + while (newlinesPending > 0) { + // drop leading blank lines + if (!mutableLines.isEmpty() || lineBuilder.length() > 0) { + mutableLines.add(lineBuilder.toString()); + } + lineBuilder = new StringBuilder(); + rangesSet = false; + --newlinesPending; + } + if (spacesPending.length() > 0) { + lineBuilder.append(spacesPending); + spacesPending = new StringBuilder(); + } + lineBuilder.append(c); + if (!range.isEmpty()) { + if (!rangesSet) { + while (ranges.size() <= mutableLines.size()) { + ranges.add(Formatter.EMPTY_RANGE); + } + ranges.set(mutableLines.size(), union(ranges.get(mutableLines.size()), range)); + rangesSet = true; + } + } + } + } + } + if (!range.isEmpty()) { + lastK = range.upperEndpoint(); + } + } + + @Override + public void indent(int indent) { + spacesPending.append(Strings.repeat(" ", indent)); + } + + /** Flush any incomplete last line, then add the EOF token into our data structures. */ + public void flush() { + String lastLine = lineBuilder.toString(); + if (!CharMatcher.whitespace().matchesAllOf(lastLine)) { + mutableLines.add(lastLine); + } + int jN = mutableLines.size(); + Range eofRange = Range.closedOpen(kN, kN + 1); + while (ranges.size() < jN) { + ranges.add(Formatter.EMPTY_RANGE); + } + ranges.add(eofRange); + setLines(ImmutableList.copyOf(mutableLines)); + } + + // The following methods can be used after the Output has been built. + + @Override + public CommentsHelper getCommentsHelper() { + return commentsHelper; + } + + /** + * Emit a list of {@link Replacement}s to convert from input to output. + * + * @return a list of {@link Replacement}s, sorted by start index, without overlaps + */ + public ImmutableList getFormatReplacements(RangeSet iRangeSet0) { + ImmutableList.Builder result = ImmutableList.builder(); + Map> kToJ = JavaOutput.makeKToIJ(this); + + // Expand the token ranges to align with re-formattable boundaries. + RangeSet breakableRanges = TreeRangeSet.create(); + RangeSet iRangeSet = iRangeSet0.subRangeSet(Range.closed(0, javaInput.getkN())); + for (Range iRange : iRangeSet.asRanges()) { + Range range = expandToBreakableRegions(iRange.canonical(DiscreteDomain.integers())); + if (range.equals(EMPTY_RANGE)) { + // the range contains only whitespace + continue; + } + breakableRanges.add(range); + } + + // Construct replacements for each reformatted region. + for (Range range : breakableRanges.asRanges()) { + + Input.Tok startTok = startTok(javaInput.getToken(range.lowerEndpoint())); + Input.Tok endTok = endTok(javaInput.getToken(range.upperEndpoint() - 1)); + + // Add all output lines in the given token range to the replacement. + StringBuilder replacement = new StringBuilder(); + + int replaceFrom = startTok.getPosition(); + // Replace leading whitespace in the input with the whitespace from the formatted file + while (replaceFrom > 0) { + char previous = javaInput.getText().charAt(replaceFrom - 1); + if (!CharMatcher.whitespace().matches(previous)) { + break; + } + replaceFrom--; + } + + int i = kToJ.get(startTok.getIndex()).lowerEndpoint(); + // Include leading blank lines from the formatted output, unless the formatted range + // starts at the beginning of the file. + while (i > 0 && getLine(i - 1).isEmpty()) { + i--; + } + // Write out the formatted range. + for (; i < kToJ.get(endTok.getIndex()).upperEndpoint(); i++) { + // It's possible to run out of output lines (e.g. if the input ended with + // multiple trailing newlines). + if (i < getLineCount()) { + if (i > 0) { + replacement.append(lineSeparator); + } + replacement.append(getLine(i)); + } + } + + int replaceTo = min(endTok.getPosition() + endTok.length(), javaInput.getText().length()); + // If the formatted ranged ended in the trailing trivia of the last token before EOF, + // format all the way up to EOF to deal with trailing whitespace correctly. + if (endTok.getIndex() == javaInput.getkN() - 1) { + replaceTo = javaInput.getText().length(); + } + // Replace trailing whitespace in the input with the whitespace from the formatted file. + // If the trailing whitespace in the input includes one or more line breaks, preserve the + // whitespace after the last newline to avoid re-indenting the line following the formatted + // line. + int newline = -1; + while (replaceTo < javaInput.getText().length()) { + char next = javaInput.getText().charAt(replaceTo); + if (!CharMatcher.whitespace().matches(next)) { + break; + } + int newlineLength = Newlines.hasNewlineAt(javaInput.getText(), replaceTo); + if (newlineLength != -1) { + newline = replaceTo; + // Skip over the entire newline; don't count the second character of \r\n as a newline. + replaceTo += newlineLength; + } else { + replaceTo++; + } + } + if (newline != -1) { + replaceTo = newline; + } + + if (newline == -1) { + // There wasn't an existing trailing newline; add one. + replacement.append(lineSeparator); + } + for (; i < getLineCount(); i++) { + String after = getLine(i); + int idx = CharMatcher.whitespace().negate().indexIn(after); + if (idx == -1) { + // Write out trailing empty lines from the formatted output. + replacement.append(lineSeparator); + } else { + if (newline == -1) { + // If there wasn't a trailing newline in the input, indent the next line. + replacement.append(after, 0, idx); + } + break; + } + } + + result.add(Replacement.create(replaceFrom, replaceTo, replacement.toString())); + } + return result.build(); + } + + /** + * Expand a token range to start and end on acceptable boundaries for re-formatting. + * + * @param iRange the {@link Range} of tokens + * @return the expanded token range + */ + private Range expandToBreakableRegions(Range iRange) { + // The original line range. + int loTok = iRange.lowerEndpoint(); + int hiTok = iRange.upperEndpoint() - 1; + + // Expand the token indices to formattable boundaries (e.g. edges of statements). + if (!partialFormatRanges.contains(loTok) || !partialFormatRanges.contains(hiTok)) { + return EMPTY_RANGE; + } + loTok = partialFormatRanges.rangeContaining(loTok).lowerEndpoint(); + hiTok = partialFormatRanges.rangeContaining(hiTok).upperEndpoint(); + return Range.closedOpen(loTok, hiTok + 1); + } + + public static String applyReplacements(String input, List replacements) { + replacements = new ArrayList<>(replacements); + replacements.sort(comparing((Replacement r) -> r.getReplaceRange().lowerEndpoint()).reversed()); + StringBuilder writer = new StringBuilder(input); + for (Replacement replacement : replacements) { + writer.replace( + replacement.getReplaceRange().lowerEndpoint(), + replacement.getReplaceRange().upperEndpoint(), + replacement.getReplacementString()); + } + return writer.toString(); + } + + /** The earliest position of any Tok in the Token, including leading whitespace. */ + public static int startPosition(Token token) { + int min = token.getTok().getPosition(); + for (Input.Tok tok : token.getToksBefore()) { + min = min(min, tok.getPosition()); + } + return min; + } + + /** The earliest non-whitespace Tok in the Token. */ + public static Input.Tok startTok(Token token) { + for (Input.Tok tok : token.getToksBefore()) { + if (tok.getIndex() >= 0) { + return tok; + } + } + return token.getTok(); + } + + /** The last non-whitespace Tok in the Token. */ + public static Input.Tok endTok(Token token) { + for (int i = token.getToksAfter().size() - 1; i >= 0; i--) { + Input.Tok tok = token.getToksAfter().get(i); + if (tok.getIndex() >= 0) { + return tok; + } + } + return token.getTok(); + } + + private boolean isComment(String text) { + return text.startsWith("//") || text.startsWith("/*"); + } + + private static Range union(Range x, Range y) { + return x.isEmpty() ? y : y.isEmpty() ? x : x.span(y).canonical(DiscreteDomain.integers()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("iLine", iLine) + .add("lastK", lastK) + .add("spacesPending", spacesPending.toString().replace("\t", "\\t")) + .add("newlinesPending", newlinesPending) + .add("blankLines", blankLines) + .add("super", super.toString()) + .toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java new file mode 100644 index 000000000..ba7e3b774 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java @@ -0,0 +1,232 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.sun.tools.javac.parser.JavaTokenizer; +import com.sun.tools.javac.parser.Scanner; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; +import com.sun.tools.javac.parser.Tokens.Token; +import com.sun.tools.javac.parser.Tokens.TokenKind; +import com.sun.tools.javac.parser.UnicodeReader; +import com.sun.tools.javac.util.Context; +import java.util.Set; + +/** A wrapper around javac's lexer. */ +class JavacTokens { + + /** The lexer eats terminal comments, so feed it one we don't care about. */ + // TODO(b/33103797): fix javac and remove the work-around + private static final CharSequence EOF_COMMENT = "\n//EOF"; + + /** An unprocessed input token, including whitespace and comments. */ + static class RawTok { + private final String stringVal; + private final TokenKind kind; + private final int pos; + private final int endPos; + + RawTok(String stringVal, TokenKind kind, int pos, int endPos) { + this.stringVal = stringVal; + this.kind = kind; + this.pos = pos; + this.endPos = endPos; + } + + /** The token kind, or {@code null} for whitespace and comments. */ + public TokenKind kind() { + return kind; + } + + /** The start position. */ + public int pos() { + return pos; + } + + /** The end position. */ + public int endPos() { + return endPos; + } + + /** The escaped string value of a literal, or {@code null} for other tokens. */ + public String stringVal() { + return stringVal; + } + } + + /** Lex the input and return a list of {@link RawTok}s. */ + public static ImmutableList getTokens( + String source, Context context, Set stopTokens) { + if (source == null) { + return ImmutableList.of(); + } + ScannerFactory fac = ScannerFactory.instance(context); + char[] buffer = (source + EOF_COMMENT).toCharArray(); + Scanner scanner = + new AccessibleScanner(fac, new CommentSavingTokenizer(fac, buffer, buffer.length)); + ImmutableList.Builder tokens = ImmutableList.builder(); + int end = source.length(); + int last = 0; + do { + scanner.nextToken(); + Token t = scanner.token(); + if (t.comments != null) { + for (Comment c : Lists.reverse(t.comments)) { + if (last < c.getSourcePos(0)) { + tokens.add(new RawTok(null, null, last, c.getSourcePos(0))); + } + tokens.add( + new RawTok(null, null, c.getSourcePos(0), c.getSourcePos(0) + c.getText().length())); + last = c.getSourcePos(0) + c.getText().length(); + } + } + if (stopTokens.contains(t.kind)) { + if (t.kind != TokenKind.EOF) { + end = t.pos; + } + break; + } + if (last < t.pos) { + tokens.add(new RawTok(null, null, last, t.pos)); + } + tokens.add( + new RawTok( + t.kind == TokenKind.STRINGLITERAL ? "\"" + t.stringVal() + "\"" : null, + t.kind, + t.pos, + t.endPos)); + last = t.endPos; + } while (scanner.token().kind != TokenKind.EOF); + if (last < end) { + tokens.add(new RawTok(null, null, last, end)); + } + return tokens.build(); + } + + /** A {@link JavaTokenizer} that saves comments. */ + static class CommentSavingTokenizer extends JavaTokenizer { + CommentSavingTokenizer(ScannerFactory fac, char[] buffer, int length) { + super(fac, buffer, length); + } + + @Override + protected Comment processComment(int pos, int endPos, CommentStyle style) { + char[] buf = getRawCharactersReflectively(pos, endPos); + return new CommentWithTextAndPosition( + pos, endPos, new AccessibleReader(fac, buf, buf.length), style); + } + + private char[] getRawCharactersReflectively(int beginIndex, int endIndex) { + Object instance; + try { + instance = JavaTokenizer.class.getDeclaredField("reader").get(this); + } catch (ReflectiveOperationException e) { + instance = this; + } + try { + return (char[]) + instance + .getClass() + .getMethod("getRawCharacters", int.class, int.class) + .invoke(instance, beginIndex, endIndex); + } catch (ReflectiveOperationException e) { + throw new LinkageError(e.getMessage(), e); + } + } + } + + /** A {@link Comment} that saves its text and start position. */ + static class CommentWithTextAndPosition implements Comment { + + private final int pos; + private final int endPos; + private final AccessibleReader reader; + private final CommentStyle style; + + private String text = null; + + public CommentWithTextAndPosition( + int pos, int endPos, AccessibleReader reader, CommentStyle style) { + this.pos = pos; + this.endPos = endPos; + this.reader = reader; + this.style = style; + } + + /** + * Returns the source position of the character at index {@code index} in the comment text. + * + *

The handling of javadoc comments in javac has more logic to skip over leading whitespace + * and '*' characters when indexing into doc comments, but we don't need any of that. + */ + @Override + public int getSourcePos(int index) { + checkArgument( + 0 <= index && index < (endPos - pos), + "Expected %s in the range [0, %s)", + index, + endPos - pos); + return pos + index; + } + + @Override + public CommentStyle getStyle() { + return style; + } + + @Override + public String getText() { + String text = this.text; + if (text == null) { + this.text = text = new String(reader.getRawCharacters()); + } + return text; + } + + /** + * We don't care about {@code @deprecated} javadoc tags (see the DepAnn check). + * + * @return false + */ + @Override + public boolean isDeprecated() { + return false; + } + + @Override + public String toString() { + return String.format("Comment: '%s'", getText()); + } + } + + // Scanner(ScannerFactory, JavaTokenizer) is package-private + static class AccessibleScanner extends Scanner { + protected AccessibleScanner(ScannerFactory fac, JavaTokenizer tokenizer) { + super(fac, tokenizer); + } + } + + // UnicodeReader(ScannerFactory, char[], int) is package-private + static class AccessibleReader extends UnicodeReader { + protected AccessibleReader(ScannerFactory fac, char[] buffer, int length) { + super(fac, buffer, length); + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java new file mode 100644 index 000000000..ff05dff91 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java @@ -0,0 +1,279 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static java.lang.Math.min; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Comparator.comparing; + +import com.google.common.io.ByteStreams; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.googlejavaformat.FormatterDiagnostic; +import com.google.googlejavaformat.java.JavaFormatterOptions.Style; +import java.io.IOError; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorCompletionService; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** The main class for the Java formatter CLI. */ +public final class Main { + private static final int MAX_THREADS = 20; + private static final String STDIN_FILENAME = ""; + + static String versionString() { + return "google-java-format: Version 4ade3471b7978af553f425bfc28b36c425e12a67"; + } + + private final PrintWriter outWriter; + private final PrintWriter errWriter; + private final InputStream inStream; + + public Main(PrintWriter outWriter, PrintWriter errWriter, InputStream inStream) { + this.outWriter = outWriter; + this.errWriter = errWriter; + this.inStream = inStream; + } + + /** + * The main method for the formatter, with some number of file names to format. We process them in + * parallel, but we must be careful; if multiple file names refer to the same file (which is hard + * to determine), we must serialize their updates. + * + * @param args the command-line arguments + */ + public static void main(String[] args) { + PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out, UTF_8)); + PrintWriter err = new PrintWriter(new OutputStreamWriter(System.err, UTF_8)); + int result = main(out, err, args); + System.exit(result); + } + + /** + * Package-private main entry point used this CLI program and the java.util.spi.ToolProvider + * implementation in the same package as this Main class. + */ + static int main(PrintWriter out, PrintWriter err, String... args) { + try { + Main formatter = new Main(out, err, System.in); + return formatter.format(args); + } catch (UsageException e) { + err.print(e.getMessage()); + // We return exit code 2 to differentiate usage issues from code formatting issues. + return 2; + } finally { + err.flush(); + out.flush(); + } + } + + /** + * The main entry point for the formatter, with some number of file names to format. We process + * them in parallel, but we must be careful; if multiple file names refer to the same file (which + * is hard to determine), we must serialize their update. + * + * @param args the command-line arguments + */ + public int format(String... args) throws UsageException { + CommandLineOptions parameters = processArgs(args); + if (parameters.version()) { + errWriter.println(versionString()); + return 0; + } + if (parameters.help()) { + throw new UsageException(); + } + + JavaFormatterOptions options = + JavaFormatterOptions.builder() + .style(parameters.aosp() ? Style.AOSP : Style.GOOGLE) + .formatJavadoc(parameters.formatJavadoc()) + .build(); + + if (parameters.stdin()) { + return formatStdin(parameters, options); + } else { + return formatFiles(parameters, options); + } + } + + private int formatFiles(CommandLineOptions parameters, JavaFormatterOptions options) { + int numThreads = min(MAX_THREADS, parameters.files().size()); + ExecutorService executorService = Executors.newFixedThreadPool(numThreads); + + ExecutorCompletionService cs = + new ExecutorCompletionService<>(executorService); + boolean allOk = true; + + int files = 0; + for (String fileName : parameters.files()) { + if (!fileName.endsWith(".java")) { + errWriter.println("Skipping non-Java file: " + fileName); + continue; + } + Path path = Paths.get(fileName); + try { + String input = new String(Files.readAllBytes(path), UTF_8); + cs.submit(new FormatFileCallable(parameters, path, input, options)); + files++; + } catch (IOException e) { + errWriter.println(fileName + ": could not read file: " + e.getMessage()); + allOk = false; + } + } + + List results = new ArrayList<>(); + while (files > 0) { + try { + files--; + results.add(cs.take().get()); + } catch (InterruptedException e) { + errWriter.println(e.getMessage()); + allOk = false; + continue; + } catch (ExecutionException e) { + errWriter.println("error: " + e.getCause().getMessage()); + e.getCause().printStackTrace(errWriter); + allOk = false; + continue; + } + } + Collections.sort(results, comparing(FormatFileCallable.Result::path)); + for (FormatFileCallable.Result result : results) { + Path path = result.path(); + if (result.exception() != null) { + for (FormatterDiagnostic diagnostic : result.exception().diagnostics()) { + errWriter.println(path + ":" + diagnostic); + } + allOk = false; + continue; + } + String formatted = result.output(); + boolean changed = result.changed(); + if (changed && parameters.setExitIfChanged()) { + allOk = false; + } + if (parameters.inPlace()) { + if (!changed) { + continue; // preserve original file + } + try { + Files.write(path, formatted.getBytes(UTF_8)); + } catch (IOException e) { + errWriter.println(path + ": could not write file: " + e.getMessage()); + allOk = false; + continue; + } + } else if (parameters.dryRun()) { + if (changed) { + outWriter.println(path); + } + } else { + outWriter.write(formatted); + } + } + if (!MoreExecutors.shutdownAndAwaitTermination(executorService, Duration.ofSeconds(5))) { + errWriter.println("Failed to shut down ExecutorService"); + allOk = false; + } + return allOk ? 0 : 1; + } + + private int formatStdin(CommandLineOptions parameters, JavaFormatterOptions options) { + String input; + try { + input = new String(ByteStreams.toByteArray(inStream), UTF_8); + } catch (IOException e) { + throw new IOError(e); + } + String stdinFilename = parameters.assumeFilename().orElse(STDIN_FILENAME); + boolean ok = true; + FormatFileCallable.Result result = + new FormatFileCallable(parameters, null, input, options).call(); + if (result.exception() != null) { + for (FormatterDiagnostic diagnostic : result.exception().diagnostics()) { + errWriter.println(stdinFilename + ":" + diagnostic); + } + ok = false; + } else { + String output = result.output(); + boolean changed = result.changed(); + if (changed && parameters.setExitIfChanged()) { + ok = false; + } + if (parameters.dryRun()) { + if (changed) { + outWriter.println(stdinFilename); + } + } else { + outWriter.write(output); + } + } + return ok ? 0 : 1; + } + + /** Parses and validates command-line flags. */ + public static CommandLineOptions processArgs(String... args) throws UsageException { + CommandLineOptions parameters; + try { + parameters = CommandLineOptionsParser.parse(Arrays.asList(args)); + } catch (IllegalArgumentException e) { + throw new UsageException(e.getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + throw new UsageException(t.getMessage()); + } + int filesToFormat = parameters.files().size(); + if (parameters.stdin()) { + filesToFormat++; + } + + if (parameters.inPlace() && parameters.files().isEmpty()) { + throw new UsageException("in-place formatting was requested but no files were provided"); + } + if (parameters.isSelection() && filesToFormat != 1) { + throw new UsageException("partial formatting is only support for a single file"); + } + if (parameters.offsets().size() != parameters.lengths().size()) { + throw new UsageException("-offsets and -lengths flags must be provided in matching pairs"); + } + if (filesToFormat <= 0 && !parameters.version() && !parameters.help()) { + throw new UsageException("no files were provided"); + } + if (parameters.stdin() && !parameters.files().isEmpty()) { + throw new UsageException("cannot format from standard input and files simultaneously"); + } + if (parameters.assumeFilename().isPresent() && !parameters.stdin()) { + throw new UsageException( + "--assume-filename is only supported when formatting standard input"); + } + if (parameters.dryRun() && parameters.inPlace()) { + throw new UsageException("cannot use --dry-run and --in-place at the same time"); + } + return parameters; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java new file mode 100644 index 000000000..e14b29036 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java @@ -0,0 +1,173 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package com.google.googlejavaformat.java; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Ordering; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeMap; +import com.google.googlejavaformat.Input.Tok; +import com.google.googlejavaformat.Input.Token; +import com.sun.tools.javac.parser.Tokens.TokenKind; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import javax.lang.model.element.Modifier; + +/** Fixes sequences of modifiers to be in JLS order. */ +final class ModifierOrderer { + + /** Reorders all modifiers in the given text to be in JLS order. */ + static JavaInput reorderModifiers(String text) throws FormatterException { + return reorderModifiers( + new JavaInput(text), ImmutableList.of(Range.closedOpen(0, text.length()))); + } + + /** + * Reorders all modifiers in the given text and within the given character ranges to be in JLS + * order. + */ + static JavaInput reorderModifiers(JavaInput javaInput, Collection> characterRanges) + throws FormatterException { + if (javaInput.getTokens().isEmpty()) { + // There weren't any tokens, possible because of a lexing error. + // Errors about invalid input will be reported later after parsing. + return javaInput; + } + RangeSet tokenRanges = javaInput.characterRangesToTokenRanges(characterRanges); + Iterator it = javaInput.getTokens().iterator(); + TreeRangeMap replacements = TreeRangeMap.create(); + while (it.hasNext()) { + Token token = it.next(); + if (!tokenRanges.contains(token.getTok().getIndex())) { + continue; + } + Modifier mod = asModifier(token); + if (mod == null) { + continue; + } + + List modifierTokens = new ArrayList<>(); + List mods = new ArrayList<>(); + + int begin = token.getTok().getPosition(); + mods.add(mod); + modifierTokens.add(token); + + int end = -1; + while (it.hasNext()) { + token = it.next(); + mod = asModifier(token); + if (mod == null) { + break; + } + mods.add(mod); + modifierTokens.add(token); + end = token.getTok().getPosition() + token.getTok().length(); + } + + if (!Ordering.natural().isOrdered(mods)) { + Collections.sort(mods); + StringBuilder replacement = new StringBuilder(); + for (int i = 0; i < mods.size(); i++) { + if (i > 0) { + addTrivia(replacement, modifierTokens.get(i).getToksBefore()); + } + replacement.append(mods.get(i)); + if (i < (modifierTokens.size() - 1)) { + addTrivia(replacement, modifierTokens.get(i).getToksAfter()); + } + } + replacements.put(Range.closedOpen(begin, end), replacement.toString()); + } + } + return applyReplacements(javaInput, replacements); + } + + private static void addTrivia(StringBuilder replacement, ImmutableList toks) { + for (Tok tok : toks) { + replacement.append(tok.getText()); + } + } + + /** + * Returns the given token as a {@link javax.lang.model.element.Modifier}, or {@code null} if it + * is not a modifier. + */ + private static Modifier asModifier(Token token) { + TokenKind kind = ((JavaInput.Tok) token.getTok()).kind(); + if (kind != null) { + switch (kind) { + case PUBLIC: + return Modifier.PUBLIC; + case PROTECTED: + return Modifier.PROTECTED; + case PRIVATE: + return Modifier.PRIVATE; + case ABSTRACT: + return Modifier.ABSTRACT; + case STATIC: + return Modifier.STATIC; + case DEFAULT: + return Modifier.DEFAULT; + case FINAL: + return Modifier.FINAL; + case TRANSIENT: + return Modifier.TRANSIENT; + case VOLATILE: + return Modifier.VOLATILE; + case SYNCHRONIZED: + return Modifier.SYNCHRONIZED; + case NATIVE: + return Modifier.NATIVE; + case STRICTFP: + return Modifier.STRICTFP; + default: // fall out + } + } + switch (token.getTok().getText()) { + case "non-sealed": + return Modifier.valueOf("NON_SEALED"); + case "sealed": + return Modifier.valueOf("SEALED"); + default: + return null; + } + } + + /** Applies replacements to the given string. */ + private static JavaInput applyReplacements( + JavaInput javaInput, TreeRangeMap replacementMap) throws FormatterException { + // process in descending order so the replacement ranges aren't perturbed if any replacements + // differ in size from the input + Map, String> ranges = replacementMap.asDescendingMapOfRanges(); + if (ranges.isEmpty()) { + return javaInput; + } + StringBuilder sb = new StringBuilder(javaInput.getText()); + for (Entry, String> entry : ranges.entrySet()) { + Range range = entry.getKey(); + sb.replace(range.lowerEndpoint(), range.upperEndpoint(), entry.getValue()); + } + return new JavaInput(sb.toString()); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java new file mode 100644 index 000000000..a0fc2f54a --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java @@ -0,0 +1,358 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.googlejavaformat.java; + +import static java.lang.Math.max; +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.google.common.base.CharMatcher; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; +import com.google.common.collect.Range; +import com.google.common.collect.RangeMap; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeMap; +import com.google.common.collect.TreeRangeSet; +import com.google.googlejavaformat.Newlines; +import com.sun.source.doctree.DocCommentTree; +import com.sun.source.doctree.ReferenceTree; +import com.sun.source.tree.CaseTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.ImportTree; +import com.sun.source.tree.Tree; +import com.sun.source.util.DocTreePath; +import com.sun.source.util.DocTreePathScanner; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.TreeScanner; +import com.sun.tools.javac.api.JavacTrees; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.parser.JavacParser; +import com.sun.tools.javac.parser.ParserFactory; +import com.sun.tools.javac.tree.DCTree; +import com.sun.tools.javac.tree.DCTree.DCReference; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.tree.JCTree.JCFieldAccess; +import com.sun.tools.javac.tree.JCTree.JCImport; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Options; +import java.io.IOError; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.DiagnosticListener; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardLocation; + +/** + * Removes unused imports from a source file. Imports that are only used in javadoc are also + * removed, and the references in javadoc are replaced with fully qualified names. + */ +public class RemoveUnusedImports { + + // Visits an AST, recording all simple names that could refer to imported + // types and also any javadoc references that could refer to imported + // types (`@link`, `@see`, `@throws`, etc.) + // + // No attempt is made to determine whether simple names occur in contexts + // where they are type names, so there will be false positives. For example, + // `List` is not identified as unused import below: + // + // ``` + // import java.util.List; + // class List {} + // ``` + // + // This is still reasonably effective in practice because type names differ + // from other kinds of names in casing convention, and simple name + // clashes between imported and declared types are rare. + private static class UnusedImportScanner extends TreePathScanner { + + private final Set usedNames = new LinkedHashSet<>(); + private final Multimap> usedInJavadoc = HashMultimap.create(); + final JavacTrees trees; + final DocTreeScanner docTreeSymbolScanner; + + private UnusedImportScanner(JavacTrees trees) { + this.trees = trees; + docTreeSymbolScanner = new DocTreeScanner(); + } + + /** Skip the imports themselves when checking for usage. */ + @Override + public Void visitImport(ImportTree importTree, Void usedSymbols) { + return null; + } + + @Override + public Void visitIdentifier(IdentifierTree tree, Void unused) { + if (tree == null) { + return null; + } + usedNames.add(tree.getName().toString()); + return null; + } + + // TODO(cushon): remove this override when pattern matching in switch is no longer a preview + // feature, and TreePathScanner visits CaseTree#getLabels instead of CaseTree#getExpressions + @SuppressWarnings("unchecked") // reflection + @Override + public Void visitCase(CaseTree tree, Void unused) { + if (CASE_TREE_GET_LABELS != null) { + try { + scan((List) CASE_TREE_GET_LABELS.invoke(tree), null); + } catch (ReflectiveOperationException e) { + throw new LinkageError(e.getMessage(), e); + } + } + return super.visitCase(tree, null); + } + + private static final Method CASE_TREE_GET_LABELS = caseTreeGetLabels(); + + private static Method caseTreeGetLabels() { + try { + return CaseTree.class.getMethod("getLabels"); + } catch (NoSuchMethodException e) { + return null; + } + } + + @Override + public Void scan(Tree tree, Void unused) { + if (tree == null) { + return null; + } + scanJavadoc(); + return super.scan(tree, unused); + } + + private void scanJavadoc() { + if (getCurrentPath() == null) { + return; + } + DocCommentTree commentTree = trees.getDocCommentTree(getCurrentPath()); + if (commentTree == null) { + return; + } + docTreeSymbolScanner.scan(new DocTreePath(getCurrentPath(), commentTree), null); + } + + // scan javadoc comments, checking for references to imported types + class DocTreeScanner extends DocTreePathScanner { + @Override + public Void visitIdentifier(com.sun.source.doctree.IdentifierTree node, Void aVoid) { + return null; + } + + @Override + public Void visitReference(ReferenceTree referenceTree, Void unused) { + DCReference reference = (DCReference) referenceTree; + long basePos = + reference + .pos((DCTree.DCDocComment) getCurrentPath().getDocComment()) + .getStartPosition(); + // the position of trees inside the reference node aren't stored, but the qualifier's + // start position is the beginning of the reference node + if (reference.qualifierExpression != null) { + new ReferenceScanner(basePos).scan(reference.qualifierExpression, null); + } + // Record uses inside method parameters. The javadoc tool doesn't use these, but + // IntelliJ does. + if (reference.paramTypes != null) { + for (JCTree param : reference.paramTypes) { + // TODO(cushon): get start positions for the parameters + new ReferenceScanner(-1).scan(param, null); + } + } + return null; + } + + // scans the qualifier and parameters of a javadoc reference for possible type names + private class ReferenceScanner extends TreeScanner { + private final long basePos; + + public ReferenceScanner(long basePos) { + this.basePos = basePos; + } + + @Override + public Void visitIdentifier(IdentifierTree node, Void aVoid) { + usedInJavadoc.put( + node.getName().toString(), + basePos != -1 + ? Range.closedOpen((int) basePos, (int) basePos + node.getName().length()) + : null); + return super.visitIdentifier(node, aVoid); + } + } + } + } + + public static String removeUnusedImports(final String contents) throws FormatterException { + Context context = new Context(); + JCCompilationUnit unit = parse(context, contents); + if (unit == null) { + // error handling is done during formatting + return contents; + } + UnusedImportScanner scanner = new UnusedImportScanner(JavacTrees.instance(context)); + scanner.scan(unit, null); + return applyReplacements( + contents, buildReplacements(contents, unit, scanner.usedNames, scanner.usedInJavadoc)); + } + + private static JCCompilationUnit parse(Context context, String javaInput) + throws FormatterException { + DiagnosticCollector diagnostics = new DiagnosticCollector<>(); + context.put(DiagnosticListener.class, diagnostics); + Options.instance(context).put("--enable-preview", "true"); + Options.instance(context).put("allowStringFolding", "false"); + JCCompilationUnit unit; + JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8); + try { + fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.of()); + } catch (IOException e) { + // impossible + throw new IOError(e); + } + SimpleJavaFileObject source = + new SimpleJavaFileObject(URI.create("source"), JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return javaInput; + } + }; + Log.instance(context).useSource(source); + ParserFactory parserFactory = ParserFactory.instance(context); + JavacParser parser = + parserFactory.newParser( + javaInput, + /* keepDocComments= */ true, + /* keepEndPos= */ true, + /* keepLineMap= */ true); + unit = parser.parseCompilationUnit(); + unit.sourcefile = source; + Iterable> errorDiagnostics = + Iterables.filter(diagnostics.getDiagnostics(), Formatter::errorDiagnostic); + if (!Iterables.isEmpty(errorDiagnostics)) { + // error handling is done during formatting + throw FormatterException.fromJavacDiagnostics(errorDiagnostics); + } + return unit; + } + + /** Construct replacements to fix unused imports. */ + private static RangeMap buildReplacements( + String contents, + JCCompilationUnit unit, + Set usedNames, + Multimap> usedInJavadoc) { + RangeMap replacements = TreeRangeMap.create(); + for (JCImport importTree : unit.getImports()) { + String simpleName = getSimpleName(importTree); + if (!isUnused(unit, usedNames, usedInJavadoc, importTree, simpleName)) { + continue; + } + // delete the import + int endPosition = importTree.getEndPosition(unit.endPositions); + endPosition = max(CharMatcher.isNot(' ').indexIn(contents, endPosition), endPosition); + String sep = Newlines.guessLineSeparator(contents); + if (endPosition + sep.length() < contents.length() + && contents.subSequence(endPosition, endPosition + sep.length()).toString().equals(sep)) { + endPosition += sep.length(); + } + replacements.put(Range.closedOpen(importTree.getStartPosition(), endPosition), ""); + } + return replacements; + } + + private static String getSimpleName(JCImport importTree) { + return getQualifiedIdentifier(importTree).getIdentifier().toString(); + } + + private static boolean isUnused( + JCCompilationUnit unit, + Set usedNames, + Multimap> usedInJavadoc, + JCImport importTree, + String simpleName) { + JCFieldAccess qualifiedIdentifier = getQualifiedIdentifier(importTree); + String qualifier = qualifiedIdentifier.getExpression().toString(); + if (qualifier.equals("java.lang")) { + return true; + } + if (unit.getPackageName() != null && unit.getPackageName().toString().equals(qualifier)) { + return true; + } + if (qualifiedIdentifier.getIdentifier().contentEquals("*")) { + return false; + } + + if (usedNames.contains(simpleName)) { + return false; + } + if (usedInJavadoc.containsKey(simpleName)) { + return false; + } + return true; + } + + private static JCFieldAccess getQualifiedIdentifier(JCImport importTree) { + // Use reflection because the return type is JCTree in some versions and JCFieldAccess in others + try { + return (JCFieldAccess) JCImport.class.getMethod("getQualifiedIdentifier").invoke(importTree); + } catch (ReflectiveOperationException e) { + throw new LinkageError(e.getMessage(), e); + } + } + + /** Applies the replacements to the given source, and re-format any edited javadoc. */ + private static String applyReplacements(String source, RangeMap replacements) { + // save non-empty fixed ranges for reformatting after fixes are applied + RangeSet fixedRanges = TreeRangeSet.create(); + + // Apply the fixes in increasing order, adjusting ranges to account for + // earlier fixes that change the length of the source. The output ranges are + // needed so we can reformat fixed regions, otherwise the fixes could just + // be applied in descending order without adjusting offsets. + StringBuilder sb = new StringBuilder(source); + int offset = 0; + for (Map.Entry, String> replacement : replacements.asMapOfRanges().entrySet()) { + Range range = replacement.getKey(); + String replaceWith = replacement.getValue(); + int start = offset + range.lowerEndpoint(); + int end = offset + range.upperEndpoint(); + sb.replace(start, end, replaceWith); + if (!replaceWith.isEmpty()) { + fixedRanges.add(Range.closedOpen(start, end)); + } + offset += replaceWith.length() - (range.upperEndpoint() - range.lowerEndpoint()); + } + return sb.toString(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Replacement.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Replacement.java new file mode 100644 index 000000000..5df0991f2 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Replacement.java @@ -0,0 +1,72 @@ +/* + * Copyright 2014 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.collect.Range; +import java.util.Objects; + +/** + * Represents a range in the original source and replacement text for that range. + * + *

google-java-format doesn't depend on AutoValue, to allow AutoValue to depend on + * google-java-format. + */ +public final class Replacement { + + public static Replacement create(int startPosition, int endPosition, String replaceWith) { + checkArgument(startPosition >= 0, "startPosition must be non-negative"); + checkArgument(startPosition <= endPosition, "startPosition cannot be after endPosition"); + return new Replacement(Range.closedOpen(startPosition, endPosition), replaceWith); + } + + private final Range replaceRange; + private final String replacementString; + + private Replacement(Range replaceRange, String replacementString) { + this.replaceRange = checkNotNull(replaceRange, "Null replaceRange"); + this.replacementString = checkNotNull(replacementString, "Null replacementString"); + } + + /** The range of characters in the original source to replace. */ + public Range getReplaceRange() { + return replaceRange; + } + + /** The string to replace the range of characters with. */ + public String getReplacementString() { + return replacementString; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof Replacement) { + Replacement that = (Replacement) o; + return replaceRange.equals(that.getReplaceRange()) + && replacementString.equals(that.getReplacementString()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(replaceRange, replacementString); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java new file mode 100644 index 000000000..8d426b65d --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java @@ -0,0 +1,215 @@ +/* + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static com.google.common.collect.ImmutableList.toImmutableList; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Preconditions; +import com.google.common.collect.DiscreteDomain; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeSet; +import java.util.ArrayList; +import java.util.List; + +/** Formats a subset of a compilation unit. */ +public class SnippetFormatter { + + /** The kind of snippet to format. */ + public enum SnippetKind { + COMPILATION_UNIT, + CLASS_BODY_DECLARATIONS, + STATEMENTS, + EXPRESSION + } + + private class SnippetWrapper { + int offset; + final StringBuilder contents = new StringBuilder(); + + public SnippetWrapper append(String str) { + contents.append(str); + return this; + } + + public SnippetWrapper appendSource(String source) { + this.offset = contents.length(); + contents.append(source); + return this; + } + + public void closeBraces(int initialIndent) { + for (int i = initialIndent; --i >= 0; ) { + contents.append("\n").append(createIndentationString(i)).append("}"); + } + } + } + + private static final int INDENTATION_SIZE = 2; + private final Formatter formatter = new Formatter(); + private static final CharMatcher NOT_WHITESPACE = CharMatcher.whitespace().negate(); + + public String createIndentationString(int indentationLevel) { + Preconditions.checkArgument( + indentationLevel >= 0, + "Indentation level cannot be less than zero. Given: %s", + indentationLevel); + int spaces = indentationLevel * INDENTATION_SIZE; + StringBuilder buf = new StringBuilder(spaces); + for (int i = 0; i < spaces; i++) { + buf.append(' '); + } + return buf.toString(); + } + + private static Range offsetRange(Range range, int offset) { + range = range.canonical(DiscreteDomain.integers()); + return Range.closedOpen(range.lowerEndpoint() + offset, range.upperEndpoint() + offset); + } + + private static List> offsetRanges(List> ranges, int offset) { + List> result = new ArrayList<>(); + for (Range range : ranges) { + result.add(offsetRange(range, offset)); + } + return result; + } + + /** Runs the Google Java formatter on the given source, with only the given ranges specified. */ + public ImmutableList format( + SnippetKind kind, + String source, + List> ranges, + int initialIndent, + boolean includeComments) + throws FormatterException { + RangeSet rangeSet = TreeRangeSet.create(); + for (Range range : ranges) { + rangeSet.add(range); + } + if (includeComments) { + if (kind != SnippetKind.COMPILATION_UNIT) { + throw new IllegalArgumentException( + "comment formatting is only supported for compilation units"); + } + return formatter.getFormatReplacements(source, ranges); + } + SnippetWrapper wrapper = snippetWrapper(kind, source, initialIndent); + ranges = offsetRanges(ranges, wrapper.offset); + + String replacement = formatter.formatSource(wrapper.contents.toString(), ranges); + replacement = + replacement.substring( + wrapper.offset, + replacement.length() - (wrapper.contents.length() - wrapper.offset - source.length())); + + return toReplacements(source, replacement).stream() + .filter(r -> rangeSet.encloses(r.getReplaceRange())) + .collect(toImmutableList()); + } + + /** + * Generates {@code Replacement}s rewriting {@code source} to {@code replacement}, under the + * assumption that they differ in whitespace alone. + */ + private static List toReplacements(String source, String replacement) { + if (!NOT_WHITESPACE.retainFrom(source).equals(NOT_WHITESPACE.retainFrom(replacement))) { + throw new IllegalArgumentException( + "source = \"" + source + "\", replacement = \"" + replacement + "\""); + } + /* + * In the past we seemed to have problems touching non-whitespace text in the formatter, even + * just replacing some code with itself. Retrospective attempts to reproduce this have failed, + * but this may be an issue for future changes. + */ + List replacements = new ArrayList<>(); + int i = NOT_WHITESPACE.indexIn(source); + int j = NOT_WHITESPACE.indexIn(replacement); + if (i != 0 || j != 0) { + replacements.add(Replacement.create(0, i, replacement.substring(0, j))); + } + while (i != -1 && j != -1) { + int i2 = NOT_WHITESPACE.indexIn(source, i + 1); + int j2 = NOT_WHITESPACE.indexIn(replacement, j + 1); + if (i2 == -1 || j2 == -1) { + break; + } + if ((i2 - i) != (j2 - j) + || !source.substring(i + 1, i2).equals(replacement.substring(j + 1, j2))) { + replacements.add(Replacement.create(i + 1, i2, replacement.substring(j + 1, j2))); + } + i = i2; + j = j2; + } + return replacements; + } + + private SnippetWrapper snippetWrapper(SnippetKind kind, String source, int initialIndent) { + /* + * Synthesize a dummy class around the code snippet provided by Eclipse. The dummy class is + * correctly formatted -- the blocks use correct indentation, etc. + */ + switch (kind) { + case COMPILATION_UNIT: + { + SnippetWrapper wrapper = new SnippetWrapper(); + for (int i = 1; i <= initialIndent; i++) { + wrapper.append("class Dummy {\n").append(createIndentationString(i)); + } + wrapper.appendSource(source); + wrapper.closeBraces(initialIndent); + return wrapper; + } + case CLASS_BODY_DECLARATIONS: + { + SnippetWrapper wrapper = new SnippetWrapper(); + for (int i = 1; i <= initialIndent; i++) { + wrapper.append("class Dummy {\n").append(createIndentationString(i)); + } + wrapper.appendSource(source); + wrapper.closeBraces(initialIndent); + return wrapper; + } + case STATEMENTS: + { + SnippetWrapper wrapper = new SnippetWrapper(); + wrapper.append("class Dummy {\n").append(createIndentationString(1)); + for (int i = 2; i <= initialIndent; i++) { + wrapper.append("{\n").append(createIndentationString(i)); + } + wrapper.appendSource(source); + wrapper.closeBraces(initialIndent); + return wrapper; + } + case EXPRESSION: + { + SnippetWrapper wrapper = new SnippetWrapper(); + wrapper.append("class Dummy {\n").append(createIndentationString(1)); + for (int i = 2; i <= initialIndent; i++) { + wrapper.append("{\n").append(createIndentationString(i)); + } + wrapper.append("Object o = "); + wrapper.appendSource(source); + wrapper.append(";"); + wrapper.closeBraces(initialIndent); + return wrapper; + } + default: + throw new IllegalArgumentException("Unknown snippet kind: " + kind); + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java new file mode 100644 index 000000000..d801c9b86 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java @@ -0,0 +1,431 @@ +/* + * Copyright 2019 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static com.google.common.collect.Iterables.getLast; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.stream.Collectors.joining; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Strings; +import com.google.common.base.Verify; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.common.collect.Range; +import com.google.common.collect.TreeRangeMap; +import com.google.googlejavaformat.Newlines; +import com.sun.source.tree.BinaryTree; +import com.sun.source.tree.LiteralTree; +import com.sun.source.tree.MemberSelectTree; +import com.sun.source.tree.Tree; +import com.sun.source.tree.Tree.Kind; +import com.sun.source.util.TreePath; +import com.sun.source.util.TreePathScanner; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.parser.JavacParser; +import com.sun.tools.javac.parser.ParserFactory; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Options; +import com.sun.tools.javac.util.Position; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.net.URI; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.DiagnosticListener; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardLocation; + +/** Wraps string literals that exceed the column limit. */ +public final class StringWrapper { + /** Reflows long string literals in the given Java source code. */ + public static String wrap(String input, Formatter formatter) throws FormatterException { + return StringWrapper.wrap(Formatter.MAX_LINE_LENGTH, input, formatter); + } + + /** + * Reflows string literals in the given Java source code that extend past the given column limit. + */ + static String wrap(final int columnLimit, String input, Formatter formatter) + throws FormatterException { + if (!longLines(columnLimit, input)) { + // fast path + return input; + } + + TreeRangeMap replacements = getReflowReplacements(columnLimit, input); + String firstPass = formatter.formatSource(input, replacements.asMapOfRanges().keySet()); + + if (!firstPass.equals(input)) { + // If formatting the replacement ranges resulted in a change, recalculate the replacements on + // the updated input. + input = firstPass; + replacements = getReflowReplacements(columnLimit, input); + } + + String result = applyReplacements(input, replacements); + + { + // We really don't want bugs in this pass to change the behaviour of programs we're + // formatting, so check that the pretty-printed AST is the same before and after reformatting. + String expected = parse(input, /* allowStringFolding= */ true).toString(); + String actual = parse(result, /* allowStringFolding= */ true).toString(); + if (!expected.equals(actual)) { + throw new FormatterException( + String.format( + "Something has gone terribly wrong. We planned to make the below formatting change," + + " but have aborted because it would unexpectedly change the AST.\n" + + "Please file a bug: " + + "https://github.com/google/google-java-format/issues/new" + + "\n\n=== Actual: ===\n%s\n=== Expected: ===\n%s\n", + actual, expected)); + } + } + + return result; + } + + private static TreeRangeMap getReflowReplacements( + int columnLimit, final String input) throws FormatterException { + JCTree.JCCompilationUnit unit = parse(input, /* allowStringFolding= */ false); + String separator = Newlines.guessLineSeparator(input); + + // Paths to string literals that extend past the column limit. + List toFix = new ArrayList<>(); + final Position.LineMap lineMap = unit.getLineMap(); + new TreePathScanner() { + @Override + public Void visitLiteral(LiteralTree literalTree, Void aVoid) { + if (literalTree.getKind() != Kind.STRING_LITERAL) { + return null; + } + Tree parent = getCurrentPath().getParentPath().getLeaf(); + if (parent instanceof MemberSelectTree + && ((MemberSelectTree) parent).getExpression().equals(literalTree)) { + return null; + } + int endPosition = getEndPosition(unit, literalTree); + int lineEnd = endPosition; + while (Newlines.hasNewlineAt(input, lineEnd) == -1) { + lineEnd++; + } + if (lineMap.getColumnNumber(lineEnd) - 1 <= columnLimit) { + return null; + } + toFix.add(getCurrentPath()); + return null; + } + }.scan(new TreePath(unit), null); + + TreeRangeMap replacements = TreeRangeMap.create(); + for (TreePath path : toFix) { + // Find the outermost contiguous enclosing concatenation expression + TreePath enclosing = path; + while (enclosing.getParentPath().getLeaf().getKind() == Tree.Kind.PLUS) { + enclosing = enclosing.getParentPath(); + } + // Is the literal being wrapped the first in a chain of concatenation expressions? + // i.e. `ONE + TWO + THREE` + // We need this information to handle continuation indents. + AtomicBoolean first = new AtomicBoolean(false); + // Finds the set of string literals in the concat expression that includes the one that needs + // to be wrapped. + List flat = flatten(input, unit, path, enclosing, first); + // Zero-indexed start column + int startColumn = lineMap.getColumnNumber(getStartPosition(flat.get(0))) - 1; + + // Handling leaving trailing non-string tokens at the end of the literal, + // e.g. the trailing `);` in `foo("...");`. + int end = getEndPosition(unit, getLast(flat)); + int lineEnd = end; + while (Newlines.hasNewlineAt(input, lineEnd) == -1) { + lineEnd++; + } + int trailing = lineEnd - end; + + // Get the original source text of the string literals, excluding `"` and `+`. + ImmutableList components = stringComponents(input, unit, flat); + replacements.put( + Range.closedOpen(getStartPosition(flat.get(0)), getEndPosition(unit, getLast(flat))), + reflow(separator, columnLimit, startColumn, trailing, components, first.get())); + } + return replacements; + } + + /** + * Returns the source text of the given string literal trees, excluding the leading and trailing + * double-quotes and the `+` operator. + */ + private static ImmutableList stringComponents( + String input, JCTree.JCCompilationUnit unit, List flat) { + ImmutableList.Builder result = ImmutableList.builder(); + StringBuilder piece = new StringBuilder(); + for (Tree tree : flat) { + // adjust for leading and trailing double quotes + String text = input.substring(getStartPosition(tree) + 1, getEndPosition(unit, tree) - 1); + int start = 0; + for (int idx = 0; idx < text.length(); idx++) { + if (CharMatcher.whitespace().matches(text.charAt(idx))) { + // continue below + } else if (hasEscapedWhitespaceAt(text, idx) != -1) { + // continue below + } else if (hasEscapedNewlineAt(text, idx) != -1) { + int length; + while ((length = hasEscapedNewlineAt(text, idx)) != -1) { + idx += length; + } + } else { + continue; + } + piece.append(text, start, idx); + result.add(piece.toString()); + piece = new StringBuilder(); + start = idx; + } + if (piece.length() > 0) { + result.add(piece.toString()); + piece = new StringBuilder(); + } + if (start < text.length()) { + piece.append(text, start, text.length()); + } + } + if (piece.length() > 0) { + result.add(piece.toString()); + } + return result.build(); + } + + static int hasEscapedWhitespaceAt(String input, int idx) { + return Stream.of("\\t") + .mapToInt(x -> input.startsWith(x, idx) ? x.length() : -1) + .filter(x -> x != -1) + .findFirst() + .orElse(-1); + } + + static int hasEscapedNewlineAt(String input, int idx) { + return Stream.of("\\r\\n", "\\r", "\\n") + .mapToInt(x -> input.startsWith(x, idx) ? x.length() : -1) + .filter(x -> x != -1) + .findFirst() + .orElse(-1); + } + + /** + * Reflows the given source text, trying to split on word boundaries. + * + * @param separator the line separator + * @param columnLimit the number of columns to wrap at + * @param startColumn the column position of the beginning of the original text + * @param trailing extra space to leave after the last line, to accommodate a ; or ) + * @param components the text to reflow. This is a list of “words†of a single literal. Its first + * and last quotes have been stripped + * @param first0 true if the text includes the beginning of its enclosing concat chain + */ + private static String reflow( + String separator, + int columnLimit, + int startColumn, + int trailing, + ImmutableList components, + boolean first0) { + // We have space between the start column and the limit to output the first line. + // Reserve two spaces for the start and end quotes. + int width = columnLimit - startColumn - 2; + Deque input = new ArrayDeque<>(components); + List lines = new ArrayList<>(); + boolean first = first0; + while (!input.isEmpty()) { + int length = 0; + List line = new ArrayList<>(); + // If we know this is going to be the last line, then remove a bit of width to account for the + // trailing characters. + if (input.stream().mapToInt(String::length).sum() <= width) { + // This isn’t quite optimal, but arguably good enough. See b/179561701 + width -= trailing; + } + while (!input.isEmpty() && (length <= 4 || (length + input.peekFirst().length()) <= width)) { + String text = input.removeFirst(); + line.add(text); + length += text.length(); + if (text.endsWith("\\n") || text.endsWith("\\r")) { + break; + } + } + if (line.isEmpty()) { + line.add(input.removeFirst()); + } + // add the split line to the output, and process whatever's left + lines.add(String.join("", line)); + if (first) { + width -= 6; // subsequent lines have a four-space continuation indent and a `+ ` + first = false; + } + } + + return lines.stream() + .collect( + joining( + "\"" + separator + Strings.repeat(" ", startColumn + (first0 ? 4 : -2)) + "+ \"", + "\"", + "\"")); + } + + /** + * Flattens the given binary expression tree, and extracts the subset that contains the given path + * and any adjacent nodes that are also string literals. + */ + private static List flatten( + String input, + JCTree.JCCompilationUnit unit, + TreePath path, + TreePath parent, + AtomicBoolean firstInChain) { + List flat = new ArrayList<>(); + + // flatten the expression tree with a pre-order traversal + ArrayDeque todo = new ArrayDeque<>(); + todo.add(parent.getLeaf()); + while (!todo.isEmpty()) { + Tree first = todo.removeFirst(); + if (first.getKind() == Tree.Kind.PLUS) { + BinaryTree bt = (BinaryTree) first; + todo.addFirst(bt.getRightOperand()); + todo.addFirst(bt.getLeftOperand()); + } else { + flat.add(first); + } + } + + int idx = flat.indexOf(path.getLeaf()); + Verify.verify(idx != -1); + + // walk outwards from the leaf for adjacent string literals to also reflow + int startIdx = idx; + int endIdx = idx + 1; + while (startIdx > 0 + && flat.get(startIdx - 1).getKind() == Tree.Kind.STRING_LITERAL + && noComments(input, unit, flat.get(startIdx - 1), flat.get(startIdx))) { + startIdx--; + } + while (endIdx < flat.size() + && flat.get(endIdx).getKind() == Tree.Kind.STRING_LITERAL + && noComments(input, unit, flat.get(endIdx - 1), flat.get(endIdx))) { + endIdx++; + } + + firstInChain.set(startIdx == 0); + return ImmutableList.copyOf(flat.subList(startIdx, endIdx)); + } + + private static boolean noComments( + String input, JCTree.JCCompilationUnit unit, Tree one, Tree two) { + return STRING_CONCAT_DELIMITER.matchesAllOf( + input.subSequence(getEndPosition(unit, one), getStartPosition(two))); + } + + public static final CharMatcher STRING_CONCAT_DELIMITER = + CharMatcher.whitespace().or(CharMatcher.anyOf("\"+")); + + private static int getEndPosition(JCTree.JCCompilationUnit unit, Tree tree) { + return ((JCTree) tree).getEndPosition(unit.endPositions); + } + + private static int getStartPosition(Tree tree) { + return ((JCTree) tree).getStartPosition(); + } + + /** Returns true if any lines in the given Java source exceed the column limit. */ + private static boolean longLines(int columnLimit, String input) { + // TODO(cushon): consider adding Newlines.lineIterable? + Iterator it = Newlines.lineIterator(input); + while (it.hasNext()) { + String line = it.next(); + if (line.length() > columnLimit) { + return true; + } + } + return false; + } + + /** Parses the given Java source. */ + private static JCTree.JCCompilationUnit parse(String source, boolean allowStringFolding) + throws FormatterException { + DiagnosticCollector diagnostics = new DiagnosticCollector<>(); + Context context = new Context(); + context.put(DiagnosticListener.class, diagnostics); + Options.instance(context).put("--enable-preview", "true"); + Options.instance(context).put("allowStringFolding", Boolean.toString(allowStringFolding)); + JCTree.JCCompilationUnit unit; + JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8); + try { + fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.of()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + SimpleJavaFileObject sjfo = + new SimpleJavaFileObject(URI.create("source"), JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + }; + Log.instance(context).useSource(sjfo); + ParserFactory parserFactory = ParserFactory.instance(context); + JavacParser parser = + parserFactory.newParser( + source, /* keepDocComments= */ true, /* keepEndPos= */ true, /* keepLineMap= */ true); + unit = parser.parseCompilationUnit(); + unit.sourcefile = sjfo; + Iterable> errorDiagnostics = + Iterables.filter(diagnostics.getDiagnostics(), Formatter::errorDiagnostic); + if (!Iterables.isEmpty(errorDiagnostics)) { + // error handling is done during formatting + throw FormatterException.fromJavacDiagnostics(errorDiagnostics); + } + return unit; + } + + /** Applies replacements to the given string. */ + private static String applyReplacements( + String javaInput, TreeRangeMap replacementMap) throws FormatterException { + // process in descending order so the replacement ranges aren't perturbed if any replacements + // differ in size from the input + Map, String> ranges = replacementMap.asDescendingMapOfRanges(); + if (ranges.isEmpty()) { + return javaInput; + } + StringBuilder sb = new StringBuilder(javaInput); + for (Map.Entry, String> entry : ranges.entrySet()) { + Range range = entry.getKey(); + sb.replace(range.lowerEndpoint(), range.upperEndpoint(), entry.getValue()); + } + return sb.toString(); + } + + private StringWrapper() {} +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java new file mode 100644 index 000000000..397dacae6 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java @@ -0,0 +1,118 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompoundAssignmentTree; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.MemberSelectTree; +import com.sun.source.tree.MethodInvocationTree; +import com.sun.source.tree.ParenthesizedTree; +import com.sun.source.tree.Tree; +import com.sun.source.util.TreePath; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.Pretty; +import com.sun.tools.javac.tree.TreeInfo; +import java.io.IOError; +import java.io.IOException; +import javax.lang.model.element.Name; + +/** Utilities for working with {@link Tree}s. */ +class Trees { + /** Returns the length of the source for the node. */ + static int getLength(Tree tree, TreePath path) { + return getEndPosition(tree, path) - getStartPosition(tree); + } + + /** Returns the source start position of the node. */ + static int getStartPosition(Tree expression) { + return ((JCTree) expression).getStartPosition(); + } + + /** Returns the source end position of the node. */ + static int getEndPosition(Tree expression, TreePath path) { + return ((JCTree) expression) + .getEndPosition(((JCTree.JCCompilationUnit) path.getCompilationUnit()).endPositions); + } + + /** Returns the source text for the node. */ + static String getSourceForNode(Tree node, TreePath path) { + CharSequence source; + try { + source = path.getCompilationUnit().getSourceFile().getCharContent(false); + } catch (IOException e) { + throw new IOError(e); + } + return source.subSequence(getStartPosition(node), getEndPosition(node, path)).toString(); + } + + /** Returns the simple name of a (possibly qualified) method invocation expression. */ + static Name getMethodName(MethodInvocationTree methodInvocation) { + ExpressionTree select = methodInvocation.getMethodSelect(); + return select instanceof MemberSelectTree + ? ((MemberSelectTree) select).getIdentifier() + : ((IdentifierTree) select).getName(); + } + + /** Returns the receiver of a qualified method invocation expression, or {@code null}. */ + static ExpressionTree getMethodReceiver(MethodInvocationTree methodInvocation) { + ExpressionTree select = methodInvocation.getMethodSelect(); + return select instanceof MemberSelectTree ? ((MemberSelectTree) select).getExpression() : null; + } + + /** Returns the string name of an operator, including assignment and compound assignment. */ + static String operatorName(ExpressionTree expression) { + JCTree.Tag tag = ((JCTree) expression).getTag(); + if (tag == JCTree.Tag.ASSIGN) { + return "="; + } + boolean assignOp = expression instanceof CompoundAssignmentTree; + if (assignOp) { + tag = tag.noAssignOp(); + } + String name = new Pretty(/*writer*/ null, /*sourceOutput*/ true).operatorName(tag); + return assignOp ? name + "=" : name; + } + + /** Returns the precedence of an expression's operator. */ + static int precedence(ExpressionTree expression) { + return TreeInfo.opPrec(((JCTree) expression).getTag()); + } + + /** + * Returns the enclosing type declaration (class, enum, interface, or annotation) for the given + * path. + */ + static ClassTree getEnclosingTypeDeclaration(TreePath path) { + for (; path != null; path = path.getParentPath()) { + switch (path.getLeaf().getKind()) { + case CLASS: + case ENUM: + case INTERFACE: + case ANNOTATED_TYPE: + return (ClassTree) path.getLeaf(); + default: + break; + } + } + throw new AssertionError(); + } + + /** Skips a single parenthesized tree. */ + static ExpressionTree skipParen(ExpressionTree node) { + return ((ParenthesizedTree) node).getExpression(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/TypeNameClassifier.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/TypeNameClassifier.java new file mode 100644 index 000000000..21fae5f03 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/TypeNameClassifier.java @@ -0,0 +1,173 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import com.google.common.base.Verify; +import java.util.List; +import java.util.Optional; + +/** Heuristics for classifying qualified names as types. */ +public final class TypeNameClassifier { + + private TypeNameClassifier() {} + + /** A state machine for classifying qualified names. */ + private enum TyParseState { + + /** The start state. */ + START(false) { + @Override + public TyParseState next(JavaCaseFormat n) { + switch (n) { + case UPPERCASE: + // if we see an UpperCamel later, assume this was a class + // e.g. com.google.FOO.Bar + return TyParseState.AMBIGUOUS; + case LOWER_CAMEL: + return TyParseState.REJECT; + case LOWERCASE: + // could be a package + return TyParseState.START; + case UPPER_CAMEL: + return TyParseState.TYPE; + } + throw new AssertionError(); + } + }, + + /** The current prefix is a type. */ + TYPE(true) { + @Override + public TyParseState next(JavaCaseFormat n) { + switch (n) { + case UPPERCASE: + case LOWER_CAMEL: + case LOWERCASE: + return TyParseState.FIRST_STATIC_MEMBER; + case UPPER_CAMEL: + return TyParseState.TYPE; + } + throw new AssertionError(); + } + }, + + /** The current prefix is a type, followed by a single static member access. */ + FIRST_STATIC_MEMBER(true) { + @Override + public TyParseState next(JavaCaseFormat n) { + return TyParseState.REJECT; + } + }, + + /** Anything not represented by one of the other states. */ + REJECT(false) { + @Override + public TyParseState next(JavaCaseFormat n) { + return TyParseState.REJECT; + } + }, + + /** An ambiguous type prefix. */ + AMBIGUOUS(false) { + @Override + public TyParseState next(JavaCaseFormat n) { + switch (n) { + case UPPERCASE: + return AMBIGUOUS; + case LOWER_CAMEL: + case LOWERCASE: + return TyParseState.REJECT; + case UPPER_CAMEL: + return TyParseState.TYPE; + } + throw new AssertionError(); + } + }; + + private final boolean isSingleUnit; + + TyParseState(boolean isSingleUnit) { + this.isSingleUnit = isSingleUnit; + } + + public boolean isSingleUnit() { + return isSingleUnit; + } + + /** Transition function. */ + public abstract TyParseState next(JavaCaseFormat n); + } + + /** + * Returns the end index (inclusive) of the longest prefix that matches the naming conventions of + * a type or static field access, or -1 if no such prefix was found. + * + *

Examples: + * + *

    + *
  • ClassName + *
  • ClassName.staticMemberName + *
  • com.google.ClassName.InnerClass.staticMemberName + *
+ */ + static Optional typePrefixLength(List nameParts) { + TyParseState state = TyParseState.START; + Optional typeLength = Optional.empty(); + for (int i = 0; i < nameParts.size(); i++) { + state = state.next(JavaCaseFormat.from(nameParts.get(i))); + if (state == TyParseState.REJECT) { + break; + } + if (state.isSingleUnit()) { + typeLength = Optional.of(i); + } + } + return typeLength; + } + + /** Case formats used in Java identifiers. */ + public enum JavaCaseFormat { + UPPERCASE, + LOWERCASE, + UPPER_CAMEL, + LOWER_CAMEL; + + /** Classifies an identifier's case format. */ + static JavaCaseFormat from(String name) { + Verify.verify(!name.isEmpty()); + boolean firstUppercase = false; + boolean hasUppercase = false; + boolean hasLowercase = false; + boolean first = true; + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (!Character.isAlphabetic(c)) { + continue; + } + if (first) { + firstUppercase = Character.isUpperCase(c); + first = false; + } + hasUppercase |= Character.isUpperCase(c); + hasLowercase |= Character.isLowerCase(c); + } + if (firstUppercase) { + return (hasLowercase || name.length() == 1) ? UPPER_CAMEL : UPPERCASE; + } else { + return hasUppercase ? LOWER_CAMEL : LOWERCASE; + } + } + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/UsageException.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/UsageException.java new file mode 100644 index 000000000..a10f2d076 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/UsageException.java @@ -0,0 +1,108 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Joiner; + +/** Checked exception class for formatter command-line usage errors. */ +final class UsageException extends Exception { + + private static final Joiner NEWLINE_JOINER = Joiner.on(System.lineSeparator()); + + private static final String[] DOCS_LINK = { + "https://github.com/google/google-java-format", + }; + + private static final String[] USAGE = { + "", + "Usage: google-java-format [options] file(s)", + "", + "Options:", + " -i, -r, -replace, --replace", + " Send formatted output back to files, not stdout.", + " -", + " Format stdin -> stdout", + " --assume-filename, -assume-filename", + " File name to use for diagnostics when formatting standard input (default is ).", + " --aosp, -aosp, -a", + " Use AOSP style instead of Google Style (4-space indentation).", + " --fix-imports-only", + " Fix import order and remove any unused imports, but do no other formatting.", + " --skip-sorting-imports", + " Do not fix the import order. Unused imports will still be removed.", + " --skip-removing-unused-imports", + " Do not remove unused imports. Imports will still be sorted.", + " --skip-reflowing-long-strings", + " Do not reflow string literals that exceed the column limit.", + " --skip-javadoc-formatting", + " Do not reformat javadoc.", + " --dry-run, -n", + " Prints the paths of the files whose contents would change if the formatter were run" + + " normally.", + " --set-exit-if-changed", + " Return exit code 1 if there are any formatting changes.", + " --lines, -lines, --line, -line", + " Line range(s) to format, like 5:10 (1-based; default is all).", + " --offset, -offset", + " Character offset to format (0-based; default is all).", + " --length, -length", + " Character length to format.", + " --help, -help, -h", + " Print this usage statement.", + " --version, -version, -v", + " Print the version.", + " @", + " Read options and filenames from file.", + "", + }; + + private static final String[] ADDITIONAL_USAGE = { + "If -i is given with -, the result is sent to stdout.", + "The --lines, --offset, and --length flags may be given more than once.", + "The --offset and --length flags must be given an equal number of times.", + "If --lines, --offset, or --length are given, only one file (or -) may be given." + }; + + UsageException() { + super(buildMessage(null)); + } + + UsageException(String message) { + super(buildMessage(checkNotNull(message))); + } + + private static String buildMessage(String message) { + StringBuilder builder = new StringBuilder(); + if (message != null) { + builder.append(message).append('\n'); + } + appendLines(builder, USAGE); + appendLines(builder, ADDITIONAL_USAGE); + appendLines(builder, new String[] {""}); + appendLine(builder, Main.versionString()); + appendLines(builder, DOCS_LINK); + return builder.toString(); + } + + private static void appendLine(StringBuilder builder, String line) { + builder.append(line).append(System.lineSeparator()); + } + + private static void appendLines(StringBuilder builder, String[] lines) { + NEWLINE_JOINER.appendTo(builder, lines).append(System.lineSeparator()); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java new file mode 100644 index 000000000..d38d84eca --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java @@ -0,0 +1,86 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.filer; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.googlejavaformat.java.Formatter; +import java.io.IOException; +import javax.annotation.processing.Filer; +import javax.annotation.processing.Messager; +import javax.lang.model.element.Element; +import javax.tools.FileObject; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** + * A decorating {@link Filer} implementation which formats Java source files with a {@link + * Formatter}. + */ +public final class FormattingFiler implements Filer { + + private final Filer delegate; + // TODO(ronshapiro): consider allowing users to create their own Formatter instance + private final Formatter formatter = new Formatter(); + private final Messager messager; + + /** @param delegate filer to decorate */ + public FormattingFiler(Filer delegate) { + this(delegate, null); + } + + /** + * Create a new {@link FormattingFiler}. An optional {@link Messager} may be specified to make + * logs more visible. + * + * @param delegate filer to decorate + * @param messager to log warnings to + */ + public FormattingFiler(Filer delegate, @Nullable Messager messager) { + this.delegate = checkNotNull(delegate); + this.messager = messager; + } + + @Override + public JavaFileObject createSourceFile(CharSequence name, Element... originatingElements) + throws IOException { + return new FormattingJavaFileObject( + delegate.createSourceFile(name, originatingElements), formatter, messager); + } + + @Override + public JavaFileObject createClassFile(CharSequence name, Element... originatingElements) + throws IOException { + return delegate.createClassFile(name, originatingElements); + } + + @Override + public FileObject createResource( + JavaFileManager.Location location, + CharSequence pkg, + CharSequence relativeName, + Element... originatingElements) + throws IOException { + return delegate.createResource(location, pkg, relativeName, originatingElements); + } + + @Override + public FileObject getResource( + JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName) + throws IOException { + return delegate.getResource(location, pkg, relativeName); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java new file mode 100644 index 000000000..c8ae80769 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java @@ -0,0 +1,94 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.filer; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.io.CharSink; +import com.google.common.io.CharSource; +import com.google.googlejavaformat.java.Formatter; +import com.google.googlejavaformat.java.FormatterException; +import java.io.IOException; +import java.io.Writer; +import javax.annotation.processing.Messager; +import javax.tools.Diagnostic; +import javax.tools.ForwardingJavaFileObject; +import javax.tools.JavaFileObject; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** A {@link JavaFileObject} decorator which {@linkplain Formatter formats} source code. */ +final class FormattingJavaFileObject extends ForwardingJavaFileObject { + /** A rough estimate of the average file size: 80 chars per line, 500 lines. */ + private static final int DEFAULT_FILE_SIZE = 80 * 500; + + private final Formatter formatter; + private final Messager messager; + + /** + * Create a new {@link FormattingJavaFileObject}. + * + * @param delegate {@link JavaFileObject} to decorate + * @param messager to log messages with. + */ + FormattingJavaFileObject( + JavaFileObject delegate, Formatter formatter, @Nullable Messager messager) { + super(checkNotNull(delegate)); + this.formatter = checkNotNull(formatter); + this.messager = messager; + } + + @Override + public Writer openWriter() throws IOException { + final StringBuilder stringBuilder = new StringBuilder(DEFAULT_FILE_SIZE); + return new Writer() { + @Override + public void write(char[] chars, int start, int end) throws IOException { + stringBuilder.append(chars, start, end - start); + } + + @Override + public void write(String string) throws IOException { + stringBuilder.append(string); + } + + @Override + public void flush() throws IOException {} + + @Override + public void close() throws IOException { + try { + formatter.formatSource( + CharSource.wrap(stringBuilder), + new CharSink() { + @Override + public Writer openStream() throws IOException { + return fileObject.openWriter(); + } + }); + } catch (FormatterException e) { + // An exception will happen when the code being formatted has an error. It's better to + // log the exception and emit unformatted code so the developer can view the code which + // caused a problem. + try (Writer writer = fileObject.openWriter()) { + writer.append(stringBuilder.toString()); + } + if (messager != null) { + messager.printMessage(Diagnostic.Kind.NOTE, "Error formatting " + getName()); + } + } + } + }; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java new file mode 100644 index 000000000..a0561e2fe --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java @@ -0,0 +1,270 @@ +/* + * Copyright 2020 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.java17; + +import static com.google.common.collect.ImmutableList.toImmutableList; +import static com.google.common.collect.Iterables.getOnlyElement; + +import com.google.common.base.Verify; +import com.google.common.collect.ImmutableList; +import com.google.googlejavaformat.OpsBuilder; +import com.google.googlejavaformat.OpsBuilder.BlankLineWanted; +import com.google.googlejavaformat.java.JavaInputAstVisitor; +import com.sun.source.tree.AnnotationTree; +import com.sun.source.tree.BindingPatternTree; +import com.sun.source.tree.BlockTree; +import com.sun.source.tree.CaseLabelTree; +import com.sun.source.tree.CaseTree; +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.InstanceOfTree; +import com.sun.source.tree.ModifiersTree; +import com.sun.source.tree.ModuleTree; +import com.sun.source.tree.SwitchExpressionTree; +import com.sun.source.tree.Tree; +import com.sun.source.tree.VariableTree; +import com.sun.source.tree.YieldTree; +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.tree.TreeInfo; +import java.util.List; +import java.util.Optional; +import javax.lang.model.element.Name; + +/** + * Extends {@link JavaInputAstVisitor} with support for AST nodes that were added or modified in + * Java 17. + */ +public class Java17InputAstVisitor extends JavaInputAstVisitor { + + public Java17InputAstVisitor(OpsBuilder builder, int indentMultiplier) { + super(builder, indentMultiplier); + } + + @Override + protected void handleModule(boolean first, CompilationUnitTree node) { + ModuleTree module = node.getModule(); + if (module != null) { + if (!first) { + builder.blankLineWanted(BlankLineWanted.YES); + } + markForPartialFormat(); + visitModule(module, null); + builder.forcedBreak(); + } + } + + @Override + protected List getPermitsClause(ClassTree node) { + return node.getPermitsClause(); + } + + @Override + public Void visitBindingPattern(BindingPatternTree node, Void unused) { + sync(node); + VariableTree variableTree = node.getVariable(); + visitBindingPattern( + variableTree.getModifiers(), variableTree.getType(), variableTree.getName()); + return null; + } + + private void visitBindingPattern(ModifiersTree modifiers, Tree type, Name name) { + if (modifiers != null) { + List annotations = + visitModifiers(modifiers, Direction.HORIZONTAL, Optional.empty()); + visitAnnotations(annotations, BreakOrNot.NO, BreakOrNot.YES); + } + scan(type, null); + builder.breakOp(" "); + visit(name); + } + + @Override + public Void visitYield(YieldTree node, Void aVoid) { + sync(node); + token("yield"); + builder.space(); + scan(node.getValue(), null); + token(";"); + return null; + } + + @Override + public Void visitSwitchExpression(SwitchExpressionTree node, Void aVoid) { + sync(node); + visitSwitch(node.getExpression(), node.getCases()); + return null; + } + + @Override + public Void visitClass(ClassTree tree, Void unused) { + switch (tree.getKind()) { + case ANNOTATION_TYPE: + visitAnnotationType(tree); + break; + case CLASS: + case INTERFACE: + visitClassDeclaration(tree); + break; + case ENUM: + visitEnumDeclaration(tree); + break; + case RECORD: + visitRecordDeclaration(tree); + break; + default: + throw new AssertionError(tree.getKind()); + } + return null; + } + + public void visitRecordDeclaration(ClassTree node) { + sync(node); + typeDeclarationModifiers(node.getModifiers()); + Verify.verify(node.getExtendsClause() == null); + boolean hasSuperInterfaceTypes = !node.getImplementsClause().isEmpty(); + token("record"); + builder.space(); + visit(node.getSimpleName()); + if (!node.getTypeParameters().isEmpty()) { + token("<"); + } + builder.open(plusFour); + { + if (!node.getTypeParameters().isEmpty()) { + typeParametersRest(node.getTypeParameters(), hasSuperInterfaceTypes ? plusFour : ZERO); + } + ImmutableList parameters = recordVariables(node); + token("("); + if (!parameters.isEmpty()) { + // Break before args. + builder.breakToFill(""); + } + // record headers can't declare receiver parameters + visitFormals(/* receiver= */ Optional.empty(), parameters); + token(")"); + if (hasSuperInterfaceTypes) { + builder.breakToFill(" "); + builder.open(node.getImplementsClause().size() > 1 ? plusFour : ZERO); + token("implements"); + builder.space(); + boolean first = true; + for (Tree superInterfaceType : node.getImplementsClause()) { + if (!first) { + token(","); + builder.breakOp(" "); + } + scan(superInterfaceType, null); + first = false; + } + builder.close(); + } + } + builder.close(); + if (node.getMembers() == null) { + token(";"); + } else { + List members = + node.getMembers().stream() + .filter(t -> (TreeInfo.flags((JCTree) t) & Flags.GENERATED_MEMBER) == 0) + .collect(toImmutableList()); + addBodyDeclarations(members, BracesOrNot.YES, FirstDeclarationsOrNot.YES); + } + dropEmptyDeclarations(); + } + + private static ImmutableList recordVariables(ClassTree node) { + return node.getMembers().stream() + .filter(JCVariableDecl.class::isInstance) + .map(JCVariableDecl.class::cast) + .filter(m -> (m.mods.flags & RECORD) == RECORD) + .collect(toImmutableList()); + } + + @Override + public Void visitInstanceOf(InstanceOfTree node, Void unused) { + sync(node); + builder.open(plusFour); + scan(node.getExpression(), null); + builder.breakOp(" "); + builder.open(ZERO); + token("instanceof"); + builder.breakOp(" "); + if (node.getPattern() != null) { + scan(node.getPattern(), null); + } else { + scan(node.getType(), null); + } + builder.close(); + builder.close(); + return null; + } + + @Override + public Void visitCase(CaseTree node, Void unused) { + sync(node); + markForPartialFormat(); + builder.forcedBreak(); + List labels = node.getLabels(); + boolean isDefault = + labels.size() == 1 && getOnlyElement(labels).getKind().name().equals("DEFAULT_CASE_LABEL"); + if (isDefault) { + token("default", plusTwo); + } else { + token("case", plusTwo); + builder.open(labels.size() > 1 ? plusFour : ZERO); + builder.space(); + boolean first = true; + for (Tree expression : labels) { + if (!first) { + token(","); + builder.breakOp(" "); + } + scan(expression, null); + first = false; + } + builder.close(); + } + switch (node.getCaseKind()) { + case STATEMENT: + token(":"); + builder.open(plusTwo); + visitStatements(node.getStatements()); + builder.close(); + break; + case RULE: + builder.space(); + token("-"); + token(">"); + builder.space(); + if (node.getBody().getKind() == Tree.Kind.BLOCK) { + // Explicit call with {@link CollapseEmptyOrNot.YES} to handle empty case blocks. + visitBlock( + (BlockTree) node.getBody(), + CollapseEmptyOrNot.YES, + AllowLeadingBlankLine.NO, + AllowTrailingBlankLine.NO); + } else { + scan(node.getBody(), null); + } + builder.guessToken(";"); + break; + default: + throw new AssertionError(node.getCaseKind()); + } + return null; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/CharStream.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/CharStream.java new file mode 100644 index 000000000..8fbd49f9f --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/CharStream.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.javadoc; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * String reader designed for use from the lexer. Callers invoke the {@link #tryConsume tryConsume*} + * methods to specify what characters they expect and then {@link #readAndResetRecorded} to retrieve + * and consume the matched characters. This is a slightly odd API -- why not just return the matched + * characters from tryConsume? -- but it is convenient for the lexer. + */ +final class CharStream { + String remaining; + int toConsume; + + CharStream(String input) { + this.remaining = checkNotNull(input); + } + + boolean tryConsume(String expected) { + if (!remaining.startsWith(expected)) { + return false; + } + toConsume = expected.length(); + return true; + } + + /* + * @param pattern the pattern to search for, which must be anchored to match only at position 0 + */ + boolean tryConsumeRegex(Pattern pattern) { + Matcher matcher = pattern.matcher(remaining); + if (!matcher.find()) { + return false; + } + checkArgument(matcher.start() == 0); + toConsume = matcher.end(); + return true; + } + + String readAndResetRecorded() { + String result = remaining.substring(0, toConsume); + remaining = remaining.substring(toConsume); + toConsume = 0; // TODO(cpovirk): Set this to a bogus value here and in the constructor. + return result; + } + + boolean isExhausted() { + return remaining.isEmpty(); + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocFormatter.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocFormatter.java new file mode 100644 index 000000000..03938a677 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocFormatter.java @@ -0,0 +1,195 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.javadoc; + +import static com.google.googlejavaformat.java.javadoc.JavadocLexer.lex; +import static com.google.googlejavaformat.java.javadoc.Token.Type.BR_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.PARAGRAPH_OPEN_TAG; +import static java.util.regex.Pattern.CASE_INSENSITIVE; +import static java.util.regex.Pattern.compile; + +import com.google.common.collect.ImmutableList; +import com.google.googlejavaformat.java.javadoc.JavadocLexer.LexException; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Entry point for formatting Javadoc. + * + *

This stateless class reads tokens from the stateful lexer and translates them to "requests" + * and "writes" to the stateful writer. It also munges tokens into "standardized" forms. Finally, it + * performs postprocessing to convert the written Javadoc to a one-liner if possible or to leave a + * single blank line if it's empty. + */ +public final class JavadocFormatter { + + static final int MAX_LINE_LENGTH = 100; + + /** + * Formats the given Javadoc comment, which must start with ∕✱✱ and end with ✱∕. The output will + * start and end with the same characters. + */ + public static String formatJavadoc(String input, int blockIndent) { + ImmutableList tokens; + try { + tokens = lex(input); + } catch (LexException e) { + return input; + } + String result = render(tokens, blockIndent); + return makeSingleLineIfPossible(blockIndent, result); + } + + private static String render(List input, int blockIndent) { + JavadocWriter output = new JavadocWriter(blockIndent); + for (Token token : input) { + switch (token.getType()) { + case BEGIN_JAVADOC: + output.writeBeginJavadoc(); + break; + case END_JAVADOC: + output.writeEndJavadoc(); + return output.toString(); + case FOOTER_JAVADOC_TAG_START: + output.writeFooterJavadocTagStart(token); + break; + case LIST_OPEN_TAG: + output.writeListOpen(token); + break; + case LIST_CLOSE_TAG: + output.writeListClose(token); + break; + case LIST_ITEM_OPEN_TAG: + output.writeListItemOpen(token); + break; + case HEADER_OPEN_TAG: + output.writeHeaderOpen(token); + break; + case HEADER_CLOSE_TAG: + output.writeHeaderClose(token); + break; + case PARAGRAPH_OPEN_TAG: + output.writeParagraphOpen(standardizePToken(token)); + break; + case BLOCKQUOTE_OPEN_TAG: + case BLOCKQUOTE_CLOSE_TAG: + output.writeBlockquoteOpenOrClose(token); + break; + case PRE_OPEN_TAG: + output.writePreOpen(token); + break; + case PRE_CLOSE_TAG: + output.writePreClose(token); + break; + case CODE_OPEN_TAG: + output.writeCodeOpen(token); + break; + case CODE_CLOSE_TAG: + output.writeCodeClose(token); + break; + case TABLE_OPEN_TAG: + output.writeTableOpen(token); + break; + case TABLE_CLOSE_TAG: + output.writeTableClose(token); + break; + case MOE_BEGIN_STRIP_COMMENT: + output.requestMoeBeginStripComment(token); + break; + case MOE_END_STRIP_COMMENT: + output.writeMoeEndStripComment(token); + break; + case HTML_COMMENT: + output.writeHtmlComment(token); + break; + case BR_TAG: + output.writeBr(standardizeBrToken(token)); + break; + case WHITESPACE: + output.requestWhitespace(); + break; + case FORCED_NEWLINE: + output.writeLineBreakNoAutoIndent(); + break; + case LITERAL: + output.writeLiteral(token); + break; + case PARAGRAPH_CLOSE_TAG: + case LIST_ITEM_CLOSE_TAG: + case OPTIONAL_LINE_BREAK: + break; + default: + throw new AssertionError(token.getType()); + } + } + throw new AssertionError(); + } + + /* + * TODO(cpovirk): Is this really the right location for the standardize* methods? Maybe the lexer + * should include them as part of its own postprocessing? Or even the writer could make sense. + */ + + private static Token standardizeBrToken(Token token) { + return standardize(token, STANDARD_BR_TOKEN); + } + + private static Token standardizePToken(Token token) { + return standardize(token, STANDARD_P_TOKEN); + } + + private static Token standardize(Token token, Token standardToken) { + return SIMPLE_TAG_PATTERN.matcher(token.getValue()).matches() ? standardToken : token; + } + + private static final Token STANDARD_BR_TOKEN = new Token(BR_TAG, "
"); + private static final Token STANDARD_P_TOKEN = new Token(PARAGRAPH_OPEN_TAG, "

"); + private static final Pattern SIMPLE_TAG_PATTERN = compile("^<\\w+\\s*/?\\s*>", CASE_INSENSITIVE); + + private static final Pattern ONE_CONTENT_LINE_PATTERN = compile(" */[*][*]\n *[*] (.*)\n *[*]/"); + + /** + * Returns the given string or a one-line version of it (e.g., "∕✱✱ Tests for foos. ✱∕") if it + * fits on one line. + */ + private static String makeSingleLineIfPossible(int blockIndent, String input) { + Matcher matcher = ONE_CONTENT_LINE_PATTERN.matcher(input); + if (matcher.matches()) { + String line = matcher.group(1); + if (line.isEmpty()) { + return "/** */"; + } else if (oneLineJavadoc(line, blockIndent)) { + return "/** " + line + " */"; + } + } + return input; + } + + private static boolean oneLineJavadoc(String line, int blockIndent) { + int oneLinerContentLength = MAX_LINE_LENGTH - "/** */".length() - blockIndent; + if (line.length() > oneLinerContentLength) { + return false; + } + // If the javadoc contains only a tag, use multiple lines to encourage writing a summary + // fragment, unless it's /* @hide */. + if (line.startsWith("@") && !line.equals("@hide")) { + return false; + } + return true; + } + + private JavadocFormatter() {} +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocLexer.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocLexer.java new file mode 100644 index 000000000..cc707ae7e --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocLexer.java @@ -0,0 +1,557 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.javadoc; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Verify.verify; +import static com.google.common.collect.Iterators.peekingIterator; +import static com.google.googlejavaformat.java.javadoc.Token.Type.BEGIN_JAVADOC; +import static com.google.googlejavaformat.java.javadoc.Token.Type.BLOCKQUOTE_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.BLOCKQUOTE_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.BR_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.CODE_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.CODE_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.END_JAVADOC; +import static com.google.googlejavaformat.java.javadoc.Token.Type.FOOTER_JAVADOC_TAG_START; +import static com.google.googlejavaformat.java.javadoc.Token.Type.FORCED_NEWLINE; +import static com.google.googlejavaformat.java.javadoc.Token.Type.HEADER_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.HEADER_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.HTML_COMMENT; +import static com.google.googlejavaformat.java.javadoc.Token.Type.LIST_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.LIST_ITEM_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.LIST_ITEM_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.LIST_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.LITERAL; +import static com.google.googlejavaformat.java.javadoc.Token.Type.MOE_BEGIN_STRIP_COMMENT; +import static com.google.googlejavaformat.java.javadoc.Token.Type.MOE_END_STRIP_COMMENT; +import static com.google.googlejavaformat.java.javadoc.Token.Type.OPTIONAL_LINE_BREAK; +import static com.google.googlejavaformat.java.javadoc.Token.Type.PARAGRAPH_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.PARAGRAPH_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.PRE_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.PRE_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.TABLE_CLOSE_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.TABLE_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.WHITESPACE; +import static java.lang.String.format; +import static java.util.regex.Pattern.CASE_INSENSITIVE; +import static java.util.regex.Pattern.DOTALL; +import static java.util.regex.Pattern.compile; + +import com.google.common.base.CharMatcher; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.PeekingIterator; +import com.google.googlejavaformat.java.javadoc.Token.Type; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Deque; +import java.util.List; +import java.util.regex.Pattern; + +/** Lexer for the Javadoc formatter. */ +final class JavadocLexer { + /** Takes a Javadoc comment, including ∕✱✱ and ✱∕, and returns tokens, including ∕✱✱ and ✱∕. */ + static ImmutableList lex(String input) throws LexException { + /* + * TODO(cpovirk): In theory, we should interpret Unicode escapes (yet output them in their + * original form). This would mean mean everything from an encoded ∕✱✱ to an encoded

 tag,
+     * so we'll probably never bother.
+     */
+    input = stripJavadocBeginAndEnd(input);
+    input = normalizeLineEndings(input);
+    return new JavadocLexer(new CharStream(input)).generateTokens();
+  }
+
+  /** The lexer crashes on windows line endings, so for now just normalize to `\n`. */
+  // TODO(cushon): use the platform line separator for output
+  private static String normalizeLineEndings(String input) {
+    return NON_UNIX_LINE_ENDING.matcher(input).replaceAll("\n");
+  }
+
+  private static final Pattern NON_UNIX_LINE_ENDING = Pattern.compile("\r\n?");
+
+  private static String stripJavadocBeginAndEnd(String input) {
+    /*
+     * We do this ahead of time so that the main part of the lexer need not say things like
+     * "(?![*]/)" to avoid accidentally swallowing ✱∕ when consuming a newline.
+     */
+    checkArgument(input.startsWith("/**"), "Missing /**: %s", input);
+    checkArgument(input.endsWith("*/") && input.length() > 4, "Missing */: %s", input);
+    return input.substring("/**".length(), input.length() - "*/".length());
+  }
+
+  private final CharStream input;
+  private final NestingCounter braceDepth = new NestingCounter();
+  private final NestingCounter preDepth = new NestingCounter();
+  private final NestingCounter codeDepth = new NestingCounter();
+  private final NestingCounter tableDepth = new NestingCounter();
+  private boolean somethingSinceNewline;
+
+  private JavadocLexer(CharStream input) {
+    this.input = checkNotNull(input);
+  }
+
+  private ImmutableList generateTokens() throws LexException {
+    ImmutableList.Builder tokens = ImmutableList.builder();
+
+    Token token = new Token(BEGIN_JAVADOC, "/**");
+    tokens.add(token);
+
+    while (!input.isExhausted()) {
+      token = readToken();
+      tokens.add(token);
+    }
+
+    checkMatchingTags();
+
+    token = new Token(END_JAVADOC, "*/");
+    tokens.add(token);
+
+    ImmutableList result = tokens.build();
+    result = joinAdjacentLiteralsAndAdjacentWhitespace(result);
+    result = inferParagraphTags(result);
+    result = optionalizeSpacesAfterLinks(result);
+    result = deindentPreCodeBlocks(result);
+    return result;
+  }
+
+  private Token readToken() throws LexException {
+    Type type = consumeToken();
+    String value = input.readAndResetRecorded();
+    return new Token(type, value);
+  }
+
+  private Type consumeToken() throws LexException {
+    boolean preserveExistingFormatting = preserveExistingFormatting();
+
+    if (input.tryConsumeRegex(NEWLINE_PATTERN)) {
+      somethingSinceNewline = false;
+      return preserveExistingFormatting ? FORCED_NEWLINE : WHITESPACE;
+    } else if (input.tryConsume(" ") || input.tryConsume("\t")) {
+      // TODO(cpovirk): How about weird whitespace chars? Ideally we'd distinguish breaking vs. not.
+      // Returning LITERAL here prevent us from breaking a 
 line. For more info, see LITERAL.
+      return preserveExistingFormatting ? LITERAL : WHITESPACE;
+    }
+
+    /*
+     * TODO(cpovirk): Maybe try to detect things like "{@code\n@GwtCompatible}" that aren't intended
+     * as tags. But in the most likely case, in which that happens inside 
{@code, we have no
+     * great options for fixing it.
+     * https://github.com/google/google-java-format/issues/7#issuecomment-197383926
+     */
+    if (!somethingSinceNewline && input.tryConsumeRegex(FOOTER_TAG_PATTERN)) {
+      checkMatchingTags();
+      somethingSinceNewline = true;
+      return FOOTER_JAVADOC_TAG_START;
+    }
+    somethingSinceNewline = true;
+
+    if (input.tryConsumeRegex(INLINE_TAG_OPEN_PATTERN)) {
+      braceDepth.increment();
+      return LITERAL;
+    } else if (input.tryConsume("{")) {
+      braceDepth.incrementIfPositive();
+      return LITERAL;
+    } else if (input.tryConsume("}")) {
+      braceDepth.decrementIfPositive();
+      return LITERAL;
+    }
+
+    // Inside an inline tag, don't do any HTML interpretation.
+    if (braceDepth.isPositive()) {
+      verify(input.tryConsumeRegex(LITERAL_PATTERN));
+      return LITERAL;
+    }
+
+    if (input.tryConsumeRegex(PRE_OPEN_PATTERN)) {
+      preDepth.increment();
+      return preserveExistingFormatting ? LITERAL : PRE_OPEN_TAG;
+    } else if (input.tryConsumeRegex(PRE_CLOSE_PATTERN)) {
+      preDepth.decrementIfPositive();
+      return preserveExistingFormatting() ? LITERAL : PRE_CLOSE_TAG;
+    }
+
+    if (input.tryConsumeRegex(CODE_OPEN_PATTERN)) {
+      codeDepth.increment();
+      return preserveExistingFormatting ? LITERAL : CODE_OPEN_TAG;
+    } else if (input.tryConsumeRegex(CODE_CLOSE_PATTERN)) {
+      codeDepth.decrementIfPositive();
+      return preserveExistingFormatting() ? LITERAL : CODE_CLOSE_TAG;
+    }
+
+    if (input.tryConsumeRegex(TABLE_OPEN_PATTERN)) {
+      tableDepth.increment();
+      return preserveExistingFormatting ? LITERAL : TABLE_OPEN_TAG;
+    } else if (input.tryConsumeRegex(TABLE_CLOSE_PATTERN)) {
+      tableDepth.decrementIfPositive();
+      return preserveExistingFormatting() ? LITERAL : TABLE_CLOSE_TAG;
+    }
+
+    if (preserveExistingFormatting) {
+      verify(input.tryConsumeRegex(LITERAL_PATTERN));
+      return LITERAL;
+    }
+
+    if (input.tryConsumeRegex(PARAGRAPH_OPEN_PATTERN)) {
+      return PARAGRAPH_OPEN_TAG;
+    } else if (input.tryConsumeRegex(PARAGRAPH_CLOSE_PATTERN)) {
+      return PARAGRAPH_CLOSE_TAG;
+    } else if (input.tryConsumeRegex(LIST_OPEN_PATTERN)) {
+      return LIST_OPEN_TAG;
+    } else if (input.tryConsumeRegex(LIST_CLOSE_PATTERN)) {
+      return LIST_CLOSE_TAG;
+    } else if (input.tryConsumeRegex(LIST_ITEM_OPEN_PATTERN)) {
+      return LIST_ITEM_OPEN_TAG;
+    } else if (input.tryConsumeRegex(LIST_ITEM_CLOSE_PATTERN)) {
+      return LIST_ITEM_CLOSE_TAG;
+    } else if (input.tryConsumeRegex(BLOCKQUOTE_OPEN_PATTERN)) {
+      return BLOCKQUOTE_OPEN_TAG;
+    } else if (input.tryConsumeRegex(BLOCKQUOTE_CLOSE_PATTERN)) {
+      return BLOCKQUOTE_CLOSE_TAG;
+    } else if (input.tryConsumeRegex(HEADER_OPEN_PATTERN)) {
+      return HEADER_OPEN_TAG;
+    } else if (input.tryConsumeRegex(HEADER_CLOSE_PATTERN)) {
+      return HEADER_CLOSE_TAG;
+    } else if (input.tryConsumeRegex(BR_PATTERN)) {
+      return BR_TAG;
+    } else if (input.tryConsumeRegex(MOE_BEGIN_STRIP_COMMENT_PATTERN)) {
+      return MOE_BEGIN_STRIP_COMMENT;
+    } else if (input.tryConsumeRegex(MOE_END_STRIP_COMMENT_PATTERN)) {
+      return MOE_END_STRIP_COMMENT;
+    } else if (input.tryConsumeRegex(HTML_COMMENT_PATTERN)) {
+      return HTML_COMMENT;
+    } else if (input.tryConsumeRegex(LITERAL_PATTERN)) {
+      return LITERAL;
+    }
+    throw new AssertionError();
+  }
+
+  private boolean preserveExistingFormatting() {
+    return preDepth.isPositive() || tableDepth.isPositive() || codeDepth.isPositive();
+  }
+
+  private void checkMatchingTags() throws LexException {
+    if (braceDepth.isPositive()
+        || preDepth.isPositive()
+        || tableDepth.isPositive()
+        || codeDepth.isPositive()) {
+      throw new LexException();
+    }
+  }
+
+  /**
+   * Join together adjacent literal tokens, and join together adjacent whitespace tokens.
+   *
+   * 

For literal tokens, this means something like {@code ["", "foo", ""] => + * ["foo"]}. See {@link #LITERAL_PATTERN} for discussion of why those tokens are separate + * to begin with. + * + *

Whitespace tokens are treated analogously. We don't really "want" to join whitespace tokens, + * but in the course of joining literals, we incidentally join whitespace, too. We do take + * advantage of the joining later on: It simplifies {@link #inferParagraphTags}. + * + *

Note that we do not merge a literal token and a whitespace token together. + */ + private static ImmutableList joinAdjacentLiteralsAndAdjacentWhitespace(List input) { + /* + * Note: Our final token is always END_JAVADOC. This saves us some trouble: + * + * - Our inner while() doesn't need a hasNext() check. + * + * - We don't need to check for leftover accumulated literals after we exit the loop. + */ + ImmutableList.Builder output = ImmutableList.builder(); + StringBuilder accumulated = new StringBuilder(); + + for (PeekingIterator tokens = peekingIterator(input.iterator()); tokens.hasNext(); ) { + if (tokens.peek().getType() == LITERAL) { + accumulated.append(tokens.peek().getValue()); + tokens.next(); + continue; + } + + /* + * IF we have accumulated some literals to join together (say, "foobar"), and IF we'll + * next see whitespace followed by a "@" literal, we need to join that together with the + * previous literals. That ensures that we won't insert a line break before the "@," turning + * it into a tag. + */ + + if (accumulated.length() == 0) { + output.add(tokens.peek()); + tokens.next(); + continue; + } + + StringBuilder seenWhitespace = new StringBuilder(); + while (tokens.peek().getType() == WHITESPACE) { + seenWhitespace.append(tokens.next().getValue()); + } + + if (tokens.peek().getType() == LITERAL && tokens.peek().getValue().startsWith("@")) { + // OK, we're in the case described above. + accumulated.append(" "); + accumulated.append(tokens.peek().getValue()); + tokens.next(); + continue; + } + + output.add(new Token(LITERAL, accumulated.toString())); + accumulated.setLength(0); + + if (seenWhitespace.length() > 0) { + output.add(new Token(WHITESPACE, seenWhitespace.toString())); + } + + // We have another token coming, possibly of type OTHER. Leave it for the next iteration. + } + + /* + * TODO(cpovirk): Another case where we could try to join tokens is if a line ends with + * /[^ -]-/, as in "non-\nblocking." + */ + return output.build(); + } + + /** + * Where the input has two consecutive line breaks between literals, insert a {@code

} tag + * between the literals. + * + *

This method must be called after {@link #joinAdjacentLiteralsAndAdjacentWhitespace}, as it + * assumes that adjacent whitespace tokens have already been joined. + */ + private static ImmutableList inferParagraphTags(List input) { + ImmutableList.Builder output = ImmutableList.builder(); + + for (PeekingIterator tokens = peekingIterator(input.iterator()); tokens.hasNext(); ) { + if (tokens.peek().getType() == LITERAL) { + output.add(tokens.next()); + + if (tokens.peek().getType() == WHITESPACE + && hasMultipleNewlines(tokens.peek().getValue())) { + output.add(tokens.next()); + + if (tokens.peek().getType() == LITERAL) { + output.add(new Token(PARAGRAPH_OPEN_TAG, "

")); + } + } + } else { + // TODO(cpovirk): Or just `continue` from the

case and move this out of the `else`? + output.add(tokens.next()); + } + } + + return output.build(); + + /* + * Note: We do not want to insert

tags inside

. Fortunately, the formatter gets that
+     * right without special effort on our part. The reason: Line breaks inside a 
 section are
+     * of type FORCED_NEWLINE rather than WHITESPACE.
+     */
+  }
+
+  /**
+   * Replaces whitespace after a {@code href=...>} token with an "optional link break." This allows
+   * us to output either {@code foo} or {@code \nfoo}, depending on
+   * how much space we have left on the line.
+   *
+   * 

This method must be called after {@link #joinAdjacentLiteralsAndAdjacentWhitespace}, as it + * assumes that adjacent whitespace tokens have already been joined. + */ + private static ImmutableList optionalizeSpacesAfterLinks(List input) { + ImmutableList.Builder output = ImmutableList.builder(); + + for (PeekingIterator tokens = peekingIterator(input.iterator()); tokens.hasNext(); ) { + if (tokens.peek().getType() == LITERAL && tokens.peek().getValue().matches("^href=[^>]*>")) { + output.add(tokens.next()); + + if (tokens.peek().getType() == WHITESPACE) { + output.add(new Token(OPTIONAL_LINE_BREAK, tokens.next().getValue())); + } + } else { + output.add(tokens.next()); + } + } + + return output.build(); + + /* + * Note: We do not want to insert

tags inside

. Fortunately, the formatter gets that
+     * right without special effort on our part. The reason: Line breaks inside a 
 section are
+     * of type FORCED_NEWLINE rather than WHITESPACE.
+     */
+  }
+
+  /**
+   * Adjust indentation inside `
{@code` blocks.
+   *
+   * 

Also trim leading and trailing blank lines, and move the trailing `}` to its own line. + */ + private static ImmutableList deindentPreCodeBlocks(List input) { + ImmutableList.Builder output = ImmutableList.builder(); + for (PeekingIterator tokens = peekingIterator(input.iterator()); tokens.hasNext(); ) { + if (tokens.peek().getType() != PRE_OPEN_TAG) { + output.add(tokens.next()); + continue; + } + + output.add(tokens.next()); + List initialNewlines = new ArrayList<>(); + while (tokens.hasNext() && tokens.peek().getType() == FORCED_NEWLINE) { + initialNewlines.add(tokens.next()); + } + if (tokens.peek().getType() != LITERAL + || !tokens.peek().getValue().matches("[ \t]*[{]@code")) { + output.addAll(initialNewlines); + output.add(tokens.next()); + continue; + } + + deindentPreCodeBlock(output, tokens); + } + return output.build(); + } + + private static void deindentPreCodeBlock( + ImmutableList.Builder output, PeekingIterator tokens) { + Deque saved = new ArrayDeque<>(); + output.add(new Token(LITERAL, tokens.next().getValue().trim())); + while (tokens.hasNext() && tokens.peek().getType() != PRE_CLOSE_TAG) { + Token token = tokens.next(); + saved.addLast(token); + } + while (!saved.isEmpty() && saved.peekFirst().getType() == FORCED_NEWLINE) { + saved.removeFirst(); + } + while (!saved.isEmpty() && saved.peekLast().getType() == FORCED_NEWLINE) { + saved.removeLast(); + } + if (saved.isEmpty()) { + return; + } + + // move the trailing `}` to its own line + Token last = saved.peekLast(); + boolean trailingBrace = false; + if (last.getType() == LITERAL && last.getValue().endsWith("}")) { + saved.removeLast(); + if (last.length() > 1) { + saved.addLast( + new Token(LITERAL, last.getValue().substring(0, last.getValue().length() - 1))); + saved.addLast(new Token(FORCED_NEWLINE, null)); + } + trailingBrace = true; + } + + int trim = -1; + for (Token token : saved) { + if (token.getType() == LITERAL) { + int idx = CharMatcher.isNot(' ').indexIn(token.getValue()); + if (idx != -1 && (trim == -1 || idx < trim)) { + trim = idx; + } + } + } + + output.add(new Token(FORCED_NEWLINE, "\n")); + for (Token token : saved) { + if (token.getType() == LITERAL) { + output.add( + new Token( + LITERAL, + trim > 0 && token.length() > trim + ? token.getValue().substring(trim) + : token.getValue())); + } else { + output.add(token); + } + } + + if (trailingBrace) { + output.add(new Token(LITERAL, "}")); + } else { + output.add(new Token(FORCED_NEWLINE, "\n")); + } + } + + private static final CharMatcher NEWLINE = CharMatcher.is('\n'); + + private static boolean hasMultipleNewlines(String s) { + return NEWLINE.countIn(s) > 1; + } + + /* + * This also eats any trailing whitespace. We would be smart enough to ignore that, anyway -- + * except in the case of

/, inside which we otherwise leave whitespace intact.
+   *
+   * We'd remove the trailing whitespace later on (in JavaCommentsHelper.rewrite), but I feel safer
+   * stripping it now: It otherwise might confuse our line-length count, which we use for wrapping.
+   */
+  private static final Pattern NEWLINE_PATTERN = compile("^[ \t]*\n[ \t]*[*]?[ \t]?");
+
+  // We ensure elsewhere that we match this only at the beginning of a line.
+  // Only match tags that start with a lowercase letter, to avoid false matches on unescaped
+  // annotations inside code blocks.
+  // Match "@param " specially in case the  is a 

or other HTML tag we treat specially. + private static final Pattern FOOTER_TAG_PATTERN = compile("^@(param\\s+<\\w+>|[a-z]\\w*)"); + private static final Pattern MOE_BEGIN_STRIP_COMMENT_PATTERN = + compile("^"); + private static final Pattern MOE_END_STRIP_COMMENT_PATTERN = + compile("^"); + private static final Pattern HTML_COMMENT_PATTERN = fullCommentPattern(); + private static final Pattern PRE_OPEN_PATTERN = openTagPattern("pre"); + private static final Pattern PRE_CLOSE_PATTERN = closeTagPattern("pre"); + private static final Pattern CODE_OPEN_PATTERN = openTagPattern("code"); + private static final Pattern CODE_CLOSE_PATTERN = closeTagPattern("code"); + private static final Pattern TABLE_OPEN_PATTERN = openTagPattern("table"); + private static final Pattern TABLE_CLOSE_PATTERN = closeTagPattern("table"); + private static final Pattern LIST_OPEN_PATTERN = openTagPattern("ul|ol|dl"); + private static final Pattern LIST_CLOSE_PATTERN = closeTagPattern("ul|ol|dl"); + private static final Pattern LIST_ITEM_OPEN_PATTERN = openTagPattern("li|dt|dd"); + private static final Pattern LIST_ITEM_CLOSE_PATTERN = closeTagPattern("li|dt|dd"); + private static final Pattern HEADER_OPEN_PATTERN = openTagPattern("h[1-6]"); + private static final Pattern HEADER_CLOSE_PATTERN = closeTagPattern("h[1-6]"); + private static final Pattern PARAGRAPH_OPEN_PATTERN = openTagPattern("p"); + private static final Pattern PARAGRAPH_CLOSE_PATTERN = closeTagPattern("p"); + private static final Pattern BLOCKQUOTE_OPEN_PATTERN = openTagPattern("blockquote"); + private static final Pattern BLOCKQUOTE_CLOSE_PATTERN = closeTagPattern("blockquote"); + private static final Pattern BR_PATTERN = openTagPattern("br"); + private static final Pattern INLINE_TAG_OPEN_PATTERN = compile("^[{]@\\w*"); + /* + * We exclude < so that we don't swallow following HTML tags. This lets us fix up "foo

" (~400 + * hits in Google-internal code). We will join unnecessarily split "words" (like "foobar") + * in a later step. There's a similar story for braces. I'm not sure I actually need to exclude @ + * or *. TODO(cpovirk): Try removing them. + * + * Thanks to the "rejoin" step in joinAdjacentLiteralsAndAdjacentWhitespace(), we could get away + * with matching only one character here. That would eliminate the need for the regex entirely. + * That might be faster or slower than what we do now. + */ + private static final Pattern LITERAL_PATTERN = compile("^.[^ \t\n@<{}*]*", DOTALL); + + private static Pattern fullCommentPattern() { + return compile("^", DOTALL); + } + + private static Pattern openTagPattern(String namePattern) { + return compile(format("^<(?:%s)\\b[^>]*>", namePattern), CASE_INSENSITIVE); + } + + private static Pattern closeTagPattern(String namePattern) { + return compile(format("^]*>", namePattern), CASE_INSENSITIVE); + } + + static class LexException extends Exception {} +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java new file mode 100644 index 000000000..0361415a1 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java @@ -0,0 +1,410 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.javadoc; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Comparators.max; +import static com.google.common.collect.Sets.immutableEnumSet; +import static com.google.googlejavaformat.java.javadoc.JavadocWriter.AutoIndent.AUTO_INDENT; +import static com.google.googlejavaformat.java.javadoc.JavadocWriter.AutoIndent.NO_AUTO_INDENT; +import static com.google.googlejavaformat.java.javadoc.JavadocWriter.RequestedWhitespace.BLANK_LINE; +import static com.google.googlejavaformat.java.javadoc.JavadocWriter.RequestedWhitespace.NEWLINE; +import static com.google.googlejavaformat.java.javadoc.JavadocWriter.RequestedWhitespace.NONE; +import static com.google.googlejavaformat.java.javadoc.JavadocWriter.RequestedWhitespace.WHITESPACE; +import static com.google.googlejavaformat.java.javadoc.Token.Type.HEADER_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.LIST_ITEM_OPEN_TAG; +import static com.google.googlejavaformat.java.javadoc.Token.Type.PARAGRAPH_OPEN_TAG; + +import com.google.common.collect.ImmutableSet; +import com.google.googlejavaformat.java.javadoc.Token.Type; + +/** + * Stateful object that accepts "requests" and "writes," producing formatted Javadoc. + * + *

Our Javadoc formatter doesn't ever generate a parse tree, only a stream of tokens, so the + * writer must compute and store the answer to questions like "How many levels of nested HTML list + * are we inside?" + */ +final class JavadocWriter { + private final int blockIndent; + private final StringBuilder output = new StringBuilder(); + /** + * Whether we are inside an {@code

  • } element, excluding the case in which the {@code
  • } + * contains a {@code
      } or {@code
        } that we are also inside -- unless of course we're + * inside an {@code
      1. } element in that inner list :) + */ + private boolean continuingListItemOfInnermostList; + + private boolean continuingFooterTag; + private final NestingCounter continuingListItemCount = new NestingCounter(); + private final NestingCounter continuingListCount = new NestingCounter(); + private final NestingCounter postWriteModifiedContinuingListCount = new NestingCounter(); + private int remainingOnLine; + private boolean atStartOfLine; + private RequestedWhitespace requestedWhitespace = NONE; + private Token requestedMoeBeginStripComment; + private int indentForMoeEndStripComment; + private boolean wroteAnythingSignificant; + + JavadocWriter(int blockIndent) { + this.blockIndent = blockIndent; + } + + /** + * Requests whitespace between the previously written token and the next written token. The + * request may be honored, or it may be overridden by a request for "more significant" whitespace, + * like a newline. + */ + void requestWhitespace() { + requestWhitespace(WHITESPACE); + } + + void requestMoeBeginStripComment(Token token) { + // We queue this up so that we can put it after any requested whitespace. + requestedMoeBeginStripComment = checkNotNull(token); + } + + void writeBeginJavadoc() { + /* + * JavaCommentsHelper will make sure this is indented right. But it seems sensible enough that, + * if our input starts with ∕✱✱, so too does our output. + */ + output.append("/**"); + writeNewline(); + } + + void writeEndJavadoc() { + output.append("\n"); + appendSpaces(blockIndent + 1); + output.append("*/"); + } + + void writeFooterJavadocTagStart(Token token) { + // Close any unclosed lists (e.g.,
      2. without
          ). + // TODO(cpovirk): Actually generate
        , etc.? + /* + * TODO(cpovirk): Also generate and
  • if appropriate. This is necessary for + * idempotency in broken Javadoc. (We don't necessarily need that, but full idempotency may be a + * nice goal, especially if it helps us use a fuzzer to test.) Unfortunately, the writer doesn't + * currently know which of those tags are open. + */ + continuingListItemOfInnermostList = false; + continuingListItemCount.reset(); + continuingListCount.reset(); + /* + * There's probably no need for this, since its only effect is to disable blank lines in some + * cases -- and we're doing that already in the footer. + */ + postWriteModifiedContinuingListCount.reset(); + + if (!wroteAnythingSignificant) { + // Javadoc consists solely of tags. This is frowned upon in general but OK for @Overrides. + } else if (!continuingFooterTag) { + // First footer tag after a body tag. + requestBlankLine(); + } else { + // Subsequent footer tag. + continuingFooterTag = false; + requestNewline(); + } + writeToken(token); + continuingFooterTag = true; + } + + void writeListOpen(Token token) { + requestBlankLine(); + + writeToken(token); + continuingListItemOfInnermostList = false; + continuingListCount.increment(); + postWriteModifiedContinuingListCount.increment(); + + requestNewline(); + } + + void writeListClose(Token token) { + requestNewline(); + + continuingListItemCount.decrementIfPositive(); + continuingListCount.decrementIfPositive(); + writeToken(token); + postWriteModifiedContinuingListCount.decrementIfPositive(); + + requestBlankLine(); + } + + void writeListItemOpen(Token token) { + requestNewline(); + + if (continuingListItemOfInnermostList) { + continuingListItemOfInnermostList = false; + continuingListItemCount.decrementIfPositive(); + } + writeToken(token); + continuingListItemOfInnermostList = true; + continuingListItemCount.increment(); + } + + void writeHeaderOpen(Token token) { + requestBlankLine(); + + writeToken(token); + } + + void writeHeaderClose(Token token) { + writeToken(token); + + requestBlankLine(); + } + + void writeParagraphOpen(Token token) { + if (!wroteAnythingSignificant) { + /* + * The user included an initial

    tag. Ignore it, and don't request a blank line before the + * next token. + */ + return; + } + + requestBlankLine(); + + writeToken(token); + } + + void writeBlockquoteOpenOrClose(Token token) { + requestBlankLine(); + + writeToken(token); + + requestBlankLine(); + } + + void writePreOpen(Token token) { + requestBlankLine(); + + writeToken(token); + } + + void writePreClose(Token token) { + writeToken(token); + + requestBlankLine(); + } + + void writeCodeOpen(Token token) { + writeToken(token); + } + + void writeCodeClose(Token token) { + writeToken(token); + } + + void writeTableOpen(Token token) { + requestBlankLine(); + + writeToken(token); + } + + void writeTableClose(Token token) { + writeToken(token); + + requestBlankLine(); + } + + void writeMoeEndStripComment(Token token) { + writeLineBreakNoAutoIndent(); + appendSpaces(indentForMoeEndStripComment); + + // Or maybe just "output.append(token.getValue())?" I'm kind of surprised this is so easy. + writeToken(token); + + requestNewline(); + } + + void writeHtmlComment(Token token) { + requestNewline(); + + writeToken(token); + + requestNewline(); + } + + void writeBr(Token token) { + writeToken(token); + + requestNewline(); + } + + void writeLineBreakNoAutoIndent() { + writeNewline(NO_AUTO_INDENT); + } + + void writeLiteral(Token token) { + writeToken(token); + } + + @Override + public String toString() { + return output.toString(); + } + + private void requestBlankLine() { + requestWhitespace(BLANK_LINE); + } + + private void requestNewline() { + requestWhitespace(NEWLINE); + } + + private void requestWhitespace(RequestedWhitespace requestedWhitespace) { + this.requestedWhitespace = max(requestedWhitespace, this.requestedWhitespace); + } + + /** + * The kind of whitespace that has been requested between the previous and next tokens. The order + * of the values is significant: It goes from lowest priority to highest. For example, if the + * previous token requests {@link #BLANK_LINE} after it but the next token requests only {@link + * #NEWLINE} before it, we insert {@link #BLANK_LINE}. + */ + enum RequestedWhitespace { + NONE, + WHITESPACE, + NEWLINE, + BLANK_LINE, + ; + } + + private void writeToken(Token token) { + if (requestedMoeBeginStripComment != null) { + requestNewline(); + } + + if (requestedWhitespace == BLANK_LINE + && (postWriteModifiedContinuingListCount.isPositive() || continuingFooterTag)) { + /* + * We don't write blank lines inside lists or footer tags, even in cases where we otherwise + * would (e.g., before a

    tag). Justification: We don't write blank lines _between_ list + * items or footer tags, so it would be strange to write blank lines _within_ one. Of course, + * an alternative approach would be to go ahead and write blank lines between items/tags, + * either always or only in the case that an item contains a blank line. + */ + requestedWhitespace = NEWLINE; + } + + if (requestedWhitespace == BLANK_LINE) { + writeBlankLine(); + requestedWhitespace = NONE; + } else if (requestedWhitespace == NEWLINE) { + writeNewline(); + requestedWhitespace = NONE; + } + boolean needWhitespace = (requestedWhitespace == WHITESPACE); + + /* + * Write a newline if necessary to respect the line limit. (But if we're at the beginning of the + * line, a newline won't help. Or it might help but only by separating "

    veryverylongword," + * which goes against our style.) + */ + if (!atStartOfLine && token.length() + (needWhitespace ? 1 : 0) > remainingOnLine) { + writeNewline(); + } + if (!atStartOfLine && needWhitespace) { + output.append(" "); + remainingOnLine--; + } + + if (requestedMoeBeginStripComment != null) { + output.append(requestedMoeBeginStripComment.getValue()); + requestedMoeBeginStripComment = null; + indentForMoeEndStripComment = innerIndent(); + requestNewline(); + writeToken(token); + return; + } + + output.append(token.getValue()); + + if (!START_OF_LINE_TOKENS.contains(token.getType())) { + atStartOfLine = false; + } + + /* + * TODO(cpovirk): We really want the number of "characters," not chars. Figure out what the + * right way of measuring that is (grapheme count (with BreakIterator?)? sum of widths of all + * graphemes? I don't think that our style guide is specific about this.). Moreover, I am + * probably brushing other problems with surrogates, etc. under the table. Hopefully I mostly + * get away with it by joining all non-space, non-tab characters together. + * + * Possibly the "width" question has no right answer: + * http://denisbider.blogspot.com/2015/09/when-monospace-fonts-arent-unicode.html + */ + remainingOnLine -= token.length(); + requestedWhitespace = NONE; + wroteAnythingSignificant = true; + } + + private void writeBlankLine() { + output.append("\n"); + appendSpaces(blockIndent + 1); + output.append("*"); + writeNewline(); + } + + private void writeNewline() { + writeNewline(AUTO_INDENT); + } + + private void writeNewline(AutoIndent autoIndent) { + output.append("\n"); + appendSpaces(blockIndent + 1); + output.append("*"); + appendSpaces(1); + remainingOnLine = JavadocFormatter.MAX_LINE_LENGTH - blockIndent - 3; + if (autoIndent == AUTO_INDENT) { + appendSpaces(innerIndent()); + remainingOnLine -= innerIndent(); + } + atStartOfLine = true; + } + + enum AutoIndent { + AUTO_INDENT, + NO_AUTO_INDENT + } + + private int innerIndent() { + int innerIndent = continuingListItemCount.value() * 4 + continuingListCount.value() * 2; + if (continuingFooterTag) { + innerIndent += 4; + } + return innerIndent; + } + + // If this is a hotspot, keep a String of many spaces around, and call append(string, start, end). + private void appendSpaces(int count) { + output.append(" ".repeat(count)); + } + + /** + * Tokens that are always pinned to the following token. For example, {@code

    } in {@code

    Foo + * bar} (never {@code

    Foo bar} or {@code

    \nFoo bar}). + * + *

    This is not the only kind of "pinning" that we do: See also the joining of LITERAL tokens + * done by the lexer. The special pinning here is necessary because these tokens are not of type + * LITERAL (because they require other special handling). + */ + private static final ImmutableSet START_OF_LINE_TOKENS = + immutableEnumSet(LIST_ITEM_OPEN_TAG, PARAGRAPH_OPEN_TAG, HEADER_OPEN_TAG); +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/NestingCounter.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/NestingCounter.java new file mode 100644 index 000000000..43e7125c9 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/NestingCounter.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.javadoc; + +/** Mutable integer for tracking the level of nesting. */ +final class NestingCounter { + private int value; + + int value() { + return value; + } + + void increment() { + value++; + } + + void incrementIfPositive() { + if (value > 0) { + value++; + } + } + + void decrementIfPositive() { + if (value > 0) { + value--; + } + } + + boolean isPositive() { + return value > 0; + } + + void reset() { + value = 0; + } +} diff --git a/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/Token.java b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/Token.java new file mode 100644 index 000000000..d617824b0 --- /dev/null +++ b/feature/formatter/google-java-format/src/main/java/com/google/googlejavaformat/java/javadoc/Token.java @@ -0,0 +1,131 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.googlejavaformat.java.javadoc; + +/** + * Javadoc token. Our idea of what constitutes a token is often larger or smaller than what you'd + * naturally expect. The decision is usually pragmatic rather than theoretical. Most of the details + * are in {@link JavadocLexer}. + */ +final class Token { + /** + * Javadoc token type. + * + *

    The general idea is that every token that requires special handling (extra line breaks, + * indentation, forcing or forbidding whitespace) from {@link JavadocWriter} gets its own type. + * But I haven't been super careful about it, so I'd imagine that we could merge or remove some of + * these if we wanted. (For example, PARAGRAPH_CLOSE_TAG and LIST_ITEM_CLOSE_TAG could share a + * common IGNORABLE token type. But their corresponding OPEN tags exist, so I've kept the CLOSE + * tags.) + * + *

    Note, though, that tokens of the same type may still have been handled differently by {@link + * JavadocLexer} when it created them. For example, LITERAL is used for both plain text and inline + * tags, even though the two affect the lexer's state differently. + */ + enum Type { + /** ∕✱✱ */ + BEGIN_JAVADOC, + /** ✱∕ */ + END_JAVADOC, + /** The {@code @foo} that begins a block Javadoc tag like {@code @throws}. */ + FOOTER_JAVADOC_TAG_START, + LIST_OPEN_TAG, + LIST_CLOSE_TAG, + LIST_ITEM_OPEN_TAG, + LIST_ITEM_CLOSE_TAG, + HEADER_OPEN_TAG, + HEADER_CLOSE_TAG, + PARAGRAPH_OPEN_TAG, + PARAGRAPH_CLOSE_TAG, + // TODO(cpovirk): Support

    (probably identically to
    ). + BLOCKQUOTE_OPEN_TAG, + BLOCKQUOTE_CLOSE_TAG, + PRE_OPEN_TAG, + PRE_CLOSE_TAG, + CODE_OPEN_TAG, + CODE_CLOSE_TAG, + TABLE_OPEN_TAG, + TABLE_CLOSE_TAG, + /** {@code } */ + MOE_BEGIN_STRIP_COMMENT, + /** {@code } */ + MOE_END_STRIP_COMMENT, + HTML_COMMENT, + // TODO(cpovirk): Support
    (probably a blank line before and after). + BR_TAG, + /** + * Whitespace that is not in a {@code
    } or {@code } section. Whitespace includes
    +     * leading newlines, asterisks, and tabs and spaces. In the output, it is translated to newlines
    +     * (with leading spaces and asterisks) or spaces.
    +     */
    +    WHITESPACE,
    +    /**
    +     * A newline in a {@code 
    } or {@code 
    } section. We preserve user formatting in these + * sections, including newlines. + */ + FORCED_NEWLINE, + /** + * Token that permits but does not force a line break. The way that we accomplish this is + * somewhat indirect: As far as {@link JavadocWriter} is concerned, this token is meaningless. + * But its mere existence prevents {@link JavadocLexer} from joining two {@link #LITERAL} tokens + * that would otherwise be adjacent. Since this token is not real whitespace, the writer may end + * up writing the literals together with no space between, just as if they'd been joined. + * However, if they don't fit together on the line, the writer will write the first one, start a + * new line, and write the second. Hence, the token acts as an optional line break. + */ + OPTIONAL_LINE_BREAK, + /** + * Anything else: {@code foo}, {@code }, {@code {@code foo}} etc. {@link JavadocLexer} + * sometimes creates adjacent literal tokens, which it then merges into a single, larger literal + * token before returning its output. + * + *

    This also includes whitespace in a {@code

    } or {@code 
    } section. We preserve + * user formatting in these sections, including arbitrary numbers of spaces. By treating such + * whitespace as a literal, we can merge it with adjacent literals, preventing us from + * autowrapping inside these sections -- and doing so naively, to boot. The wrapped line would + * have no indentation after "* " or, possibly worse, it might begin with an arbitrary amount of + * whitespace that didn't fit on the previous line. Of course, by doing this, we're potentially + * creating lines of more than 100 characters. But it seems fair to call in the humans to + * resolve such problems. + */ + LITERAL, + ; + } + + private final Type type; + private final String value; + + Token(Type type, String value) { + this.type = type; + this.value = value; + } + + Type getType() { + return type; + } + + String getValue() { + return value; + } + + int length() { + return value.length(); + } + + @Override + public String toString() { + return "\n" + getType() + ": " + getValue(); + } +} diff --git a/feature/jaxp/.gitignore b/feature/jaxp/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/feature/jaxp/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/jaxp/build.gradle.kts b/feature/jaxp/build.gradle.kts new file mode 100644 index 000000000..14f198b6a --- /dev/null +++ b/feature/jaxp/build.gradle.kts @@ -0,0 +1,15 @@ +/* + * This file is part of Cosmic IDE. + * Cosmic IDE is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see . + */ + +plugins { + id("java-library") +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} diff --git a/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Scanner.java b/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Scanner.java new file mode 100644 index 000000000..a390688fd --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Scanner.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java_cup.internal.runtime; + +/** + * Defines the Scanner interface, which CUP uses in the default + * implementation of lr_parser.scan(). Integration + * of scanners implementing Scanner is facilitated. + * + * @author David MacMahon + */ + +/* ************************************************* + Interface Scanner + + Declares the next_token() method that should be + implemented by scanners. This method is typically + called by lr_parser.scan(). + ***************************************************/ +public interface Scanner { + public Symbol next_token() throws java.lang.Exception; +} diff --git a/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Symbol.java b/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Symbol.java new file mode 100644 index 000000000..d25e2e837 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Symbol.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java_cup.internal.runtime; + +/** + * Defines the Symbol class, which is used to represent all terminals + * and nonterminals while parsing. The lexer should pass CUP Symbols + * and CUP returns a Symbol. + * + * @author Frank Flannery + */ + +/* **************************************************************** + Class Symbol + what the parser expects to receive from the lexer. + the token is identified as follows: + sym: the symbol type + parse_state: the parse state. + value: is the lexical value of type Object + left : is the left position in the original input file + right: is the right position in the original input file +******************************************************************/ + +public class Symbol { + +/******************************* + Constructor for l,r values + *******************************/ + + public Symbol(int id, int l, int r, Object o) { + this(id); + left = l; + right = r; + value = o; + } + +/******************************* + Constructor for no l,r values +********************************/ + + public Symbol(int id, Object o) { + this(id); + left = -1; + right = -1; + value = o; + } + +/***************************** + Constructor for no value + ***************************/ + + public Symbol(int sym_num, int l, int r) { + sym = sym_num; + left = l; + right = r; + value = null; + } + +/*********************************** + Constructor for no value or l,r +***********************************/ + + public Symbol(int sym_num) { + this(sym_num, -1); + left = -1; + right = -1; + value = null; + } + +/*********************************** + Constructor to give a start state +***********************************/ + public Symbol(int sym_num, int state) + { + sym = sym_num; + parse_state = state; + } + +/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The symbol number of the terminal or non terminal being represented */ + public int sym; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The parse state to be recorded on the parse stack with this symbol. + * This field is for the convenience of the parser and shouldn't be + * modified except by the parser. + */ + public int parse_state; + /** This allows us to catch some errors caused by scanners recycling + * symbols. For the use of the parser only. [CSA, 23-Jul-1999] */ + boolean used_by_parser = false; + +/******************************* + The data passed to parser + *******************************/ + + public int left, right; + public Object value; + + /***************************** + Printing this token out. (Override for pretty-print). + ****************************/ + public String toString() { return "#"+sym; } +} diff --git a/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/lr_parser.java b/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/lr_parser.java new file mode 100644 index 000000000..8d14d5f81 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/java_cup/internal/runtime/lr_parser.java @@ -0,0 +1,1335 @@ +/* + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +package com.sun.java_cup.internal.runtime; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.sym; +import java.util.Arrays; +import java.util.Stack; + +/** This class implements a skeleton table driven LR parser. In general, + * LR parsers are a form of bottom up shift-reduce parsers. Shift-reduce + * parsers act by shifting input onto a parse stack until the Symbols + * matching the right hand side of a production appear on the top of the + * stack. Once this occurs, a reduce is performed. This involves removing + * the Symbols corresponding to the right hand side of the production + * (the so called "handle") and replacing them with the non-terminal from + * the left hand side of the production.

    + * + * To control the decision of whether to shift or reduce at any given point, + * the parser uses a state machine (the "viable prefix recognition machine" + * built by the parser generator). The current state of the machine is placed + * on top of the parse stack (stored as part of a Symbol object representing + * a terminal or non terminal). The parse action table is consulted + * (using the current state and the current lookahead Symbol as indexes) to + * determine whether to shift or to reduce. When the parser shifts, it + * changes to a new state by pushing a new Symbol (containing a new state) + * onto the stack. When the parser reduces, it pops the handle (right hand + * side of a production) off the stack. This leaves the parser in the state + * it was in before any of those Symbols were matched. Next the reduce-goto + * table is consulted (using the new state and current lookahead Symbol as + * indexes) to determine a new state to go to. The parser then shifts to + * this goto state by pushing the left hand side Symbol of the production + * (also containing the new state) onto the stack.

    + * + * This class actually provides four LR parsers. The methods parse() and + * debug_parse() provide two versions of the main parser (the only difference + * being that debug_parse() emits debugging trace messages as it parses). + * In addition to these main parsers, the error recovery mechanism uses two + * more. One of these is used to simulate "parsing ahead" in the input + * without carrying out actions (to verify that a potential error recovery + * has worked), and the other is used to parse through buffered "parse ahead" + * input in order to execute all actions and re-synchronize the actual parser + * configuration.

    + * + * This is an abstract class which is normally filled out by a subclass + * generated by the JavaCup parser generator. In addition to supplying + * the actual parse tables, generated code also supplies methods which + * invoke various pieces of user supplied code, provide access to certain + * special Symbols (e.g., EOF and error), etc. Specifically, the following + * abstract methods are normally supplied by generated code: + *

    + *
    short[][] production_table() + *
    Provides a reference to the production table (indicating the index of + * the left hand side non terminal and the length of the right hand side + * for each production in the grammar). + *
    short[][] action_table() + *
    Provides a reference to the parse action table. + *
    short[][] reduce_table() + *
    Provides a reference to the reduce-goto table. + *
    int start_state() + *
    Indicates the index of the start state. + *
    int start_production() + *
    Indicates the index of the starting production. + *
    int EOF_sym() + *
    Indicates the index of the EOF Symbol. + *
    int error_sym() + *
    Indicates the index of the error Symbol. + *
    Symbol do_action() + *
    Executes a piece of user supplied action code. This always comes at + * the point of a reduce in the parse, so this code also allocates and + * fills in the left hand side non terminal Symbol object that is to be + * pushed onto the stack for the reduce. + *
    void init_actions() + *
    Code to initialize a special object that encapsulates user supplied + * actions (this object is used by do_action() to actually carry out the + * actions). + *
    + * + * In addition to these routines that must be supplied by the + * generated subclass there are also a series of routines that may + * be supplied. These include: + *
    + *
    Symbol scan() + *
    Used to get the next input Symbol from the scanner. + *
    Scanner getScanner() + *
    Used to provide a scanner for the default implementation of + * scan(). + *
    int error_sync_size() + *
    This determines how many Symbols past the point of an error + * must be parsed without error in order to consider a recovery to + * be valid. This defaults to 3. Values less than 2 are not + * recommended. + *
    void report_error(String message, Object info) + *
    This method is called to report an error. The default implementation + * simply prints a message to System.err and where the error occurred. + * This method is often replaced in order to provide a more sophisticated + * error reporting mechanism. + *
    void report_fatal_error(String message, Object info) + *
    This method is called when a fatal error that cannot be recovered from + * is encountered. In the default implementation, it calls + * report_error() to emit a message, then throws an exception. + *
    void syntax_error(Symbol cur_token) + *
    This method is called as soon as syntax error is detected (but + * before recovery is attempted). In the default implementation it + * invokes: report_error("Syntax error", null); + *
    void unrecovered_syntax_error(Symbol cur_token) + *
    This method is called if syntax error recovery fails. In the default + * implementation it invokes:
    + * report_fatal_error("Couldn't repair and continue parse", null); + *
    + * + * @see com.sun.java_cup.internal.runtime.Symbol + * @see com.sun.java_cup.internal.runtime.Symbol + * @see com.sun.java_cup.internal.runtime.virtual_parse_stack + * @author Frank Flannery + * + * @LastModified: July 2022 + */ + +public abstract class lr_parser { + public static final int ID_GROUP = 1; + public static final int ID_OPERATOR = 2; + public static final int ID_TOTAL_OPERATOR = 3; + + private boolean isLiteral = false; + private int grpCount = 0; + private int opCount = 0; + private int totalOpCount = 0; + private int lastSym; + private boolean overLimit = false; + public int grpLimit = 0; + public int opLimit = 0; + public int totalOpLimit = 0; + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Simple constructor. */ + public lr_parser() + { + /* nothing to do here */ + } + + /** Constructor that sets the default scanner. [CSA/davidm] */ + public lr_parser(Scanner s) { + this(); /* in case default constructor someday does something */ + setScanner(s); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Static (Class) Variables ------------------*/ + /*-----------------------------------------------------------*/ + + /** The default number of Symbols after an error we much match to consider + * it recovered from. + */ + protected final static int _error_sync_size = 3; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The number of Symbols after an error we much match to consider it + * recovered from. + */ + protected int error_sync_size() {return _error_sync_size; } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** Table of production information (supplied by generated subclass). + * This table contains one entry per production and is indexed by + * the negative-encoded values (reduce actions) in the action_table. + * Each entry has two parts, the index of the non-terminal on the + * left hand side of the production, and the number of Symbols + * on the right hand side. + */ + public abstract short[][] production_table(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The action table (supplied by generated subclass). This table is + * indexed by state and terminal number indicating what action is to + * be taken when the parser is in the given state (i.e., the given state + * is on top of the stack) and the given terminal is next on the input. + * States are indexed using the first dimension, however, the entries for + * a given state are compacted and stored in adjacent index, value pairs + * which are searched for rather than accessed directly (see get_action()). + * The actions stored in the table will be either shifts, reduces, or + * errors. Shifts are encoded as positive values (one greater than the + * state shifted to). Reduces are encoded as negative values (one less + * than the production reduced by). Error entries are denoted by zero. + * + * @see com.sun.java_cup.internal.runtime.lr_parser#get_action + */ + public abstract short[][] action_table(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The reduce-goto table (supplied by generated subclass). This + * table is indexed by state and non-terminal number and contains + * state numbers. States are indexed using the first dimension, however, + * the entries for a given state are compacted and stored in adjacent + * index, value pairs which are searched for rather than accessed + * directly (see get_reduce()). When a reduce occurs, the handle + * (corresponding to the RHS of the matched production) is popped off + * the stack. The new top of stack indicates a state. This table is + * then indexed by that state and the LHS of the reducing production to + * indicate where to "shift" to. + * + * @see com.sun.java_cup.internal.runtime.lr_parser#get_reduce + */ + public abstract short[][] reduce_table(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The index of the start state (supplied by generated subclass). */ + public abstract int start_state(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The index of the start production (supplied by generated subclass). */ + public abstract int start_production(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The index of the end of file terminal Symbol (supplied by generated + * subclass). + */ + public abstract int EOF_sym(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The index of the special error Symbol (supplied by generated subclass). */ + public abstract int error_sym(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Internal flag to indicate when parser should quit. */ + protected boolean _done_parsing = false; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** This method is called to indicate that the parser should quit. This is + * normally called by an accept action, but can be used to cancel parsing + * early in other circumstances if desired. + */ + public void done_parsing() + { + _done_parsing = true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + /* Global parse state shared by parse(), error recovery, and + * debugging routines */ + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Indication of the index for top of stack (for use by actions). */ + protected int tos; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The current lookahead Symbol. */ + protected Symbol cur_token; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The parse stack itself. */ + protected Stack stack = new Stack<>(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Direct reference to the production table. */ + protected short[][] production_tab; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Direct reference to the action table. */ + protected short[][] action_tab; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Direct reference to the reduce-goto table. */ + protected short[][] reduce_tab; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** This is the scanner object used by the default implementation + * of scan() to get Symbols. To avoid name conflicts with existing + * code, this field is private. [CSA/davidm] */ + private Scanner _scanner; + + /** + * Simple accessor method to set the default scanner. + */ + public void setScanner(Scanner s) { _scanner = s; } + + /** + * Simple accessor method to get the default scanner. + */ + public Scanner getScanner() { return _scanner; } + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Perform a bit of user supplied action code (supplied by generated + * subclass). Actions are indexed by an internal action number assigned + * at parser generation time. + * + * @param act_num the internal index of the action to be performed. + * @param parser the parser object we are acting for. + * @param stack the parse stack of that object. + * @param top the index of the top element of the parse stack. + */ + public abstract Symbol do_action( + int act_num, + lr_parser parser, + Stack stack, + int top) + throws java.lang.Exception; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** User code for initialization inside the parser. Typically this + * initializes the scanner. This is called before the parser requests + * the first Symbol. Here this is just a placeholder for subclasses that + * might need this and we perform no action. This method is normally + * overridden by the generated code using this contents of the "init with" + * clause as its body. + */ + public void user_init() throws java.lang.Exception { } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Initialize the action object. This is called before the parser does + * any parse actions. This is filled in by generated code to create + * an object that encapsulates all action code. + */ + protected abstract void init_actions() throws java.lang.Exception; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Get the next Symbol from the input (supplied by generated subclass). + * Once end of file has been reached, all subsequent calls to scan + * should return an EOF Symbol (which is Symbol number 0). By default + * this method returns getScanner().next_token(); this implementation + * can be overriden by the generated parser using the code declared in + * the "scan with" clause. Do not recycle objects; every call to + * scan() should return a fresh object. + */ + public Symbol scan() throws Exception { + Symbol s = getScanner().next_token(); + + if (s.sym == sym.LPAREN) { + if (!isLiteral) { + grpCount++; + } + opCount++; // function + totalOpCount++; + isLiteral = false; + } else if (contains(sym.OPERATORS, s.sym)) { + // axis nodetest is counted as one step, so not counted if last=DCOLON + if (lastSym != sym.DCOLON) { + opCount++; + totalOpCount++; + } + isLiteral = false; + } + + if (s.sym == sym.Literal || s.sym == sym.QNAME) { + isLiteral = true; + } + lastSym = s.sym; + + /* + * Sets the overLimit status as soon as the count of operators is over the + * limit, which in turn triggers the XPathParser to report an error. + */ + if (grpLimit > 0 && grpCount > grpLimit + || opLimit > 0 && opCount > opLimit + || totalOpLimit > 0 && totalOpCount > totalOpLimit) { + overLimit = true; + } + + return s; + } + + private boolean contains(final int[] arr, final int key) { + return Arrays.stream(arr).anyMatch(i -> i == key); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Report a fatal error. This method takes a message string and an + * additional object (to be used by specializations implemented in + * subclasses). Here in the base class a very simple implementation + * is provided which reports the error then throws an exception. + * + * @param message an error message. + * @param info an extra object reserved for use by specialized subclasses. + */ + public void report_fatal_error( + String message, + Object info) + throws java.lang.Exception + { + /* stop parsing (not really necessary since we throw an exception, but) */ + done_parsing(); + + /* use the normal error message reporting to put out the message */ + report_error(message, info); + + /* throw an exception */ + throw new Exception("Can't recover from previous error(s)"); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Report a non fatal error (or warning). This method takes a message + * string and an additional object (to be used by specializations + * implemented in subclasses). Here in the base class a very simple + * implementation is provided which simply prints the message to + * System.err. + * + * @param message an error message. + * @param info an extra object reserved for use by specialized subclasses. + */ + public void report_error(String message, Object info) + { + System.err.print(message); + if (info instanceof Symbol) + if (((Symbol)info).left != -1) + System.err.println(" at character " + ((Symbol)info).left + + " of input"); + else System.err.println(""); + else System.err.println(""); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** This method is called when a syntax error has been detected and recovery + * is about to be invoked. Here in the base class we just emit a + * "Syntax error" error message. + * + * @param cur_token the current lookahead Symbol. + */ + public void syntax_error(Symbol cur_token) + { + report_error("Syntax error", cur_token); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** This method is called if it is determined that syntax error recovery + * has been unsuccessful. Here in the base class we report a fatal error. + * + * @param cur_token the current lookahead Symbol. + */ + public void unrecovered_syntax_error(Symbol cur_token) + throws java.lang.Exception + { + report_fatal_error("Couldn't repair and continue parse", cur_token); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Fetch an action from the action table. The table is broken up into + * rows, one per state (rows are indexed directly by state number). + * Within each row, a list of index, value pairs are given (as sequential + * entries in the table), and the list is terminated by a default entry + * (denoted with a Symbol index of -1). To find the proper entry in a row + * we do a linear or binary search (depending on the size of the row). + * + * @param state the state index of the action being accessed. + * @param sym the Symbol index of the action being accessed. + */ + protected final short get_action(int state, int sym) + { + short tag; + int first, last, probe; + short[] row = action_tab[state]; + + /* linear search if we are < 10 entries */ + if (row.length < 20) + for (probe = 0; probe < row.length; probe++) + { + /* is this entry labeled with our Symbol or the default? */ + tag = row[probe++]; + if (tag == sym || tag == -1) + { + /* return the next entry */ + return row[probe]; + } + } + /* otherwise binary search */ + else + { + first = 0; + last = (row.length-1)/2 - 1; /* leave out trailing default entry */ + while (first <= last) + { + probe = (first+last)/2; + if (sym == row[probe*2]) + return row[probe*2+1]; + else if (sym > row[probe*2]) + first = probe+1; + else + last = probe-1; + } + + /* not found, use the default at the end */ + return row[row.length-1]; + } + + /* shouldn't happened, but if we run off the end we return the + default (error == 0) */ + return 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Fetch a state from the reduce-goto table. The table is broken up into + * rows, one per state (rows are indexed directly by state number). + * Within each row, a list of index, value pairs are given (as sequential + * entries in the table), and the list is terminated by a default entry + * (denoted with a Symbol index of -1). To find the proper entry in a row + * we do a linear search. + * + * @param state the state index of the entry being accessed. + * @param sym the Symbol index of the entry being accessed. + */ + protected final short get_reduce(int state, int sym) + { + short tag; + short[] row = reduce_tab[state]; + + /* if we have a null row we go with the default */ + if (row == null) + return -1; + + for (int probe = 0; probe < row.length; probe++) + { + /* is this entry labeled with our Symbol or the default? */ + tag = row[probe++]; + if (tag == sym || tag == -1) + { + /* return the next entry */ + return row[probe]; + } + } + /* if we run off the end we return the default (error == -1) */ + return -1; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** This method provides the main parsing routine. It returns only when + * done_parsing() has been called (typically because the parser has + * accepted, or a fatal error has been reported). See the header + * documentation for the class regarding how shift/reduce parsers operate + * and how the various tables are used. + */ + public Symbol parse() throws java.lang.Exception + { + /* the current action code */ + int act; + + /* the Symbol/stack element returned by a reduce */ + Symbol lhs_sym = null; + + /* information about production being reduced with */ + short handle_size, lhs_sym_num; + + /* set up direct reference to tables to drive the parser */ + + production_tab = production_table(); + action_tab = action_table(); + reduce_tab = reduce_table(); + + /* initialize the action encapsulation object */ + init_actions(); + + /* do user initialization */ + user_init(); + isLiteral = false; + overLimit = false; + grpCount = 0; + opCount = 0; + lastSym = -1; + + /* get the first token */ + cur_token = scan(); + if (overLimit) return null; + + /* push dummy Symbol with start state to get us underway */ + stack.removeAllElements(); + stack.push(new Symbol(0, start_state())); + tos = 0; + + /* continue until we are told to stop */ + for (_done_parsing = false; !_done_parsing; ) + { + /* Check current token for freshness. */ + if (cur_token.used_by_parser) + throw new Error("Symbol recycling detected (fix your scanner)."); + + /* current state is always on the top of the stack */ + + /* look up action out of the current state with the current input */ + act = get_action((stack.peek()).parse_state, cur_token.sym); + + /* decode the action -- > 0 encodes shift */ + if (act > 0) + { + /* shift to the encoded state by pushing it on the stack */ + cur_token.parse_state = act-1; + cur_token.used_by_parser = true; + stack.push(cur_token); + tos++; + + /* advance to the next Symbol */ + cur_token = scan(); + } + /* if its less than zero, then it encodes a reduce action */ + else if (act < 0) + { + /* perform the action for the reduce */ + lhs_sym = do_action((-act)-1, this, stack, tos); + + /* look up information about the production */ + lhs_sym_num = production_tab[(-act)-1][0]; + handle_size = production_tab[(-act)-1][1]; + + /* pop the handle off the stack */ + for (int i = 0; i < handle_size; i++) + { + stack.pop(); + tos--; + } + + /* look up the state to go to from the one popped back to */ + act = get_reduce((stack.peek()).parse_state, lhs_sym_num); + + /* shift to that state */ + lhs_sym.parse_state = act; + lhs_sym.used_by_parser = true; + stack.push(lhs_sym); + tos++; + } + /* finally if the entry is zero, we have an error */ + else if (act == 0) + { + /* call user syntax error reporting routine */ + syntax_error(cur_token); + + /* try to error recover */ + if (!error_recovery(false)) + { + /* if that fails give up with a fatal syntax error */ + unrecovered_syntax_error(cur_token); + + /* just in case that wasn't fatal enough, end parse */ + done_parsing(); + } else { + lhs_sym = stack.peek(); + } + } + if (overLimit) return null; + } + + return lhs_sym; + } + + public boolean isOverLimit() { + return overLimit; + } + + /** + * Returns the count of operators in XPath expressions. + * + * @param id the ID of the count + * @return the count associated with the ID + */ + public int getCount(int id) { + switch (id) { + case ID_GROUP: + return grpCount; + case ID_OPERATOR: + return opCount; + case ID_TOTAL_OPERATOR: + return totalOpCount; + } + return 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Write a debugging message to System.err for the debugging version + * of the parser. + * + * @param mess the text of the debugging message. + */ + public void debug_message(String mess) + { + System.err.println(mess); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Dump the parse stack for debugging purposes. */ + public void dump_stack() + { + if (stack == null) + { + debug_message("# Stack dump requested, but stack is null"); + return; + } + + debug_message("============ Parse Stack Dump ============"); + + /* dump the stack */ + for (int i=0; i"); + if ((i%3)==2 || (i==(stack.size()-1))) { + debug_message(sb.toString()); + sb = new StringBuilder(" "); + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Perform a parse with debugging output. This does exactly the + * same things as parse(), except that it calls debug_shift() and + * debug_reduce() when shift and reduce moves are taken by the parser + * and produces various other debugging messages. + */ + public Symbol debug_parse() + throws java.lang.Exception + { + /* the current action code */ + int act; + + /* the Symbol/stack element returned by a reduce */ + Symbol lhs_sym = null; + + /* information about production being reduced with */ + short handle_size, lhs_sym_num; + + /* set up direct reference to tables to drive the parser */ + production_tab = production_table(); + action_tab = action_table(); + reduce_tab = reduce_table(); + + debug_message("# Initializing parser"); + + /* initialize the action encapsulation object */ + init_actions(); + + /* do user initialization */ + user_init(); + + /* the current Symbol */ + cur_token = scan(); + + debug_message("# Current Symbol is #" + cur_token.sym); + + /* push dummy Symbol with start state to get us underway */ + stack.removeAllElements(); + stack.push(new Symbol(0, start_state())); + tos = 0; + + /* continue until we are told to stop */ + for (_done_parsing = false; !_done_parsing; ) + { + /* Check current token for freshness. */ + if (cur_token.used_by_parser) + throw new Error("Symbol recycling detected (fix your scanner)."); + + /* current state is always on the top of the stack */ + //debug_stack(); + + /* look up action out of the current state with the current input */ + act = get_action((stack.peek()).parse_state, cur_token.sym); + + /* decode the action -- > 0 encodes shift */ + if (act > 0) + { + /* shift to the encoded state by pushing it on the stack */ + cur_token.parse_state = act-1; + cur_token.used_by_parser = true; + debug_shift(cur_token); + stack.push(cur_token); + tos++; + + /* advance to the next Symbol */ + cur_token = scan(); + debug_message("# Current token is " + cur_token); + } + /* if its less than zero, then it encodes a reduce action */ + else if (act < 0) + { + /* perform the action for the reduce */ + lhs_sym = do_action((-act)-1, this, stack, tos); + + /* look up information about the production */ + lhs_sym_num = production_tab[(-act)-1][0]; + handle_size = production_tab[(-act)-1][1]; + + debug_reduce((-act)-1, lhs_sym_num, handle_size); + + /* pop the handle off the stack */ + for (int i = 0; i < handle_size; i++) + { + stack.pop(); + tos--; + } + + /* look up the state to go to from the one popped back to */ + act = get_reduce((stack.peek()).parse_state, lhs_sym_num); + debug_message("# Reduce rule: top state " + + (stack.peek()).parse_state + + ", lhs sym " + lhs_sym_num + " -> state " + act); + + /* shift to that state */ + lhs_sym.parse_state = act; + lhs_sym.used_by_parser = true; + stack.push(lhs_sym); + tos++; + + debug_message("# Goto state #" + act); + } + /* finally if the entry is zero, we have an error */ + else if (act == 0) + { + /* call user syntax error reporting routine */ + syntax_error(cur_token); + + /* try to error recover */ + if (!error_recovery(true)) + { + /* if that fails give up with a fatal syntax error */ + unrecovered_syntax_error(cur_token); + + /* just in case that wasn't fatal enough, end parse */ + done_parsing(); + } else { + lhs_sym = stack.peek(); + } + } + } + return lhs_sym; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + /* Error recovery code */ + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Attempt to recover from a syntax error. This returns false if recovery + * fails, true if it succeeds. Recovery happens in 4 steps. First we + * pop the parse stack down to a point at which we have a shift out + * of the top-most state on the error Symbol. This represents the + * initial error recovery configuration. If no such configuration is + * found, then we fail. Next a small number of "lookahead" or "parse + * ahead" Symbols are read into a buffer. The size of this buffer is + * determined by error_sync_size() and determines how many Symbols beyond + * the error must be matched to consider the recovery a success. Next, + * we begin to discard Symbols in attempt to get past the point of error + * to a point where we can continue parsing. After each Symbol, we attempt + * to "parse ahead" though the buffered lookahead Symbols. The "parse ahead" + * process simulates that actual parse, but does not modify the real + * parser's configuration, nor execute any actions. If we can parse all + * the stored Symbols without error, then the recovery is considered a + * success. Once a successful recovery point is determined, we do an + * actual parse over the stored input -- modifying the real parse + * configuration and executing all actions. Finally, we return the the + * normal parser to continue with the overall parse. + * + * @param debug should we produce debugging messages as we parse. + */ + protected boolean error_recovery(boolean debug) + throws java.lang.Exception + { + if (debug) debug_message("# Attempting error recovery"); + + /* first pop the stack back into a state that can shift on error and + do that shift (if that fails, we fail) */ + if (!find_recovery_config(debug)) + { + if (debug) debug_message("# Error recovery fails"); + return false; + } + + /* read ahead to create lookahead we can parse multiple times */ + read_lookahead(); + + /* repeatedly try to parse forward until we make it the required dist */ + for (;;) + { + /* try to parse forward, if it makes it, bail out of loop */ + if (debug) debug_message("# Trying to parse ahead"); + if (try_parse_ahead(debug)) + { + break; + } + + /* if we are now at EOF, we have failed */ + if (lookahead[0].sym == EOF_sym()) + { + if (debug) debug_message("# Error recovery fails at EOF"); + return false; + } + + /* otherwise, we consume another Symbol and try again */ + if (debug) + debug_message("# Consuming Symbol #" + cur_err_token().sym); + restart_lookahead(); + } + + /* we have consumed to a point where we can parse forward */ + if (debug) debug_message("# Parse-ahead ok, going back to normal parse"); + + /* do the real parse (including actions) across the lookahead */ + parse_lookahead(debug); + + /* we have success */ + return true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Determine if we can shift under the special error Symbol out of the + * state currently on the top of the (real) parse stack. + */ + protected boolean shift_under_error() + { + /* is there a shift under error Symbol */ + return get_action((stack.peek()).parse_state, error_sym()) > 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Put the (real) parse stack into error recovery configuration by + * popping the stack down to a state that can shift on the special + * error Symbol, then doing the shift. If no suitable state exists on + * the stack we return false + * + * @param debug should we produce debugging messages as we parse. + */ + protected boolean find_recovery_config(boolean debug) + { + Symbol error_token; + int act; + + if (debug) debug_message("# Finding recovery state on stack"); + + /* Remember the right-position of the top symbol on the stack */ + int right_pos = (stack.peek()).right; + int left_pos = (stack.peek()).left; + + /* pop down until we can shift under error Symbol */ + while (!shift_under_error()) + { + /* pop the stack */ + if (debug) + debug_message("# Pop stack by one, state was # " + + (stack.peek()).parse_state); + left_pos = stack.pop().left; + tos--; + + /* if we have hit bottom, we fail */ + if (stack.empty()) + { + if (debug) debug_message("# No recovery state found on stack"); + return false; + } + } + + /* state on top of the stack can shift under error, find the shift */ + act = get_action((stack.peek()).parse_state, error_sym()); + if (debug) + { + debug_message("# Recover state found (#" + + (stack.peek()).parse_state + ")"); + debug_message("# Shifting on error to state #" + (act-1)); + } + + /* build and shift a special error Symbol */ + error_token = new Symbol(error_sym(), left_pos, right_pos); + error_token.parse_state = act-1; + error_token.used_by_parser = true; + stack.push(error_token); + tos++; + + return true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Lookahead Symbols used for attempting error recovery "parse aheads". */ + protected Symbol lookahead[]; + + /** Position in lookahead input buffer used for "parse ahead". */ + protected int lookahead_pos; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Read from input to establish our buffer of "parse ahead" lookahead + * Symbols. + */ + protected void read_lookahead() throws java.lang.Exception + { + /* create the lookahead array */ + lookahead = new Symbol[error_sync_size()]; + + /* fill in the array */ + for (int i = 0; i < error_sync_size(); i++) + { + lookahead[i] = cur_token; + cur_token = scan(); + } + + /* start at the beginning */ + lookahead_pos = 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return the current lookahead in our error "parse ahead" buffer. */ + protected Symbol cur_err_token() { return lookahead[lookahead_pos]; } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Advance to next "parse ahead" input Symbol. Return true if we have + * input to advance to, false otherwise. + */ + protected boolean advance_lookahead() + { + /* advance the input location */ + lookahead_pos++; + + /* return true if we didn't go off the end */ + return lookahead_pos < error_sync_size(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Reset the parse ahead input to one Symbol past where we started error + * recovery (this consumes one new Symbol from the real input). + */ + protected void restart_lookahead() throws java.lang.Exception + { + /* move all the existing input over */ + for (int i = 1; i < error_sync_size(); i++) + lookahead[i-1] = lookahead[i]; + + /* read a new Symbol into the last spot */ + cur_token = scan(); + lookahead[error_sync_size()-1] = cur_token; + + /* reset our internal position marker */ + lookahead_pos = 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Do a simulated parse forward (a "parse ahead") from the current + * stack configuration using stored lookahead input and a virtual parse + * stack. Return true if we make it all the way through the stored + * lookahead input without error. This basically simulates the action of + * parse() using only our saved "parse ahead" input, and not executing any + * actions. + * + * @param debug should we produce debugging messages as we parse. + */ + protected boolean try_parse_ahead(boolean debug) + throws java.lang.Exception + { + int act; + short lhs, rhs_size; + + /* create a virtual stack from the real parse stack */ + virtual_parse_stack vstack = new virtual_parse_stack(stack); + + /* parse until we fail or get past the lookahead input */ + for (;;) + { + /* look up the action from the current state (on top of stack) */ + act = get_action(vstack.top(), cur_err_token().sym); + + /* if its an error, we fail */ + if (act == 0) return false; + + /* > 0 encodes a shift */ + if (act > 0) + { + /* push the new state on the stack */ + vstack.push(act-1); + + if (debug) debug_message("# Parse-ahead shifts Symbol #" + + cur_err_token().sym + " into state #" + (act-1)); + + /* advance simulated input, if we run off the end, we are done */ + if (!advance_lookahead()) return true; + } + /* < 0 encodes a reduce */ + else + { + /* if this is a reduce with the start production we are done */ + if ((-act)-1 == start_production()) + { + if (debug) debug_message("# Parse-ahead accepts"); + return true; + } + + /* get the lhs Symbol and the rhs size */ + lhs = production_tab[(-act)-1][0]; + rhs_size = production_tab[(-act)-1][1]; + + /* pop handle off the stack */ + for (int i = 0; i < rhs_size; i++) + vstack.pop(); + + if (debug) + debug_message("# Parse-ahead reduces: handle size = " + + rhs_size + " lhs = #" + lhs + " from state #" + vstack.top()); + + /* look up goto and push it onto the stack */ + vstack.push(get_reduce(vstack.top(), lhs)); + if (debug) + debug_message("# Goto state #" + vstack.top()); + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Parse forward using stored lookahead Symbols. In this case we have + * already verified that parsing will make it through the stored lookahead + * Symbols and we are now getting back to the point at which we can hand + * control back to the normal parser. Consequently, this version of the + * parser performs all actions and modifies the real parse configuration. + * This returns once we have consumed all the stored input or we accept. + * + * @param debug should we produce debugging messages as we parse. + */ + protected void parse_lookahead(boolean debug) + throws java.lang.Exception + { + /* the current action code */ + int act; + + /* the Symbol/stack element returned by a reduce */ + Symbol lhs_sym = null; + + /* information about production being reduced with */ + short handle_size, lhs_sym_num; + + /* restart the saved input at the beginning */ + lookahead_pos = 0; + + if (debug) + { + debug_message("# Reparsing saved input with actions"); + debug_message("# Current Symbol is #" + cur_err_token().sym); + debug_message("# Current state is #" + + (stack.peek()).parse_state); + } + + /* continue until we accept or have read all lookahead input */ + while(!_done_parsing) + { + /* current state is always on the top of the stack */ + + /* look up action out of the current state with the current input */ + act = + get_action((stack.peek()).parse_state, cur_err_token().sym); + + /* decode the action -- > 0 encodes shift */ + if (act > 0) + { + /* shift to the encoded state by pushing it on the stack */ + cur_err_token().parse_state = act-1; + cur_err_token().used_by_parser = true; + if (debug) debug_shift(cur_err_token()); + stack.push(cur_err_token()); + tos++; + + /* advance to the next Symbol, if there is none, we are done */ + if (!advance_lookahead()) + { + if (debug) debug_message("# Completed reparse"); + + /* scan next Symbol so we can continue parse */ + // BUGFIX by Chris Harris : + // correct a one-off error by commenting out + // this next line. + /*cur_token = scan();*/ + + /* go back to normal parser */ + return; + } + + if (debug) + debug_message("# Current Symbol is #" + cur_err_token().sym); + } + /* if its less than zero, then it encodes a reduce action */ + else if (act < 0) + { + /* perform the action for the reduce */ + lhs_sym = do_action((-act)-1, this, stack, tos); + + /* look up information about the production */ + lhs_sym_num = production_tab[(-act)-1][0]; + handle_size = production_tab[(-act)-1][1]; + + if (debug) debug_reduce((-act)-1, lhs_sym_num, handle_size); + + /* pop the handle off the stack */ + for (int i = 0; i < handle_size; i++) + { + stack.pop(); + tos--; + } + + /* look up the state to go to from the one popped back to */ + act = get_reduce((stack.peek()).parse_state, lhs_sym_num); + + /* shift to that state */ + lhs_sym.parse_state = act; + lhs_sym.used_by_parser = true; + stack.push(lhs_sym); + tos++; + + if (debug) debug_message("# Goto state #" + act); + + } + /* finally if the entry is zero, we have an error + (shouldn't happen here, but...)*/ + else if (act == 0) + { + report_fatal_error("Syntax error", lhs_sym); + return; + } + } + + + } + + /*-----------------------------------------------------------*/ + + /** Utility function: unpacks parse tables from strings */ + protected static short[][] unpackFromStrings(String[] sa) + { + // Concatanate initialization strings. + StringBuilder sb = new StringBuilder(sa[0]); + for (int i=1; i shadowing_stack) throws java.lang.Exception + { + /* sanity check */ + if (shadowing_stack == null) + throw new Exception( + "Internal parser error: attempt to create null virtual stack"); + + /* set up our internals */ + real_stack = shadowing_stack; + vstack = new Stack<>(); + real_next = 0; + + /* get one element onto the virtual portion of the stack */ + get_from_real(); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** The real stack that we shadow. This is accessed when we move off + * the bottom of the virtual portion of the stack, but is always left + * unmodified. + */ + protected Stack real_stack; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Top of stack indicator for where we leave off in the real stack. + * This is measured from top of stack, so 0 would indicate that no + * elements have been "moved" from the real to virtual stack. + */ + protected int real_next; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** The virtual top portion of the stack. This stack contains Integer + * objects with state numbers. This stack shadows the top portion + * of the real stack within the area that has been modified (via operations + * on the virtual stack). When this portion of the stack becomes empty we + * transfer elements from the underlying stack onto this stack. + */ + protected Stack vstack; + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** Transfer an element from the real to the virtual stack. This assumes + * that the virtual stack is currently empty. + */ + protected void get_from_real() + { + Symbol stack_sym; + + /* don't transfer if the real stack is empty */ + if (real_next >= real_stack.size()) return; + + /* get a copy of the first Symbol we have not transfered */ + stack_sym = real_stack.get(real_stack.size()-1-real_next); + + /* record the transfer */ + real_next++; + + /* put the state number from the Symbol onto the virtual stack */ + vstack.push(stack_sym.parse_state); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Indicate whether the stack is empty. */ + public boolean empty() + { + /* if vstack is empty then we were unable to transfer onto it and + the whole thing is empty. */ + return vstack.empty(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Return value on the top of the stack (without popping it). */ + public int top() throws java.lang.Exception + { + if (vstack.empty()) + throw new Exception( + "Internal parser error: top() called on empty virtual stack"); + + return (vstack.peek()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Pop the stack. */ + public void pop() throws java.lang.Exception + { + if (vstack.empty()) + throw new Exception( + "Internal parser error: pop from empty virtual stack"); + + /* pop it */ + vstack.pop(); + + /* if we are now empty transfer an element (if there is one) */ + if (vstack.empty()) + get_from_real(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** Push a state number onto the stack. */ + public void push(int state_num) + { + vstack.push(state_num); + } + + /*-----------------------------------------------------------*/ + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Const.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Const.java new file mode 100644 index 000000000..3e92b1cd4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Const.java @@ -0,0 +1,3243 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal; + +import java.util.Arrays; +import java.util.Collections; + +/** + * Constants for the project, mostly defined in the JVM specification. + * + * @since 6.0 (intended to replace the Constants interface) + * @LastModified: May 2023 + */ +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; + + /** + * Minor version number of class files for Java 1.8. + * + * @see #MAJOR_1_8 + */ + public static final short MINOR_1_8 = 0; + + /** + * Major version number of class files for Java 9. + * + * @see #MINOR_9 + */ + public static final short MAJOR_9 = 53; + + /** + * Minor version number of class files for Java 9. + * + * @see #MAJOR_9 + */ + public static final short MINOR_9 = 0; + + /** + * @deprecated Use {@link #MAJOR_9} instead + */ + @Deprecated + public static final short MAJOR_1_9 = MAJOR_9; + + /** + * @deprecated Use {@link #MINOR_9} instead + */ + @Deprecated + public static final short MINOR_1_9 = MINOR_9; + + /** + * Major version number of class files for Java 10. + * + * @see #MINOR_10 + */ + public static final short MAJOR_10 = 54; + + /** + * Minor version number of class files for Java 10. + * + * @see #MAJOR_10 + */ + public static final short MINOR_10 = 0; + + /** + * Major version number of class files for Java 11. + * + * @see #MINOR_11 + */ + public static final short MAJOR_11 = 55; + + /** + * Minor version number of class files for Java 11. + * + * @see #MAJOR_11 + */ + public static final short MINOR_11 = 0; + + /** + * Major version number of class files for Java 12. + * + * @see #MINOR_12 + */ + public static final short MAJOR_12 = 56; + + /** + * Minor version number of class files for Java 12. + * + * @see #MAJOR_12 + */ + public static final short MINOR_12 = 0; + + /** + * Major version number of class files for Java 13. + * + * @see #MINOR_13 + */ + public static final short MAJOR_13 = 57; + + /** + * Minor version number of class files for Java 13. + * + * @see #MAJOR_13 + */ + public static final short MINOR_13 = 0; + + /** + * Minor version number of class files for Java 14. + * + * @see #MAJOR_14 + * @since 6.4.0 + */ + public static final short MINOR_14 = 0; + + /** + * Minor version number of class files for Java 15. + * + * @see #MAJOR_15 + * @since 6.6.0 + */ + public static final short MINOR_15 = 0; + + /** + * Minor version number of class files for Java 16. + * + * @see #MAJOR_16 + * @since 6.6.0 + */ + public static final short MINOR_16 = 0; + + /** + * Minor version number of class files for Java 17. + * + * @see #MAJOR_17 + * @since 6.6.0 + */ + public static final short MINOR_17 = 0; + + /** + * Minor version number of class files for Java 18. + * + * @see #MAJOR_18 + * @since 6.6.0 + */ + public static final short MINOR_18 = 0; + + /** + * Minor version number of class files for Java 19. + * + * @see #MAJOR_19 + * @since 6.6.0 + */ + public static final short MINOR_19 = 0; + + /** + * Major version number of class files for Java 14. + * + * @see #MINOR_14 + * @since 6.4.0 + */ + public static final short MAJOR_14 = 58; + + /** + * Major version number of class files for Java 15. + * + * @see #MINOR_15 + * @since 6.6.0 + */ + public static final short MAJOR_15 = 59; + + /** + * Major version number of class files for Java 16. + * + * @see #MINOR_16 + * @since 6.6.0 + */ + public static final short MAJOR_16 = 60; + + /** + * Major version number of class files for Java 17. + * + * @see #MINOR_17 + * @since 6.6.0 + */ + public static final short MAJOR_17 = 61; + + /** + * Major version number of class files for Java 18. + * + * @see #MINOR_18 + * @since 6.6.0 + */ + public static final short MAJOR_18 = 62; + + /** + * Major version number of class files for Java 19. + * + * @see #MINOR_19 + * @since 6.6.0 + */ + public static final short MAJOR_19 = 63; + + /** + * 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 + * Classes in the Java Virtual Machine Specification (Java SE 9 Edition). + * @see Flag definitions for Fields + * in the Java Virtual Machine Specification (Java SE 9 Edition). + * @see Flag definitions for Methods + * in the Java Virtual Machine Specification (Java SE 9 Edition). + * @see Flag + * definitions for Inner Classes in the Java Virtual Machine Specification (Java SE 9 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 the Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_OPEN = 0x0020; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_SUPER = 0x0020; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_SYNCHRONIZED = 0x0020; + + /** + * One of the access flags for the Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_TRANSITIVE = 0x0020; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_BRIDGE = 0x0040; + + /** + * One of the access flags for the Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_STATIC_PHASE = 0x0040; + + /** + * One of the access flags for fields. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_VOLATILE = 0x0040; + + /** + * One of the access flags for fields. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_TRANSIENT = 0x0080; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_VARARGS = 0x0080; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_NATIVE = 0x0100; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_INTERFACE = 0x0200; + + /** + * One of the access flags for methods or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_ABSTRACT = 0x0400; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_STRICT = 0x0800; + + /** + * One of the access flags for fields, methods, classes, MethodParameter attribute, or Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_SYNTHETIC = 0x1000; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_ANNOTATION = 0x2000; + + /** + * One of the access flags for fields or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_ENUM = 0x4000; + + // Applies to classes compiled by new compilers only + /** + * One of the access flags for MethodParameter or Module attributes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_MANDATED = (short) 0x8000; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_MODULE = (short) 0x8000; + + /** + * One of the access flags for fields, methods, or classes. + * + * @see #ACC_PUBLIC + * @deprecated Use {@link #MAX_ACC_FLAG_I} + */ + @Deprecated + public static final short MAX_ACC_FLAG = ACC_ENUM; + + /** + * One of the access flags for fields, methods, or classes. ACC_MODULE is negative as a short. + * + * @see #ACC_PUBLIC + * @since 6.4.0 + */ + public static final int MAX_ACC_FLAG_I = 0x8000; // ACC_MODULE is negative as a short + + // Note that do to overloading: + // 'synchronized' is for methods, might be 'open' (if Module), 'super' (if class), or 'transitive' (if Module). + // 'volatile' is for fields, might be 'bridge' (if method) or 'static_phase' (if Module) + // 'transient' is for fields, might be 'varargs' (if method) + // 'module' is for classes, might be 'mandated' (if Module or MethodParameters) + /** + * 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", "module"}; + + /** @since 6.0 */ + public static final int ACCESS_NAMES_LENGTH = ACCESS_NAMES.length; + + /** + * 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; + + /* + * The description of the constant pool is at: https://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 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 dynamically computed. + * + * @see Change request for JEP + * 309 + * @since 6.3 + */ + public static final byte CONSTANT_Dynamic = 17; + + /** + * 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. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + * @since 6.1 + */ + public static final byte CONSTANT_Module = 19; + + /** + * Marks a constant pool entry as a Package Reference. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + * @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_Dynamic", "CONSTANT_InvokeDynamic", "CONSTANT_Module", "CONSTANT_Package"}; + + /** + * 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"}; + + /** + * 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; + + /** Empty arrays used to replace references to ArrayUtils */ + public static final byte[] EMPTY_BYTE_ARRAY = {}; + public static final int[] EMPTY_INT_ARRAY = {}; + public static final String[] EMPTY_STRING_ARRAY = {}; + + /** + * 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 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 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}; + + /** + * 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. + */ + 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 */ + }; + + /** + * 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. + */ + 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 */ + }; + + /** + * Names of opcodes. Indexed by opcode. OPCODE_NAMES[ALOAD] = "aload". + */ + 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; + + /** + * 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. + */ + 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 */ + }; + + /** + * 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. + */ + 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 */ + }; + + /** + * 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 byte ATTR_MODULE = 22; + public static final byte ATTR_MODULE_PACKAGES = 23; + public static final byte ATTR_MODULE_MAIN_CLASS = 24; + public static final byte ATTR_NEST_HOST = 25; + public static final byte ATTR_NEST_MEMBERS = 26; + public static final short KNOWN_ATTRIBUTES = 27; // 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", "Module", "ModulePackages", "ModuleMainClass", "NestHost", "NestMembers"}; + /** + * 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"}; + + /** + * 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; + 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 ACCESS_NAMES entry at the given index + * @since 6.0 + */ + public static String getAccessName(final int index) { + return ACCESS_NAMES[index]; + } + + /** + * + * @param index + * @return the attribute name + * @since 6.0 + */ + public static String getAttributeName(final int index) { + return ATTRIBUTE_NAMES[index]; + } + + /** + * 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]; + } + + /** + * + * @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]; + } + + // Constants defining the behavior of the Method Handles (JVMS 5.4.3.5) + + /** + * + * @param index + * @return Number of words consumed on operand stack + * @since 6.0 + */ + public static int getConsumeStack(final int index) { + return CONSUME_STACK[index]; + } + + /** + * @since 6.0 + */ + public static Iterable getInterfacesImplementedByArrays() { + return Collections.unmodifiableList(Arrays.asList(INTERFACES_IMPLEMENTED_BY_ARRAYS)); + } + + /** + * + * @param index + * @return the item name + * @since 6.0 + */ + public static String getItemName(final int index) { + return ITEM_NAMES[index]; + } + + /** + * + * @param index + * @return the method handle name + * @since 6.0 + */ + public static String getMethodHandleName(final int index) { + return METHODHANDLE_NAMES[index]; + } + + /** + * + * @param index + * @return Number of byte code operands + * @since 6.0 + */ + public static short getNoOfOperands(final int index) { + return NO_OF_OPERANDS[index]; + } + + /** + * @since 6.0 + */ + public static String getOpcodeName(final int index) { + return OPCODE_NAMES[index]; + } + + /** + * @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; + } + + /** + * + * @param index + * @return Number of words produced onto operand stack + * @since 6.0 + */ + public static int getProduceStack(final int index) { + return PRODUCE_STACK[index]; + } + + /** + * + * @param index + * @return the short type name + * @since 6.0 + */ + public static String getShortTypeName(final int index) { + return SHORT_TYPE_NAMES[index]; + } + + /** + * 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]; + } + + private Const() { + } // not instantiable + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/ExceptionConst.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/ExceptionConst.java new file mode 100644 index 000000000..d45c5794b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/ExceptionConst.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal; + +import jdk.xml.internal.Utils; + +/** + * Exception constants. + * + * @since 6.0 (intended to replace the InstructionConstant interface) + * @LastModified: Feb 2023 + */ +public final class ExceptionConst { + + /** + * 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, + } + + /** + * 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 + + /** + * Empty array. + */ + private static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below) + + /** + * Empty array. + */ + 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}; + + /** + * 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); + } + } + + // helper method to merge exception class arrays + private static Class[] mergeExceptions(final Class[] input, final Class... extraClasses) { + return Utils.arraysAppend(input, extraClasses); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Repository.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Repository.java new file mode 100644 index 000000000..d36260cc2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Repository.java @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal; + + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.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 com.sun.org.apache.bcel.internal.util.Repository + * @see SyntheticRepository + * + * @LastModified: Feb 2023 + */ +public abstract class Repository { + + private static com.sun.org.apache.bcel.internal.util.Repository repository = SyntheticRepository.getInstance(); + + /** + * Adds 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; + } + + /** + * Clears the repository. + */ + public static void clearCache() { + repository.clear(); + } + + /** + * @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 className) throws ClassNotFoundException { + return getInterfaces(lookupClass(className)); + } + + /** + * @return currently used repository instance + */ + public static com.sun.org.apache.bcel.internal.util.Repository getRepository() { + return repository; + } + + /** + * @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 className) throws ClassNotFoundException { + return getSuperClasses(lookupClass(className)); + } + + /** + * @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 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); + } + + /** + * @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)); + } + + /** + * Equivalent to runtime "instanceof" operator. + * + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if any superclasses or superinterfaces of clazz can't be found + */ + public static boolean instanceOf(final JavaClass clazz, final JavaClass superclass) throws ClassNotFoundException { + return clazz.instanceOf(superclass); + } + + /** + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if superclass can't be found + */ + public static boolean instanceOf(final JavaClass clazz, final String superclass) throws ClassNotFoundException { + return instanceOf(clazz, lookupClass(superclass)); + } + + /** + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if clazz can't be found + */ + public static boolean instanceOf(final String clazz, final JavaClass superclass) throws ClassNotFoundException { + return instanceOf(lookupClass(clazz), superclass); + } + + /** + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if either clazz or superclass can't be found + */ + public static boolean instanceOf(final String clazz, final String superclass) throws ClassNotFoundException { + return instanceOf(lookupClass(clazz), lookupClass(superclass)); + } + + /** + * Tries 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); + } + + /** + * Lookups class somewhere found on your CLASSPATH, or wherever 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 className) throws ClassNotFoundException { + return repository.loadClass(className); + } + + /** + * Removes given class from repository. + */ + public static void removeClass(final JavaClass clazz) { + repository.removeClass(clazz); + } + + /** + * Removes class with given (fully qualified) name from repository. + */ + public static void removeClass(final String clazz) { + repository.removeClass(repository.findClass(clazz)); + } + + /** + * Sets repository instance to be used for class loading + */ + public static void setRepository(final com.sun.org.apache.bcel.internal.util.Repository rep) { + repository = rep; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java new file mode 100644 index 000000000..61ec9c4d6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Super class for all objects that have modifiers like private, final, ... I.e. + * classes, fields, and methods. + * + * @LastModified: Jan 2020 + */ +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 initial 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; + } + + public final boolean isAbstract() { + return (access_flags & Const.ACC_ABSTRACT) != 0; + } + + public final void isAbstract(final boolean flag) { + setFlag(Const.ACC_ABSTRACT, flag); + } + + public final boolean isAnnotation() { + return (access_flags & Const.ACC_ANNOTATION) != 0; + } + + public final void isAnnotation(final boolean flag) { + setFlag(Const.ACC_ANNOTATION, flag); + } + + public final boolean isEnum() { + return (access_flags & Const.ACC_ENUM) != 0; + } + + public final void isEnum(final boolean flag) { + setFlag(Const.ACC_ENUM, flag); + } + + public final boolean isFinal() { + return (access_flags & Const.ACC_FINAL) != 0; + } + + public final void isFinal(final boolean flag) { + setFlag(Const.ACC_FINAL, flag); + } + + public final boolean isInterface() { + return (access_flags & Const.ACC_INTERFACE) != 0; + } + + public final void isInterface(final boolean flag) { + setFlag(Const.ACC_INTERFACE, flag); + } + + public final boolean isNative() { + return (access_flags & Const.ACC_NATIVE) != 0; + } + + public final void isNative(final boolean flag) { + setFlag(Const.ACC_NATIVE, flag); + } + + public final boolean isPrivate() { + return (access_flags & Const.ACC_PRIVATE) != 0; + } + + public final void isPrivate(final boolean flag) { + setFlag(Const.ACC_PRIVATE, flag); + } + + public final boolean isProtected() { + return (access_flags & Const.ACC_PROTECTED) != 0; + } + + public final void isProtected(final boolean flag) { + setFlag(Const.ACC_PROTECTED, flag); + } + + public final boolean isPublic() { + return (access_flags & Const.ACC_PUBLIC) != 0; + } + + public final void isPublic(final boolean flag) { + setFlag(Const.ACC_PUBLIC, flag); + } + + public final boolean isStatic() { + return (access_flags & Const.ACC_STATIC) != 0; + } + + public final void isStatic(final boolean flag) { + setFlag(Const.ACC_STATIC, flag); + } + + public final boolean isStrictfp() { + return (access_flags & Const.ACC_STRICT) != 0; + } + + public final void isStrictfp(final boolean flag) { + setFlag(Const.ACC_STRICT, flag); + } + + public final boolean isSynchronized() { + return (access_flags & Const.ACC_SYNCHRONIZED) != 0; + } + + public final void isSynchronized(final boolean flag) { + setFlag(Const.ACC_SYNCHRONIZED, flag); + } + + public final boolean isSynthetic() { + return (access_flags & Const.ACC_SYNTHETIC) != 0; + } + + public final void isSynthetic(final boolean flag) { + setFlag(Const.ACC_SYNTHETIC, flag); + } + + public final boolean isTransient() { + return (access_flags & Const.ACC_TRANSIENT) != 0; + } + + public final void isTransient(final boolean flag) { + setFlag(Const.ACC_TRANSIENT, flag); + } + + public final boolean isVarArgs() { + return (access_flags & Const.ACC_VARARGS) != 0; + } + + public final void isVarArgs(final boolean flag) { + setFlag(Const.ACC_VARARGS, flag); + } + + public final boolean isVolatile() { + return (access_flags & Const.ACC_VOLATILE) != 0; + } + + public final void isVolatile(final boolean flag) { + setFlag(Const.ACC_VOLATILE, flag); + } + + /** + * Set access flags aka "modifiers". + * + * @param accessFlags Access flags of the object. + */ + public final void setAccessFlags(final int accessFlags) { + this.access_flags = accessFlags; + } + + private void setFlag(final int flag, final boolean set) { + if ((access_flags & flag) != 0) { // Flag is set already + if (!set) { + access_flags ^= flag; + } + } else if (set) { + access_flags |= flag; + } + } + + /** + * Set access flags aka "modifiers". + * + * @param accessFlags Access flags of the object. + */ + public final void setModifiers(final int accessFlags) { + setAccessFlags(accessFlags); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java new file mode 100644 index 000000000..40bbfb6ea --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java @@ -0,0 +1,96 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Represents the default value of a annotation for a method info. + * + * @since 6.0 + */ +public class AnnotationDefault extends Attribute { + + private ElementValue defaultValue; + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + */ + AnnotationDefault(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (ElementValue) null, constantPool); + defaultValue = ElementValue.readElementValue(input, constantPool); + } + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param defaultValue the annotation's default value + * @param constantPool Array of constants + */ + public AnnotationDefault(final int nameIndex, final int length, final ElementValue defaultValue, final ConstantPool constantPool) { + super(Const.ATTR_ANNOTATION_DEFAULT, nameIndex, length, constantPool); + this.defaultValue = defaultValue; + } + + /** + * 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.visitAnnotationDefault(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + defaultValue.dump(dos); + } + + /** + * @return the default value + */ + public final ElementValue getDefaultValue() { + return defaultValue; + } + + /** + * @param defaultValue the default value of this methodinfo's annotation + */ + public final void setDefaultValue(final ElementValue defaultValue) { + this.defaultValue = defaultValue; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java new file mode 100644 index 000000000..8d618258d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 ClassFormatException("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); + } + + public AnnotationEntry getAnnotationEntry() { + return annotationEntry; + } + + @Override + public String stringifyValue() { + return annotationEntry.toString(); + } + + @Override + public String toString() { + return stringifyValue(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java new file mode 100644 index 000000000..466e9bf34 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java @@ -0,0 +1,167 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** + * Represents one annotation in the annotation table + * + * @since 6.0 + */ +public class AnnotationEntry implements Node { + + public static final AnnotationEntry[] EMPTY_ARRAY = {}; + + public static AnnotationEntry[] createAnnotationEntries(final Attribute[] attrs) { + // Find attributes that contain annotation data + return Stream.of(attrs).filter(Annotations.class::isInstance).flatMap(e -> Stream.of(((Annotations) e).getAnnotationEntries())) + .toArray(AnnotationEntry[]::new); + } + + /** + * Factory method to create an AnnotionEntry from a DataInput + * + * @param input + * @param constantPool + * @param isRuntimeVisible + * @return the entry + * @throws IOException if an I/O error occurs. + */ + public static AnnotationEntry read(final DataInput input, final ConstantPool constantPool, final boolean isRuntimeVisible) throws IOException { + final AnnotationEntry annotationEntry = new AnnotationEntry(input.readUnsignedShort(), constantPool, isRuntimeVisible); + final int numElementValuePairs = input.readUnsignedShort(); + annotationEntry.elementValuePairs = new ArrayList<>(); + for (int i = 0; i < numElementValuePairs; i++) { + annotationEntry.elementValuePairs + .add(new ElementValuePair(input.readUnsignedShort(), ElementValue.readElementValue(input, constantPool), constantPool)); + } + return annotationEntry; + } + + private final int typeIndex; + + private final ConstantPool constantPool; + + private final boolean isRuntimeVisible; + + private List elementValuePairs; + + public AnnotationEntry(final int typeIndex, final ConstantPool constantPool, final boolean isRuntimeVisible) { + this.typeIndex = typeIndex; + this.constantPool = constantPool; + this.isRuntimeVisible = isRuntimeVisible; + } + + /** + * 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.visitAnnotationEntry(this); + } + + public void addElementNameValuePair(final ElementValuePair elementNameValuePair) { + elementValuePairs.add(elementNameValuePair); + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(typeIndex); // u2 index of type name in cpool + dos.writeShort(elementValuePairs.size()); // u2 element_value pair + // count + for (final ElementValuePair envp : elementValuePairs) { + envp.dump(dos); + } + } + + /** + * @return the annotation type name + */ + public String getAnnotationType() { + return constantPool.getConstantUtf8(typeIndex).getBytes(); + } + + /** + * @return the annotation type index + */ + public int getAnnotationTypeIndex() { + return typeIndex; + } + + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @return the element value pairs in this annotation entry + */ + public ElementValuePair[] getElementValuePairs() { + // TODO return List + return elementValuePairs.toArray(ElementValuePair.EMPTY_ARRAY); + } + + /** + * @return the number of element value pairs in this annotation entry + */ + public final int getNumElementValuePairs() { + return elementValuePairs.size(); + } + + public int getTypeIndex() { + return typeIndex; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + 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(", "); + } + // remove last ", " + result.setLength(result.length() - 2); + result.append(")"); + } + return result.toString(); + } + + @Override + public String toString() { + return toShortString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Annotations.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Annotations.java new file mode 100644 index 000000000..52ac9d0dd --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Annotations.java @@ -0,0 +1,163 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * base class for annotations + * + * @since 6.0 + */ +public abstract class Annotations extends Attribute implements Iterable { + + private AnnotationEntry[] annotationTable; + private final boolean isRuntimeVisible; + + /** + * Constructs an instance. + * + * @param annotationType the subclass type of the annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param annotationTable the actual annotations + * @param constantPool Array of constants + * @param isRuntimeVisible whether this Annotation visible at runtime + */ + public Annotations(final byte annotationType, final int nameIndex, final int length, final AnnotationEntry[] annotationTable, + final ConstantPool constantPool, final boolean isRuntimeVisible) { + super(annotationType, nameIndex, length, constantPool); + this.annotationTable = annotationTable; + this.isRuntimeVisible = isRuntimeVisible; + } + + /** + * Constructs an instance. + * + * @param annotationType the subclass type of the annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @param isRuntimeVisible whether this Annotation visible at runtime + * @throws IOException if an I/O error occurs. + */ + Annotations(final byte annotationType, final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool, + final boolean isRuntimeVisible) throws IOException { + this(annotationType, nameIndex, length, (AnnotationEntry[]) null, constantPool, isRuntimeVisible); + final int annotationTableLength = input.readUnsignedShort(); + annotationTable = new AnnotationEntry[annotationTableLength]; + for (int i = 0; i < annotationTableLength; i++) { + annotationTable[i] = AnnotationEntry.read(input, constantPool, isRuntimeVisible); + } + } + + /** + * 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.visitAnnotation(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + // TODO Auto-generated method stub + return null; + } + + /** + * Gets the array of annotation entries in this annotation + */ + public AnnotationEntry[] getAnnotationEntries() { + return annotationTable; + } + + /** + * Gets the number of annotation entries in this annotation. + * + * @return the number of annotation entries in this annotation + */ + public final int getNumAnnotations() { + if (annotationTable == null) { + return 0; + } + return annotationTable.length; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + @Override + public Iterator iterator() { + return Stream.of(annotationTable).iterator(); + } + + /** + * Sets the entries to set in this annotation. + * + * @param annotationTable the entries to set in this annotation + */ + public final void setAnnotationTable(final AnnotationEntry[] annotationTable) { + this.annotationTable = annotationTable; + } + + /** + * Converts to a String representation. + * + * @return String representation + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(Const.getAttributeName(getTag())); + buf.append(":\n"); + for (int i = 0; i < annotationTable.length; i++) { + buf.append(" ").append(annotationTable[i]); + if (i < annotationTable.length - 1) { + buf.append('\n'); + } + } + return buf.toString(); + } + + protected void writeAnnotations(final DataOutputStream dos) throws IOException { + if (annotationTable == null) { + return; + } + dos.writeShort(annotationTable.length); + for (final AnnotationEntry element : annotationTable) { + element.dump(dos); + } + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java new file mode 100644 index 000000000..e8768886d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java @@ -0,0 +1,86 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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[] elementValues; + + public ArrayElementValue(final int type, final ElementValue[] datums, final ConstantPool cpool) { + super(type, cpool); + if (type != ARRAY) { + throw new ClassFormatException("Only element values of type array can be built with this ctor - type specified: " + type); + } + this.elementValues = datums; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getType()); // u1 type of value (ARRAY == '[') + dos.writeShort(elementValues.length); + for (final ElementValue evalue : elementValues) { + evalue.dump(dos); + } + } + + public ElementValue[] getElementValuesArray() { + return elementValues; + } + + public int getElementValuesArraySize() { + return elementValues.length; + } + + @Override + public String stringifyValue() { + final StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < elementValues.length; i++) { + sb.append(elementValues[i].stringifyValue()); + if (i + 1 < elementValues.length) { + sb.append(","); + } + } + sb.append("]"); + return sb.toString(); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("{"); + for (int i = 0; i < elementValues.length; i++) { + sb.append(elementValues[i]); + if (i + 1 < elementValues.length) { + sb.append(","); + } + } + sb.append("}"); + return sb.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Attribute.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Attribute.java new file mode 100644 index 000000000..bf72fee4e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Attribute.java @@ -0,0 +1,370 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.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 com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + *
    + * attribute_info {
    + *   u2 attribute_name_index;
    + *   u4 attribute_length;
    + *   u1 info[attribute_length];
    + * }
    + * 
    + * + * @see ConstantValue + * @see SourceFile + * @see Code + * @see Unknown + * @see ExceptionTable + * @see LineNumberTable + * @see LocalVariableTable + * @see InnerClasses + * @see Synthetic + * @see Deprecated + * @see Signature + * @LastModified: Feb 2023 + */ +public abstract class Attribute implements Cloneable, Node { + private static final boolean debug = false; + + private static final Map READERS = new HashMap<>(); + + /** + * Empty array. + * + * @since 6.6.0 + */ + public static final Attribute[] EMPTY_ARRAY = {}; + + /** + * 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 unknownAttributeReader the reader object + */ + public static void addAttributeReader(final String name, final UnknownAttributeReader unknownAttributeReader) { + READERS.put(name, unknownAttributeReader); + } + + protected static void println(final String msg) { + if (debug) { + System.err.println(msg); + } + } + + /** + * 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 dataInput Input stream + * @param constantPool Array of constants + * @return Attribute + * @throws IOException if an I/O error occurs. + * @since 6.0 + */ + public static Attribute readAttribute(final DataInput dataInput, final ConstantPool constantPool) throws IOException { + byte tag = Const.ATTR_UNKNOWN; // Unknown attribute + // Get class name from constant pool via 'name_index' indirection + final int nameIndex = dataInput.readUnsignedShort(); + final String name = constantPool.getConstantUtf8(nameIndex).getBytes(); + + // Length of data in bytes + final int length = dataInput.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(nameIndex, length, dataInput, constantPool); + } + return new Unknown(nameIndex, length, dataInput, constantPool); + case Const.ATTR_CONSTANT_VALUE: + return new ConstantValue(nameIndex, length, dataInput, constantPool); + case Const.ATTR_SOURCE_FILE: + return new SourceFile(nameIndex, length, dataInput, constantPool); + case Const.ATTR_CODE: + return new Code(nameIndex, length, dataInput, constantPool); + case Const.ATTR_EXCEPTIONS: + return new ExceptionTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_LINE_NUMBER_TABLE: + return new LineNumberTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_LOCAL_VARIABLE_TABLE: + return new LocalVariableTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_INNER_CLASSES: + return new InnerClasses(nameIndex, length, dataInput, constantPool); + case Const.ATTR_SYNTHETIC: + return new Synthetic(nameIndex, length, dataInput, constantPool); + case Const.ATTR_DEPRECATED: + return new Deprecated(nameIndex, length, dataInput, constantPool); + case Const.ATTR_PMG: + return new PMGClass(nameIndex, length, dataInput, constantPool); + case Const.ATTR_SIGNATURE: + return new Signature(nameIndex, length, dataInput, constantPool); + 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. + println("Warning: Obsolete StackMap attribute ignored."); + return new Unknown(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS: + return new RuntimeVisibleAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS: + return new RuntimeInvisibleAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeVisibleParameterAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeInvisibleParameterAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_ANNOTATION_DEFAULT: + return new AnnotationDefault(nameIndex, length, dataInput, constantPool); + case Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE: + return new LocalVariableTypeTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_ENCLOSING_METHOD: + return new EnclosingMethod(nameIndex, length, dataInput, constantPool); + 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(nameIndex, length, dataInput, constantPool); + case Const.ATTR_BOOTSTRAP_METHODS: + return new BootstrapMethods(nameIndex, length, dataInput, constantPool); + case Const.ATTR_METHOD_PARAMETERS: + return new MethodParameters(nameIndex, length, dataInput, constantPool); + case Const.ATTR_MODULE: + return new Module(nameIndex, length, dataInput, constantPool); + case Const.ATTR_MODULE_PACKAGES: + return new ModulePackages(nameIndex, length, dataInput, constantPool); + case Const.ATTR_MODULE_MAIN_CLASS: + return new ModuleMainClass(nameIndex, length, dataInput, constantPool); + case Const.ATTR_NEST_HOST: + return new NestHost(nameIndex, length, dataInput, constantPool); + case Const.ATTR_NEST_MEMBERS: + return new NestMembers(nameIndex, length, dataInput, constantPool); + default: + // Never reached + throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag); + } + } + + /** + * 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 dataInputStream Input stream + * @param constantPool Array of constants + * @return Attribute + * @throws IOException if an I/O error occurs. + */ + public static Attribute readAttribute(final DataInputStream dataInputStream, final ConstantPool constantPool) throws IOException { + return readAttribute((DataInput) dataInputStream, constantPool); + } + + /** + * 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); + } + + /** + * @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) + + /** + * Constructs an instance. + * + *
    +     * attribute_info {
    +     *   u2 attribute_name_index;
    +     *   u4 attribute_length;
    +     *   u1 info[attribute_length];
    +     * }
    +     * 
    + * + * @param tag tag. + * @param nameIndex u2 name index. + * @param length u4 length. + * @param constantPool constant pool. + */ + protected Attribute(final byte tag, final int nameIndex, final int length, final ConstantPool constantPool) { + this.tag = tag; + this.name_index = Args.requireU2(nameIndex, 0, constantPool.getLength(), getClass().getSimpleName() + " name index"); + this.length = Args.requireU4(length, getClass().getSimpleName() + " attribute length"); + this.constant_pool = constantPool; + } + + /** + * 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 abstract void accept(Visitor v); + + /** + * 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; + } + + /** + * @param constantPool constant pool to save. + * @return deep copy of this attribute. + */ + public abstract Attribute copy(ConstantPool constantPool); + + /** + * Dumps attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(name_index); + file.writeInt(length); + } + + /** + * @return Constant pool used by this object. + * @see ConstantPool + */ + public final ConstantPool getConstantPool() { + return constant_pool; + } + + /** + * @return Length of attribute field in bytes. + */ + public final int getLength() { + return length; + } + + /** + * @return Name of attribute + * @since 6.0 + */ + public String getName() { + return constant_pool.getConstantUtf8(name_index).getBytes(); + } + + /** + * @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; + } + + /** + * @param constantPool Constant pool to be used for this object. + * @see ConstantPool + */ + public final void setConstantPool(final ConstantPool constantPool) { + this.constant_pool = constantPool; + } + + /** + * @param length length in bytes. + */ + public final void setLength(final int length) { + this.length = length; + } + + /** + * @param nameIndex of attribute. + */ + public final void setNameIndex(final int nameIndex) { + this.name_index = nameIndex; + } + + /** + * @return attribute name. + */ + @Override + public String toString() { + return Const.getAttributeName(tag); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java new file mode 100644 index 000000000..6d4891f95 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java @@ -0,0 +1,55 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 + * + * @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 nameIndex 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 constantPool 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 nameIndex, int length, java.io.DataInputStream file, ConstantPool constantPool); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java new file mode 100644 index 000000000..61b818ec4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java @@ -0,0 +1,170 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.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 bootstrapMethodRef; + + /** Array of references to the constant_pool table */ + private int[] bootstrapArguments; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public BootstrapMethod(final BootstrapMethod c) { + this(c.getBootstrapMethodRef(), c.getBootstrapArguments()); + } + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException if an I/O error occurs. + */ + BootstrapMethod(final DataInput input) throws IOException { + this(input.readUnsignedShort(), input.readUnsignedShort()); + + for (int i = 0; i < bootstrapArguments.length; i++) { + bootstrapArguments[i] = input.readUnsignedShort(); + } + } + + // helper method + private BootstrapMethod(final int bootstrapMethodRef, final int numBootstrapArguments) { + this(bootstrapMethodRef, new int[numBootstrapArguments]); + } + + /** + * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle + * @param bootstrapArguments int[] indices into constant_pool of CONSTANT_[type]_info + */ + public BootstrapMethod(final int bootstrapMethodRef, final int[] bootstrapArguments) { + this.bootstrapMethodRef = bootstrapMethodRef; + this.bootstrapArguments = bootstrapArguments; + } + + /** + * @return deep copy of this object + */ + public BootstrapMethod copy() { + try { + return (BootstrapMethod) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump object to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(bootstrapMethodRef); + file.writeShort(bootstrapArguments.length); + for (final int bootstrapArgument : bootstrapArguments) { + file.writeShort(bootstrapArgument); + } + } + + /** + * @return int[] of bootstrap_method indices into constant_pool of CONSTANT_[type]_info + */ + public int[] getBootstrapArguments() { + return bootstrapArguments; + } + + /** + * @return index into constant_pool of bootstrap_method + */ + public int getBootstrapMethodRef() { + return bootstrapMethodRef; + } + + /** + * @return count of number of boostrap arguments + */ + public int getNumBootstrapArguments() { + return bootstrapArguments.length; + } + + /** + * @param bootstrapArguments int[] indices into constant_pool of CONSTANT_[type]_info + */ + public void setBootstrapArguments(final int[] bootstrapArguments) { + this.bootstrapArguments = bootstrapArguments; + } + + /** + * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle + */ + public void setBootstrapMethodRef(final int bootstrapMethodRef) { + this.bootstrapMethodRef = bootstrapMethodRef; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + return "BootstrapMethod(" + bootstrapMethodRef + ", " + bootstrapArguments.length + ", " + Arrays.toString(bootstrapArguments) + ")"; + } + + /** + * @return Resolved string representation + */ + public final String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String bootstrapMethodName = constantPool.constantToString(bootstrapMethodRef, Const.CONSTANT_MethodHandle); + buf.append(Utility.compactClassName(bootstrapMethodName, false)); + final int bootstrapArgumentsLen = bootstrapArguments.length; + if (bootstrapArgumentsLen > 0) { + buf.append("\nMethod Arguments:"); + for (int i = 0; i < bootstrapArgumentsLen; i++) { + buf.append("\n ").append(i).append(": "); + buf.append(constantPool.constantToString(constantPool.getConstant(bootstrapArguments[i]))); + } + } + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java new file mode 100644 index 000000000..6f9930f1b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java @@ -0,0 +1,163 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a BootstrapMethods attribute. + * + * @see The class File Format : + * The BootstrapMethods Attribute + * @since 6.0 + */ +public class BootstrapMethods extends Attribute implements Iterable { + + private BootstrapMethod[] bootstrapMethods; // 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. + * + * @param c Source to copy. + */ + public BootstrapMethods(final BootstrapMethods c) { + this(c.getNameIndex(), c.getLength(), c.getBootstrapMethods(), c.getConstantPool()); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param bootstrapMethods array of bootstrap methods + * @param constantPool Array of constants + */ + public BootstrapMethods(final int nameIndex, final int length, final BootstrapMethod[] bootstrapMethods, final ConstantPool constantPool) { + super(Const.ATTR_BOOTSTRAP_METHODS, nameIndex, length, constantPool); + this.bootstrapMethods = bootstrapMethods; + } + + /** + * Construct object from Input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + BootstrapMethods(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (BootstrapMethod[]) null, constantPool); + + final int numBootstrapMethods = input.readUnsignedShort(); + bootstrapMethods = new BootstrapMethod[numBootstrapMethods]; + for (int i = 0; i < numBootstrapMethods; i++) { + bootstrapMethods[i] = new BootstrapMethod(input); + } + } + + /** + * @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 constantPool) { + final BootstrapMethods c = (BootstrapMethods) clone(); + c.bootstrapMethods = new BootstrapMethod[bootstrapMethods.length]; + + for (int i = 0; i < bootstrapMethods.length; i++) { + c.bootstrapMethods[i] = bootstrapMethods[i].copy(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump bootstrap methods attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + + file.writeShort(bootstrapMethods.length); + for (final BootstrapMethod bootstrapMethod : bootstrapMethods) { + bootstrapMethod.dump(file); + } + } + + /** + * @return array of bootstrap method "records" + */ + public final BootstrapMethod[] getBootstrapMethods() { + return bootstrapMethods; + } + + @Override + public Iterator iterator() { + return Stream.of(bootstrapMethods).iterator(); + } + + /** + * @param bootstrapMethods the array of bootstrap methods + */ + public final void setBootstrapMethods(final BootstrapMethod[] bootstrapMethods) { + this.bootstrapMethods = bootstrapMethods; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("BootstrapMethods("); + buf.append(bootstrapMethods.length); + buf.append("):"); + for (int i = 0; i < bootstrapMethods.length; i++) { + buf.append("\n"); + final int start = buf.length(); + buf.append(" ").append(i).append(": "); + final int indentCount = buf.length() - start; + final String[] lines = bootstrapMethods[i].toString(super.getConstantPool()).split("\\r?\\n"); + buf.append(lines[0]); + for (int j = 1; j < lines.length; j++) { + buf.append("\n").append(" ", 0, indentCount).append(lines[j]); + } + } + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java new file mode 100644 index 000000000..3df0eb986 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java @@ -0,0 +1,59 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @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; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getType()); // u1 kind of value + dos.writeShort(idx); + } + + public String getClassString() { + return super.getConstantPool().getConstantUtf8(idx).getBytes(); + } + + public int getIndex() { + return idx; + } + + @Override + public String stringifyValue() { + return super.getConstantPool().getConstantUtf8(idx).getBytes(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java new file mode 100644 index 000000000..a61e1d753 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java @@ -0,0 +1,73 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Thrown when the BCEL attempts to read a class file and determines that a class is malformed or otherwise cannot be interpreted as a class file. + */ +public class ClassFormatException extends RuntimeException { + + private static final long serialVersionUID = -3569097343160139969L; + + /** + * Constructs a new instance with {@code null} as its detail message. The cause is not initialized, and may subsequently be initialized by a call to + * {@link #initCause}. + */ + public ClassFormatException() { + } + + /** + * Constructs a new instance with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to + * {@link #initCause}. + * + * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. + */ + public ClassFormatException(final String message) { + super(message); + } + + /** + * Constructs a new instance with the specified detail message and cause. + *

    + * Note that the detail message associated with {@code cause} is not automatically incorporated in this runtime exception's detail message. + * + * @param message the detail message (which is saved for later retrieval by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that + * the cause is nonexistent or unknown.) + * @since 6.0 + */ + public ClassFormatException(final String message, final Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new instance with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the + * class and detail message of {@code cause}). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables. + * + * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the + * cause is nonexistent or unknown.) + * @since 6.7.0 + */ + public ClassFormatException(final Throwable cause) { + super(cause); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassParser.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassParser.java new file mode 100644 index 000000000..c9daaeabf --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassParser.java @@ -0,0 +1,297 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 com.sun.org.apache.bcel.internal.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 + * appropriate 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. + */ +public final class ClassParser { + + private static final int BUFSIZE = 8192; + private DataInputStream dataInputStream; + private final boolean fileOwned; + private final String fileName; + private String zipFile; + private int classNameIndex; + private int superclassNameIndex; + private int major; // Compiler version + private int minor; // Compiler version + private int accessFlags; // Access rights of parsed class + private int[] interfaces; // Names of implemented interfaces + private ConstantPool constantPool; // 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 isZip; // Loaded from zip file + + /** + * Parses class from the given stream. + * + * @param inputStream Input stream + * @param fileName File name + */ + public ClassParser(final InputStream inputStream, final String fileName) { + this.fileName = fileName; + this.fileOwned = false; + final String clazz = inputStream.getClass().getName(); // Not a very clean solution ... + this.isZip = 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)); + } + } + + /** + * Parses class from given .class file. + * + * @param fileName file name + */ + public ClassParser(final String fileName) { + this.isZip = false; + this.fileName = fileName; + this.fileOwned = true; + } + + /** + * Parses class from given .class file in a ZIP-archive + * + * @param zipFile zip file name + * @param fileName file name + */ + public ClassParser(final String zipFile, final String fileName) { + this.isZip = true; + this.fileOwned = true; + this.zipFile = zipFile; + this.fileName = fileName; + } + + /** + * Parses 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 if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public JavaClass parse() throws IOException, ClassFormatException { + ZipFile zip = null; + try { + if (fileOwned) { + if (isZip) { + zip = new ZipFile(zipFile); + final ZipEntry entry = zip.getEntry(fileName); + + if (entry == null) { + throw new IOException("File " + fileName + " not found"); + } + + dataInputStream = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), BUFSIZE)); + } else { + dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(fileName), 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(!(isZip && (buf.length == 1))) { + // System.err.println("WARNING: Trailing garbage at end of " + fileName); + // 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 ignored) { + // ignore close exceptions + } + } + try { + if (zip != null) { + zip.close(); + } + } catch (final IOException ignored) { + // ignore close exceptions + } + } + // Return the information we have gathered in a new object + return new JavaClass(classNameIndex, superclassNameIndex, fileName, major, minor, accessFlags, constantPool, interfaces, fields, methods, attributes, + isZip ? JavaClass.ZIP : JavaClass.FILE); + } + + /** + * Reads information about the attributes of the class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readAttributes() throws IOException, ClassFormatException { + final int attributesCount = dataInputStream.readUnsignedShort(); + attributes = new Attribute[attributesCount]; + for (int i = 0; i < attributesCount; i++) { + attributes[i] = Attribute.readAttribute(dataInputStream, constantPool); + } + } + + /** + * Reads information about the class and its super class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readClassInfo() throws IOException, ClassFormatException { + accessFlags = dataInputStream.readUnsignedShort(); + /* + * Interfaces are implicitly abstract, the flag should be set according to the JVM specification. + */ + if ((accessFlags & Const.ACC_INTERFACE) != 0) { + accessFlags |= Const.ACC_ABSTRACT; + } + if ((accessFlags & Const.ACC_ABSTRACT) != 0 && (accessFlags & Const.ACC_FINAL) != 0) { + throw new ClassFormatException("Class " + fileName + " can't be both final and abstract"); + } + classNameIndex = dataInputStream.readUnsignedShort(); + superclassNameIndex = dataInputStream.readUnsignedShort(); + } + + /** + * Reads constant pool entries. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readConstantPool() throws IOException, ClassFormatException { + constantPool = new ConstantPool(dataInputStream); + } + + /** + * Reads information about the fields of the class, i.e., its variables. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readFields() throws IOException, ClassFormatException { + final int fieldsCount = dataInputStream.readUnsignedShort(); + fields = new Field[fieldsCount]; + for (int i = 0; i < fieldsCount; i++) { + fields[i] = new Field(dataInputStream, constantPool); + } + } + + /******************** Private utility methods **********************/ + /** + * Checks whether the header of the file is ok. Of course, this has to be the first action on successive file reads. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readID() throws IOException, ClassFormatException { + if (dataInputStream.readInt() != Const.JVM_CLASSFILE_MAGIC) { + throw new ClassFormatException(fileName + " is not a Java .class file"); + } + } + + /** + * Reads information about the interfaces implemented by this class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readInterfaces() throws IOException, ClassFormatException { + final int interfacesCount = dataInputStream.readUnsignedShort(); + interfaces = new int[interfacesCount]; + for (int i = 0; i < interfacesCount; i++) { + interfaces[i] = dataInputStream.readUnsignedShort(); + } + } + + /** + * Reads information about the methods of the class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readMethods() throws IOException { + final int methodsCount = dataInputStream.readUnsignedShort(); + methods = new Method[methodsCount]; + for (int i = 0; i < methodsCount; i++) { + methods[i] = new Method(dataInputStream, constantPool); + } + } + + /** + * Reads major and minor version of compiler which created the file. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readVersion() throws IOException, ClassFormatException { + minor = dataInputStream.readUnsignedShort(); + major = dataInputStream.readUnsignedShort(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Code.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Code.java new file mode 100644 index 000000000..498a8c71b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Code.java @@ -0,0 +1,351 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + *

    + * Code_attribute {
    + *   u2 attribute_name_index;
    + *   u4 attribute_length;
    + *   u2 max_stack;
    + *   u2 max_locals;
    + *   u4 code_length;
    + *   u1 code[code_length];
    + *   u2 exception_table_length;
    + *   {
    + *     u2 start_pc;
    + *     u2 end_pc;
    + *     u2 handler_pc;
    + *     u2 catch_type;
    + *   } exception_table[exception_table_length];
    + *   u2 attributes_count;
    + *   attribute_info attributes[attributes_count];
    + * }
    + * 
    + * @see Attribute + * @see CodeException + * @see LineNumberTable + * @see LocalVariableTable + * @LastModified: Feb 2023 + */ +public final class Code extends Attribute { + + private int maxStack; // Maximum size of stack used by this method // TODO this could be made final (setter is not used) + private int maxLocals; // Number of local variables // TODO this could be made final (setter is not used) + private byte[] code; // Actual byte code + private CodeException[] exceptionTable; // 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. + * + * @param code The source Code. + */ + public Code(final Code code) { + this(code.getNameIndex(), code.getLength(), code.getMaxStack(), code.getMaxLocals(), code.getCode(), code.getExceptionTable(), code.getAttributes(), + code.getConstantPool()); + } + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param file Input stream + * @param constantPool Array of constants + */ + Code(final int nameIndex, final int length, final DataInput file, final ConstantPool constantPool) throws IOException { + // Initialize with some default values which will be overwritten later + this(nameIndex, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null, (CodeException[]) null, (Attribute[]) null, constantPool); + final int codeLength = Args.requireU4(file.readInt(), 1, "Code length attribute"); + code = new byte[codeLength]; // 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 exceptionTableLength = file.readUnsignedShort(); + exceptionTable = new CodeException[exceptionTableLength]; + for (int i = 0; i < exceptionTableLength; i++) { + exceptionTable[i] = new CodeException(file); + } + /* + * Read all attributes, currently 'LineNumberTable' and 'LocalVariableTable' + */ + final int attributesCount = file.readUnsignedShort(); + attributes = new Attribute[attributesCount]; + for (int i = 0; i < attributesCount; i++) { + attributes[i] = Attribute.readAttribute(file, constantPool); + } + /* + * 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 nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param maxStack Maximum size of stack + * @param maxLocals Number of local variables + * @param code Actual byte code + * @param exceptionTable of handled exceptions + * @param attributes Attributes of code: LineNumber or LocalVariable + * @param constantPool Array of constants + */ + public Code(final int nameIndex, final int length, final int maxStack, final int maxLocals, final byte[] code, final CodeException[] exceptionTable, + final Attribute[] attributes, final ConstantPool constantPool) { + super(Const.ATTR_CODE, nameIndex, length, constantPool); + this.maxStack = Args.requireU2(maxStack, "maxStack"); + this.maxLocals = Args.requireU2(maxLocals, "maxLocals"); + this.code = code != null ? code : Const.EMPTY_BYTE_ARRAY; + this.exceptionTable = exceptionTable != null ? exceptionTable : CodeException.EMPTY_CODE_EXCEPTION_ARRAY; + Args.requireU2(this.exceptionTable.length, "exceptionTable.length"); + this.attributes = attributes != null ? attributes : EMPTY_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * 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.visitCode(this); + } + + /** + * @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(); + } + + /** + * @return deep copy of this attribute + * + * @param constantPool the constant pool to duplicate + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Code c = (Code) clone(); + if (code != null) { + c.code = code.clone(); + } + c.setConstantPool(constantPool); + c.exceptionTable = new CodeException[exceptionTable.length]; + Arrays.setAll(c.exceptionTable, i -> exceptionTable[i].copy()); + c.attributes = new Attribute[attributes.length]; + Arrays.setAll(c.attributes, i -> attributes[i].copy(constantPool)); + return c; + } + + /** + * Dump code attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(maxStack); + file.writeShort(maxLocals); + file.writeInt(code.length); + file.write(code, 0, code.length); + file.writeShort(exceptionTable.length); + for (final CodeException exception : exceptionTable) { + exception.dump(file); + } + file.writeShort(attributes.length); + for (final Attribute attribute : attributes) { + attribute.dump(file); + } + } + + /** + * @return Collection of code attributes. + * @see Attribute + */ + public Attribute[] getAttributes() { + return attributes; + } + + /** + * @return Actual byte code of the method. + */ + public byte[] getCode() { + return code; + } + + /** + * @return Table of handled exceptions. + * @see CodeException + */ + public CodeException[] getExceptionTable() { + return exceptionTable; + } + + /** + * @return the internal length of this code attribute (minus the first 6 bytes) and excluding all its attributes + */ + private int getInternalLength() { + return 2 /* maxStack */ + 2 /* maxLocals */ + 4 /* code length */ + + code.length /* byte-code */ + + 2 /* exception-table length */ + + 8 * (exceptionTable == null ? 0 : exceptionTable.length) /* exception table */ + + 2 /* attributes count */; + } + + /** + * @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 Number of local variables. + */ + public int getMaxLocals() { + return maxLocals; + } + + /** + * @return Maximum size of stack used by this method. + */ + public int getMaxStack() { + return maxStack; + } + + /** + * @param attributes the attributes to set for this Code + */ + public void setAttributes(final Attribute[] attributes) { + this.attributes = attributes != null ? attributes : EMPTY_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * @param code byte code + */ + public void setCode(final byte[] code) { + this.code = code != null ? code : Const.EMPTY_BYTE_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * @param exceptionTable exception table + */ + public void setExceptionTable(final CodeException[] exceptionTable) { + this.exceptionTable = exceptionTable != null ? exceptionTable : CodeException.EMPTY_CODE_EXCEPTION_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * @param maxLocals maximum number of local variables + */ + public void setMaxLocals(final int maxLocals) { + this.maxLocals = maxLocals; + } + + /** + * @param maxStack maximum stack size + */ + public void setMaxStack(final int maxStack) { + this.maxStack = maxStack; + } + + /** + * @return String representation of code chunk. + */ + @Override + public String toString() { + return toString(true); + } + + /** + * Converts this object to a String. + * + * @param verbose Provides verbose output when true. + * @return String representation of code chunk. + */ + public String toString(final boolean verbose) { + final StringBuilder buf = new StringBuilder(100); // CHECKSTYLE IGNORE MagicNumber + buf.append("Code(maxStack = ").append(maxStack).append(", maxLocals = ").append(maxLocals).append(", code_length = ").append(code.length).append(")\n") + .append(Utility.codeToString(code, super.getConstantPool(), 0, -1, verbose)); + if (exceptionTable.length > 0) { + buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n"); + for (final CodeException exception : exceptionTable) { + 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.getName()).append(":"); + buf.append("\n").append(attribute); + } + } + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/CodeException.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/CodeException.java new file mode 100644 index 000000000..ee224e6b3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/CodeException.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + *
    + * Code_attribute {
    + *   u2 attribute_name_index;
    + *   u4 attribute_length;
    + *   u2 max_stack;
    + *   u2 max_locals;
    + *   u4 code_length;
    + *   u1 code[code_length];
    + *   u2 exception_table_length;
    + *   {
    + *     u2 start_pc;
    + *     u2 end_pc;
    + *     u2 handler_pc;
    + *     u2 catch_type;
    + *   } exception_table[exception_table_length];
    + *   u2 attributes_count;
    + *   attribute_info attributes[attributes_count];
    + * }
    + * 
    + * + * @see Code + * @LastModified: Feb 2023 + */ +public final class CodeException implements Cloneable, Node { + + /** + * Empty array. + */ + static final CodeException[] EMPTY_CODE_EXCEPTION_ARRAY = {}; + + /** Range in the code the exception handler. */ + private int startPc; + + /** active. startPc is inclusive, endPc exclusive. */ + private int endPc; + + /** + * Starting address of exception handler, i.e., an offset from start of code. + */ + private int handlerPc; + + /* + * If this is zero the handler catches any exception, otherwise it points to the exception class which is to be caught. + */ + private int catchType; + + /** + * Constructs a new instance from another instance. + * + * @param c Source for copying. + */ + public CodeException(final CodeException c) { + this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); + } + + /** + * Constructs a new instance from a DataInput. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + CodeException(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * Constructs a new instance. + * + * @param startPc Range in the code the exception handler is active, startPc is inclusive while + * @param endPc is exclusive + * @param handlerPc Starting address of exception handler, i.e., an offset from start of code. + * @param catchType If zero the handler catches any exception, otherwise it points to the exception class which is to be + * caught. + */ + public CodeException(final int startPc, final int endPc, final int handlerPc, final int catchType) { + this.startPc = Args.requireU2(startPc, "startPc"); + this.endPc = Args.requireU2(endPc, "endPc"); + this.handlerPc = Args.requireU2(handlerPc, "handlerPc"); + this.catchType = Args.requireU2(catchType, "catchType"); + } + + /** + * 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.visitCodeException(this); + } + + /** + * @return deep copy of this object + */ + public CodeException copy() { + try { + return (CodeException) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dumps code exception to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(startPc); + file.writeShort(endPc); + file.writeShort(handlerPc); + file.writeShort(catchType); + } + + /** + * @return 0, if the handler catches any exception, otherwise it points to the exception class which is to be caught. + */ + public int getCatchType() { + return catchType; + } + + /** + * @return Exclusive end index of the region where the handler is active. + */ + public int getEndPC() { + return endPc; + } + + /** + * @return Starting address of exception handler, relative to the code. + */ + public int getHandlerPC() { + return handlerPc; + } + + /** + * @return Inclusive start index of the region where the handler is active. + */ + public int getStartPC() { + return startPc; + } + + /** + * @param catchType the type of exception that is caught + */ + public void setCatchType(final int catchType) { + this.catchType = catchType; + } + + /** + * @param endPc end of handled block + */ + public void setEndPC(final int endPc) { + this.endPc = endPc; + } + + /** + * @param handlerPc where the actual code is + */ + public void setHandlerPC(final int handlerPc) { // TODO unused + this.handlerPc = handlerPc; + } + + /** + * @param startPc start of handled block + */ + public void setStartPC(final int startPc) { // TODO unused + this.startPc = startPc; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return "CodeException(startPc = " + startPc + ", endPc = " + endPc + ", handlerPc = " + handlerPc + ", catchType = " + catchType + ")"; + } + + public String toString(final ConstantPool cp) { + return toString(cp, true); + } + + /** + * @param cp constant pool source. + * @param verbose Output more if true. + * @return String representation. + */ + public String toString(final ConstantPool cp, final boolean verbose) { + String str; + if (catchType == 0) { + str = "(0)"; + } else { + str = Utility.compactClassName(cp.getConstantString(catchType, Const.CONSTANT_Class), false) + (verbose ? "(" + catchType + ")" : ""); + } + return startPc + "\t" + endPc + "\t" + handlerPc + "\t" + str; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Constant.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Constant.java new file mode 100644 index 000000000..885e1b599 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Constant.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.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. + * + * @LastModified: May 2021 + */ +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 Objects.equals(THIS.toString(), THAT.toString()); + } + + @Override + public int hashCode(final Object o) { + final Constant THIS = (Constant) o; + return THIS.toString().hashCode(); + } + }; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * Reads one constant from the given input, the type depends on a tag byte. + * + * @param dataInput Input stream + * @return Constant object + * @throws IOException if an I/O error occurs reading from the given {@code dataInput}. + * @throws ClassFormatException if the next byte is not recognized + * @since 6.0 made public + */ + public static Constant readConstant(final DataInput dataInput) throws IOException, ClassFormatException { + final byte b = dataInput.readByte(); // Read tag byte + switch (b) { + case Const.CONSTANT_Class: + return new ConstantClass(dataInput); + case Const.CONSTANT_Fieldref: + return new ConstantFieldref(dataInput); + case Const.CONSTANT_Methodref: + return new ConstantMethodref(dataInput); + case Const.CONSTANT_InterfaceMethodref: + return new ConstantInterfaceMethodref(dataInput); + case Const.CONSTANT_String: + return new ConstantString(dataInput); + case Const.CONSTANT_Integer: + return new ConstantInteger(dataInput); + case Const.CONSTANT_Float: + return new ConstantFloat(dataInput); + case Const.CONSTANT_Long: + return new ConstantLong(dataInput); + case Const.CONSTANT_Double: + return new ConstantDouble(dataInput); + case Const.CONSTANT_NameAndType: + return new ConstantNameAndType(dataInput); + case Const.CONSTANT_Utf8: + return ConstantUtf8.getInstance(dataInput); + case Const.CONSTANT_MethodHandle: + return new ConstantMethodHandle(dataInput); + case Const.CONSTANT_MethodType: + return new ConstantMethodType(dataInput); + case Const.CONSTANT_Dynamic: + return new ConstantDynamic(dataInput); + case Const.CONSTANT_InvokeDynamic: + return new ConstantInvokeDynamic(dataInput); + case Const.CONSTANT_Module: + return new ConstantModule(dataInput); + case Const.CONSTANT_Package: + return new ConstantPackage(dataInput); + default: + throw new ClassFormatException("Invalid byte tag in constant pool: " + b); + } + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + /* + * 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 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 abstract void accept(Visitor v); + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return deep copy of this constant + */ + public Constant copy() { + try { + return (Constant) super.clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + public abstract void dump(DataOutputStream file) throws IOException; + + /** + * Returns 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 Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * @return Tag of constant, i.e., its type. No setTag() method to avoid confusion. + */ + public final byte getTag() { + return tag; + } + + /** + * Returns value as defined by given BCELComparator strategy. By default return the hashcode of the result of + * toString(). + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return Const.getConstantName(tag) + "[" + tag + "]"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java new file mode 100644 index 000000000..71fd91b24 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Abstract super class for Fieldref, Methodref, InterfaceMethodref and InvokeDynamic constants. + * + * @see ConstantFieldref + * @see ConstantMethodref + * @see ConstantInterfaceMethodref + * @see ConstantInvokeDynamic + * @LastModified: Jun 2019 + */ +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 instance from file data. + * + * @param tag Constant type tag + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantCP(final byte tag, final DataInput file) throws IOException { + this(tag, file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * @param classIndex Reference to the class containing the field + * @param nameAndTypeIndex and the field signature + */ + protected ConstantCP(final byte tag, final int classIndex, final int nameAndTypeIndex) { + super(tag); + this.class_index = classIndex; + this.name_and_type_index = nameAndTypeIndex; + } + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantCP(final ConstantCP c) { + this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Dump constant field reference to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @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 Class this field belongs to. + */ + public String getClass(final ConstantPool cp) { + return cp.constantToString(class_index, Const.CONSTANT_Class); + } + + /** + * @return Reference (index) to class this constant refers 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 classIndex points to Constant_class + */ + public final void setClassIndex(final int classIndex) { + this.class_index = classIndex; + } + + /** + * @param nameAndTypeIndex points to Constant_NameAndType + */ + public final void setNameAndTypeIndex(final int nameAndTypeIndex) { + this.name_and_type_index = nameAndTypeIndex; + } + + /** + * @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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java new file mode 100644 index 000000000..9361a5d57 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a (external) class. + * + * @see Constant + */ +public final class ConstantClass extends Constant implements ConstantObject { + + private int nameIndex; // Identical to ConstantString except for the name + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantClass(final ConstantClass c) { + this(c.getNameIndex()); + } + + /** + * Constructs an instance from file data. + * + * @param dataInput Input stream + * @throws IOException if an I/O error occurs reading from the given {@code dataInput}. + */ + ConstantClass(final DataInput dataInput) throws IOException { + this(dataInput.readUnsignedShort()); + } + + /** + * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8. + */ + public ConstantClass(final int nameIndex) { + super(Const.CONSTANT_Class); + this.nameIndex = nameIndex; + } + + /** + * 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.visitConstantClass(this); + } + + /** + * Dumps constant class to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs writing to the DataOutputStream. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Name index in constant pool of class name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @param nameIndex the name index in the constant pool of this Constant Class + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java new file mode 100644 index 000000000..ebb3d0af4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a Double object. + * + * @see Constant + * @LastModified: Jun 2019 + */ +public final class ConstantDouble extends Constant implements ConstantObject { + + private double bytes; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantDouble(final ConstantDouble c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantDouble(final DataInput file) throws IOException { + this(file.readDouble()); + } + + /** + * @param bytes Data + */ + public ConstantDouble(final double bytes) { + super(Const.CONSTANT_Double); + this.bytes = bytes; + } + + /** + * 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.visitConstantDouble(this); + } + + /** + * Dump constant double to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeDouble(bytes); + } + + /** + * @return data, i.e., 8 bytes. + */ + public double getBytes() { + return bytes; + } + + /** + * @return Double object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Double.valueOf(bytes); + } + + /** + * @param bytes the raw bytes that represent the double value + */ + public void setBytes(final double bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java new file mode 100644 index 000000000..6313b0c85 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java @@ -0,0 +1,94 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a dynamically computed + * constant. + * + * @see Constant + * @see Change request for JEP + * 309 + * @since 6.3 + */ +public final class ConstantDynamic extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantDynamic(final ConstantDynamic c) { + this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantDynamic(final DataInput file) throws IOException { + this(file.readShort(), file.readShort()); + } + + + public ConstantDynamic(final int bootstrapMethodAttrIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_Dynamic, bootstrapMethodAttrIndex, nameAndTypeIndex); + } + + + /** + * 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.visitConstantDynamic(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 int getBootstrapMethodAttrIndex() { + return super.getClassIndex(); // AKA bootstrap_method_attr_index + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString().replace("class_index", "bootstrap_method_attr_index"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java new file mode 100644 index 000000000..32bd750be --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java @@ -0,0 +1,71 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a constant pool reference to a field. + */ +public final class ConstantFieldref extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantFieldref(final ConstantFieldref c) { + super(Const.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException if an I/O error occurs. + */ + ConstantFieldref(final DataInput input) throws IOException { + super(Const.CONSTANT_Fieldref, input); + } + + /** + * @param classIndex Reference to the class containing the Field + * @param nameAndTypeIndex and the Field signature + */ + public ConstantFieldref(final int classIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_Fieldref, classIndex, nameAndTypeIndex); + } + + /** + * 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 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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java new file mode 100644 index 000000000..9c30c9e4f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a float object. + * + * @see Constant + * @LastModified: Jun 2019 + */ +public final class ConstantFloat extends Constant implements ConstantObject { + + private float bytes; + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public ConstantFloat(final ConstantFloat c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantFloat(final DataInput file) throws IOException { + this(file.readFloat()); + } + + /** + * @param bytes Data + */ + public ConstantFloat(final float bytes) { + super(Const.CONSTANT_Float); + this.bytes = bytes; + } + + /** + * 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.visitConstantFloat(this); + } + + /** + * Dump constant float to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeFloat(bytes); + } + + /** + * @return data, i.e., 4 bytes. + */ + public float getBytes() { + return bytes; + } + + /** + * @return Float object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Float.valueOf(bytes); + } + + /** + * @param bytes the raw bytes that represent this float + */ + public void setBytes(final float bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java new file mode 100644 index 000000000..cabd2e15b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to an int object. + * + * @see Constant + * @LastModified: Jun 2019 + */ +public final class ConstantInteger extends Constant implements ConstantObject { + + private int bytes; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantInteger(final ConstantInteger c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantInteger(final DataInput file) throws IOException { + this(file.readInt()); + } + + /** + * @param bytes Data + */ + public ConstantInteger(final int bytes) { + super(Const.CONSTANT_Integer); + this.bytes = bytes; + } + + /** + * 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.visitConstantInteger(this); + } + + /** + * Dump constant integer to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeInt(bytes); + } + + /** + * @return data, i.e., 4 bytes. + */ + public int getBytes() { + return bytes; + } + + /** + * @return Integer object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Integer.valueOf(bytes); + } + + /** + * @param bytes the raw bytes that represent this integer + */ + public void setBytes(final int bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java new file mode 100644 index 000000000..14cac5b90 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java @@ -0,0 +1,71 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a constant pool reference to an interface method. + */ +public final class ConstantInterfaceMethodref extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantInterfaceMethodref(final ConstantInterfaceMethodref c) { + super(Const.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException if an I/O error occurs. + */ + ConstantInterfaceMethodref(final DataInput input) throws IOException { + super(Const.CONSTANT_InterfaceMethodref, input); + } + + /** + * @param classIndex Reference to the class containing the method + * @param nameAndTypeIndex and the method signature + */ + public ConstantInterfaceMethodref(final int classIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_InterfaceMethodref, classIndex, nameAndTypeIndex); + } + + /** + * 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.visitConstantInterfaceMethodref(this); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java new file mode 100644 index 000000000..b4154edd5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java @@ -0,0 +1,90 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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. + * + * @param c Source to copy. + */ + public ConstantInvokeDynamic(final ConstantInvokeDynamic c) { + this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantInvokeDynamic(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort()); + } + + public ConstantInvokeDynamic(final int bootstrapMethodAttrIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_InvokeDynamic, bootstrapMethodAttrIndex, nameAndTypeIndex); + } + + /** + * 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 int getBootstrapMethodAttrIndex() { + return super.getClassIndex(); // AKA bootstrap_method_attr_index + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString().replace("class_index", "bootstrap_method_attr_index"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java new file mode 100644 index 000000000..c1e683aba --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a long object. + * + * @see Constant + * @LastModified: Jan 2020 + */ +public final class ConstantLong extends Constant implements ConstantObject { + + private long bytes; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantLong(final ConstantLong c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantLong(final DataInput file) throws IOException { + this(file.readLong()); + } + + /** + * @param bytes Data + */ + public ConstantLong(final long bytes) { + super(Const.CONSTANT_Long); + this.bytes = bytes; + } + + /** + * 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.visitConstantLong(this); + } + + /** + * Dump constant long to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeLong(bytes); + } + + /** + * @return data, i.e., 8 bytes. + */ + public long getBytes() { + return bytes; + } + + /** + * @return Long object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Long.valueOf(bytes); + } + + /** + * @param bytes the raw bytes that represent this long + */ + public void setBytes(final long bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java new file mode 100644 index 000000000..40dfc8fe6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java @@ -0,0 +1,113 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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 referenceKind; + private int referenceIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantMethodHandle(final ConstantMethodHandle c) { + this(c.getReferenceKind(), c.getReferenceIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantMethodHandle(final DataInput file) throws IOException { + this(file.readUnsignedByte(), file.readUnsignedShort()); + } + + public ConstantMethodHandle(final int referenceKind, final int referenceIndex) { + super(Const.CONSTANT_MethodHandle); + this.referenceKind = referenceKind; + this.referenceIndex = referenceIndex; + } + + /** + * 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 if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeByte(referenceKind); + file.writeShort(referenceIndex); + } + + public int getReferenceIndex() { + return referenceIndex; + } + + public int getReferenceKind() { + return referenceKind; + } + + public void setReferenceIndex(final int referenceIndex) { + this.referenceIndex = referenceIndex; + } + + public void setReferenceKind(final int referenceKind) { + this.referenceKind = referenceKind; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(referenceKind = " + referenceKind + ", referenceIndex = " + referenceIndex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java new file mode 100644 index 000000000..654d80170 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java @@ -0,0 +1,102 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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 descriptorIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantMethodType(final ConstantMethodType c) { + this(c.getDescriptorIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantMethodType(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + public ConstantMethodType(final int descriptorIndex) { + super(Const.CONSTANT_MethodType); + this.descriptorIndex = descriptorIndex; + } + + /** + * 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 if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(descriptorIndex); + } + + public int getDescriptorIndex() { + return descriptorIndex; + } + + public void setDescriptorIndex(final int descriptorIndex) { + this.descriptorIndex = descriptorIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(descriptorIndex = " + descriptorIndex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java new file mode 100644 index 000000000..cd914092c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java @@ -0,0 +1,71 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a constant pool reference to a method. + */ +public final class ConstantMethodref extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantMethodref(final ConstantMethodref c) { + super(Const.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException if an I/O error occurs. + */ + ConstantMethodref(final DataInput input) throws IOException { + super(Const.CONSTANT_Methodref, input); + } + + /** + * @param classIndex Reference to the class containing the method + * @param nameAndTypeIndex and the method signature + */ + public ConstantMethodref(final int classIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_Methodref, classIndex, nameAndTypeIndex); + } + + /** + * 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.visitConstantMethodref(this); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java new file mode 100644 index 000000000..06754b967 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java @@ -0,0 +1,130 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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 nameIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantModule(final ConstantModule c) { + this(c.getNameIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantModule(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + /** + * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8. + */ + public ConstantModule(final int nameIndex) { + super(Const.CONSTANT_Module); + this.nameIndex = nameIndex; + } + + /** + * 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 if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Name index in constant pool of module name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @param nameIndex the name index in the constant pool of this Constant Module + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java new file mode 100644 index 000000000..fbf09c979 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java @@ -0,0 +1,143 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to the name and signature of a + * field or method. + * + * @see Constant + */ +public final class ConstantNameAndType extends Constant { + + private int nameIndex; // Name of field/method + private int signatureIndex; // and its signature. + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantNameAndType(final ConstantNameAndType c) { + this(c.getNameIndex(), c.getSignatureIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantNameAndType(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * @param nameIndex Name of field/method + * @param signatureIndex and its signature + */ + public ConstantNameAndType(final int nameIndex, final int signatureIndex) { + super(Const.CONSTANT_NameAndType); + this.nameIndex = nameIndex; + this.signatureIndex = signatureIndex; + } + + /** + * 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.visitConstantNameAndType(this); + } + + /** + * Dump name and signature index to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + file.writeShort(signatureIndex); + } + + /** + * @return name + */ + public String getName(final ConstantPool cp) { + return cp.constantToString(getNameIndex(), Const.CONSTANT_Utf8); + } + + /** + * @return Name index in constant pool of field/method name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @return signature + */ + public String getSignature(final ConstantPool cp) { + return cp.constantToString(getSignatureIndex(), Const.CONSTANT_Utf8); + } + + /** + * @return Index in constant pool of field/method signature. + */ + public int getSignatureIndex() { + return signatureIndex; + } + + /** + * @param nameIndex the name index of this constant + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @param signatureIndex the signature index in the constant pool of this type + */ + public void setSignatureIndex(final int signatureIndex) { + this.signatureIndex = signatureIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ", signatureIndex = " + signatureIndex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java new file mode 100644 index 000000000..cb28f7dac --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java @@ -0,0 +1,35 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * This interface denotes those constants that have a "natural" value, such as ConstantLong, ConstantString, etc.. + * + * @see Constant + */ +public interface ConstantObject { + + /** + * @return object representing the constant, e.g., Long for ConstantLong + */ + Object getConstantValue(ConstantPool cp); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java new file mode 100644 index 000000000..2e8c72150 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java @@ -0,0 +1,130 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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 nameIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantPackage(final ConstantPackage c) { + this(c.getNameIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantPackage(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + /** + * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8. + */ + public ConstantPackage(final int nameIndex) { + super(Const.CONSTANT_Package); + this.nameIndex = nameIndex; + } + + /** + * 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.visitConstantPackage(this); + } + + /** + * Dump constant package to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Name index in constant pool of package name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @param nameIndex the name index in the constant pool of this Constant Package + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java new file mode 100644 index 000000000..5fb4ef1b0 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java @@ -0,0 +1,438 @@ +/* + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; + +import com.sun.org.apache.bcel.internal.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 programmatically should see + * ConstantPoolGen. + * + * @see Constant + * @see com.sun.org.apache.bcel.internal.generic.ConstantPoolGen + * @LastModified: Feb 2023 + */ +public class ConstantPool implements Cloneable, Node, Iterable { + + 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(); + } + + private Constant[] constantPool; + + /** + * @param constantPool Array of constants + */ + public ConstantPool(final Constant[] constantPool) { + this.constantPool = constantPool; + } + + /** + * Reads constants from given input stream. + * + * @param input Input stream + * @throws IOException if problem in readUnsignedShort or readConstant + */ + public ConstantPool(final DataInput input) throws IOException { + byte tag; + final int constantPoolCount = input.readUnsignedShort(); + constantPool = new Constant[constantPoolCount]; + /* + * constantPool[0] is unused by the compiler and may be used freely by the implementation. + */ + for (int i = 1; i < constantPoolCount; i++) { + constantPool[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 = constantPool[i].getTag(); + if (tag == Const.CONSTANT_Double || tag == Const.CONSTANT_Long) { + i++; + } + } + } + + /** + * 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.visitConstantPool(this); + } + + /** + * Resolves constant to a string representation. + * + * @param c Constant to be printed + * @return String representation + * @throws IllegalArgumentException if c is unknown constant type + */ + public String constantToString(Constant c) throws IllegalArgumentException { + String str; + int i; + final byte tag = c.getTag(); + switch (tag) { + case Const.CONSTANT_Class: + i = ((ConstantClass) c).getNameIndex(); + c = getConstantUtf8(i); + str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); + break; + case Const.CONSTANT_String: + i = ((ConstantString) c).getStringIndex(); + c = getConstantUtf8(i); + 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; + case Const.CONSTANT_Dynamic: + final ConstantDynamic cd = (ConstantDynamic) c; + str = cd.getBootstrapMethodAttrIndex() + ":" + constantToString(cd.getNameAndTypeIndex(), Const.CONSTANT_NameAndType); + break; + case Const.CONSTANT_Module: + i = ((ConstantModule) c).getNameIndex(); + c = getConstantUtf8(i); + str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); + break; + case Const.CONSTANT_Package: + i = ((ConstantPackage) c).getNameIndex(); + c = getConstantUtf8(i); + str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); + break; + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + tag); + } + return str; + } + + /** + * Retrieves 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) { + return constantToString(getConstant(index, tag)); + } + + /** + * @return deep copy of this constant pool + */ + public ConstantPool copy() { + ConstantPool c = null; + try { + c = (ConstantPool) clone(); + c.constantPool = new Constant[constantPool.length]; + for (int i = 1; i < constantPool.length; i++) { + if (constantPool[i] != null) { + c.constantPool[i] = constantPool[i].copy(); + } + } + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return c; + } + + /** + * Dump constant pool to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if problem in writeShort or dump + */ + public void dump(final DataOutputStream file) throws IOException { + /* + * Constants over the size of the constant pool shall not be written out. + * This is a redundant measure as the ConstantPoolGen should have already + * reported an error back in the situation. + */ + final int size = Math.min(constantPool.length, Const.MAX_CP_ENTRIES); + + file.writeShort(size); + for (int i = 1; i < size; i++) { + if (constantPool[i] != null) { + constantPool[i].dump(file); + } + } + } + + /** + * Gets constant from constant pool. + * + * @param index Index in constant pool + * @return Constant value + * @see Constant + * @throws ClassFormatException if index is invalid + */ + @SuppressWarnings("unchecked") + public T getConstant(final int index) throws ClassFormatException { + return (T) getConstant(index, Constant.class); + } + + /** + * Gets 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 if constant type does not match tag + */ + @SuppressWarnings("unchecked") + public T getConstant(final int index, final byte tag) throws ClassFormatException { + return (T) getConstant(index, tag, Constant.class); + } + + /** + * Gets 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 if constant type does not match tag + * @since 6.6.0 + */ + public T getConstant(final int index, final byte tag, final Class castTo) throws ClassFormatException { + final T c = getConstant(index); + if (c.getTag() != tag) { + throw new ClassFormatException("Expected class '" + Const.getConstantName(tag) + "' at index " + index + " and got " + c); + } + return c; + } + + /** + * Gets constant from constant pool. + * + * @param A {@link Constant} subclass + * @param index Index in constant pool + * @param castTo The {@link Constant} subclass to cast to. + * @return Constant value + * @see Constant + * @throws ClassFormatException if index is invalid + * @since 6.6.0 + */ + public T getConstant(final int index, final Class castTo) throws ClassFormatException { + if (index >= constantPool.length || index < 0) { + throw new ClassFormatException("Invalid constant pool reference using index: " + index + ". Constant pool size is: " + constantPool.length); + } + if (constantPool[index] != null && !castTo.isAssignableFrom(constantPool[index].getClass())) { + throw new ClassFormatException("Invalid constant pool reference at index: " + index + + ". Expected " + castTo + " but was " + constantPool[index].getClass()); + } + // Previous check ensures this won't throw a ClassCastException + final T c = castTo.cast(constantPool[index]); + if (c == null + // the 0th element is always null + && index != 0) { + final Constant prev = constantPool[index - 1]; + if (prev == null || prev.getTag() != Const.CONSTANT_Double && prev.getTag() != Const.CONSTANT_Long) { + throw new ClassFormatException("Constant pool at index " + index + " is null."); + } + } + return c; + } + + /** + * Gets constant from constant pool and check whether it has the expected type. + * + * @param index Index in constant pool + * @return ConstantInteger value + * @see ConstantInteger + * @throws ClassFormatException if constant type does not match tag + */ + public ConstantInteger getConstantInteger(final int index) { + return getConstant(index, Const.CONSTANT_Integer, ConstantInteger.class); + } + + /** + * @return Array of constants. + * @see Constant + */ + public Constant[] getConstantPool() { + return constantPool; + } + + /** + * Gets 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 IllegalArgumentException if tag is invalid + */ + public String getConstantString(final int index, final byte tag) throws IllegalArgumentException { + int i; + /* + * This switch() is not that elegant, since the four 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 = getConstant(index, ConstantClass.class).getNameIndex(); + break; + case Const.CONSTANT_String: + i = getConstant(index, ConstantString.class).getStringIndex(); + break; + case Const.CONSTANT_Module: + i = getConstant(index, ConstantModule.class).getNameIndex(); + break; + case Const.CONSTANT_Package: + i = getConstant(index, ConstantPackage.class).getNameIndex(); + break; + case Const.CONSTANT_Utf8: + return getConstantUtf8(index).getBytes(); + default: + throw new IllegalArgumentException("getConstantString called with illegal tag " + tag); + } + // Finally get the string from the constant pool + return getConstantUtf8(i).getBytes(); + } + + /** + * Gets constant from constant pool and check whether it has the expected type. + * + * @param index Index in constant pool + * @return ConstantUtf8 value + * @see ConstantUtf8 + * @throws ClassFormatException if constant type does not match tag + */ + public ConstantUtf8 getConstantUtf8(final int index) throws ClassFormatException { + return getConstant(index, Const.CONSTANT_Utf8, ConstantUtf8.class); + } + + /** + * @return Length of constant pool. + */ + public int getLength() { + return constantPool == null ? 0 : constantPool.length; + } + + @Override + public Iterator iterator() { + return Arrays.stream(constantPool).iterator(); + } + + /** + * @param constant Constant to set + */ + public void setConstant(final int index, final Constant constant) { + constantPool[index] = constant; + } + + /** + * @param constantPool + */ + public void setConstantPool(final Constant[] constantPool) { + this.constantPool = constantPool; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 1; i < constantPool.length; i++) { + buf.append(i).append(")").append(constantPool[i]).append("\n"); + } + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantString.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantString.java new file mode 100644 index 000000000..287e092b9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantString.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a String object. + * + * @see Constant + */ +public final class ConstantString extends Constant implements ConstantObject { + + private int stringIndex; // Identical to ConstantClass except for this name + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantString(final ConstantString c) { + this(c.getStringIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantString(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + /** + * @param stringIndex Index of Constant_Utf8 in constant pool + */ + public ConstantString(final int stringIndex) { + super(Const.CONSTANT_String); + this.stringIndex = stringIndex; + } + + /** + * 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.visitConstantString(this); + } + + /** + * Dump constant field reference to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(stringIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(stringIndex).getBytes(); + } + + /** + * @return Index in constant pool of the string (ConstantUtf8). + */ + public int getStringIndex() { + return stringIndex; + } + + /** + * @param stringIndex the index into the constant of the string value + */ + public void setStringIndex(final int stringIndex) { + this.stringIndex = stringIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(stringIndex = " + stringIndex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java new file mode 100644 index 000000000..ec875554c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Extends the abstract {@link Constant} to represent a reference to a UTF-8 encoded string. + *

    + * The following system properties govern caching this class performs. + *

    + *
      + *
    • {@value #SYS_PROP_CACHE_MAX_ENTRIES} (since 6.4): The size of the cache, by default 0, meaning caching is + * disabled.
    • + *
    • {@value #SYS_PROP_CACHE_MAX_ENTRY_SIZE} (since 6.0): The maximum size of the values to cache, by default 200, 0 + * disables caching. Values larger than this are not cached.
    • + *
    • {@value #SYS_PROP_STATISTICS} (since 6.0): Prints statistics on the console when the JVM exits.
    • + *
    + *

    + * Here is a sample Maven invocation with caching disabled: + *

    + * + *
    + * mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=0 -Dbcel.maxcached=0
    + * 
    + *

    + * Here is a sample Maven invocation with caching enabled: + *

    + * + *
    + * mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=100000 -Dbcel.maxcached=5000000
    + * 
    + * + * @see Constant + * @LastModified: Feb 2023 + */ +public final class ConstantUtf8 extends Constant { + + private static class Cache { + + private static final boolean BCEL_STATISTICS = false; + private static final int MAX_ENTRIES = 20000; + private static final int INITIAL_CAPACITY = (int) (MAX_ENTRIES / 0.75); + + private static final HashMap CACHE = new LinkedHashMap(INITIAL_CAPACITY, 0.75f, true) { + + private static final long serialVersionUID = -8506975356158971766L; + + @Override + protected boolean removeEldestEntry(final Map.Entry eldest) { + return size() > MAX_ENTRIES; + } + }; + + // Set the size to 0 or below to skip caching entirely + private static final int MAX_ENTRY_SIZE = 200; + + static boolean isEnabled() { + return Cache.MAX_ENTRIES > 0 && MAX_ENTRY_SIZE > 0; + } + + } + + // TODO these should perhaps be AtomicInt? + private static volatile int considered; + private static volatile int created; + private static volatile int hits; + private static volatile int skipped; + + private static final String SYS_PROP_CACHE_MAX_ENTRIES = "bcel.maxcached"; + private static final String SYS_PROP_CACHE_MAX_ENTRY_SIZE = "bcel.maxcached.size"; + private static final String SYS_PROP_STATISTICS = "bcel.statistics"; + + static { + if (Cache.BCEL_STATISTICS) { + Runtime.getRuntime().addShutdownHook(new Thread(ConstantUtf8::printStats)); + } + } + + /** + * Clears the cache. + * + * @since 6.4.0 + */ + public static synchronized void clearCache() { + Cache.CACHE.clear(); + } + + // for access by test code + static synchronized void clearStats() { + hits = considered = skipped = created = 0; + } + + /** + * Gets a new or cached instance of the given value. + *

    + * See {@link ConstantUtf8} class Javadoc for details. + *

    + * + * @param value the value. + * @return a new or cached instance of the given value. + * @since 6.0 + */ + public static ConstantUtf8 getCachedInstance(final String value) { + if (value.length() > Cache.MAX_ENTRY_SIZE) { + skipped++; + return new ConstantUtf8(value); + } + considered++; + synchronized (ConstantUtf8.class) { // might be better with a specific lock object + ConstantUtf8 result = Cache.CACHE.get(value); + if (result != null) { + hits++; + return result; + } + result = new ConstantUtf8(value); + Cache.CACHE.put(value, result); + return result; + } + } + + /** + * Gets a new or cached instance of the given value. + *

    + * See {@link ConstantUtf8} class Javadoc for details. + *

    + * + * @param dataInput the value. + * @return a new or cached instance of the given value. + * @throws IOException if an I/O error occurs. + * @since 6.0 + */ + public static ConstantUtf8 getInstance(final DataInput dataInput) throws IOException { + return getInstance(dataInput.readUTF()); + } + + /** + * Gets a new or cached instance of the given value. + *

    + * See {@link ConstantUtf8} class Javadoc for details. + *

    + * + * @param value the value. + * @return a new or cached instance of the given value. + * @since 6.0 + */ + public static ConstantUtf8 getInstance(final String value) { + return Cache.isEnabled() ? getCachedInstance(value) : new ConstantUtf8(value); + } + + // for access by test code + static void printStats() { + final String prefix = "[Apache Commons BCEL]"; + System.err.printf("%s Cache hit %,d/%,d, %d skipped.%n", prefix, hits, considered, skipped); + System.err.printf("%s Total of %,d ConstantUtf8 objects created.%n", prefix, created); + System.err.printf("%s Configuration: %s=%,d, %s=%,d.%n", prefix, SYS_PROP_CACHE_MAX_ENTRIES, Cache.MAX_ENTRIES, SYS_PROP_CACHE_MAX_ENTRY_SIZE, + Cache.MAX_ENTRY_SIZE); + } + + private final String value; + + /** + * Initializes from another object. + * + * @param constantUtf8 the value. + */ + public ConstantUtf8(final ConstantUtf8 constantUtf8) { + this(constantUtf8.getBytes()); + } + + /** + * Initializes instance from file data. + * + * @param dataInput Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantUtf8(final DataInput dataInput) throws IOException { + super(Const.CONSTANT_Utf8); + value = dataInput.readUTF(); + created++; + } + + /** + * @param value Data + */ + public ConstantUtf8(final String value) { + super(Const.CONSTANT_Utf8); + this.value = Objects.requireNonNull(value, "value"); + created++; + } + + /** + * 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.visitConstantUtf8(this); + } + + /** + * Dumps String in Utf8 format to file stream. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeUTF(value); + } + + /** + * @return Data converted to string. + */ + public String getBytes() { + return value; + } + + /** + * @param bytes the raw bytes of this UTF-8 + * @deprecated (since 6.0) + */ + @java.lang.Deprecated + public void setBytes(final String bytes) { + throw new UnsupportedOperationException(); + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(\"" + Utility.replace(value, "\n", "\\n") + "\")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java new file mode 100644 index 000000000..311e9a33f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java @@ -0,0 +1,161 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + *
    + * ConstantValue_attribute {
    + *   u2 attribute_name_index;
    + *   u4 attribute_length;
    + *   u2 constantvalue_index;
    + * }
    + * 
    + * @see Attribute + */ +public final class ConstantValue extends Attribute { + + private int constantValueIndex; + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public ConstantValue(final ConstantValue c) { + this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c.getConstantPool()); + } + + /** + * Construct object from input stream. + * + * @param nameIndex Name index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ConstantValue(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex Name index in constant pool + * @param length Content length in bytes + * @param constantValueIndex Index in constant pool + * @param constantPool Array of constants + */ + public ConstantValue(final int nameIndex, final int length, final int constantValueIndex, final ConstantPool constantPool) { + super(Const.ATTR_CONSTANT_VALUE, nameIndex, Args.require(length, 2, "ConstantValue attribute length"), constantPool); + this.constantValueIndex = constantValueIndex; + } + + /** + * 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.visitConstantValue(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ConstantValue c = (ConstantValue) clone(); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump constant value attribute to file stream on binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(constantValueIndex); + } + + /** + * @return Index in constant pool of constant value. + */ + public int getConstantValueIndex() { + return constantValueIndex; + } + + /** + * @param constantValueIndex the index info the constant pool of this constant value + */ + public void setConstantValueIndex(final int constantValueIndex) { + this.constantValueIndex = constantValueIndex; + } + + /** + * @return String representation of constant value. + */ + @Override + public String toString() { + Constant c = super.getConstantPool().getConstant(constantValueIndex); + 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().getConstantUtf8(i); + buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\""; + break; + default: + throw new IllegalStateException("Type of ConstValue invalid: " + c); + } + return buf; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Deprecated.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Deprecated.java new file mode 100644 index 000000000..90841d960 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Deprecated.java @@ -0,0 +1,138 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and denotes that this is a deprecated method. It is instantiated from + * the Attribute.readAttribute() method. + * + * @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. + * + * @param c Source to copy. + */ + public Deprecated(final Deprecated c) { + this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param bytes Attribute contents + * @param constantPool Array of constants + */ + public Deprecated(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) { + super(Const.ATTR_DEPRECATED, nameIndex, Args.require0(length, "Deprecated attribute length"), constantPool); + this.bytes = bytes; + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Deprecated(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (byte[]) null, constantPool); + if (length > 0) { + bytes = new byte[length]; + input.readFully(bytes); + println("Deprecated attribute with length > 0"); + } + } + + /** + * 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.visitDeprecated(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Deprecated c = (Deprecated) clone(); + if (bytes != null) { + c.bytes = bytes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + /** + * @return data bytes. + */ + public byte[] getBytes() { + return bytes; + } + + /** + * @param bytes the raw bytes that represents this byte array + */ + public void setBytes(final byte[] bytes) { + this.bytes = bytes; + } + + /** + * @return attribute name + */ + @Override + public String toString() { + return Const.getAttributeName(Const.ATTR_DEPRECATED) + ": true"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java new file mode 100644 index 000000000..3c475891a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java @@ -0,0 +1,552 @@ +/* + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.util.Objects; +import java.util.Stack; +import java.util.stream.Stream; + +/** + * 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. + * + */ +public class DescendingVisitor implements Visitor { + private final JavaClass clazz; + + private final Visitor visitor; + + private final Stack stack = new Stack<>(); + + /** + * @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; + } + + private void accept(final E[] node) { + Stream.of(node).forEach(e -> e.accept(this)); + } + + /** + * @return current object + */ + public Object current() { + return stack.peek(); + } + + /** + * @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 + } + + /** + * Start traversal. + */ + public void visit() { + clazz.accept(this); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotation(final Annotations annotation) { + stack.push(annotation); + annotation.accept(visitor); + accept(annotation.getAnnotationEntries()); + 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 visitAnnotationEntry(final AnnotationEntry annotationEntry) { + stack.push(annotationEntry); + annotationEntry.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 visitCode(final Code code) { + stack.push(code); + code.accept(visitor); + accept(code.getExceptionTable()); + accept(code.getAttributes()); + stack.pop(); + } + + @Override + public void visitCodeException(final CodeException ce) { + stack.push(ce); + ce.accept(visitor); + 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(); + } + + /** @since 6.3 */ + @Override + public void visitConstantDynamic(final ConstantDynamic obj) { + stack.push(obj); + obj.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(); + } + + /** @since 6.0 */ + @Override + public void visitConstantMethodHandle(final ConstantMethodHandle obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantMethodref(final ConstantMethodref constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** @since 6.0 */ + @Override + public void visitConstantMethodType(final ConstantMethodType 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(); + } + + @Override + public void visitConstantNameAndType(final ConstantNameAndType constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** @since 6.1 */ + @Override + public void visitConstantPackage(final ConstantPackage obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantPool(final ConstantPool cp) { + stack.push(cp); + cp.accept(visitor); + Stream.of(cp.getConstantPool()).filter(Objects::nonNull).forEach(e -> e.accept(this)); + 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 visitConstantValue(final ConstantValue cv) { + stack.push(cv); + cv.accept(visitor); + stack.pop(); + } + + @Override + public void visitDeprecated(final Deprecated attribute) { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitEnclosingMethod(final EnclosingMethod obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitExceptionTable(final ExceptionTable table) { + stack.push(table); + table.accept(visitor); + stack.pop(); + } + + @Override + public void visitField(final Field field) { + stack.push(field); + field.accept(visitor); + accept(field.getAttributes()); + stack.pop(); + } + + @Override + public void visitInnerClass(final InnerClass inner) { + stack.push(inner); + inner.accept(visitor); + stack.pop(); + } + + @Override + public void visitInnerClasses(final InnerClasses ic) { + stack.push(ic); + ic.accept(visitor); + accept(ic.getInnerClasses()); + stack.pop(); + } + + @Override + public void visitJavaClass(final JavaClass clazz) { + stack.push(clazz); + clazz.accept(visitor); + accept(clazz.getFields()); + accept(clazz.getMethods()); + accept(clazz.getAttributes()); + clazz.getConstantPool().accept(this); + stack.pop(); + } + + @Override + public void visitLineNumber(final LineNumber number) { + stack.push(number); + number.accept(visitor); + stack.pop(); + } + + @Override + public void visitLineNumberTable(final LineNumberTable table) { + stack.push(table); + table.accept(visitor); + accept(table.getLineNumberTable()); + stack.pop(); + } + + @Override + public void visitLocalVariable(final LocalVariable var) { + stack.push(var); + var.accept(visitor); + stack.pop(); + } + + @Override + public void visitLocalVariableTable(final LocalVariableTable table) { + stack.push(table); + table.accept(visitor); + accept(table.getLocalVariableTable()); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitMethod(final Method method) { + stack.push(method); + method.accept(visitor); + accept(method.getAttributes()); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitMethodParameter(final MethodParameter 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); + Stream.of(obj.getParameters()).forEach(e -> e.accept(this)); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitModule(final Module obj) { + stack.push(obj); + obj.accept(visitor); + accept(obj.getRequiresTable()); + accept(obj.getExportsTable()); + accept(obj.getOpensTable()); + accept(obj.getProvidesTable()); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitModuleExports(final ModuleExports obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitModuleMainClass(final ModuleMainClass obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitModuleOpens(final ModuleOpens obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitModulePackages(final ModulePackages obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitModuleProvides(final ModuleProvides obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitModuleRequires(final ModuleRequires obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitNestHost(final NestHost obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.4.0 */ + @Override + public void visitNestMembers(final NestMembers 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 visitParameterAnnotationEntry(final ParameterAnnotationEntry obj) { + stack.push(obj); + obj.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 visitStackMap(final StackMap table) { + stack.push(table); + table.accept(visitor); + accept(table.getStackMap()); + stack.pop(); + } + + @Override + public void visitStackMapEntry(final StackMapEntry var) { + stack.push(var); + var.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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValue.java new file mode 100644 index 000000000..5c3d9b317 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValue.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * The element_value structure is documented at https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.16.1 + * + *
    + * element_value {
    + *    u1 tag;
    + *    union {
    + *        u2 const_value_index;
    + *
    + *        {   u2 type_name_index;
    + *            u2 const_name_index;
    + *        } enum_const_value;
    + *
    + *        u2 class_info_index;
    + *
    + *        annotation annotation_value;
    + *
    + *        {   u2            num_values;
    + *            element_value values[num_values];
    + *        } array_value;
    + *    } value;
    + *}
    + *
    + * @since 6.0 + * @LastModified: May 2021 + */ +public abstract class ElementValue { + + 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'; + + /** + * Reads an {@code element_value} as an {@code ElementValue}. + * + * @param input Raw data input. + * @param cpool Constant pool. + * @return a new ElementValue. + * @throws IOException if an I/O error occurs. + */ + public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool) throws IOException { + return readElementValue(input, cpool, 0); + } + + /** + * Reads an {@code element_value} as an {@code ElementValue}. + * + * @param input Raw data input. + * @param cpool Constant pool. + * @param arrayNesting level of current array nesting. + * @return a new ElementValue. + * @throws IOException if an I/O error occurs. + * @since 6.7.0 + */ + public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool, int arrayNesting) + throws IOException { + final byte tag = input.readByte(); + switch (tag) { + 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(tag, 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: + arrayNesting++; + if (arrayNesting > Const.MAX_ARRAY_DIMENSIONS) { + // JVM spec 4.4.1 + throw new ClassFormatException(String.format("Arrays are only valid if they represent %,d or fewer dimensions.", Const.MAX_ARRAY_DIMENSIONS)); + } + final int numArrayVals = input.readUnsignedShort(); + final ElementValue[] evalues = new ElementValue[numArrayVals]; + for (int j = 0; j < numArrayVals; j++) { + evalues[j] = ElementValue.readElementValue(input, cpool, arrayNesting); + } + return new ArrayElementValue(ARRAY, evalues, cpool); + + default: + throw new ClassFormatException("Unexpected element value tag in annotation: " + tag); + } + } + + /** + * @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 + + protected ElementValue(final int type, final ConstantPool cpool) { + this.type = type; + this.cpool = cpool; + } + + public abstract void dump(DataOutputStream dos) throws IOException; + + /** @since 6.0 */ + final ConstantPool getConstantPool() { + return cpool; + } + + public int getElementValueType() { + return type; + } + + /** @since 6.0 */ + final int getType() { + return type; + } + + public abstract String stringifyValue(); + + public String toShortString() { + return stringifyValue(); + } + + @Override + public String toString() { + return stringifyValue(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java new file mode 100644 index 000000000..8a2e67060 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java @@ -0,0 +1,70 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * An annotation's element value pair. + * + * @since 6.0 + */ +public class ElementValuePair { + + static final ElementValuePair[] EMPTY_ARRAY = {}; + + 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; + } + + protected void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(elementNameIndex); // u2 name of the element + elementValue.dump(dos); + } + + public int getNameIndex() { + return elementNameIndex; + } + + public String getNameString() { + return constantPool.getConstantUtf8(elementNameIndex).getBytes(); + } + + public final ElementValue getValue() { + return elementValue; + } + + public String toShortString() { + final StringBuilder result = new StringBuilder(); + result.append(getNameString()).append("=").append(getValue().toShortString()); + return result.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java new file mode 100644 index 000000000..826ba41af --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java @@ -0,0 +1,325 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 + */ +public class EmptyVisitor implements Visitor { + protected EmptyVisitor() { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotation(final Annotations obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationDefault(final AnnotationDefault obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationEntry(final AnnotationEntry obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitBootstrapMethods(final BootstrapMethods 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) { + } + + /** + * @since 6.3 + */ + @Override + public void visitConstantDynamic(final ConstantDynamic 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) { + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodHandle(final ConstantMethodHandle constantMethodHandle) { + } + + @Override + public void visitConstantMethodref(final ConstantMethodref obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodType(final ConstantMethodType obj) { + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantModule(final ConstantModule constantModule) { + } + + @Override + public void visitConstantNameAndType(final ConstantNameAndType obj) { + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantPackage(final ConstantPackage constantPackage) { + } + + @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) { + } + + /** + * @since 6.0 + */ + @Override + public void visitEnclosingMethod(final EnclosingMethod 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) { + } + + @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) { + } + + /** + * @since 6.0 + */ + @Override + public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) { + } + + @Override + public void visitMethod(final Method obj) { + } + + /** + * @since 6.0 + * @Override public void visitStackMapTable(StackMapTable obj) { } + */ + + /** + * @since 6.0 + * @Override public void visitStackMapTableEntry(StackMapTableEntry obj) { } + */ + + /** + * @since 6.4.0 + */ + @Override + public void visitMethodParameter(final MethodParameter obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitMethodParameters(final MethodParameters obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitModule(final Module obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitModuleExports(final ModuleExports obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitModuleMainClass(final ModuleMainClass obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitModuleOpens(final ModuleOpens obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitModulePackages(final ModulePackages obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitModuleProvides(final ModuleProvides obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitModuleRequires(final ModuleRequires obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitNestHost(final NestHost obj) { + } + + /** @since 6.4.0 */ + @Override + public void visitNestMembers(final NestMembers obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotation(final ParameterAnnotations obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotationEntry(final ParameterAnnotationEntry parameterAnnotationEntry) { + } + + @Override + public void visitSignature(final Signature obj) { + } + + @Override + public void visitSourceFile(final SourceFile obj) { + } + + @Override + public void visitStackMap(final StackMap obj) { + } + + @Override + public void visitStackMapEntry(final StackMapEntry obj) { + } + + @Override + public void visitSynthetic(final Synthetic obj) { + } + + @Override + public void visitUnknown(final Unknown obj) { + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java new file mode 100644 index 000000000..326e77738 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java @@ -0,0 +1,107 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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 classIndex, final int methodIndex, final ConstantPool cpool) { + super(Const.ATTR_ENCLOSING_METHOD, nameIndex, Args.require(len, 4, "EnclosingMethod attribute length"), cpool); + this.classIndex = Args.requireU2(classIndex, 0, cpool.getLength(), "EnclosingMethod class index"); + this.methodIndex = Args.requireU2(methodIndex, "EnclosingMethod method index"); + } + + @Override + public void accept(final Visitor v) { + v.visitEnclosingMethod(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(classIndex); + file.writeShort(methodIndex); + } + + public final ConstantClass getEnclosingClass() { + return super.getConstantPool().getConstant(classIndex, Const.CONSTANT_Class, ConstantClass.class); + } + + // Accessors + public final int getEnclosingClassIndex() { + return classIndex; + } + + public final ConstantNameAndType getEnclosingMethod() { + if (methodIndex == 0) { + return null; + } + return super.getConstantPool().getConstant(methodIndex, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + } + + public final int getEnclosingMethodIndex() { + return methodIndex; + } + + public final void setEnclosingClassIndex(final int idx) { + classIndex = idx; + } + + public final void setEnclosingMethodIndex(final int idx) { + methodIndex = idx; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java new file mode 100644 index 000000000..0a8163ede --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java @@ -0,0 +1,72 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @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 ClassFormatException("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 + } + + public String getEnumTypeString() { + return super.getConstantPool().getConstantUtf8(typeIdx).getBytes(); + } + + public String getEnumValueString() { + return super.getConstantPool().getConstantUtf8(valueIdx).getBytes(); + } + + public int getTypeIndex() { + return typeIdx; + } + + public int getValueIndex() { + return valueIdx; + } + + @Override + public String stringifyValue() { + return super.getConstantPool().getConstantUtf8(valueIdx).getBytes(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java new file mode 100644 index 000000000..90eaa3eb0 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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). + * + *
    + * Exceptions_attribute {
    + *   u2 attribute_name_index;
    + *   u4 attribute_length;
    + *   u2 number_of_exceptions;
    + *   u2 exception_index_table[number_of_exceptions];
    + * }
    + * 
    + * @see Code + * @LastModified: Feb 2023 + */ +public final class ExceptionTable extends Attribute { + + private int[] exceptionIndexTable; // constant pool + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public ExceptionTable(final ExceptionTable c) { + this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), c.getConstantPool()); + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ExceptionTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (int[]) null, constantPool); + final int exceptionCount = input.readUnsignedShort(); + exceptionIndexTable = new int[exceptionCount]; + for (int i = 0; i < exceptionCount; i++) { + exceptionIndexTable[i] = input.readUnsignedShort(); + } + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param exceptionIndexTable Table of indices in constant pool + * @param constantPool Array of constants + */ + public ExceptionTable(final int nameIndex, final int length, final int[] exceptionIndexTable, final ConstantPool constantPool) { + super(Const.ATTR_EXCEPTIONS, nameIndex, length, constantPool); + this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : Const.EMPTY_INT_ARRAY; + Args.requireU2(this.exceptionIndexTable.length, "exceptionIndexTable.length"); + } + + /** + * 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.visitExceptionTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ExceptionTable c = (ExceptionTable) clone(); + if (exceptionIndexTable != null) { + c.exceptionIndexTable = exceptionIndexTable.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump exceptions attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(exceptionIndexTable.length); + for (final int index : exceptionIndexTable) { + file.writeShort(index); + } + } + + /** + * @return Array of indices into constant pool of thrown exceptions. + */ + public int[] getExceptionIndexTable() { + return exceptionIndexTable; + } + + /** + * @return class names of thrown exceptions + */ + public String[] getExceptionNames() { + final String[] names = new String[exceptionIndexTable.length]; + Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(exceptionIndexTable[i], Const.CONSTANT_Class))); + return names; + } + + /** + * @return Length of exception table. + */ + public int getNumberOfExceptions() { + return exceptionIndexTable == null ? 0 : exceptionIndexTable.length; + } + + /** + * @param exceptionIndexTable the list of exception indexes Also redefines number_of_exceptions according to table + * length. + */ + public void setExceptionIndexTable(final int[] exceptionIndexTable) { + this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : Const.EMPTY_INT_ARRAY; + } + + /** + * @return String representation, i.e., a list of thrown exceptions. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + String str; + buf.append("Exceptions: "); + for (int i = 0; i < exceptionIndexTable.length; i++) { + str = super.getConstantPool().getConstantString(exceptionIndexTable[i], Const.CONSTANT_Class); + buf.append(Utility.compactClassName(str, false)); + if (i < exceptionIndexTable.length - 1) { + buf.append(", "); + } + } + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Field.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Field.java new file mode 100644 index 000000000..7e6ccb2ec --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Field.java @@ -0,0 +1,198 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.generic.Type; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * This class represents the field info structure, i.e., the representation for a variable in the class. See JVM + * specification for details. + */ +public final class Field extends FieldOrMethod { + + /** + * Empty array constant. + * + * @since 6.6.0 + */ + public static final Field[] EMPTY_ARRAY = {}; + + 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 Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final Field THIS = (Field) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + /** + * Empty array. + */ + static final Field[] EMPTY_FIELD_ARRAY = {}; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + /** + * Construct object from file stream. + * + * @param file Input stream + */ + Field(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException { + super(file, constantPool); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public Field(final Field c) { + super(c); + } + + /** + * @param accessFlags Access rights of field + * @param nameIndex Points to field name in constant pool + * @param signatureIndex Points to encoded signature + * @param attributes Collection of attributes + * @param constantPool Array of constants + */ + public Field(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool) { + super(accessFlags, nameIndex, signatureIndex, attributes, constantPool); + } + + /** + * 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.visitField(this); + } + + /** + * @return deep copy of this field + */ + public Field copy(final ConstantPool constantPool) { + return (Field) copy_(constantPool); + } + + /** + * 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 Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * @return constant value associated with this field (may be null) + */ + public ConstantValue getConstantValue() { + for (final Attribute attribute : super.getAttributes()) { + if (attribute.getTag() == Const.ATTR_CONSTANT_VALUE) { + return (ConstantValue) attribute; + } + } + return null; + } + + /** + * @return type of field + */ + public Type getType() { + return Type.getReturnType(getSignature()); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the field's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * 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 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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java new file mode 100644 index 000000000..1daa6a62f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +/** + * Abstract super class for fields and methods. + * + * @LastModified: Jan 2020 + */ +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; + private boolean searchedForSignatureAttribute; + + FieldOrMethod() { + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + protected FieldOrMethod(final DataInput file, final ConstantPool constantPool) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null, constantPool); + final int attributesCount = file.readUnsignedShort(); + attributes = new Attribute[attributesCount]; + for (int i = 0; i < attributesCount; i++) { + attributes[i] = Attribute.readAttribute(file, constantPool); + } + this.attributes_count = attributesCount; // init deprecated field + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + * @deprecated (6.0) Use {@link #FieldOrMethod(java.io.DataInput, ConstantPool)} instead. + */ + @java.lang.Deprecated + protected FieldOrMethod(final DataInputStream file, final ConstantPool constantPool) throws IOException { + this((DataInput) file, constantPool); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + protected FieldOrMethod(final FieldOrMethod c) { + this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), c.getAttributes(), c.getConstantPool()); + } + + /** + * @param accessFlags Access rights of method + * @param nameIndex Points to field name in constant pool + * @param signatureIndex Points to encoded signature + * @param attributes Collection of attributes + * @param constantPool Array of constants + */ + protected FieldOrMethod(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, + final ConstantPool constantPool) { + super(accessFlags); + this.name_index = nameIndex; + this.signature_index = signatureIndex; + this.constant_pool = constantPool; + setAttributes(attributes); + } + + /** + * @return deep copy of this field + */ + protected FieldOrMethod copy_(final ConstantPool constantPool) { + try { + final FieldOrMethod c = (FieldOrMethod) clone(); + c.constant_pool = constantPool; + c.attributes = new Attribute[attributes.length]; + c.attributes_count = attributes_count; // init deprecated field + Arrays.setAll(c.attributes, i -> attributes[i].copy(constantPool)); + return c; + } catch (final CloneNotSupportedException e) { + throw new IllegalStateException(e); + } + } + + /** + * Dump object to file stream on binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(super.getAccessFlags()); + file.writeShort(name_index); + file.writeShort(signature_index); + file.writeShort(attributes_count); + if (attributes != null) { + for (final Attribute attribute : attributes) { + attribute.dump(file); + } + } + } + + /** + * @return Annotations on the field or method + * @since 6.0 + */ + public AnnotationEntry[] getAnnotationEntries() { + if (annotationEntries == null) { + annotationEntries = AnnotationEntry.createAnnotationEntries(getAttributes()); + } + + return annotationEntries; + } + + /** + * @return Collection of object attributes. + */ + public final Attribute[] getAttributes() { + return attributes; + } + + /** + * @return Constant pool used by this object. + */ + public final ConstantPool getConstantPool() { + return constant_pool; + } + + /** + * 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; + } + + /** + * @return Name of object, i.e., method name or field name + */ + public final String getName() { + return constant_pool.getConstantUtf8(name_index).getBytes(); + } + + /** + * @return Index in constant pool of object's name. + */ + public final int getNameIndex() { + return name_index; + } + + /** + * @return String representation of object's type signature (java style) + */ + public final String getSignature() { + return constant_pool.getConstantUtf8(signature_index).getBytes(); + } + + /** + * @return Index in constant pool of field signature. + */ + public final int getSignatureIndex() { + return signature_index; + } + + /** + * @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 + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public final void setConstantPool(final ConstantPool constantPool) { + this.constant_pool = constantPool; + } + + /** + * @param nameIndex Index in constant pool of object's name. + */ + public final void setNameIndex(final int nameIndex) { + this.name_index = nameIndex; + } + + /** + * @param signatureIndex Index in constant pool of field signature. + */ + public final void setSignatureIndex(final int signatureIndex) { + this.signature_index = signatureIndex; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClass.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClass.java new file mode 100644 index 000000000..d77582815 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClass.java @@ -0,0 +1,198 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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. + * + * @see InnerClasses + */ +public final class InnerClass implements Cloneable, Node { + + private int innerClassIndex; + private int outerClassIndex; + private int innerNameIndex; + private int innerAccessFlags; + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + InnerClass(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public InnerClass(final InnerClass c) { + this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c.getInnerAccessFlags()); + } + + /** + * @param innerClassIndex Class index in constant pool of inner class + * @param outerClassIndex Class index in constant pool of outer class + * @param innerNameIndex Name index in constant pool of inner class + * @param innerAccessFlags Access flags of inner class + */ + public InnerClass(final int innerClassIndex, final int outerClassIndex, final int innerNameIndex, final int innerAccessFlags) { + this.innerClassIndex = innerClassIndex; + this.outerClassIndex = outerClassIndex; + this.innerNameIndex = innerNameIndex; + this.innerAccessFlags = innerAccessFlags; + } + + /** + * 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.visitInnerClass(this); + } + + /** + * @return deep copy of this object + */ + public InnerClass copy() { + try { + return (InnerClass) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump inner class attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(innerClassIndex); + file.writeShort(outerClassIndex); + file.writeShort(innerNameIndex); + file.writeShort(innerAccessFlags); + } + + /** + * @return access flags of inner class. + */ + public int getInnerAccessFlags() { + return innerAccessFlags; + } + + /** + * @return class index of inner class. + */ + public int getInnerClassIndex() { + return innerClassIndex; + } + + /** + * @return name index of inner class. + */ + public int getInnerNameIndex() { + return innerNameIndex; + } + + /** + * @return class index of outer class. + */ + public int getOuterClassIndex() { + return outerClassIndex; + } + + /** + * @param innerAccessFlags access flags for this inner class + */ + public void setInnerAccessFlags(final int innerAccessFlags) { + this.innerAccessFlags = innerAccessFlags; + } + + /** + * @param innerClassIndex index into the constant pool for this class + */ + public void setInnerClassIndex(final int innerClassIndex) { + this.innerClassIndex = innerClassIndex; + } + + /** + * @param innerNameIndex index into the constant pool for this class's name + */ + public void setInnerNameIndex(final int innerNameIndex) { // TODO unused + this.innerNameIndex = innerNameIndex; + } + + /** + * @param outerClassIndex index into the constant pool for the owning class + */ + public void setOuterClassIndex(final int outerClassIndex) { // TODO unused + this.outerClassIndex = outerClassIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return "InnerClass(" + innerClassIndex + ", " + outerClassIndex + ", " + innerNameIndex + ", " + innerAccessFlags + ")"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + String outerClassName; + String innerName; + String innerClassName = constantPool.getConstantString(innerClassIndex, Const.CONSTANT_Class); + innerClassName = Utility.compactClassName(innerClassName, false); + if (outerClassIndex != 0) { + outerClassName = constantPool.getConstantString(outerClassIndex, Const.CONSTANT_Class); + outerClassName = " of class " + Utility.compactClassName(outerClassName, false); + } else { + outerClassName = ""; + } + if (innerNameIndex != 0) { + innerName = constantPool.getConstantUtf8(innerNameIndex).getBytes(); + } else { + innerName = "(anonymous)"; + } + String access = Utility.accessToString(innerAccessFlags, true); + access = access.isEmpty() ? "" : access + " "; + return " " + access + innerName + "=class " + innerClassName + outerClassName; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java new file mode 100644 index 000000000..2295ca5c6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java @@ -0,0 +1,161 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + * @see Attribute + */ +public final class InnerClasses extends Attribute implements Iterable { + + /** + * Empty array. + */ + private static final InnerClass[] EMPTY_INNER_CLASSE_ARRAY = {}; + + private InnerClass[] innerClasses; + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public InnerClasses(final InnerClasses c) { + this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c.getConstantPool()); + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + InnerClasses(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (InnerClass[]) null, constantPool); + final int classCount = input.readUnsignedShort(); + innerClasses = new InnerClass[classCount]; + for (int i = 0; i < classCount; i++) { + innerClasses[i] = new InnerClass(input); + } + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param innerClasses array of inner classes attributes + * @param constantPool Array of constants + */ + public InnerClasses(final int nameIndex, final int length, final InnerClass[] innerClasses, final ConstantPool constantPool) { + super(Const.ATTR_INNER_CLASSES, nameIndex, length, constantPool); + this.innerClasses = innerClasses != null ? innerClasses : EMPTY_INNER_CLASSE_ARRAY; + Args.requireU2(this.innerClasses.length, "innerClasses.length"); + } + + /** + * 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.visitInnerClasses(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + // 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.innerClasses = new InnerClass[innerClasses.length]; + Arrays.setAll(c.innerClasses, i -> innerClasses[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(innerClasses.length); + for (final InnerClass innerClass : innerClasses) { + innerClass.dump(file); + } + } + + /** + * @return array of inner class "records" + */ + public InnerClass[] getInnerClasses() { + return innerClasses; + } + + @Override + public Iterator iterator() { + return Stream.of(innerClasses).iterator(); + } + + /** + * @param innerClasses the array of inner classes + */ + public void setInnerClasses(final InnerClass[] innerClasses) { + this.innerClasses = innerClasses != null ? innerClasses : EMPTY_INNER_CLASSE_ARRAY; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("InnerClasses("); + buf.append(innerClasses.length); + buf.append("):\n"); + for (final InnerClass innerClass : innerClasses) { + buf.append(innerClass.toString(super.getConstantPool())).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/JavaClass.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/JavaClass.java new file mode 100644 index 000000000..d6c4cfa6a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/JavaClass.java @@ -0,0 +1,864 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.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.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeSet; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.generic.Type; +import com.sun.org.apache.bcel.internal.util.BCELComparator; +import com.sun.org.apache.bcel.internal.util.ClassQueue; +import com.sun.org.apache.bcel.internal.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 programmatically generating + * classes should see the ClassGen class. + * + * @see com.sun.org.apache.bcel.internal.generic.ClassGen + * @LastModified: Feb 2023 + */ +public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable { + + /** + * The standard class file extension. + * + * @since 6.7.0 + */ + public static final String EXTENSION = ".class"; + + /** + * Empty array. + * + * @since 6.6.0 + */ + public static final JavaClass[] EMPTY_ARRAY = {}; + + public static final byte HEAP = 1; + public static final byte FILE = 2; + public static final byte ZIP = 3; + 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 Objects.equals(THIS.getClassName(), THAT.getClassName()); + } + + @Override + public int hashCode(final Object o) { + final JavaClass THIS = (JavaClass) o; + return THIS.getClassName().hashCode(); + } + }; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + private static String indent(final Object obj) { + final StringTokenizer tokenizer = new StringTokenizer(obj.toString(), "\n"); + final StringBuilder buf = new StringBuilder(); + while (tokenizer.hasMoreTokens()) { + buf.append("\t").append(tokenizer.nextToken()).append("\n"); + } + return buf.toString(); + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + private String fileName; + private final String packageName; + private String sourceFileName = ""; + private int classNameIndex; + private int superclassNameIndex; + private String className; + private String superclassName; + private int major; + private int minor; // Compiler version + private ConstantPool constantPool; // Constant pool + private int[] interfaces; // implemented interfaces + private String[] interfaceNames; + 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; + + private boolean isNested; + + private boolean computedNestedTypeStatus; + + /** + * In cases where we go ahead and create something, use the default SyntheticRepository, because we don't know any + * better. + */ + private transient com.sun.org.apache.bcel.internal.util.Repository repository = SyntheticRepository.getInstance(); + + /** + * Constructor gets all contents as arguments. + * + * @param classNameIndex Class name + * @param superclassNameIndex Superclass name + * @param fileName File name + * @param major Major compiler version + * @param minor Minor compiler version + * @param accessFlags Access rights defined by bit flags + * @param constantPool Array of constants + * @param interfaces Implemented interfaces + * @param fields Class fields + * @param methods Class methods + * @param attributes Class attributes + */ + public JavaClass(final int classNameIndex, final int superclassNameIndex, final String fileName, final int major, final int minor, final int accessFlags, + final ConstantPool constantPool, final int[] interfaces, final Field[] fields, final Method[] methods, final Attribute[] attributes) { + this(classNameIndex, superclassNameIndex, fileName, major, minor, accessFlags, constantPool, interfaces, fields, methods, attributes, HEAP); + } + + /** + * Constructor gets all contents as arguments. + * + * @param classNameIndex Index into constant pool referencing a ConstantClass that represents this class. + * @param superclassNameIndex Index into constant pool referencing a ConstantClass that represents this class's + * superclass. + * @param fileName File name + * @param major Major compiler version + * @param minor Minor compiler version + * @param accessFlags Access rights defined by bit flags + * @param constantPool 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 classNameIndex, final int superclassNameIndex, final String fileName, final int major, final int minor, final int accessFlags, + final ConstantPool constantPool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes, final byte source) { + super(accessFlags); + if (interfaces == null) { + interfaces = Const.EMPTY_INT_ARRAY; + } + if (attributes == null) { + attributes = Attribute.EMPTY_ARRAY; + } + if (fields == null) { + fields = Field.EMPTY_FIELD_ARRAY; + } + if (methods == null) { + methods = Method.EMPTY_METHOD_ARRAY; + } + this.classNameIndex = classNameIndex; + this.superclassNameIndex = superclassNameIndex; + this.fileName = fileName; + this.major = major; + this.minor = minor; + this.constantPool = constantPool; + 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) { + sourceFileName = ((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. + */ + className = constantPool.getConstantString(classNameIndex, Const.CONSTANT_Class); + className = Utility.compactClassName(className, false); + final int index = className.lastIndexOf('.'); + if (index < 0) { + packageName = ""; + } else { + packageName = className.substring(0, index); + } + if (superclassNameIndex > 0) { + // May be zero -> class is java.lang.Object + superclassName = constantPool.getConstantString(superclassNameIndex, Const.CONSTANT_Class); + superclassName = Utility.compactClassName(superclassName, false); + } else { + superclassName = "java.lang.Object"; + } + interfaceNames = new String[interfaces.length]; + for (int i = 0; i < interfaces.length; i++) { + final String str = constantPool.getConstantString(interfaces[i], Const.CONSTANT_Class); + interfaceNames[i] = Utility.compactClassName(str, false); + } + } + + /** + * 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.visitJavaClass(this); + } + + /** + * 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()); + } + + private void computeNestedTypeStatus() { + if (computedNestedTypeStatus) { + return; + } + for (final Attribute attribute : this.attributes) { + if (attribute instanceof InnerClasses) { + ((InnerClasses) attribute).forEach(innerClass -> { + boolean innerClassAttributeRefersToMe = false; + String innerClassName = constantPool.getConstantString(innerClass.getInnerClassIndex(), Const.CONSTANT_Class); + innerClassName = Utility.compactClassName(innerClassName, false); + if (innerClassName.equals(getClassName())) { + innerClassAttributeRefersToMe = true; + } + if (innerClassAttributeRefersToMe) { + this.isNested = true; + if (innerClass.getInnerNameIndex() == 0) { + this.isAnonymous = true; + } + } + }); + } + } + this.computedNestedTypeStatus = true; + } + + /** + * @return deep copy of this class + */ + public JavaClass copy() { + try { + final JavaClass c = (JavaClass) clone(); + c.constantPool = constantPool.copy(); + c.interfaces = interfaces.clone(); + c.interfaceNames = interfaceNames.clone(); + c.fields = new Field[fields.length]; + Arrays.setAll(c.fields, i -> fields[i].copy(c.constantPool)); + c.methods = new Method[methods.length]; + Arrays.setAll(c.methods, i -> methods[i].copy(c.constantPool)); + c.attributes = new Attribute[attributes.length]; + Arrays.setAll(c.attributes, i -> attributes[i].copy(c.constantPool)); + return c; + } catch (final CloneNotSupportedException e) { + return null; + } + } + + /** + * Dump Java class to output stream in binary format. + * + * @param file Output stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeInt(Const.JVM_CLASSFILE_MAGIC); + file.writeShort(minor); + file.writeShort(major); + constantPool.dump(file); + file.writeShort(super.getAccessFlags()); + file.writeShort(classNameIndex); + file.writeShort(superclassNameIndex); + 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(); + } + + /** + * Dump class to a file. + * + * @param file Output file + * @throws IOException if an I/O error occurs. + */ + 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() && !dir.isDirectory()) { + throw new IOException("Could not create the directory " + dir); + } + } + try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(file))) { + dump(dos); + } + } + + /** + * Dump Java class to output stream in binary format. + * + * @param file Output stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final OutputStream file) throws IOException { + dump(new DataOutputStream(file)); + } + + /** + * Dump class to a file named fileName. + * + * @param fileName Output file name + * @throws IOException if an I/O error occurs. + */ + public void dump(final String fileName) throws IOException { + dump(new File(fileName)); + } + + /** + * 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 Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * Get all interfaces implemented by this JavaClass (transitively). + * + * @throws ClassNotFoundException if any of the class's superclasses or interfaces can't be found. + */ + 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 iface : interfaces) { + queue.enqueue(iface); + } + } + return allInterfaces.toArray(JavaClass.EMPTY_ARRAY); + } + + /** + * @return Annotations on the class + * @since 6.0 + */ + public AnnotationEntry[] getAnnotationEntries() { + if (annotations == null) { + annotations = AnnotationEntry.createAnnotationEntries(getAttributes()); + } + + return annotations; + } + + /** + * @return Attributes of the class. + */ + public Attribute[] getAttributes() { + return attributes; + } + + /** + * @return class in binary format + */ + public byte[] getBytes() { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (DataOutputStream dos = new DataOutputStream(baos)) { + dump(dos); + } catch (final IOException e) { + e.printStackTrace(); + } + return baos.toByteArray(); + } + + /** + * @return Class name. + */ + public String getClassName() { + return className; + } + + /** + * @return Class name index. + */ + public int getClassNameIndex() { + return classNameIndex; + } + + /** + * @return Constant pool. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @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 fileName; + } + + /** + * @return Indices in constant pool of implemented interfaces. + */ + public int[] getInterfaceIndices() { + return interfaces; + } + + /** + * @return Names of implemented interfaces. + */ + public String[] getInterfaceNames() { + return interfaceNames; + } + + /** + * Get interfaces directly implemented by this JavaClass. + * + * @throws ClassNotFoundException if any of the class's interfaces can't be found. + */ + 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; + } + + /** + * @return Major number of class file version. + */ + public int getMajor() { + return major; + } + + /** + * @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 Methods of the class. + */ + public Method[] getMethods() { + return methods; + } + + /** + * @return Minor number of class file version. + */ + public int getMinor() { + return minor; + } + + /** + * @return Package name. + */ + public String getPackageName() { + return packageName; + } + + /** + * Gets the ClassRepository which holds its definition. By default this is the same as + * SyntheticRepository.getInstance(); + */ + public com.sun.org.apache.bcel.internal.util.Repository getRepository() { + return repository; + } + + /** + * @return returns either HEAP (generated), FILE, or ZIP + */ + public final byte getSource() { + return source; + } + + /** + * @return file name where this class was read from + */ + public String getSourceFileName() { + return sourceFileName; + } + + /** + * Gets the source file path including the package path. + * + * @return path to original source file of parsed class, relative to original source directory. + * @since 6.7.0 + */ + public String getSourceFilePath() { + final StringBuilder outFileName = new StringBuilder(); + if (!packageName.isEmpty()) { + outFileName.append(Utility.packageToPath(packageName)); + outFileName.append('/'); + } + outFileName.append(sourceFileName); + return outFileName.toString(); + } + + /** + * @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(JavaClass.EMPTY_ARRAY); + } + + /** + * 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 superclassName; + } + + /** + * @return Class name index. + */ + public int getSuperclassNameIndex() { + return superclassNameIndex; + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the class name. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * @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[] superInterfaces = getAllInterfaces(); + for (final JavaClass superInterface : superInterfaces) { + if (superInterface.equals(inter)) { + return true; + } + } + return false; + } + + /** + * 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 superclass) throws ClassNotFoundException { + if (this.equals(superclass)) { + return true; + } + for (final JavaClass clazz : getSuperClasses()) { + if (clazz.equals(superclass)) { + return true; + } + } + if (superclass.isInterface()) { + return implementationOf(superclass); + } + return false; + } + + /** + * @since 6.0 + */ + public final boolean isAnonymous() { + computeNestedTypeStatus(); + return this.isAnonymous; + } + + public final boolean isClass() { + return (super.getAccessFlags() & Const.ACC_INTERFACE) == 0; + } + + /** + * @since 6.0 + */ + public final boolean isNested() { + computeNestedTypeStatus(); + return this.isNested; + } + + public final boolean isSuper() { + return (super.getAccessFlags() & Const.ACC_SUPER) != 0; + } + + /** + * @param attributes . + */ + public void setAttributes(final Attribute[] attributes) { + this.attributes = attributes; + } + + /** + * @param className . + */ + public void setClassName(final String className) { + this.className = className; + } + + /** + * @param classNameIndex . + */ + public void setClassNameIndex(final int classNameIndex) { + this.classNameIndex = classNameIndex; + } + + /** + * @param constantPool . + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + /** + * @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 fileName) { + this.fileName = fileName; + } + + /** + * @param interfaceNames . + */ + public void setInterfaceNames(final String[] interfaceNames) { + this.interfaceNames = interfaceNames; + } + + /** + * @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; + } + + /** + * Sets the ClassRepository which loaded the JavaClass. Should be called immediately after parsing is done. + */ + public void setRepository(final com.sun.org.apache.bcel.internal.util.Repository repository) { // TODO make protected? + this.repository = repository; + } + + /** + * Set absolute path to file this class was read from. + */ + public void setSourceFileName(final String sourceFileName) { + this.sourceFileName = sourceFileName; + } + + /** + * @param superclassName . + */ + public void setSuperclassName(final String superclassName) { + this.superclassName = superclassName; + } + + /** + * @param superclassNameIndex . + */ + public void setSuperclassNameIndex(final int superclassNameIndex) { + this.superclassNameIndex = superclassNameIndex; + } + + /** + * @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(className).append(" extends ") + .append(Utility.compactClassName(superclassName, 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(interfaceNames[i]); + if (i < size - 1) { + buf.append(", "); + } + } + buf.append('\n'); + } + buf.append("file name\t\t").append(fileName).append('\n'); + buf.append("compiled from\t\t").append(sourceFileName).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(constantPool.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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumber.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumber.java new file mode 100644 index 000000000..4380d04bc --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumber.java @@ -0,0 +1,143 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + * @see LineNumberTable + */ +public final class LineNumber implements Cloneable, Node { + + static final LineNumber[] EMPTY_ARRAY = {}; + + /** Program Counter (PC) corresponds to line */ + private int startPc; + + /** number in source file */ + private int lineNumber; + + /** + * 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 startPc Program Counter (PC) corresponds to + * @param lineNumber line number in source file + */ + public LineNumber(final int startPc, final int lineNumber) { + this.startPc = Args.requireU2(startPc, "startPc"); + this.lineNumber = Args.requireU2(lineNumber, "lineNumber"); + } + + /** + * Initialize from another object. + * + * @param c the object to copy + */ + public LineNumber(final LineNumber c) { + this(c.getStartPC(), c.getLineNumber()); + } + + /** + * 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.visitLineNumber(this); + } + + /** + * @return deep copy of this object + */ + public LineNumber copy() { + try { + return (LineNumber) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * 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 void dump(final DataOutputStream file) throws IOException { + file.writeShort(startPc); + file.writeShort(lineNumber); + } + + /** + * @return Corresponding source line + */ + public int getLineNumber() { + return lineNumber & 0xffff; + } + + /** + * @return PC in code + */ + public int getStartPC() { + return startPc & 0xffff; + } + + /** + * @param lineNumber the source line number + */ + public void setLineNumber(final int lineNumber) { + this.lineNumber = (short) lineNumber; + } + + /** + * @param startPc the pc for this line number + */ + public void setStartPC(final int startPc) { + this.startPc = (short) startPc; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "LineNumber(" + getStartPC() + ", " + getLineNumber() + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java new file mode 100644 index 000000000..6251fc514 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; +import jdk.xml.internal.SecuritySupport; + +/** + * 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. + * + * @see Code + * @see LineNumber + * @LastModified: May 2021 + */ +public final class LineNumberTable extends Attribute implements Iterable { + + private static final int MAX_LINE_LENGTH = 72; + private LineNumber[] lineNumberTable; // Table of line/numbers pairs + + /** + * Construct object from input stream. + * + * @param nameIndex Index of name + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + LineNumberTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (LineNumber[]) null, constantPool); + final int lineNumberTableLength = input.readUnsignedShort(); + lineNumberTable = new LineNumber[lineNumberTableLength]; + for (int i = 0; i < lineNumberTableLength; i++) { + lineNumberTable[i] = new LineNumber(input); + } + } + + /* + * @param nameIndex Index of name + * + * @param length Content length in bytes + * + * @param lineNumberTable Table of line/numbers pairs + * + * @param constantPool Array of constants + */ + public LineNumberTable(final int nameIndex, final int length, final LineNumber[] lineNumberTable, final ConstantPool constantPool) { + super(Const.ATTR_LINE_NUMBER_TABLE, nameIndex, length, constantPool); + this.lineNumberTable = lineNumberTable != null ? lineNumberTable : LineNumber.EMPTY_ARRAY; + Args.requireU2(this.lineNumberTable.length, "lineNumberTable.length"); + } + + /* + * 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()); + } + + /** + * 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.visitLineNumberTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + // TODO could use the lower level constructor and thereby allow + // lineNumberTable to be made final + final LineNumberTable c = (LineNumberTable) clone(); + c.lineNumberTable = new LineNumber[lineNumberTable.length]; + Arrays.setAll(c.lineNumberTable, i -> lineNumberTable[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * 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 void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(lineNumberTable.length); + for (final LineNumber lineNumber : lineNumberTable) { + lineNumber.dump(file); + } + } + + /** + * @return Array of (pc offset, line number) pairs. + */ + public LineNumber[] getLineNumberTable() { + return lineNumberTable; + } + + /** + * 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 = lineNumberTable.length - 1; + if (r < 0) { + return -1; + } + int minIndex = -1; + int min = -1; + /* + * Do a binary search since the array is ordered. + */ + do { + final int i = l + r >>> 1; + final int j = lineNumberTable[i].getStartPC(); + if (j == pos) { + return lineNumberTable[i].getLineNumber(); + } + 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; + minIndex = i; + } + } while (l <= r); + /* + * It's possible that we did not find any valid entry for the bytecode offset we were looking for. + */ + if (minIndex < 0) { + return -1; + } + return lineNumberTable[minIndex].getLineNumber(); + } + + public int getTableLength() { + return lineNumberTable == null ? 0 : lineNumberTable.length; + } + + @Override + public Iterator iterator() { + return Stream.of(lineNumberTable).iterator(); + } + + /** + * @param lineNumberTable the line number entries for this table + */ + public void setLineNumberTable(final LineNumber[] lineNumberTable) { + this.lineNumberTable = lineNumberTable; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + final StringBuilder line = new StringBuilder(); + for (int i = 0; i < lineNumberTable.length; i++) { + line.append(lineNumberTable[i].toString()); + if (i < lineNumberTable.length - 1) { + line.append(", "); + } + if (line.length() > MAX_LINE_LENGTH && i < lineNumberTable.length - 1) { + line.append(SecuritySupport.NEWLINE); + buf.append(line); + line.setLength(0); + } + } + buf.append(line); + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java new file mode 100644 index 000000000..91d99c182 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents a local variable within a method. It contains its scope, name, signature and index on the + * method's frame. It is used both to represent an element of the LocalVariableTable as well as an element of the + * LocalVariableTypeTable. The nomenclature used here may be a bit confusing; while the two items have the same layout + * in a class file, a LocalVariableTable attribute contains a descriptor_index, not a signatureIndex. The + * LocalVariableTypeTable attribute does have a signatureIndex. + * + * @see com.sun.org.apache.bcel.internal.classfile.Utility for more details on the difference. + * + * @see LocalVariableTable + * @see LocalVariableTypeTable + * @LastModified: Feb 2023 + */ +public final class LocalVariable implements Cloneable, Node { + + static final LocalVariable[] EMPTY_ARRAY = {}; + + /** Range in which the variable is valid. */ + private int startPc; + + private int length; + + /** Index in constant pool of variable name. */ + private int nameIndex; + + /** + * Technically, a decscriptor_index for a local variable table entry and a signatureIndex for a local variable type table entry. Index of variable signature + */ + private int signatureIndex; + + /* + * Variable is index'th local variable on this method's frame. + */ + private int index; + + private ConstantPool constantPool; + + /** Never changes; used to match up with LocalVariableTypeTable entries. */ + private final int origIndex; + + /** + * Constructs object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + LocalVariable(final DataInput file, final ConstantPool constantPool) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), constantPool); + } + + /** + * @param startPc Range in which the variable + * @param length ... is valid + * @param nameIndex Index in constant pool of variable name + * @param signatureIndex Index of variable's signature + * @param index Variable is 'index'th local variable on the method's frame + * @param constantPool Array of constants + */ + public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool) { + this(startPc, length, nameIndex, signatureIndex, index, constantPool, index); + } + + /** + * @param startPc Range in which the variable + * @param length ... is valid + * @param nameIndex Index in constant pool of variable name + * @param signatureIndex Index of variable's signature + * @param index Variable is 'index'th local variable on the method's frame + * @param constantPool Array of constants + * @param origIndex Variable is 'index'th local variable on the method's frame prior to any changes + */ + public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool, + final int origIndex) { + this.startPc = Args.requireU2(startPc, "startPc"); + this.length = Args.requireU2(length, "length"); + this.nameIndex = Args.requireU2(nameIndex, "nameIndex"); + this.signatureIndex = Args.requireU2(signatureIndex, "signatureIndex"); + this.index = Args.requireU2(index, "index"); + this.origIndex = Args.requireU2(origIndex, "origIndex"); + this.constantPool = constantPool; + } + + /** + * Initializes from another LocalVariable. Note that both objects use the same references (shallow copy). Use copy() for + * a physical copy. + * + * @param localVariable Another LocalVariable. + */ + public LocalVariable(final LocalVariable localVariable) { + this(localVariable.getStartPC(), localVariable.getLength(), localVariable.getNameIndex(), localVariable.getSignatureIndex(), localVariable.getIndex(), + localVariable.getConstantPool()); + } + + /** + * 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.visitLocalVariable(this); + } + + /** + * @return deep copy of this object + */ + public LocalVariable copy() { + try { + return (LocalVariable) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dumps local variable to file stream in binary format. + * + * @param dataOutputStream Output file stream + * @throws IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void dump(final DataOutputStream dataOutputStream) throws IOException { + dataOutputStream.writeShort(startPc); + dataOutputStream.writeShort(length); + dataOutputStream.writeShort(nameIndex); + dataOutputStream.writeShort(signatureIndex); + dataOutputStream.writeShort(index); + } + + /** + * @return Constant pool used by this object. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @return index of register where variable is stored + */ + public int getIndex() { + return index; + } + + /** + * @return Variable is valid within getStartPC() .. getStartPC()+getLength() + */ + public int getLength() { + return length; + } + + /** + * @return Variable name. + */ + public String getName() { + return constantPool.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Index in constant pool of variable name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @return index of register where variable was originally stored + */ + public int getOrigIndex() { + return origIndex; + } + + /** + * @return Signature. + */ + public String getSignature() { + return constantPool.getConstantUtf8(signatureIndex).getBytes(); + } + + /** + * @return Index in constant pool of variable signature. + */ + public int getSignatureIndex() { + return signatureIndex; + } + + /** + * @return Start of range where the variable is valid + */ + public int getStartPC() { + return startPc; + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + /** + * @param index the index in the local variable table of this variable + */ + public void setIndex(final int index) { // TODO unused + this.index = index; + } + + /** + * @param length the length of this local variable + */ + public void setLength(final int length) { + this.length = length; + } + + /** + * @param nameIndex the index into the constant pool for the name of this variable + */ + public void setNameIndex(final int nameIndex) { // TODO unused + this.nameIndex = nameIndex; + } + + /** + * @param signatureIndex the index into the constant pool for the signature of this variable + */ + public void setSignatureIndex(final int signatureIndex) { // TODO unused + this.signatureIndex = signatureIndex; + } + + /** + * @param startPc Specify range where the local variable is valid. + */ + public void setStartPC(final int startPc) { // TODO unused + this.startPc = startPc; + } + + /** + * @return string representation. + */ + @Override + public String toString() { + return toStringShared(false); + } + + /* + * Helper method shared with LocalVariableTypeTable + */ + String toStringShared(final boolean typeTable) { + final String name = getName(); + final String signature = Utility.signatureToString(getSignature(), false); + final String label = "LocalVariable" + (typeTable ? "Types" : ""); + return label + "(startPc = " + startPc + ", length = " + length + ", index = " + index + ":" + signature + " " + name + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java new file mode 100644 index 000000000..fd56e14a5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java @@ -0,0 +1,196 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents colection of local variables in a method. This attribute is contained in the Code + * attribute. + * + * @see Code + * @see LocalVariable + */ +public class LocalVariableTable extends Attribute implements Iterable { + + private LocalVariable[] localVariableTable; // variables + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + LocalVariableTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (LocalVariable[]) null, constantPool); + final int localVariableTableLength = input.readUnsignedShort(); + localVariableTable = new LocalVariable[localVariableTableLength]; + for (int i = 0; i < localVariableTableLength; i++) { + localVariableTable[i] = new LocalVariable(input, constantPool); + } + } + + /** + * @param nameIndex Index in constant pool to 'LocalVariableTable' + * @param length Content length in bytes + * @param localVariableTable Table of local variables + * @param constantPool Array of constants + */ + public LocalVariableTable(final int nameIndex, final int length, final LocalVariable[] localVariableTable, final ConstantPool constantPool) { + super(Const.ATTR_LOCAL_VARIABLE_TABLE, nameIndex, length, constantPool); + this.localVariableTable = localVariableTable != null ? localVariableTable : LocalVariable.EMPTY_ARRAY; + Args.requireU2(this.localVariableTable.length, "localVariableTable.length"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public LocalVariableTable(final LocalVariableTable c) { + this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool()); + } + + /** + * 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.visitLocalVariableTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final LocalVariableTable c = (LocalVariableTable) clone(); + c.localVariableTable = new LocalVariable[localVariableTable.length]; + Arrays.setAll(c.localVariableTable, i -> localVariableTable[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump local variable table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(localVariableTable.length); + for (final LocalVariable variable : localVariableTable) { + variable.dump(file); + } + } + + /** + * + * @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 : localVariableTable) { + 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 : localVariableTable) { + if (variable.getIndex() == index) { + final int startPc = variable.getStartPC(); + final int endPc = startPc + variable.getLength(); + if (pc >= startPc && pc <= endPc) { + return variable; + } + } + } + return null; + } + + /** + * @return Array of local variables of method. + */ + public final LocalVariable[] getLocalVariableTable() { + return localVariableTable; + } + + public final int getTableLength() { + return localVariableTable == null ? 0 : localVariableTable.length; + } + + @Override + public Iterator iterator() { + return Stream.of(localVariableTable).iterator(); + } + + public final void setLocalVariableTable(final LocalVariable[] localVariableTable) { + this.localVariableTable = localVariableTable; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < localVariableTable.length; i++) { + buf.append(localVariableTable[i]); + if (i < localVariableTable.length - 1) { + buf.append('\n'); + } + } + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java new file mode 100644 index 000000000..08868a82d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java @@ -0,0 +1,160 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +// 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; +// } localVariableTypeTable[local_variable_type_table_length]; +// } +// J5TODO: Needs some testing ! + +/** + * @since 6.0 + */ +public class LocalVariableTypeTable extends Attribute implements Iterable { + + private LocalVariable[] localVariableTypeTable; // variables + + LocalVariableTypeTable(final int nameIdx, final int len, final DataInput input, final ConstantPool cpool) throws IOException { + this(nameIdx, len, (LocalVariable[]) null, cpool); + + final int localVariableTypeTableLength = input.readUnsignedShort(); + localVariableTypeTable = new LocalVariable[localVariableTypeTableLength]; + + for (int i = 0; i < localVariableTypeTableLength; i++) { + localVariableTypeTable[i] = new LocalVariable(input, cpool); + } + } + + public LocalVariableTypeTable(final int nameIndex, final int length, final LocalVariable[] localVariableTypeTable, final ConstantPool constantPool) { + super(Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE, nameIndex, length, constantPool); + this.localVariableTypeTable = localVariableTypeTable != null ? localVariableTypeTable : LocalVariable.EMPTY_ARRAY; + Args.requireU2(this.localVariableTypeTable.length, "localVariableTypeTable.length"); + } + + public LocalVariableTypeTable(final LocalVariableTypeTable c) { + this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(), c.getConstantPool()); + } + + @Override + public void accept(final Visitor v) { + v.visitLocalVariableTypeTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final LocalVariableTypeTable c = (LocalVariableTypeTable) clone(); + + c.localVariableTypeTable = new LocalVariable[localVariableTypeTable.length]; + Arrays.setAll(c.localVariableTypeTable, i -> localVariableTypeTable[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(localVariableTypeTable.length); + for (final LocalVariable variable : localVariableTypeTable) { + variable.dump(file); + } + } + + public final LocalVariable getLocalVariable(final int index) { + for (final LocalVariable variable : localVariableTypeTable) { + if (variable.getIndex() == index) { + return variable; + } + } + + return null; + } + + public final LocalVariable[] getLocalVariableTypeTable() { + return localVariableTypeTable; + } + + public final int getTableLength() { + return localVariableTypeTable == null ? 0 : localVariableTypeTable.length; + } + + @Override + public Iterator iterator() { + return Stream.of(localVariableTypeTable).iterator(); + } + + public final void setLocalVariableTable(final LocalVariable[] localVariableTable) { + this.localVariableTypeTable = localVariableTable; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + + for (int i = 0; i < localVariableTypeTable.length; i++) { + buf.append(localVariableTypeTable[i].toStringShared(true)); + + if (i < localVariableTypeTable.length - 1) { + buf.append('\n'); + } + } + + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Method.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Method.java new file mode 100644 index 000000000..ba2623eec --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Method.java @@ -0,0 +1,261 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.generic.Type; +import com.sun.org.apache.bcel.internal.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. + */ +public final class Method extends FieldOrMethod { + + /** + * Empty array constant. + * + * @since 6.6.0 + */ + public static final Method[] EMPTY_ARRAY = {}; + + 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 Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final Method THIS = (Method) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + /** + * Empty array. + */ + static final Method[] EMPTY_METHOD_ARRAY = {}; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + // 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() { + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + Method(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException { + super(file, constantPool); + } + + /** + * @param accessFlags Access rights of method + * @param nameIndex Points to field name in constant pool + * @param signatureIndex Points to encoded signature + * @param attributes Collection of attributes + * @param constantPool Array of constants + */ + public Method(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool) { + super(accessFlags, nameIndex, signatureIndex, attributes, constantPool); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public Method(final Method c) { + super(c); + } + + /** + * 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.visitMethod(this); + } + + /** + * @return deep copy of this method + */ + public Method copy(final ConstantPool constantPool) { + return (Method) copy_(constantPool); + } + + /** + * 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 Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * @return array of method argument types + */ + public Type[] getArgumentTypes() { + return Type.getArgumentTypes(getSignature()); + } + + /** + * @return Code attribute of method, if any + */ + public 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 ExceptionTable getExceptionTable() { + for (final Attribute attribute : super.getAttributes()) { + if (attribute instanceof ExceptionTable) { + return (ExceptionTable) attribute; + } + } + return null; + } + + /** + * @return LineNumberTable of code attribute if any, i.e. the call is forwarded to the Code atribute. + */ + public LineNumberTable getLineNumberTable() { + final Code code = getCode(); + if (code == null) { + return null; + } + return code.getLineNumberTable(); + } + + /** + * @return LocalVariableTable of code attribute if any, i.e. the call is forwarded to the Code atribute. + */ + public LocalVariableTable getLocalVariableTable() { + final Code code = getCode(); + if (code == null) { + return null; + } + return code.getLocalVariableTable(); + } + + /** + * @return Annotations on the parameters of a method + * @since 6.0 + */ + public ParameterAnnotationEntry[] getParameterAnnotationEntries() { + if (parameterAnnotationEntries == null) { + parameterAnnotationEntries = ParameterAnnotationEntry.createParameterAnnotationEntries(getAttributes()); + } + return parameterAnnotationEntries; + } + + /** + * @return return type of method + */ + public Type getReturnType() { + return Type.getReturnType(getSignature()); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the method's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * 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 String toString() { + final String access = Utility.accessToString(super.getAccessFlags()); + // Get name and signature from constant pool + ConstantUtf8 c = super.getConstantPool().getConstantUtf8(super.getSignatureIndex()); + String signature = c.getBytes(); + c = super.getConstantPool().getConstantUtf8(super.getNameIndex()); + 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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java new file mode 100644 index 000000000..ffc1a20f8 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Entry of the parameters table. + * + * @see The class File Format : + * The MethodParameters Attribute + * @since 6.0 + */ +public class MethodParameter implements Cloneable, Node { + + /** Index of the CONSTANT_Utf8_info structure in the constant_pool table representing the name of the parameter */ + private int nameIndex; + + /** The access flags */ + private int accessFlags; + + public MethodParameter() { + } + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + MethodParameter(final DataInput input) throws IOException { + nameIndex = input.readUnsignedShort(); + accessFlags = input.readUnsignedShort(); + } + + @Override + public void accept(final Visitor v) { + v.visitMethodParameter(this); + } + + /** + * @return deep copy of this object + */ + public MethodParameter copy() { + try { + return (MethodParameter) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump object to file stream on binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(nameIndex); + file.writeShort(accessFlags); + } + + public int getAccessFlags() { + return accessFlags; + } + + public int getNameIndex() { + return nameIndex; + } + + /** + * Returns the name of the parameter. + */ + public String getParameterName(final ConstantPool constantPool) { + if (nameIndex == 0) { + return null; + } + return constantPool.getConstantUtf8(nameIndex).getBytes(); + } + + public boolean isFinal() { + return (accessFlags & Const.ACC_FINAL) != 0; + } + + public boolean isMandated() { + return (accessFlags & Const.ACC_MANDATED) != 0; + } + + public boolean isSynthetic() { + return (accessFlags & Const.ACC_SYNTHETIC) != 0; + } + + public void setAccessFlags(final int accessFlags) { + this.accessFlags = accessFlags; + } + + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java new file mode 100644 index 000000000..5b5d1d77f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java @@ -0,0 +1,101 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a MethodParameters attribute. + * + * @see The class File Format : + * The MethodParameters Attribute + * @since 6.0 + */ +public class MethodParameters extends Attribute implements Iterable { + + /** + * Empty array. + */ + private static final MethodParameter[] EMPTY_METHOD_PARAMETER_ARRAY = {}; + + private MethodParameter[] parameters = EMPTY_METHOD_PARAMETER_ARRAY; + + MethodParameters(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_METHOD_PARAMETERS, nameIndex, length, constantPool); + + final int parameterCount = input.readUnsignedByte(); + parameters = new MethodParameter[parameterCount]; + for (int i = 0; i < parameterCount; i++) { + parameters[i] = new MethodParameter(input); + } + } + + @Override + public void accept(final Visitor v) { + v.visitMethodParameters(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + final MethodParameters c = (MethodParameters) clone(); + c.parameters = new MethodParameter[parameters.length]; + + Arrays.setAll(c.parameters, i -> parameters[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump method parameters attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeByte(parameters.length); + for (final MethodParameter parameter : parameters) { + parameter.dump(file); + } + } + + public MethodParameter[] getParameters() { + return parameters; + } + + @Override + public Iterator iterator() { + return Stream.of(parameters).iterator(); + } + + public void setParameters(final MethodParameter[] parameters) { + this.parameters = parameters; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Module.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Module.java new file mode 100644 index 000000000..00eebe182 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Module.java @@ -0,0 +1,254 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from Attribute and represents the list of modules required, exported, opened or + * provided by a module. There may be at most one Module attribute in a ClassFile structure. + * + * @see Attribute + * @since 6.4.0 + */ +public final class Module extends Attribute { + + /** + * The module file name extension. + * + * @since 6.7.0 + */ + public static final String EXTENSION = ".jmod"; + + private final int moduleNameIndex; + private final int moduleFlags; + private final int moduleVersionIndex; + + private ModuleRequires[] requiresTable; + private ModuleExports[] exportsTable; + private ModuleOpens[] opensTable; + private final int usesCount; + private final int[] usesIndex; + private ModuleProvides[] providesTable; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Module(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_MODULE, nameIndex, length, constantPool); + + moduleNameIndex = input.readUnsignedShort(); + moduleFlags = input.readUnsignedShort(); + moduleVersionIndex = input.readUnsignedShort(); + + final int requiresCount = input.readUnsignedShort(); + requiresTable = new ModuleRequires[requiresCount]; + for (int i = 0; i < requiresCount; i++) { + requiresTable[i] = new ModuleRequires(input); + } + + final int exportsCount = input.readUnsignedShort(); + exportsTable = new ModuleExports[exportsCount]; + for (int i = 0; i < exportsCount; i++) { + exportsTable[i] = new ModuleExports(input); + } + + final int opensCount = input.readUnsignedShort(); + opensTable = new ModuleOpens[opensCount]; + for (int i = 0; i < opensCount; i++) { + opensTable[i] = new ModuleOpens(input); + } + + usesCount = input.readUnsignedShort(); + usesIndex = new int[usesCount]; + for (int i = 0; i < usesCount; i++) { + usesIndex[i] = input.readUnsignedShort(); + } + + final int providesCount = input.readUnsignedShort(); + providesTable = new ModuleProvides[providesCount]; + for (int i = 0; i < providesCount; i++) { + providesTable[i] = new ModuleProvides(input); + } + } + + /** + * 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.visitModule(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Module c = (Module) clone(); + + c.requiresTable = new ModuleRequires[requiresTable.length]; + Arrays.setAll(c.requiresTable, i -> requiresTable[i].copy()); + + c.exportsTable = new ModuleExports[exportsTable.length]; + Arrays.setAll(c.exportsTable, i -> exportsTable[i].copy()); + + c.opensTable = new ModuleOpens[opensTable.length]; + Arrays.setAll(c.opensTable, i -> opensTable[i].copy()); + + c.providesTable = new ModuleProvides[providesTable.length]; + Arrays.setAll(c.providesTable, i -> providesTable[i].copy()); + + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump Module attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + + file.writeShort(moduleNameIndex); + file.writeShort(moduleFlags); + file.writeShort(moduleVersionIndex); + + file.writeShort(requiresTable.length); + for (final ModuleRequires entry : requiresTable) { + entry.dump(file); + } + + file.writeShort(exportsTable.length); + for (final ModuleExports entry : exportsTable) { + entry.dump(file); + } + + file.writeShort(opensTable.length); + for (final ModuleOpens entry : opensTable) { + entry.dump(file); + } + + file.writeShort(usesIndex.length); + for (final int entry : usesIndex) { + file.writeShort(entry); + } + + file.writeShort(providesTable.length); + for (final ModuleProvides entry : providesTable) { + entry.dump(file); + } + } + + /** + * @return table of exported interfaces + * @see ModuleExports + */ + public ModuleExports[] getExportsTable() { + return exportsTable; + } + + /** + * @return table of provided interfaces + * @see ModuleOpens + */ + public ModuleOpens[] getOpensTable() { + return opensTable; + } + + /** + * @return table of provided interfaces + * @see ModuleProvides + */ + public ModuleProvides[] getProvidesTable() { + return providesTable; + } + + /** + * @return table of required modules + * @see ModuleRequires + */ + public ModuleRequires[] getRequiresTable() { + return requiresTable; + } + + /** + * @return String representation, i.e., a list of packages. + */ + @Override + public String toString() { + final ConstantPool cp = super.getConstantPool(); + final StringBuilder buf = new StringBuilder(); + buf.append("Module:\n"); + buf.append(" name: ").append(Utility.pathToPackage(cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module))).append("\n"); + buf.append(" flags: ").append(String.format("%04x", moduleFlags)).append("\n"); + final String version = moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8); + buf.append(" version: ").append(version).append("\n"); + + buf.append(" requires(").append(requiresTable.length).append("):\n"); + for (final ModuleRequires module : requiresTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + buf.append(" exports(").append(exportsTable.length).append("):\n"); + for (final ModuleExports module : exportsTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + buf.append(" opens(").append(opensTable.length).append("):\n"); + for (final ModuleOpens module : opensTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + buf.append(" uses(").append(usesIndex.length).append("):\n"); + for (final int index : usesIndex) { + final String className = cp.getConstantString(index, Const.CONSTANT_Class); + buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + } + + buf.append(" provides(").append(providesTable.length).append("):\n"); + for (final ModuleProvides module : providesTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java new file mode 100644 index 000000000..8a97f4b6d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java @@ -0,0 +1,123 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the exports table of the Module attribute. Each entry describes a package which may + * open the parent module. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleExports implements Cloneable, Node { + + private final int exportsIndex; // points to CONSTANT_Package_info + private final int exportsFlags; + private final int exportsToCount; + private final int[] exportsToIndex; // points to CONSTANT_Module_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleExports(final DataInput file) throws IOException { + exportsIndex = file.readUnsignedShort(); + exportsFlags = file.readUnsignedShort(); + exportsToCount = file.readUnsignedShort(); + exportsToIndex = new int[exportsToCount]; + for (int i = 0; i < exportsToCount; i++) { + exportsToIndex[i] = file.readUnsignedShort(); + } + } + + /** + * 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.visitModuleExports(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleExports copy() { + try { + return (ModuleExports) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(exportsIndex); + file.writeShort(exportsFlags); + file.writeShort(exportsToCount); + for (final int entry : exportsToIndex) { + file.writeShort(entry); + } + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "exports(" + exportsIndex + ", " + exportsFlags + ", " + exportsToCount + ", ...)"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String packageName = constantPool.constantToString(exportsIndex, Const.CONSTANT_Package); + buf.append(Utility.compactClassName(packageName, false)); + buf.append(", ").append(String.format("%04x", exportsFlags)); + buf.append(", to(").append(exportsToCount).append("):\n"); + for (final int index : exportsToIndex) { + final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module); + buf.append(" ").append(Utility.compactClassName(moduleName, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java new file mode 100644 index 000000000..a6ffd8828 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java @@ -0,0 +1,134 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and indicates the main class of a module. There may be at most one + * ModuleMainClass attribute in a ClassFile structure. + * + * @see Attribute + */ +public final class ModuleMainClass extends Attribute { + + private int mainClassIndex; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ModuleMainClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, 0, constantPool); + mainClassIndex = input.readUnsignedShort(); + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param mainClassIndex Host class index + * @param constantPool Array of constants + */ + public ModuleMainClass(final int nameIndex, final int length, final int mainClassIndex, final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool); + this.mainClassIndex = Args.requireU2(mainClassIndex, "mainClassIndex"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public ModuleMainClass(final ModuleMainClass c) { + this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool()); + } + + /** + * 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.visitModuleMainClass(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ModuleMainClass c = (ModuleMainClass) clone(); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump ModuleMainClass attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(mainClassIndex); + } + + /** + * @return index into constant pool of host class name. + */ + public int getHostClassIndex() { + return mainClassIndex; + } + + /** + * @param mainClassIndex the host class index + */ + public void setHostClassIndex(final int mainClassIndex) { + this.mainClassIndex = mainClassIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("ModuleMainClass: "); + final String className = super.getConstantPool().getConstantString(mainClassIndex, Const.CONSTANT_Class); + buf.append(Utility.compactClassName(className, false)); + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java new file mode 100644 index 000000000..06b404df7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java @@ -0,0 +1,123 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the opens table of the Module attribute. Each entry describes a package which the + * parent module opens. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleOpens implements Cloneable, Node { + + private final int opensIndex; // points to CONSTANT_Package_info + private final int opensFlags; + private final int opensToCount; + private final int[] opensToIndex; // points to CONSTANT_Module_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleOpens(final DataInput file) throws IOException { + opensIndex = file.readUnsignedShort(); + opensFlags = file.readUnsignedShort(); + opensToCount = file.readUnsignedShort(); + opensToIndex = new int[opensToCount]; + for (int i = 0; i < opensToCount; i++) { + opensToIndex[i] = file.readUnsignedShort(); + } + } + + /** + * 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.visitModuleOpens(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleOpens copy() { + try { + return (ModuleOpens) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(opensIndex); + file.writeShort(opensFlags); + file.writeShort(opensToCount); + for (final int entry : opensToIndex) { + file.writeShort(entry); + } + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "opens(" + opensIndex + ", " + opensFlags + ", " + opensToCount + ", ...)"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String packageName = constantPool.constantToString(opensIndex, Const.CONSTANT_Package); + buf.append(Utility.compactClassName(packageName, false)); + buf.append(", ").append(String.format("%04x", opensFlags)); + buf.append(", to(").append(opensToCount).append("):\n"); + for (final int index : opensToIndex) { + final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module); + buf.append(" ").append(Utility.compactClassName(moduleName, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java new file mode 100644 index 000000000..96367e02d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and represents the list of packages that are exported or opened by the + * Module attribute. There may be at most one ModulePackages attribute in a ClassFile structure. + * + * @see Attribute + * @LastModified: Feb 2023 + */ +public final class ModulePackages extends Attribute { + + private int[] packageIndexTable; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ModulePackages(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (int[]) null, constantPool); + final int packageCount = input.readUnsignedShort(); + packageIndexTable = new int[packageCount]; + for (int i = 0; i < packageCount; i++) { + packageIndexTable[i] = input.readUnsignedShort(); + } + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param packageIndexTable Table of indices in constant pool + * @param constantPool Array of constants + */ + public ModulePackages(final int nameIndex, final int length, final int[] packageIndexTable, final ConstantPool constantPool) { + super(Const.ATTR_MODULE_PACKAGES, nameIndex, length, constantPool); + this.packageIndexTable = packageIndexTable != null ? packageIndexTable : Const.EMPTY_INT_ARRAY; + Args.requireU2(this.packageIndexTable.length, "packageIndexTable.length"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public ModulePackages(final ModulePackages c) { + this(c.getNameIndex(), c.getLength(), c.getPackageIndexTable(), c.getConstantPool()); + } + + /** + * 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.visitModulePackages(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ModulePackages c = (ModulePackages) clone(); + if (packageIndexTable != null) { + c.packageIndexTable = packageIndexTable.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump ModulePackages attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(packageIndexTable.length); + for (final int index : packageIndexTable) { + file.writeShort(index); + } + } + + /** + * @return Length of package table. + */ + public int getNumberOfPackages() { + return packageIndexTable == null ? 0 : packageIndexTable.length; + } + + /** + * @return array of indices into constant pool of package names. + */ + public int[] getPackageIndexTable() { + return packageIndexTable; + } + + /** + * @return string array of package names + */ + public String[] getPackageNames() { + final String[] names = new String[packageIndexTable.length]; + Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(packageIndexTable[i], Const.CONSTANT_Package))); + return names; + } + + /** + * @param packageIndexTable the list of package indexes Also redefines number_of_packages according to table length. + */ + public void setPackageIndexTable(final int[] packageIndexTable) { + this.packageIndexTable = packageIndexTable != null ? packageIndexTable : Const.EMPTY_INT_ARRAY; + } + + /** + * @return String representation, i.e., a list of packages. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("ModulePackages("); + buf.append(packageIndexTable.length); + buf.append("):\n"); + for (final int index : packageIndexTable) { + final String packageName = super.getConstantPool().getConstantString(index, Const.CONSTANT_Package); + buf.append(" ").append(Utility.compactClassName(packageName, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java new file mode 100644 index 000000000..f6c6058df --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java @@ -0,0 +1,119 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the provides table of the Module attribute. Each entry describes a service + * implementation that the parent module provides. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleProvides implements Cloneable, Node { + + private final int providesIndex; // points to CONSTANT_Class_info + private final int providesWithCount; + private final int[] providesWithIndex; // points to CONSTANT_Class_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleProvides(final DataInput file) throws IOException { + providesIndex = file.readUnsignedShort(); + providesWithCount = file.readUnsignedShort(); + providesWithIndex = new int[providesWithCount]; + for (int i = 0; i < providesWithCount; i++) { + providesWithIndex[i] = file.readUnsignedShort(); + } + } + + /** + * 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.visitModuleProvides(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleProvides copy() { + try { + return (ModuleProvides) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(providesIndex); + file.writeShort(providesWithCount); + for (final int entry : providesWithIndex) { + file.writeShort(entry); + } + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "provides(" + providesIndex + ", " + providesWithCount + ", ...)"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String interfaceName = constantPool.constantToString(providesIndex, Const.CONSTANT_Class); + buf.append(Utility.compactClassName(interfaceName, false)); + buf.append(", with(").append(providesWithCount).append("):\n"); + for (final int index : providesWithIndex) { + final String className = constantPool.getConstantString(index, Const.CONSTANT_Class); + buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java new file mode 100644 index 000000000..c9c26c206 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java @@ -0,0 +1,112 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the requires table of the Module attribute. Each entry describes a module on which + * the parent module depends. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleRequires implements Cloneable, Node { + + private final int requiresIndex; // points to CONSTANT_Module_info + private final int requiresFlags; + private final int requiresVersionIndex; // either 0 or points to CONSTANT_Utf8_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleRequires(final DataInput file) throws IOException { + requiresIndex = file.readUnsignedShort(); + requiresFlags = file.readUnsignedShort(); + requiresVersionIndex = file.readUnsignedShort(); + } + + /** + * 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.visitModuleRequires(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleRequires copy() { + try { + return (ModuleRequires) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(requiresIndex); + file.writeShort(requiresFlags); + file.writeShort(requiresVersionIndex); + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "requires(" + requiresIndex + ", " + String.format("%04x", requiresFlags) + ", " + requiresVersionIndex + ")"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String moduleName = constantPool.constantToString(requiresIndex, Const.CONSTANT_Module); + buf.append(Utility.compactClassName(moduleName, false)); + buf.append(", ").append(String.format("%04x", requiresFlags)); + final String version = requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8); + buf.append(", ").append(version); + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestHost.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestHost.java new file mode 100644 index 000000000..48ba454c9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestHost.java @@ -0,0 +1,134 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and records the nest host of the nest to which the current class or + * interface claims to belong. There may be at most one NestHost attribute in a ClassFile structure. + * + * @see Attribute + */ +public final class NestHost extends Attribute { + + private int hostClassIndex; + + /** + * Constructs object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + NestHost(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, 0, constantPool); + hostClassIndex = input.readUnsignedShort(); + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param hostClassIndex Host class index + * @param constantPool Array of constants + */ + public NestHost(final int nameIndex, final int length, final int hostClassIndex, final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool); + this.hostClassIndex = Args.requireU2(hostClassIndex, "hostClassIndex"); + } + + /** + * Initializes from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public NestHost(final NestHost c) { + this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool()); + } + + /** + * 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.visitNestHost(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final NestHost c = (NestHost) clone(); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dumps NestHost attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(hostClassIndex); + } + + /** + * @return index into constant pool of host class name. + */ + public int getHostClassIndex() { + return hostClassIndex; + } + + /** + * @param hostClassIndex the host class index + */ + public void setHostClassIndex(final int hostClassIndex) { + this.hostClassIndex = hostClassIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("NestHost: "); + final String className = super.getConstantPool().getConstantString(hostClassIndex, Const.CONSTANT_Class); + buf.append(Utility.compactClassName(className, false)); + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestMembers.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestMembers.java new file mode 100644 index 000000000..05d982ca6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestMembers.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and records the classes and interfaces that are authorized to claim + * membership in the nest hosted by the current class or interface. There may be at most one NestMembers attribute in a + * ClassFile structure. + * + * @see Attribute + * @LastModified: Feb 2023 + */ +public final class NestMembers extends Attribute { + + private int[] classes; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + NestMembers(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (int[]) null, constantPool); + final int classCount = input.readUnsignedShort(); + classes = new int[classCount]; + for (int i = 0; i < classCount; i++) { + classes[i] = input.readUnsignedShort(); + } + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param classes Table of indices in constant pool + * @param constantPool Array of constants + */ + public NestMembers(final int nameIndex, final int length, final int[] classes, final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool); + this.classes = classes != null ? classes : Const.EMPTY_INT_ARRAY; + Args.requireU2(this.classes.length, "classes.length"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public NestMembers(final NestMembers c) { + this(c.getNameIndex(), c.getLength(), c.getClasses(), c.getConstantPool()); + } + + /** + * 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.visitNestMembers(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final NestMembers c = (NestMembers) clone(); + if (classes.length > 0) { + c.classes = classes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump NestMembers attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(classes.length); + for (final int index : classes) { + file.writeShort(index); + } + } + + /** + * @return array of indices into constant pool of class names. + */ + public int[] getClasses() { + return classes; + } + + /** + * @return string array of class names + */ + public String[] getClassNames() { + final String[] names = new String[classes.length]; + Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(classes[i], Const.CONSTANT_Class))); + return names; + } + + /** + * @return Length of classes table. + */ + public int getNumberClasses() { + return classes.length; + } + + /** + * @param classes the list of class indexes Also redefines number_of_classes according to table length. + */ + public void setClasses(final int[] classes) { + this.classes = classes != null ? classes : Const.EMPTY_INT_ARRAY; + } + + /** + * @return String representation, i.e., a list of classes. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("NestMembers("); + buf.append(classes.length); + buf.append("):\n"); + for (final int index : classes) { + final String className = super.getConstantPool().getConstantString(index, Const.CONSTANT_Class); + buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Node.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Node.java new file mode 100644 index 000000000..c0395732d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Node.java @@ -0,0 +1,30 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Denote class to have an accept method(); + */ +public interface Node { + + void accept(Visitor obj); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/PMGClass.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/PMGClass.java new file mode 100644 index 000000000..9b1dd4c7b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/PMGClass.java @@ -0,0 +1,157 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from Attribute and represents a reference to a PMG attribute. + * + * @see Attribute + */ +public final class PMGClass extends Attribute { + + private int pmgClassIndex; + private int pmgIndex; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + PMGClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param pmgIndex index in constant pool for source file name + * @param pmgClassIndex Index in constant pool to CONSTANT_Utf8 + * @param constantPool Array of constants + */ + public PMGClass(final int nameIndex, final int length, final int pmgIndex, final int pmgClassIndex, final ConstantPool constantPool) { + super(Const.ATTR_PMG, nameIndex, length, constantPool); + this.pmgIndex = pmgIndex; + this.pmgClassIndex = pmgClassIndex; + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param pgmClass Source to copy. + */ + public PMGClass(final PMGClass pgmClass) { + this(pgmClass.getNameIndex(), pgmClass.getLength(), pgmClass.getPMGIndex(), pgmClass.getPMGClassIndex(), pgmClass.getConstantPool()); + } + + /** + * 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) { + println("Visiting non-standard PMGClass object"); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(pmgIndex); + file.writeShort(pmgClassIndex); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getPMGClassIndex() { + return pmgClassIndex; + } + + /** + * @return PMG class name. + */ + public String getPMGClassName() { + return super.getConstantPool().getConstantUtf8(pmgClassIndex).getBytes(); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getPMGIndex() { + return pmgIndex; + } + + /** + * @return PMG name. + */ + public String getPMGName() { + return super.getConstantPool().getConstantUtf8(pmgIndex).getBytes(); + } + + /** + * @param pmgClassIndex + */ + public void setPMGClassIndex(final int pmgClassIndex) { + this.pmgClassIndex = pmgClassIndex; + } + + /** + * @param pmgIndex + */ + public void setPMGIndex(final int pmgIndex) { + this.pmgIndex = pmgIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java new file mode 100644 index 000000000..a3070fa7e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java @@ -0,0 +1,93 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 + * + * @since 6.0 + */ +public class ParameterAnnotationEntry implements Node { + + static final ParameterAnnotationEntry[] EMPTY_ARRAY = {}; + + 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(ParameterAnnotationEntry.EMPTY_ARRAY); + } + + private final AnnotationEntry[] annotationTable; + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException if an I/O error occurs. + */ + ParameterAnnotationEntry(final DataInput input, final ConstantPool constantPool) throws IOException { + final int annotationTableLength = input.readUnsignedShort(); + annotationTable = new AnnotationEntry[annotationTableLength]; + for (int i = 0; i < annotationTableLength; i++) { + // TODO isRuntimeVisible + annotationTable[i] = AnnotationEntry.read(input, constantPool, false); + } + } + + /** + * 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.visitParameterAnnotationEntry(this); + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(annotationTable.length); + for (final AnnotationEntry entry : annotationTable) { + entry.dump(dos); + } + } + + /** + * returns the array of annotation entries in this annotation + */ + public AnnotationEntry[] getAnnotationEntries() { + return annotationTable; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java new file mode 100644 index 000000000..481779312 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.stream.Stream; + +/** + * base class for parameter annotations + * + * @since 6.0 + */ +public abstract class ParameterAnnotations extends Attribute implements Iterable { + + /** Table of parameter annotations */ + private ParameterAnnotationEntry[] parameterAnnotationTable; + + /** + * @param parameterAnnotationType the subclass type of the parameter annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + */ + ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) + throws IOException { + this(parameterAnnotationType, nameIndex, length, (ParameterAnnotationEntry[]) null, constantPool); + final int numParameters = input.readUnsignedByte(); + parameterAnnotationTable = new ParameterAnnotationEntry[numParameters]; + for (int i = 0; i < numParameters; i++) { + parameterAnnotationTable[i] = new ParameterAnnotationEntry(input, constantPool); + } + } + + /** + * @param parameterAnnotationType the subclass type of the parameter annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param parameterAnnotationTable the actual parameter annotations + * @param constantPool Array of constants + */ + public ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length, + final ParameterAnnotationEntry[] parameterAnnotationTable, final ConstantPool constantPool) { + super(parameterAnnotationType, nameIndex, length, constantPool); + this.parameterAnnotationTable = parameterAnnotationTable; + } + + /** + * 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.visitParameterAnnotation(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + dos.writeByte(parameterAnnotationTable.length); + + for (final ParameterAnnotationEntry element : parameterAnnotationTable) { + element.dump(dos); + } + + } + + /** + * returns the array of parameter annotation entries in this parameter annotation + */ + public ParameterAnnotationEntry[] getParameterAnnotationEntries() { + return parameterAnnotationTable; + } + + /** + * @return the parameter annotation entry table + */ + public final ParameterAnnotationEntry[] getParameterAnnotationTable() { + return parameterAnnotationTable; + } + + @Override + public Iterator iterator() { + return Stream.of(parameterAnnotationTable).iterator(); + } + + /** + * @param parameterAnnotationTable the entries to set in this parameter annotation + */ + public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameterAnnotationTable) { + this.parameterAnnotationTable = parameterAnnotationTable; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java new file mode 100644 index 000000000..7afb87195 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * represents an annotation that is represented in the class file but is not provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeInvisibleAnnotations extends Annotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeInvisibleAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, nameIndex, length, input, constantPool, false); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + writeAnnotations(dos); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java new file mode 100644 index 000000000..e4c3276f9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Represents a parameter annotation that is represented in the class file but is not provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeInvisibleParameterAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) + throws IOException { + super(Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, nameIndex, length, input, constantPool); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java new file mode 100644 index 000000000..c91c77387 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * represents an annotation that is represented in the class file and is provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeVisibleAnnotations extends Annotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeVisibleAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, nameIndex, length, input, constantPool, true); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + writeAnnotations(dos); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java new file mode 100644 index 000000000..7e5d7eaac --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Represents a parameter annotation that is represented in the class file and is provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeVisibleParameterAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) + throws IOException { + super(Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, nameIndex, length, input, constantPool); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Signature.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Signature.java new file mode 100644 index 000000000..4f5d3a341 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Signature.java @@ -0,0 +1,258 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.ByteArrayInputStream; +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and represents a reference to a GJ attribute. + * + * @see Attribute + */ +public final class Signature extends Attribute { + + /** + * Extends ByteArrayInputStream to make 'unreading' chars possible. + */ + private static final class MyByteArrayInputStream extends ByteArrayInputStream { + + MyByteArrayInputStream(final String data) { + super(data.getBytes(StandardCharsets.UTF_8)); + } + + String getData() { + return new String(buf, StandardCharsets.UTF_8); + } + + void unread() { + if (pos > 0) { + pos--; + } + } + } + + private static boolean identStart(final int ch) { + return ch == 'T' || ch == 'L'; + } + + // @since 6.0 is no longer final + public static boolean isActualParameterList(final String s) { + return s.startsWith("L") && s.endsWith(">;"); + } + + // @since 6.0 is no longer final + public static boolean isFormalParameterList(final String s) { + return s.startsWith("<") && s.indexOf(':') > 0; + } + + 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 IllegalArgumentException("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(); + } else if (ch != ';') { + throw new IllegalArgumentException("Illegal signature: " + in.getData() + " read " + (char) ch); + } + } + + private static void matchIdent(final MyByteArrayInputStream in, final StringBuilder buf) { + int ch; + if ((ch = in.read()) == -1) { + throw new IllegalArgumentException("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 + final int skipExpected = "Ljava/lang/Object".length(); + final long skipActual = in.skip(skipExpected); + if (skipActual != skipExpected) { + throw new IllegalStateException(String.format("Unexpected skip: expected=%,d, actual=%,d", skipExpected, skipActual)); + } + 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(Utility.pathToPackage(buf2.toString())); + // System.out.println("regular return ident:"+ (char)ch + ":" + buf2); + if (ch != -1) { + in.unread(); + } + } + + 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(); + } + + private int signatureIndex; + + /** + * Construct object from file stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Signature(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param signatureIndex Index in constant pool to CONSTANT_Utf8 + * @param constantPool Array of constants + */ + public Signature(final int nameIndex, final int length, final int signatureIndex, final ConstantPool constantPool) { + super(Const.ATTR_SIGNATURE, nameIndex, Args.require(length, 2, "Signature length attribute"), constantPool); + this.signatureIndex = signatureIndex; + // validate: + Objects.requireNonNull(constantPool.getConstantUtf8(signatureIndex), "constantPool.getConstantUtf8(signatureIndex)"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public Signature(final Signature c) { + this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool()); + } + + /** + * 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) { + // System.err.println("Visiting non-standard Signature object"); + v.visitSignature(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(signatureIndex); + } + + /** + * @return GJ signature. + */ + public String getSignature() { + return super.getConstantPool().getConstantUtf8(signatureIndex).getBytes(); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getSignatureIndex() { + return signatureIndex; + } + + /** + * @param signatureIndex the index info the constant pool of this signature + */ + public void setSignatureIndex(final int signatureIndex) { + this.signatureIndex = signatureIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "Signature: " + getSignature(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java new file mode 100644 index 000000000..5e4e98d94 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java @@ -0,0 +1,183 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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; + } + + @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 ClassFormatException("SimpleElementValue doesnt know how to write out type " + type); + } + } + + /** + * @return Value entry index in the cpool + */ + public int getIndex() { + return index; + } + + public boolean getValueBoolean() { + if (super.getType() != PRIMITIVE_BOOLEAN) { + throw new IllegalStateException("Dont call getValueBoolean() on a non BOOLEAN ElementValue"); + } + final ConstantInteger bo = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); + return bo.getBytes() != 0; + } + + public byte getValueByte() { + if (super.getType() != PRIMITIVE_BYTE) { + throw new IllegalStateException("Dont call getValueByte() on a non BYTE ElementValue"); + } + return (byte) super.getConstantPool().getConstantInteger(getIndex()).getBytes(); + } + + public char getValueChar() { + if (super.getType() != PRIMITIVE_CHAR) { + throw new IllegalStateException("Dont call getValueChar() on a non CHAR ElementValue"); + } + return (char) super.getConstantPool().getConstantInteger(getIndex()).getBytes(); + } + + public double getValueDouble() { + if (super.getType() != PRIMITIVE_DOUBLE) { + throw new IllegalStateException("Dont call getValueDouble() on a non DOUBLE ElementValue"); + } + final ConstantDouble d = (ConstantDouble) super.getConstantPool().getConstant(getIndex()); + return d.getBytes(); + } + + public float getValueFloat() { + if (super.getType() != PRIMITIVE_FLOAT) { + throw new IllegalStateException("Dont call getValueFloat() on a non FLOAT ElementValue"); + } + final ConstantFloat f = (ConstantFloat) super.getConstantPool().getConstant(getIndex()); + return f.getBytes(); + } + + public int getValueInt() { + if (super.getType() != PRIMITIVE_INT) { + throw new IllegalStateException("Dont call getValueInt() on a non INT ElementValue"); + } + return super.getConstantPool().getConstantInteger(getIndex()).getBytes(); + } + + public long getValueLong() { + if (super.getType() != PRIMITIVE_LONG) { + throw new IllegalStateException("Dont call getValueLong() on a non LONG ElementValue"); + } + final ConstantLong j = (ConstantLong) super.getConstantPool().getConstant(getIndex()); + return j.getBytes(); + } + + public short getValueShort() { + if (super.getType() != PRIMITIVE_SHORT) { + throw new IllegalStateException("Dont call getValueShort() on a non SHORT ElementValue"); + } + final ConstantInteger s = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); + return (short) s.getBytes(); + } + + public String getValueString() { + if (super.getType() != STRING) { + throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue"); + } + return super.getConstantPool().getConstantUtf8(getIndex()).getBytes(); + } + + public void setIndex(final int index) { + this.index = index; + } + + // 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: + return Integer.toString(cpool.getConstantInteger(getIndex()).getBytes()); + case PRIMITIVE_LONG: + final ConstantLong j = cpool.getConstant(getIndex(), Const.CONSTANT_Long, ConstantLong.class); + return Long.toString(j.getBytes()); + case PRIMITIVE_DOUBLE: + final ConstantDouble d = cpool.getConstant(getIndex(), Const.CONSTANT_Double, ConstantDouble.class); + return Double.toString(d.getBytes()); + case PRIMITIVE_FLOAT: + final ConstantFloat f = cpool.getConstant(getIndex(), Const.CONSTANT_Float, ConstantFloat.class); + return Float.toString(f.getBytes()); + case PRIMITIVE_SHORT: + final ConstantInteger s = cpool.getConstantInteger(getIndex()); + return Integer.toString(s.getBytes()); + case PRIMITIVE_BYTE: + final ConstantInteger b = cpool.getConstantInteger(getIndex()); + return Integer.toString(b.getBytes()); + case PRIMITIVE_CHAR: + final ConstantInteger ch = cpool.getConstantInteger(getIndex()); + return String.valueOf((char) ch.getBytes()); + case PRIMITIVE_BOOLEAN: + final ConstantInteger bo = cpool.getConstantInteger(getIndex()); + if (bo.getBytes() == 0) { + return "false"; + } + return "true"; + case STRING: + return cpool.getConstantUtf8(getIndex()).getBytes(); + default: + throw new IllegalStateException("SimpleElementValue class does not know how to stringify type " + type); + } + } + + @Override + public String toString() { + return stringifyValue(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SourceFile.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SourceFile.java new file mode 100644 index 000000000..e9ceed219 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SourceFile.java @@ -0,0 +1,138 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + * @see Attribute + */ +public final class SourceFile extends Attribute { + + private int sourceFileIndex; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + SourceFile(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex 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 constantPool The constant pool that this attribute is associated with. + * @param sourceFileIndex 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 nameIndex, final int length, final int sourceFileIndex, final ConstantPool constantPool) { + super(Const.ATTR_SOURCE_FILE, nameIndex, Args.require(length, 2, "SourceFile length attribute"), constantPool); + this.sourceFileIndex = Args.requireU2(sourceFileIndex, 0, constantPool.getLength(), "SourceFile source file index"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public SourceFile(final SourceFile c) { + this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool()); + } + + /** + * 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.visitSourceFile(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(sourceFileIndex); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getSourceFileIndex() { + return sourceFileIndex; + } + + /** + * @return Source file name. + */ + public String getSourceFileName() { + return super.getConstantPool().getConstantUtf8(sourceFileIndex).getBytes(); + } + + /** + * @param sourceFileIndex + */ + public void setSourceFileIndex(final int sourceFileIndex) { + this.sourceFileIndex = sourceFileIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "SourceFile: " + getSourceFileName(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMap.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMap.java new file mode 100644 index 000000000..1f8ce5ea4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMap.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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 + * + *
    + * StackMapTable_attribute {
    + *   u2              attribute_name_index;
    + *   u4              attribute_length;
    + *   u2              number_of_entries;
    + *   stack_map_frame entries[number_of_entries];
    + * }
    + * 
    + * + * @see Code + * @see StackMapEntry + * @see StackMapType + * @LastModified: Oct 2020 + */ +public final class StackMap extends Attribute { + + private StackMapEntry[] table; // Table of stack map entries + + /** + * Construct object from input stream. + * + * @param nameIndex Index of name + * @param length Content length in bytes + * @param dataInput Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + StackMap(final int nameIndex, final int length, final DataInput dataInput, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (StackMapEntry[]) null, constantPool); + final int mapLength = dataInput.readUnsignedShort(); + table = new StackMapEntry[mapLength]; + for (int i = 0; i < mapLength; i++) { + table[i] = new StackMapEntry(dataInput, constantPool); + } + } + + /* + * @param nameIndex Index of name + * + * @param length Content length in bytes + * + * @param map Table of stack map entries + * + * @param constantPool Array of constants + */ + public StackMap(final int nameIndex, final int length, final StackMapEntry[] table, final ConstantPool constantPool) { + super(Const.ATTR_STACK_MAP, nameIndex, length, constantPool); + this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY; + Args.requireU2(this.table.length, "table.length"); + } + + /** + * 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.visitStackMap(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final StackMap c = (StackMap) clone(); + c.table = new StackMapEntry[table.length]; + Arrays.setAll(c.table, i -> table[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump stack map table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(table.length); + for (final StackMapEntry entry : table) { + entry.dump(file); + } + } + + public int getMapLength() { + return table.length; + } + + /** + * @return Array of stack map entries + */ + public StackMapEntry[] getStackMap() { + return table; + } + + /** + * @param table Array of stack map entries + */ + public void setStackMap(final StackMapEntry[] table) { + this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY; + int len = 2; // Length of 'number_of_entries' field prior to the array of stack maps + for (final StackMapEntry element : this.table) { + len += element.getMapEntrySize(); + } + setLength(len); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder("StackMap("); + int runningOffset = -1; // no +1 on first entry + for (int i = 0; i < table.length; i++) { + runningOffset = table[i].getByteCodeOffset() + runningOffset + 1; + buf.append(String.format("%n@%03d %s", runningOffset, table[i])); + if (i < table.length - 1) { + buf.append(", "); + } + } + buf.append(')'); + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java new file mode 100644 index 000000000..110e30392 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java @@ -0,0 +1,419 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a stack map entry recording the types of local variables and the of stack items at a given + * byte code offset. See CLDC specification 5.3.1.2. + * + * See also https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.4 + * + *
    + * union stack_map_frame {
    + *   same_frame;
    + *   same_locals_1_stack_item_frame;
    + *   same_locals_1_stack_item_frame_extended;
    + *   chop_frame;
    + *   same_frame_extended;
    + *   append_frame;
    + *   full_frame;
    + * }
    + * 
    + * @see StackMap + * @see StackMapType + */ +public final class StackMapEntry implements Node, Cloneable { + + static final StackMapEntry[] EMPTY_ARRAY = {}; + + private int frameType; + private int byteCodeOffset; + private StackMapType[] typesOfLocals; + private StackMapType[] typesOfStackItems; + private ConstantPool constantPool; + + /** + * Construct object from input stream. + * + * @param dataInput Input stream + * @throws IOException if an I/O error occurs. + */ + StackMapEntry(final DataInput dataInput, final ConstantPool constantPool) throws IOException { + this(dataInput.readByte() & 0xFF, -1, null, null, constantPool); + + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + byteCodeOffset = frameType - Const.SAME_FRAME; + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + byteCodeOffset = frameType - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + typesOfStackItems = new StackMapType[] { new StackMapType(dataInput, constantPool) }; + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + byteCodeOffset = dataInput.readUnsignedShort(); + typesOfStackItems = new StackMapType[] { new StackMapType(dataInput, constantPool) }; + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + byteCodeOffset = dataInput.readUnsignedShort(); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + byteCodeOffset = dataInput.readUnsignedShort(); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + byteCodeOffset = dataInput.readUnsignedShort(); + final int numberOfLocals = frameType - 251; + typesOfLocals = new StackMapType[numberOfLocals]; + for (int i = 0; i < numberOfLocals; i++) { + typesOfLocals[i] = new StackMapType(dataInput, constantPool); + } + } else if (frameType == Const.FULL_FRAME) { + byteCodeOffset = dataInput.readUnsignedShort(); + final int numberOfLocals = dataInput.readUnsignedShort(); + typesOfLocals = new StackMapType[numberOfLocals]; + for (int i = 0; i < numberOfLocals; i++) { + typesOfLocals[i] = new StackMapType(dataInput, constantPool); + } + final int numberOfStackItems = dataInput.readUnsignedShort(); + typesOfStackItems = new StackMapType[numberOfStackItems]; + for (int i = 0; i < numberOfStackItems; i++) { + typesOfStackItems[i] = new StackMapType(dataInput, constantPool); + } + } else { + /* Can't happen */ + throw new ClassFormatException("Invalid frame type found while parsing stack map table: " + frameType); + } + } + + /** + * 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.byteCodeOffset = byteCodeOffset; + this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY; + this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY; + this.constantPool = constantPool; + if (numberOfLocals < 0) { + throw new IllegalArgumentException("numberOfLocals < 0"); + } + if (numberOfStackItems < 0) { + throw new IllegalArgumentException("numberOfStackItems < 0"); + } + } + + /** + * Create an instance + * + * @param tag the frameType 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.frameType = tag; + this.byteCodeOffset = byteCodeOffset; + this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY; + this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY; + this.constantPool = constantPool; + } + + /** + * 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.visitStackMapEntry(this); + } + + /** + * @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.typesOfLocals = new StackMapType[typesOfLocals.length]; + Arrays.setAll(e.typesOfLocals, i -> typesOfLocals[i].copy()); + e.typesOfStackItems = new StackMapType[typesOfStackItems.length]; + Arrays.setAll(e.typesOfStackItems, i -> typesOfStackItems[i].copy()); + return e; + } + + /** + * Dump stack map entry + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.write(frameType); + if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + typesOfStackItems[0].dump(file); + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + file.writeShort(byteCodeOffset); + typesOfStackItems[0].dump(file); + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + file.writeShort(byteCodeOffset); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + file.writeShort(byteCodeOffset); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + file.writeShort(byteCodeOffset); + for (final StackMapType type : typesOfLocals) { + type.dump(file); + } + } else if (frameType == Const.FULL_FRAME) { + file.writeShort(byteCodeOffset); + file.writeShort(typesOfLocals.length); + for (final StackMapType type : typesOfLocals) { + type.dump(file); + } + file.writeShort(typesOfStackItems.length); + for (final StackMapType type : typesOfStackItems) { + type.dump(file); + } + } else if (!(frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX)) { + /* Can't happen */ + throw new ClassFormatException("Invalid Stack map table tag: " + frameType); + } + } + + public int getByteCodeOffset() { + return byteCodeOffset; + } + + /** + * @return Constant pool used by this object. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + public int getFrameType() { + return frameType; + } + + /** + * Calculate stack map entry size + * + */ + int getMapEntrySize() { + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + return 1; + } + if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + return 1 + (typesOfStackItems[0].hasIndex() ? 3 : 1); + } + if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + return 3 + (typesOfStackItems[0].hasIndex() ? 3 : 1); + } + if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX || frameType == Const.SAME_FRAME_EXTENDED) { + return 3; + } + if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + int len = 3; + for (final StackMapType typesOfLocal : typesOfLocals) { + len += typesOfLocal.hasIndex() ? 3 : 1; + } + return len; + } + if (frameType != Const.FULL_FRAME) { + throw new IllegalStateException("Invalid StackMap frameType: " + frameType); + } + int len = 7; + for (final StackMapType typesOfLocal : typesOfLocals) { + len += typesOfLocal.hasIndex() ? 3 : 1; + } + for (final StackMapType typesOfStackItem : typesOfStackItems) { + len += typesOfStackItem.hasIndex() ? 3 : 1; + } + return len; + } + + public int getNumberOfLocals() { + return typesOfLocals.length; + } + + public int getNumberOfStackItems() { + return typesOfStackItems.length; + } + + public StackMapType[] getTypesOfLocals() { + return typesOfLocals; + } + + public StackMapType[] getTypesOfStackItems() { + return typesOfStackItems; + } + + private boolean invalidFrameType(final int f) { + // @formatter:off + return f != Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED + && !(f >= Const.CHOP_FRAME && f <= Const.CHOP_FRAME_MAX) + && f != Const.SAME_FRAME_EXTENDED + && !(f >= Const.APPEND_FRAME && f <= Const.APPEND_FRAME_MAX) + && f != Const.FULL_FRAME; + // @formatter:on + } + + public void setByteCodeOffset(final int newOffset) { + if (newOffset < 0 || newOffset > 32767) { + throw new IllegalArgumentException("Invalid StackMap offset: " + newOffset); + } + + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + if (newOffset > Const.SAME_FRAME_MAX) { + frameType = Const.SAME_FRAME_EXTENDED; + } else { + frameType = newOffset; + } + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + if (newOffset > Const.SAME_FRAME_MAX) { + frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED; + } else { + frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME + newOffset; + } + } else if (invalidFrameType(frameType)) { + throw new IllegalStateException("Invalid StackMap frameType: " + frameType); + } + byteCodeOffset = newOffset; + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + public void setFrameType(final int ft) { + if (ft >= Const.SAME_FRAME && ft <= Const.SAME_FRAME_MAX) { + byteCodeOffset = ft - Const.SAME_FRAME; + } else if (ft >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && ft <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + byteCodeOffset = ft - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + } else if (invalidFrameType(ft)) { + throw new IllegalArgumentException("Invalid StackMap frameType"); + } + frameType = ft; + } + + /** + * + * @deprecated since 6.0 + */ + @java.lang.Deprecated + public void setNumberOfLocals(final int n) { // TODO unused + } + + /** + * + * @deprecated since 6.0 + */ + @java.lang.Deprecated + public void setNumberOfStackItems(final int n) { // TODO unused + } + + public void setTypesOfLocals(final StackMapType[] types) { + typesOfLocals = types != null ? types : StackMapType.EMPTY_ARRAY; + } + + public void setTypesOfStackItems(final StackMapType[] types) { + typesOfStackItems = types != null ? types : StackMapType.EMPTY_ARRAY; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(64); + buf.append("("); + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + buf.append("SAME"); + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + buf.append("SAME_LOCALS_1_STACK"); + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + buf.append("SAME_LOCALS_1_STACK_EXTENDED"); + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + buf.append("CHOP ").append(String.valueOf(251 - frameType)); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + buf.append("SAME_EXTENDED"); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + buf.append("APPEND ").append(String.valueOf(frameType - 251)); + } else if (frameType == Const.FULL_FRAME) { + buf.append("FULL"); + } else { + buf.append("UNKNOWN (").append(frameType).append(")"); + } + buf.append(", offset delta=").append(byteCodeOffset); + if (typesOfLocals.length > 0) { + buf.append(", locals={"); + for (int i = 0; i < typesOfLocals.length; i++) { + buf.append(typesOfLocals[i]); + if (i < typesOfLocals.length - 1) { + buf.append(", "); + } + } + buf.append("}"); + } + if (typesOfStackItems.length > 0) { + buf.append(", stack items={"); + for (int i = 0; i < typesOfStackItems.length; i++) { + buf.append(typesOfStackItems[i]); + if (i < typesOfStackItems.length - 1) { + buf.append(", "); + } + } + buf.append("}"); + } + buf.append(")"); + return buf.toString(); + } + + /** + * Update the distance (as an offset delta) from this StackMap entry to the next. Note that this might cause the + * frame type to change. Note also that delta may be negative. + * + * @param delta offset delta + */ + public void updateByteCodeOffset(final int delta) { + setByteCodeOffset(byteCodeOffset + delta); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapType.java new file mode 100644 index 000000000..4575b31df --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapType.java @@ -0,0 +1,162 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents the type of a local variable or item on stack used in the StackMap entries. + * + * @see StackMapEntry + * @see StackMap + * @see Const + */ +public final class StackMapType implements Cloneable { + + public static final StackMapType[] EMPTY_ARRAY = {}; // must be public because BCELifier code generator writes calls to it + + private byte type; + private int index = -1; // Index to CONSTANT_Class or offset + private ConstantPool constantPool; + + /** + * @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 constantPool) { + this.type = checkType(type); + this.index = index; + this.constantPool = constantPool; + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + StackMapType(final DataInput file, final ConstantPool constantPool) throws IOException { + this(file.readByte(), -1, constantPool); + if (hasIndex()) { + this.index = file.readUnsignedShort(); + } + this.constantPool = constantPool; + } + + private byte checkType(final byte type) { + if (type < Const.ITEM_Bogus || type > Const.ITEM_NewObject) { + throw new ClassFormatException("Illegal type for StackMapType: " + type); + } + return type; + } + + /** + * @return deep copy of this object + */ + public StackMapType copy() { + try { + return (StackMapType) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump type entries to file. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(type); + if (hasIndex()) { + file.writeShort(getIndex()); + } + } + + /** + * @return Constant pool used by this object. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @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; + } + + public byte getType() { + return type; + } + + /** + * @return true, if type is either ITEM_Object or ITEM_NewObject + */ + public 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=" + constantPool.constantToString(index, Const.CONSTANT_Class); + } + if (type == Const.ITEM_NewObject) { + return ", offset=" + index; + } + return ""; + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + public void setIndex(final int index) { + this.index = index; + } + + public void setType(final byte type) { + this.type = checkType(type); + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "(type=" + Const.getItemName(type) + printIndex() + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Synthetic.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Synthetic.java new file mode 100644 index 000000000..3683fd643 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Synthetic.java @@ -0,0 +1,145 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * 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. + * + * @see Attribute + */ +public final class Synthetic extends Attribute { + + private byte[] bytes; + + /** + * @param nameIndex 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 constantPool The constant pool this attribute is associated with. + */ + public Synthetic(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) { + super(Const.ATTR_SYNTHETIC, nameIndex, Args.require0(length, "Synthetic attribute length"), constantPool); + this.bytes = bytes; + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Synthetic(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (byte[]) null, constantPool); + if (length > 0) { + bytes = new byte[length]; + input.readFully(bytes); + println("Synthetic attribute with length > 0"); + } + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public Synthetic(final Synthetic c) { + this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); + } + + /** + * 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.visitSynthetic(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Synthetic c = (Synthetic) clone(); + if (bytes != null) { + c.bytes = bytes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + /** + * @return data bytes. + */ + public byte[] getBytes() { + return bytes; + } + + /** + * @param bytes + */ + public void setBytes(final byte[] bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder("Synthetic"); + if (super.getLength() > 0) { + buf.append(" ").append(Utility.toHexString(bytes)); + } + return buf.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Unknown.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Unknown.java new file mode 100644 index 000000000..3500e472c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Unknown.java @@ -0,0 +1,164 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.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)}. + * + * @see Attribute + * @see UnknownAttributeReader + */ +public final class Unknown extends Attribute { + + private byte[] bytes; + + private final String name; + + /** + * Constructs a new instance for a non-standard attribute. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param bytes Attribute contents + * @param constantPool Array of constants + */ + public Unknown(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) { + super(Const.ATTR_UNKNOWN, nameIndex, length, constantPool); + this.bytes = bytes; + this.name = constantPool.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * Constructs a new instance from an input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Unknown(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (byte[]) null, constantPool); + if (length > 0) { + bytes = new byte[length]; + input.readFully(bytes); + } + } + + /** + * Constructs a new instance from another instance. Note that both objects use the same references (shallow copy). Use clone() for a physical copy. + * + * @param unknown Source. + */ + public Unknown(final Unknown unknown) { + this(unknown.getNameIndex(), unknown.getLength(), unknown.getBytes(), unknown.getConstantPool()); + } + + /** + * 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.visitUnknown(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Unknown c = (Unknown) clone(); + if (bytes != null) { + c.bytes = bytes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dumps unknown bytes to file stream. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + /** + * @return data bytes. + */ + public byte[] getBytes() { + return bytes; + } + + /** + * @return name of attribute. + */ + @Override + public String getName() { + return name; + } + + /** + * @param bytes the bytes to set + */ + public void setBytes(final byte[] bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + if (super.getLength() == 0 || bytes == null) { + return "(Unknown attribute " + name + ")"; + } + String hex; + final int limit = 10; + if (super.getLength() > limit) { + final byte[] tmp = Arrays.copyOf(bytes, limit); + hex = Utility.toHexString(tmp) + "... (truncated)"; + } else { + hex = Utility.toHexString(bytes); + } + return "(Unknown attribute " + name + ": " + hex + ")"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java new file mode 100644 index 000000000..2c1cae9ee --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 + * @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 nameIndex 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 constantPool 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 nameIndex, int length, java.io.DataInput file, ConstantPool constantPool); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Utility.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Utility.java new file mode 100644 index 000000000..12dbbe482 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Utility.java @@ -0,0 +1,1562 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.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.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Utility functions that do not really belong to any class in particular. + * + * @LastModified: Feb 2023 + */ +// @since 6.0 methods are no longer final +public abstract class Utility { + + /** + * 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}; + return Integer.parseInt(new String(tmp), 16); + } + 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 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 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 String str, final int off, final int len) throws IOException { + write(str.toCharArray(), off, len); + } + } + + /* + * How many chars have been consumed during parsing in typeSignatureToString(). Read by methodSignatureToString(). Set + * by side effect, but only internally. + */ + private static final ThreadLocal CONSUMER_CHARS = ThreadLocal.withInitial(() -> Integer.valueOf(0)); + + /* + * 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. + */ + private static boolean wide; + + // A-Z, g-z, _, $ + private static final int FREE_CHARS = 48; + + private static final int[] CHAR_MAP = new int[FREE_CHARS]; + + private static final 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; + } + + /** + * Convert bit field of flags into string such as 'static final'. + * + * @param accessFlags Access flags + * @return String representation of flags + */ + public static String accessToString(final int accessFlags) { + return accessToString(accessFlags, 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 accessFlags Access flags + * @param forClass access flags are for class qualifiers ? + * @return String representation of flags + */ + public static String accessToString(final int accessFlags, final boolean forClass) { + final StringBuilder buf = new StringBuilder(); + int p = 0; + for (int i = 0; p < Const.MAX_ACC_FLAG_I; i++) { // Loop through known flags + p = pow2(i); + if ((accessFlags & 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 (forClass && (p == Const.ACC_SUPER || p == Const.ACC_INTERFACE)) { + continue; + } + buf.append(Const.getAccessName(i)).append(" "); + } + } + return buf.toString().trim(); + } + + /** + * 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; + } + + /** + * @param accessFlags the class flags + * + * @return "class" or "interface", depending on the ACC_INTERFACE flag + */ + public static String classOrInterface(final int accessFlags) { + return (accessFlags & Const.ACC_INTERFACE) != 0 ? "interface" : "class"; + } + + /** + * @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; + } + + public static String codeToString(final byte[] code, final ConstantPool constantPool, final int index, final int length) { + return codeToString(code, constantPool, index, length, true); + } + + /** + * 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 constantPool 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 constantPool, 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, constantPool, 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, constantPool, verbose)).append('\n'); + } + } + } catch (final IOException e) { + throw new ClassFormatException("Byte code error: " + buf.toString(), e); + } + return buf.toString(); + } + + public static String codeToString(final ByteSequence bytes, final ConstantPool constantPool) throws IOException { + return codeToString(bytes, constantPool, true); + } + + /** + * Disassemble a stream of byte codes and return the string representation. + * + * @param bytes stream of bytes + * @param constantPool 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 + */ + @SuppressWarnings("fallthrough") // by design for case Const.INSTANCEOF + public static String codeToString(final ByteSequence bytes, final ConstantPool constantPool, + final boolean verbose) throws IOException { + final short opcode = (short) bytes.readUnsignedByte(); + int defaultOffset = 0; + int low; + int high; + int npairs; + int index; + int vindex; + int constant; + int[] match; + int[] jumpTable; + int noPadBytes = 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; + noPadBytes = remainder == 0 ? 0 : 4 - remainder; + for (int i = 0; i < noPadBytes; 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 + defaultOffset = bytes.readInt(); + } + switch (opcode) { + /* + * Table switch has variable length arguments. + */ + case Const.TABLESWITCH: + low = bytes.readInt(); + high = bytes.readInt(); + offset = bytes.getIndex() - 12 - noPadBytes - 1; + defaultOffset += offset; + buf.append("\tdefault = ").append(defaultOffset).append(", low = ").append(low).append(", high = ").append(high).append("("); + jumpTable = new int[high - low + 1]; + for (int i = 0; i < jumpTable.length; i++) { + jumpTable[i] = offset + bytes.readInt(); + buf.append(jumpTable[i]); + if (i < jumpTable.length - 1) { + buf.append(", "); + } + } + buf.append(")"); + break; + /* + * Lookup switch has variable length arguments. + */ + case Const.LOOKUPSWITCH: { + npairs = bytes.readInt(); + offset = bytes.getIndex() - 8 - noPadBytes - 1; + match = new int[npairs]; + jumpTable = new int[npairs]; + defaultOffset += offset; + buf.append("\tdefault = ").append(defaultOffset).append(", npairs = ").append(npairs).append(" ("); + for (int i = 0; i < npairs; i++) { + match[i] = bytes.readInt(); + jumpTable[i] = offset + bytes.readInt(); + buf.append("(").append(match[i]).append(", ").append(jumpTable[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(constantPool.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(constantPool.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 = constantPool.getConstant(index); + // With Java8 operand may be either a CONSTANT_Methodref + // or a CONSTANT_InterfaceMethodref. (markro) + buf.append("\t").append(constantPool.constantToString(index, c.getTag())).append(verbose ? " (" + index + ")" : ""); + break; + case Const.INVOKEVIRTUAL: + index = bytes.readUnsignedShort(); + buf.append("\t").append(constantPool.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(constantPool.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(constantPool.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(constantPool.constantToString(index, constantPool.getConstant(index).getTag())) + .append(verbose ? " (" + index + ")" : ""); + break; + case Const.LDC: + index = bytes.readUnsignedByte(); + buf.append("\t\t").append(constantPool.constantToString(index, constantPool.getConstant(index).getTag())) + .append(verbose ? " (" + index + ")" : ""); + break; + /* + * Array of references. + */ + case Const.ANEWARRAY: + index = bytes.readUnsignedShort(); + buf.append("\t\t<").append(compactClassName(constantPool.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(constantPool.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(); + } + + /** + * 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 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); + } + + /** + * 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 = pathToPackage(str); // Is '/' on all systems, even DOS + // If string starts with 'prefix' and contains no further dots + if (chopit && str.startsWith(prefix) && str.substring(len).indexOf('.') == -1) { + str = str.substring(len); + } + return str; + } + + /** + * Escape all occurrences 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(); + } + + 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 IllegalArgumentException("Illegally nested brackets:" + brackets); + } + open = true; + break; + case ']': + if (!open) { + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); + } + open = false; + count++; + break; + default: + // Don't care + break; + } + } + if (open) { + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); + } + return count; + } + + /** + * 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 = Arrays.copyOf(tmp, count); + } + return bytes; + } + + /** + * 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); + gos.finish(); + 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(); + } + + /** + * 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 leftJustify format left or right + * @param fill fill character + * @return formatted string + */ + public static String fillup(final String str, final int length, final boolean leftJustify, final char fill) { + final int len = length - str.length(); + final char[] buf = new char[Math.max(len, 0)]; + Arrays.fill(buf, fill); + if (leftJustify) { + return str + new String(buf); + } + return new String(buf) + str; + } + + /** + * 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 leftJustify format left or right + * @param fill fill character + * @return formatted int + */ + public static String format(final int i, final int length, final boolean leftJustify, final char fill) { + return fillup(Integer.toString(i), length, leftJustify, fill); + } + + /** + * WARNING: + * + * There is some nomenclature confusion through much of the BCEL code base with respect to the terms Descriptor and + * Signature. For the offical definitions see: + * + * @see Descriptors in The Java + * Virtual Machine Specification + * + * @see Signatures in The Java + * Virtual Machine Specification + * + * In brief, a descriptor is a string representing the type of a field or method. Signatures are similar, but more + * complex. Signatures are used to encode declarations written in the Java programming language that use types + * outside the type system of the Java Virtual Machine. They are used to describe the type of any class, interface, + * constructor, method or field whose declaration uses type variables or parameterized types. + * + * To parse a descriptor, call typeSignatureToString. To parse a signature, call signatureToString. + * + * Note that if the signature string is a single, non-generic item, the call to signatureToString reduces to a call + * to typeSignatureToString. Also note, that if you only wish to parse the first item in a longer signature string, + * you should call typeSignatureToString directly. + */ + + /** + * 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 charFound = 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 (charFound) { + delim = true; + } + break; + case '[': + if (!charFound) { + throw new IllegalArgumentException("Illegal type: " + type); + } + index = i; + break loop; + default: + charFound = 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(packageToPath(type)).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 == '_'; + } + + /** + * @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 argument list portion of method signature to string with all class names compacted. + * + * @param signature Method signature + * @return String Array of argument types + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String[] methodSignatureArgumentTypes(final String signature) throws ClassFormatException { + return methodSignatureArgumentTypes(signature, true); + } + + /** + * Converts argument list portion of method signature to string. + * + * @param signature Method signature + * @param chopit flag that determines whether chopping is executed or not + * @return String Array of argument types + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String[] methodSignatureArgumentTypes(final String signature, final boolean chopit) throws ClassFormatException { + final List vec = new ArrayList<>(); + int index; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + while (signature.charAt(index) != ')') { + vec.add(typeSignatureToString(signature.substring(index), chopit)); + // corrected concurrent private static field acess + index += unwrap(CONSUMER_CHARS); // update position + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + return vec.toArray(Const.EMPTY_STRING_ARRAY); + } + + /** + * Converts return type portion of method signature to string with all class names compacted. + * + * @param signature Method signature + * @return String representation of method return type + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String methodSignatureReturnType(final String signature) throws ClassFormatException { + return methodSignatureReturnType(signature, true); + } + + /** + * Converts return type portion of method signature to string. + * + * @param signature Method signature + * @param chopit flag that determines whether chopping is executed or not + * @return String representation of method return type + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + 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; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + type = typeSignatureToString(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); + } + + /** + * Converts method signature to string. + * + * @param signature to convert + * @param name of method + * @param access flags of method + * @param chopit flag that determines whether chopping is executed or not + * @return Human readable signature + */ + public static String methodSignatureToString(final String signature, final String name, final String access, final boolean chopit) { + return methodSignatureToString(signature, name, access, chopit, null); + } + + /** + * This method converts a method signature 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 flag that determines whether chopping is executed or not + * @param vars the LocalVariableTable for the method + * @return Java type declaration + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + 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 varIndex = access.contains("static") ? 0 : 1; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + while (signature.charAt(index) != ')') { + final String paramType = typeSignatureToString(signature.substring(index), chopit); + buf.append(paramType); + if (vars != null) { + final LocalVariable l = vars.getLocalVariable(varIndex, 0); + if (l != null) { + buf.append(" ").append(l.getName()); + } + } else { + buf.append(" arg").append(varIndex); + } + if ("double".equals(paramType) || "long".equals(paramType)) { + varIndex += 2; + } else { + varIndex++; + } + buf.append(", "); + // corrected concurrent private static field acess + index += unwrap(CONSUMER_CHARS); // update position + } + index++; // update position + // Read return type after ')' + type = typeSignatureToString(signature.substring(index), chopit); + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + // ignore any throws information in the signature + if (buf.length() > 1) { + buf.setLength(buf.length() - 2); + } + buf.append(")"); + return access + (!access.isEmpty() ? " " : "") + // May be an empty string + type + " " + name + buf.toString(); + } + + /** + * 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(); + } + + /** + * Converts '.'s to '/'s. + * + * @param name Source + * @return converted value + * @since 6.7.0 + */ + public static String packageToPath(final String name) { + return name.replace('.', '/'); + } + + /** + * Converts a path to a package name. + * + * @param str the source path. + * @return a package name. + * @since 6.6.0 + */ + public static String pathToPackage(final String str) { + return str.replace('/', '.'); + } + + private static int pow2(final int n) { + return 1 << n; + } + + 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(); + } + + 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)); + } + + /** + * 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 oldIndex; + try { + if (str.contains(old)) { // 'old' found in str + final StringBuilder buf = new StringBuilder(); + oldIndex = 0; // String start offset + // While we have something to replace + while ((index = str.indexOf(old, oldIndex)) != -1) { + buf.append(str, oldIndex, index); // append prefix + buf.append(new_); // append replacement + oldIndex = index + old.length(); // Skip 'old'.length chars + } + buf.append(str.substring(oldIndex)); // append rest of string + str = buf.toString(); + } + } catch (final StringIndexOutOfBoundsException e) { // Should not occur + System.err.println(e); + } + return str; + } + + /** + * 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; + } + + /** + * @return 'flag' with bit 'i' set to 1 + */ + public static int setBit(final int flag, final int i) { + return flag | pow2(i); + } + + /** + * Converts a signature to a string with all class names compacted. Class, Method and Type signatures are supported. + * Enum and Interface signatures are not supported. + * + * @param signature signature to convert + * @return String containg human readable signature + */ + public static String signatureToString(final String signature) { + return signatureToString(signature, true); + } + + /** + * Converts a signature to a string. Class, Method and Type signatures are supported. Enum and Interface signatures are + * not supported. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @return String containg human readable signature + */ + public static String signatureToString(final String signature, final boolean chopit) { + String type = ""; + String typeParams = ""; + int index = 0; + if (signature.charAt(0) == '<') { + // we have type paramters + typeParams = typeParamTypesToString(signature, chopit); + index += unwrap(CONSUMER_CHARS); // update position + } + if (signature.charAt(index) == '(') { + // We have a Method signature. + // add types of arguments + type = typeParams + typeSignaturesToString(signature.substring(index), chopit, ')'); + index += unwrap(CONSUMER_CHARS); // update position + // add return type + type = type + typeSignatureToString(signature.substring(index), chopit); + index += unwrap(CONSUMER_CHARS); // update position + // ignore any throws information in the signature + return type; + } + // Could be Class or Type... + type = typeSignatureToString(signature.substring(index), chopit); + index += unwrap(CONSUMER_CHARS); // update position + if (typeParams.isEmpty() && index == signature.length()) { + // We have a Type signature. + return type; + } + // We have a Class signature. + final StringBuilder typeClass = new StringBuilder(typeParams); + typeClass.append(" extends "); + typeClass.append(type); + if (index < signature.length()) { + typeClass.append(" implements "); + typeClass.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + while (index < signature.length()) { + typeClass.append(", "); + typeClass.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + return typeClass.toString(); + } + + /** + * 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 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); + } + } + + /** + * Converts a type parameter list signature to a string. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @return String containg human readable signature + */ + private static String typeParamTypesToString(final String signature, final boolean chopit) { + // The first character is guranteed to be '<' + final StringBuilder typeParams = new StringBuilder("<"); + int index = 1; // skip the '<' + // get the first TypeParameter + typeParams.append(typeParamTypeToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + // are there more TypeParameters? + while (signature.charAt(index) != '>') { + typeParams.append(", "); + typeParams.append(typeParamTypeToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + wrap(CONSUMER_CHARS, index + 1); // account for the '>' char + return typeParams.append(">").toString(); + } + + /** + * Converts a type parameter signature to a string. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @return String containg human readable signature + */ + private static String typeParamTypeToString(final String signature, final boolean chopit) { + int index = signature.indexOf(':'); + if (index <= 0) { + throw new ClassFormatException("Invalid type parameter signature: " + signature); + } + // get the TypeParameter identifier + final StringBuilder typeParam = new StringBuilder(signature.substring(0, index)); + index++; // account for the ':' + if (signature.charAt(index) != ':') { + // we have a class bound + typeParam.append(" extends "); + typeParam.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + // look for interface bounds + while (signature.charAt(index) == ':') { + index++; // skip over the ':' + typeParam.append(" & "); + typeParam.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + wrap(CONSUMER_CHARS, index); + return typeParam.toString(); + } + + /** + * Converts a list of type signatures to a string. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @param term character indicating the end of the list + * @return String containg human readable signature + */ + private static String typeSignaturesToString(final String signature, final boolean chopit, final char term) { + // The first character will be an 'open' that matches the 'close' contained in term. + final StringBuilder typeList = new StringBuilder(signature.substring(0, 1)); + int index = 1; // skip the 'open' character + // get the first Type in the list + if (signature.charAt(index) != term) { + typeList.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + // are there more types in the list? + while (signature.charAt(index) != term) { + typeList.append(", "); + typeList.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + wrap(CONSUMER_CHARS, index + 1); // account for the term char + return typeList.append(term).toString(); + } + + /** + * + * This method converts a type signature string into a Java type declaration such as 'String[]' and throws a + * 'ClassFormatException' when the parsed type is invalid. + * + * @param signature type signature + * @param chopit flag that determines whether chopping is executed or not + * @return string containing human readable type signature + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + * @since 6.4.0 + */ + public static String typeSignatureToString(final String signature, final boolean chopit) throws ClassFormatException { + // corrected concurrent private static field acess + wrap(CONSUMER_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 type variable signature: " + signature); + } + // corrected concurrent private static field acess + wrap(CONSUMER_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(CONSUMER_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(CONSUMER_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 consumedChars = bracketIndex + 1; // Shadows global var + + // check for wildcards + if (signature.charAt(consumedChars) == '+') { + type.append("? extends "); + consumedChars++; + } else if (signature.charAt(consumedChars) == '-') { + type.append("? super "); + consumedChars++; + } + + // get the first TypeArgument + if (signature.charAt(consumedChars) == '*') { + type.append("?"); + consumedChars++; + } else { + type.append(typeSignatureToString(signature.substring(consumedChars), chopit)); + // update our consumed count by the number of characters the for type argument + consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_CHARS, consumedChars); + } + + // are there more TypeArguments? + while (signature.charAt(consumedChars) != '>') { + type.append(", "); + // check for wildcards + if (signature.charAt(consumedChars) == '+') { + type.append("? extends "); + consumedChars++; + } else if (signature.charAt(consumedChars) == '-') { + type.append("? super "); + consumedChars++; + } + if (signature.charAt(consumedChars) == '*') { + type.append("?"); + consumedChars++; + } else { + type.append(typeSignatureToString(signature.substring(consumedChars), chopit)); + // update our consumed count by the number of characters the for type argument + consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_CHARS, consumedChars); + } + } + + // process the closing ">" + consumedChars++; + type.append(">"); + + if (signature.charAt(consumedChars) == '.') { + // we have a ClassTypeSignatureSuffix + type.append("."); + // convert SimpleClassTypeSignature to fake ClassTypeSignature + // and then recurse to parse it + type.append(typeSignatureToString("L" + signature.substring(consumedChars + 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 + consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_CHARS, consumedChars); + return type.toString(); + } + if (signature.charAt(consumedChars) != ';') { + throw new ClassFormatException("Invalid signature: " + signature); + } + wrap(Utility.CONSUMER_CHARS, consumedChars + 1); // remove final ";" + return type.toString(); + } + case 'S': + return "short"; + case 'Z': + return "boolean"; + case '[': { // Array declaration + int n; + StringBuilder brackets; + String type; + int consumedChars; // 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("[]"); + } + consumedChars = n; // Remember value + // The rest of the string denotes a '' + type = typeSignatureToString(signature.substring(n), chopit); + // corrected concurrent private static field acess + // Utility.consumed_chars += consumed_chars; is replaced by: + final int temp = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_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); + } + } + + private static int unwrap(final ThreadLocal tl) { + return tl.get(); + } + + private static void wrap(final ThreadLocal tl, final int value) { + tl.set(value); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Visitor.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Visitor.java new file mode 100644 index 000000000..74cb8400d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Visitor.java @@ -0,0 +1,236 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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. + */ +public interface Visitor { + /** + * @since 6.0 + */ + void visitAnnotation(Annotations obj); + + /** + * @since 6.0 + */ + void visitAnnotationDefault(AnnotationDefault obj); + + /** + * @since 6.0 + */ + void visitAnnotationEntry(AnnotationEntry obj); + + /** + * @since 6.0 + */ + void visitBootstrapMethods(BootstrapMethods obj); + + void visitCode(Code obj); + + void visitCodeException(CodeException obj); + + void visitConstantClass(ConstantClass obj); + + void visitConstantDouble(ConstantDouble obj); + + /** + * @since 6.3 + */ + default void visitConstantDynamic(final ConstantDynamic constantDynamic) { + // empty + } + + void visitConstantFieldref(ConstantFieldref obj); + + void visitConstantFloat(ConstantFloat obj); + + void visitConstantInteger(ConstantInteger obj); + + void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj); + + void visitConstantInvokeDynamic(ConstantInvokeDynamic obj); + + void visitConstantLong(ConstantLong obj); + + /** + * @since 6.0 + */ + void visitConstantMethodHandle(ConstantMethodHandle obj); + + void visitConstantMethodref(ConstantMethodref obj); + + /** + * @since 6.0 + */ + void visitConstantMethodType(ConstantMethodType obj); + + /** + * @since 6.1 + */ + void visitConstantModule(ConstantModule constantModule); + + void visitConstantNameAndType(ConstantNameAndType obj); + + /** + * @since 6.1 + */ + void visitConstantPackage(ConstantPackage constantPackage); + + void visitConstantPool(ConstantPool obj); + + void visitConstantString(ConstantString obj); + + void visitConstantUtf8(ConstantUtf8 obj); + + void visitConstantValue(ConstantValue obj); + + void visitDeprecated(Deprecated obj); + + /** + * @since 6.0 + */ + void visitEnclosingMethod(EnclosingMethod 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); + + /** + * @since 6.0 + */ + void visitLocalVariableTypeTable(LocalVariableTypeTable obj); + + void visitMethod(Method obj); + + /** + * @since 6.4.0 + */ + default void visitMethodParameter(final MethodParameter obj) { + // empty + } + + /** + * @since 6.0 + */ + void visitMethodParameters(MethodParameters obj); + + /** + * @since 6.4.0 + */ + default void visitModule(final Module constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleExports(final ModuleExports constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleMainClass(final ModuleMainClass obj) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleOpens(final ModuleOpens constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModulePackages(final ModulePackages constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleProvides(final ModuleProvides constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleRequires(final ModuleRequires constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitNestHost(final NestHost obj) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitNestMembers(final NestMembers obj) { + // empty + } + + /** + * @since 6.0 + */ + void visitParameterAnnotation(ParameterAnnotations obj); + + /** + * @since 6.0 + */ + void visitParameterAnnotationEntry(ParameterAnnotationEntry obj); + + void visitSignature(Signature obj); + + void visitSourceFile(SourceFile obj); + + void visitStackMap(StackMap obj); + + void visitStackMapEntry(StackMapEntry obj); + + void visitSynthetic(Synthetic obj); + + void visitUnknown(Unknown obj); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/package.html new file mode 100644 index 000000000..ca3f5198c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AALOAD.java new file mode 100644 index 000000000..19bd38d0a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * AALOAD - Load reference from array + * + *
    + * Stack: ..., arrayref, index -> value
    + * 
    + */ +public class AALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load reference from array + */ + public AALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AASTORE.java new file mode 100644 index 000000000..9561ab4c7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * AASTORE - Store into reference array + * + *
    + * Stack: ..., arrayref, index, value -> ...
    + * 
    + */ +public class AASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store into reference array + */ + public AASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java new file mode 100644 index 000000000..95556b9d0 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ACONST_NULL - Push null reference + * + *
    + * Stack: ... -> ..., null
    + * 
    + */ +public class ACONST_NULL extends Instruction implements PushInstruction, TypedInstruction { + + /** + * Push null reference + */ + public ACONST_NULL() { + super(com.sun.org.apache.bcel.internal.Const.ACONST_NULL, (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.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitACONST_NULL(this); + } + + /** + * @return Type.NULL + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.NULL; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ALOAD.java new file mode 100644 index 000000000..8db0f9fad --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ALOAD.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ALOAD - Load reference from local variable + * + *
    + * Stack: ... -> ..., objectref
    + * 
    + * @LastModified: Jan 2020 + */ +public class ALOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ALOAD() { + super(com.sun.org.apache.bcel.internal.Const.ALOAD, com.sun.org.apache.bcel.internal.Const.ALOAD_0); + } + + /** + * Load reference from local variable + * + * @param n index of local variable + */ + public ALOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ALOAD, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java new file mode 100644 index 000000000..eabf15c38 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java @@ -0,0 +1,75 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * ANEWARRAY - Create new array of references + * + *
    + * Stack: ..., count -> ..., arrayref
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.ANEWARRAY, 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 + */ + @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 Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 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; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARETURN.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARETURN.java new file mode 100644 index 000000000..ff2428d45 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ARETURN - Return reference from method + * + *
    + * Stack: ..., objectref -> <empty>
    + * 
    + */ +public class ARETURN extends ReturnInstruction { + + /** + * Return reference from method + */ + public ARETURN() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java new file mode 100644 index 000000000..2d7188e91 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * ARRAYLENGTH - Get length of array + * + *
    + * Stack: ..., arrayref -> ..., length
    + * 
    + * @LastModified: Feb 2023 + */ +public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer, StackConsumer /* since 6.0 */ { + + /** + * Get length of array + */ + public ARRAYLENGTH() { + super(com.sun.org.apache.bcel.internal.Const.ARRAYLENGTH, (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.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitARRAYLENGTH(this); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.NULL_POINTER_EXCEPTION}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ASTORE.java new file mode 100644 index 000000000..7852c6646 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ASTORE.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * ASTORE - Store reference into local variable + * + *
    + * Stack ..., objectref -> ...
    + * 
    + * @LastModified: Jan 2020 + */ +public class ASTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ASTORE() { + super(com.sun.org.apache.bcel.internal.Const.ASTORE, com.sun.org.apache.bcel.internal.Const.ASTORE_0); + } + + /** + * Store reference into local variable + * + * @param n index of local variable + */ + public ASTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ASTORE, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ATHROW.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ATHROW.java new file mode 100644 index 000000000..bb2e953f8 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ATHROW.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * ATHROW - Throw exception + * + *
    + * Stack: ..., objectref -> objectref
    + * 
    + */ +public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower { + + /** + * Throw exception + */ + public ATHROW() { + super(com.sun.org.apache.bcel.internal.Const.ATHROW, (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.visitUnconditionalBranch(this); + v.visitExceptionThrower(this); + v.visitATHROW(this); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.THROWABLE}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java new file mode 100644 index 000000000..8e8626d32 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java @@ -0,0 +1,28 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote family of instructions that allocates space in the heap. + */ +public interface AllocationInstruction { +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java new file mode 100644 index 000000000..1ed232d72 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java @@ -0,0 +1,77 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.AnnotationElementValue; +import com.sun.org.apache.bcel.internal.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 AnnotationElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + super(ANNOTATION, cpool); + a = new AnnotationEntryGen(value.getAnnotationEntry(), cpool, copyPoolEntries); + } + + 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 IllegalArgumentException("Only element values of type annotation can be built with this ctor - type specified: " + type); + } + this.a = annotation; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getElementValueType()); // u1 type of value (ANNOTATION == '@') + a.dump(dos); + } + + public AnnotationEntryGen getAnnotation() { + return a; + } + + /** + * Return immutable variant of this AnnotationElementValueGen + */ + @Override + public ElementValue getElementValue() { + return new AnnotationElementValue(super.getElementValueType(), a.getAnnotation(), getConstantPool().getConstantPool()); + } + + @Override + public String stringifyValue() { + throw new UnsupportedOperationException("Not implemented yet"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java new file mode 100644 index 000000000..ea01a8371 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 com.sun.org.apache.bcel.internal.classfile.AnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValuePair; +import com.sun.org.apache.bcel.internal.classfile.RuntimeInvisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeInvisibleParameterAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleParameterAnnotations; + +/** + * @since 6.0 + * @LastModified: Jan 2020 + */ +public class AnnotationEntryGen { + + static final AnnotationEntryGen[] EMPTY_ARRAY = {}; + + /** + * 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 Attribute.EMPTY_ARRAY; + } + + 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(Attribute.EMPTY_ARRAY); + } 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(Attribute.EMPTY_ARRAY); + } catch (final IOException e) { + System.err.println("IOException whilst processing parameter annotations"); + e.printStackTrace(); + } + return null; + } + + 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; + } + + private int typeIndex; + + private List evs; + + private final ConstantPoolGen cpool; + + private boolean isRuntimeVisible; + + /** + * 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 AnnotationEntryGen(final ConstantPoolGen cpool) { + this.cpool = cpool; + } + + 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 void addElementNameValuePair(final ElementValuePairGen evp) { + if (evs == null) { + evs = new ArrayList<>(); + } + evs.add(evp); + } + + 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; + } + + 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); + } + } + + /** + * 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 int getTypeIndex() { + return typeIndex; + } + + public final String getTypeName() { + return getTypeSignature();// BCELBUG: Should I use this instead? + // Utility.signatureToString(getTypeSignature()); + } + + public final String getTypeSignature() { + // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex); + final ConstantUtf8 utf8 = (ConstantUtf8) cpool.getConstant(typeIndex/* c.getNameIndex() */); + return utf8.getBytes(); + } + + /** + * Returns list of ElementNameValuePair objects + */ + public List getValues() { + return evs; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + private void isRuntimeVisible(final boolean b) { + isRuntimeVisible = b; + } + + 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(); + } + + @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(); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java new file mode 100644 index 000000000..752ab1155 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java @@ -0,0 +1,95 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Super class for the family of arithmetic instructions. + */ +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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java new file mode 100644 index 000000000..71374877e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java @@ -0,0 +1,116 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.sun.org.apache.bcel.internal.classfile.ArrayElementValue; +import com.sun.org.apache.bcel.internal.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; + + /** + * @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)); + } + } + + 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 IllegalArgumentException("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)); + } + } + + public void addElement(final ElementValueGen gen) { + evalues.add(gen); + } + + @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); + } + } + + /** + * 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()); + } + + public List getElementValues() { + return evalues; + } + + public int getElementValuesSize() { + return evalues.size(); + } + + @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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java new file mode 100644 index 000000000..538c18071 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java @@ -0,0 +1,84 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * Super class for instructions dealing with array access such as IALOAD. + */ +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 com.sun.org.apache.bcel.internal.Const.IALOAD: + case com.sun.org.apache.bcel.internal.Const.IASTORE: + return Type.INT; + case com.sun.org.apache.bcel.internal.Const.CALOAD: + case com.sun.org.apache.bcel.internal.Const.CASTORE: + return Type.CHAR; + case com.sun.org.apache.bcel.internal.Const.BALOAD: + case com.sun.org.apache.bcel.internal.Const.BASTORE: + return Type.BYTE; + case com.sun.org.apache.bcel.internal.Const.SALOAD: + case com.sun.org.apache.bcel.internal.Const.SASTORE: + return Type.SHORT; + case com.sun.org.apache.bcel.internal.Const.LALOAD: + case com.sun.org.apache.bcel.internal.Const.LASTORE: + return Type.LONG; + case com.sun.org.apache.bcel.internal.Const.DALOAD: + case com.sun.org.apache.bcel.internal.Const.DASTORE: + return Type.DOUBLE; + case com.sun.org.apache.bcel.internal.Const.FALOAD: + case com.sun.org.apache.bcel.internal.Const.FASTORE: + return Type.FLOAT; + case com.sun.org.apache.bcel.internal.Const.AALOAD: + case com.sun.org.apache.bcel.internal.Const.AASTORE: + return Type.OBJECT; + default: + throw new ClassGenException("Unknown case in switch" + opcode); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayType.java new file mode 100644 index 000000000..138999ebe --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayType.java @@ -0,0 +1,140 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Denotes array type, such as int[][] + */ +public final class ArrayType extends ReferenceType { + + private final int dimensions; + private final Type basicType; + + /** + * Convenience constructor for array type, e.g. int[] + * + * @param type array type, e.g. T_INT + * @param dimensions array dimensions + */ + public ArrayType(final byte type, final int dimensions) { + this(BasicType.getType(type), dimensions); + } + + /** + * Convenience constructor for reference array type, e.g. Object[] + * + * @param className complete name of class (java.lang.String, e.g.) + * @param dimensions array dimensions + */ + public ArrayType(final String className, final int dimensions) { + this(ObjectType.getInstance(className), dimensions); + } + + /** + * Constructor for array of given type + * + * @param type type of array (may be an array itself) + * @param dimensions array dimensions + */ + 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; + basicType = array.basicType; + break; + case Const.T_VOID: + throw new ClassGenException("Invalid type: void[]"); + default: // Basic type or reference + this.dimensions = dimensions; + basicType = type; + break; + } + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < this.dimensions; i++) { + buf.append('['); + } + buf.append(basicType.getSignature()); + super.setSignature(buf.toString()); + } + + /** + * @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.basicType.equals(basicType); + } + return false; + } + + /** + * @return basic type of array, i.e., for int[][][] the basic type is int + */ + public Type getBasicType() { + return basicType; + } + + /** + * Gets the name of referenced class. + * + * @return name of referenced class. + * @since 6.7.0 + */ + @Override + @Deprecated + public String getClassName() { + return signature; + } + + /** + * @return number of dimensions of array + */ + public int getDimensions() { + return dimensions; + } + + /** + * @return element type of array, i.e., for int[][][] the element type is int[][] + */ + public Type getElementType() { + if (dimensions == 1) { + return basicType; + } + return new ArrayType(basicType, dimensions - 1); + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + return basicType.hashCode() ^ dimensions; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BALOAD.java new file mode 100644 index 000000000..dc14c3fcd --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BALOAD.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * BALOAD - Load byte or boolean from array + * + *
    + * Stack: ..., arrayref, index -> ..., value
    + * 
    + */ +public class BALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load byte or boolean from array + */ + public BALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BASTORE.java new file mode 100644 index 000000000..da73a504b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BASTORE.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * BASTORE - Store into byte or boolean array + * + *
    + * Stack: ..., arrayref, index, value -> ...
    + * 
    + */ +public class BASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store byte or boolean into array + */ + public BASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BIPUSH.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BIPUSH.java new file mode 100644 index 000000000..264fe1cb5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BIPUSH.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * BIPUSH - Push byte on stack + * + *
    + * Stack: ... -> ..., value
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.BIPUSH, (short) 2); + this.b = b; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * Dump instruction as byte code to stream out. + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.dump(out); + out.writeByte(b); + } + + /** + * @return Type.BYTE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.BYTE; + } + + @Override + public Number getValue() { + return Integer.valueOf(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(); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + b; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java new file mode 100644 index 000000000..a4fc7be05 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java @@ -0,0 +1,42 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * BREAKPOINT, JVM dependent, ignored by default + */ +public class BREAKPOINT extends Instruction { + + public BREAKPOINT() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BasicType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BasicType.java new file mode 100644 index 000000000..71bc54911 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BasicType.java @@ -0,0 +1,84 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Denotes basic type such as int. + */ +public final class BasicType extends 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); + } + } + + /** + * 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); + } + } + + /** + * @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(); + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + return super.getType(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchHandle.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchHandle.java new file mode 100644 index 000000000..91ab9ac54 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchHandle.java @@ -0,0 +1,104 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.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 + */ +public final class BranchHandle extends InstructionHandle { + + /** + * Factory method. + */ + static BranchHandle getBranchHandle(final BranchInstruction i) { + return new BranchHandle(i); + } + + // 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; + } + + /* + * 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(); + } + + /** + * @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; + } + + @Override + void setPosition(final int pos) { + // Original code: i_position = bi.position = pos; + bi.setPosition(pos); + super.setPosition(pos); + } + + /** + * Pass new target to instruction. + */ + public void setTarget(final InstructionHandle ih) { + bi.setTarget(ih); + } + + @Override + protected int updatePosition(final int offset, final int maxOffset) { + final int x = bi.updatePosition(offset, maxOffset); + super.setPosition(bi.getPosition()); + return x; + } + + /** + * Update target of instruction. + */ + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + bi.updateTarget(oldIh, newIh); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java new file mode 100644 index 000000000..4aba9a970 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.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 + * @LastModified: Feb 2023 + */ +public abstract class BranchInstruction extends Instruction implements InstructionTargeter { + + /** + * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen, LineNumberGen + */ + static void notifyTarget(final InstructionHandle oldIh, final InstructionHandle newIh, final InstructionTargeter t) { + if (oldIh != null) { + oldIh.removeTargeter(t); + } + if (newIh != null) { + newIh.addTargeter(t); + } + } + + /** + * @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); + } + + /** + * @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; + } + + /** + * 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 + } + + /** + * @return target offset in byte code + */ + public final int getIndex() { + return index; + } + + /** + * @return the position + * @since 6.0 + */ + protected int getPosition() { + return position; + } + + /** + * @return target of branch instruction + */ + public InstructionHandle getTarget() { + return target; + } + + /** + * @return the offset to this instruction's target + */ + protected int getTargetOffset() { + return getTargetOffset(target); + } + + /** + * @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; + } + + /** + * 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(); + } + + /** + * @param index the index to set + * @since 6.0 + */ + protected void setIndex(final int index) { + this.index = index; + } + + /** + * @param position the position to set + * @since 6.0 + */ + protected void setPosition(final int position) { + this.position = position; + } + + /** + * Updates the opcode. Before changing the opcode, reset the target so that + * the old instruction is removed from the HashSet and the new one then added. + * @param opcode the opcode + */ + @Override + void setOpcode( final short opcode ) { + if (target == null) { + super.setOpcode(opcode); + } else { + // reset target before changing the opcode + InstructionHandle t = target; + setTarget(null); + super.setOpcode(opcode); + setTarget(t); + } + } + + /** + * Set branch target + * + * @param target branch target + */ + public void setTarget(final InstructionHandle target) { + notifyTarget(this.target, target, this); + this.target = target; + } + + /** + * 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 (target != null) { + if (verbose) { + 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 { + index = target.getPosition(); + // index = getTargetOffset(); crashes if positions haven't been set + // t = "" + (index + position); + t = "" + index; + } + } + return s + " -> " + t; + } + + /** + * 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 maxOffset 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 maxOffset) { + position += offset; + return 0; + } + + /** + * @param oldIh old target + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + if (target != oldIh) { + throw new ClassGenException("Not targeting " + oldIh + ", but " + target); + } + setTarget(newIh); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CALOAD.java new file mode 100644 index 000000000..02cc46df6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * CALOAD - Load char from array + * + *
    + * Stack: ..., arrayref, index -> ..., value
    + * 
    + */ +public class CALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load char from array + */ + public CALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CASTORE.java new file mode 100644 index 000000000..ca4a4e1fe --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * CASTORE - Store into char array + * + *
    + * Stack: ..., arrayref, index, value -> ...
    + * 
    + */ +public class CASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store char into array + */ + public CASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java new file mode 100644 index 000000000..6983350f6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java @@ -0,0 +1,83 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * CHECKCAST - Check whether object is of given type + * + *
    + * Stack: ..., objectref -> ..., objectref
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.CHECKCAST, 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 + */ + @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); + } + + /** + * @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; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CPInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CPInstruction.java new file mode 100644 index 000000000..1dfd24414 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CPInstruction.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantClass; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.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 + * + * @LastModified: Jan 2020 + */ +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); + } + + /** + * @return index in constant pool referred by this instruction. + */ + @Override + public final int getIndex() { + return index; + } + + /** + * @return type related with this instruction. + */ + @Override + public Type getType(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + String name = cp.getConstantString(index, com.sun.org.apache.bcel.internal.Const.CONSTANT_Class); + if (!name.startsWith("[")) { + name = "L" + name + ";"; + } + return Type.getType(name); + } + + /** + * 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); + } + + /** + * 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; + } + + /** + * 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 = Utility.packageToPath(str); + } + return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + str; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java new file mode 100644 index 000000000..1c1c032db --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java @@ -0,0 +1,92 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ClassElementValue; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.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 final int idx; + + 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(); + } + } + + 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()); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getElementValueType()); // u1 kind of value + dos.writeShort(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(); + } + + /** + * Return immutable variant of this ClassElementValueGen + */ + @Override + public ElementValue getElementValue() { + return new ClassElementValue(super.getElementValueType(), idx, getConstantPool().getConstantPool()); + } + + public int getIndex() { + return idx; + } + + @Override + public String stringifyValue() { + return getClassString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGen.java new file mode 100644 index 000000000..acaf45195 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGen.java @@ -0,0 +1,545 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.AccessFlags; +import com.sun.org.apache.bcel.internal.classfile.Annotations; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.RuntimeInvisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.SourceFile; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * Template class for building up a java class. May be initialized with an existing java class (file). + * + * @see JavaClass + * @LastModified: Feb 2023 + */ +public class ClassGen extends AccessFlags implements Cloneable { + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final ClassGen THIS = (ClassGen) o1; + final ClassGen THAT = (ClassGen) o2; + return Objects.equals(THIS.getClassName(), THAT.getClassName()); + } + + @Override + public int hashCode(final Object o) { + final ClassGen THIS = (ClassGen) o; + return THIS.getClassName().hashCode(); + } + }; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + /* + * Corresponds to the fields found in a JavaClass object. + */ + private String className; + private String superClassName; + private final String fileName; + private int classNameIndex = -1; + private int superclassNameIndex = -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 fieldList = new ArrayList<>(); + private final List methodList = new ArrayList<>(); + + private final List attributeList = new ArrayList<>(); + + private final List interfaceList = new ArrayList<>(); + + private final List annotationList = new ArrayList<>(); + + private List observers; + + /** + * Initialize with existing class. + * + * @param clazz JavaClass object (e.g. read from file) + */ + public ClassGen(final JavaClass clazz) { + super(clazz.getAccessFlags()); + classNameIndex = clazz.getClassNameIndex(); + superclassNameIndex = clazz.getSuperclassNameIndex(); + className = clazz.getClassName(); + superClassName = clazz.getSuperclassName(); + fileName = 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); + Collections.addAll(interfaceList, clazz.getInterfaceNames()); + for (final Attribute attribute : attributes) { + if (!(attribute instanceof Annotations)) { + addAttribute(attribute); + } + } + Collections.addAll(annotationList, annotations); + Collections.addAll(methodList, clazz.getMethods()); + Collections.addAll(fieldList, clazz.getFields()); + } + + /** + * Convenience constructor to set up some important values initially. + * + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name + * @param accessFlags access qualifiers + * @param interfaces implemented interfaces + */ + public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces) { + this(className, superClassName, fileName, accessFlags, interfaces, new ConstantPoolGen()); + } + + /** + * Convenience constructor to set up some important values initially. + * + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name + * @param accessFlags access qualifiers + * @param interfaces implemented interfaces + * @param cp constant pool to use + */ + public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces, + final ConstantPoolGen cp) { + super(accessFlags); + this.className = className; + this.superClassName = superClassName; + this.fileName = fileName; + this.cp = cp; + // Put everything needed by default into the constant pool and the vectors + if (fileName != null) { + addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(fileName), cp.getConstantPool())); + } + classNameIndex = cp.addClass(className); + superclassNameIndex = cp.addClass(superClassName); + if (interfaces != null) { + Collections.addAll(interfaceList, interfaces); + } + } + + public void addAnnotationEntry(final AnnotationEntryGen a) { + annotationList.add(a); + } + + /** + * Add an attribute to this class. + * + * @param a attribute to add + */ + public void addAttribute(final Attribute a) { + attributeList.add(a); + } + + /** + * Convenience method. + * + * Add an empty constructor to this class that does nothing but calling super(). + * + * @param accessFlags rights for constructor + */ + public void addEmptyConstructor(final int accessFlags) { + final InstructionList il = new InstructionList(); + il.append(InstructionConst.THIS); // Push 'this' + il.append(new INVOKESPECIAL(cp.addMethodref(superClassName, Const.CONSTRUCTOR_NAME, "()V"))); + il.append(InstructionConst.RETURN); + final MethodGen mg = new MethodGen(accessFlags, Type.VOID, Type.NO_ARGS, null, Const.CONSTRUCTOR_NAME, className, 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) { + fieldList.add(f); + } + + /** + * 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) { + interfaceList.add(name); + } + + /** + * Add a method to this class. + * + * @param m method to add + */ + public void addMethod(final Method m) { + methodList.add(m); + } + + /** + * Add observer for this object. + */ + public void addObserver(final ClassObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + public boolean containsField(final Field f) { + return fieldList.contains(f); + } + + /** + * @return field object with given name, or null + */ + public Field containsField(final String name) { + for (final Field f : fieldList) { + 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 : methodList) { + if (m.getName().equals(name) && m.getSignature().equals(signature)) { + return m; + } + } + return null; + } + + /** + * 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 Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + // J5TODO: Should we make calling unpackAnnotations() lazy and put it in here? + public AnnotationEntryGen[] getAnnotationEntries() { + return annotationList.toArray(AnnotationEntryGen.EMPTY_ARRAY); + } + + public Attribute[] getAttributes() { + return attributeList.toArray(Attribute.EMPTY_ARRAY); + } + + public String getClassName() { + return className; + } + + public int getClassNameIndex() { + return classNameIndex; + } + + public ConstantPoolGen getConstantPool() { + return cp; + } + + public Field[] getFields() { + return fieldList.toArray(Field.EMPTY_ARRAY); + } + + public String getFileName() { + return fileName; + } + + public String[] getInterfaceNames() { + return interfaceList.toArray(Const.EMPTY_STRING_ARRAY); + } + + public int[] getInterfaces() { + final int size = interfaceList.size(); + final int[] interfaces = new int[size]; + Arrays.setAll(interfaces, i -> cp.addClass(interfaceList.get(i))); + return interfaces; + } + + /** + * @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 (annotationList.isEmpty()) { + attributes = getAttributes(); + } else { + // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' + final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); + attributes = new Attribute[attributeList.size() + annAttributes.length]; + attributeList.toArray(attributes); + System.arraycopy(annAttributes, 0, attributes, attributeList.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(classNameIndex, superclassNameIndex, fileName, major, minor, super.getAccessFlags(), cp, interfaces, fields, methods, + attributes); + } + + /** + * @return major version number of class file + */ + public int getMajor() { + return major; + } + + public Method getMethodAt(final int pos) { + return methodList.get(pos); + } + + public Method[] getMethods() { + return methodList.toArray(Method.EMPTY_ARRAY); + } + + /** + * @return minor version number of class file + */ + public int getMinor() { + return minor; + } + + public String getSuperclassName() { + return superClassName; + } + + public int getSuperclassNameIndex() { + return superclassNameIndex; + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the class name. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * Remove an attribute from this class. + * + * @param a attribute to remove + */ + public void removeAttribute(final Attribute a) { + attributeList.remove(a); + } + + /** + * Remove a field to this class. + * + * @param f field to remove + */ + public void removeField(final Field f) { + fieldList.remove(f); + } + + /** + * Remove an interface from this class. + * + * @param name interface to remove (fully qualified name) + */ + public void removeInterface(final String name) { + interfaceList.remove(name); + } + + /** + * Remove a method from this class. + * + * @param m method to remove + */ + public void removeMethod(final Method m) { + methodList.remove(m); + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final ClassObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + /** + * 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 newField) { + if (newField == null) { + throw new ClassGenException("Replacement method must not be null"); + } + final int i = fieldList.indexOf(old); + if (i < 0) { + fieldList.add(newField); + } else { + fieldList.set(i, newField); + } + } + + /** + * Replace given method with new one. If the old one does not exist add the newMethod method to the class anyway. + */ + public void replaceMethod(final Method old, final Method newMethod) { + if (newMethod == null) { + throw new ClassGenException("Replacement method must not be null"); + } + final int i = methodList.indexOf(old); + if (i < 0) { + methodList.add(newMethod); + } else { + methodList.set(i, newMethod); + } + } + + public void setClassName(final String name) { + className = Utility.pathToPackage(name); + classNameIndex = cp.addClass(name); + } + + public void setClassNameIndex(final int classNameIndex) { + this.classNameIndex = classNameIndex; + this.className = Utility.pathToPackage(cp.getConstantPool().getConstantString(classNameIndex, Const.CONSTANT_Class)); + } + + public void setConstantPool(final ConstantPoolGen constantPool) { + cp = constantPool; + } + + /** + * 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; + } + + public void setMethodAt(final Method method, final int pos) { + methodList.set(pos, method); + } + + public void setMethods(final Method[] methods) { + methodList.clear(); + Collections.addAll(methodList, methods); + } + + /** + * 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; + } + + public void setSuperclassName(final String name) { + superClassName = Utility.pathToPackage(name); + superclassNameIndex = cp.addClass(name); + } + + public void setSuperclassNameIndex(final int superclassNameIndex) { + this.superclassNameIndex = superclassNameIndex; + superClassName = Utility.pathToPackage(cp.getConstantPool().getConstantString(superclassNameIndex, Const.CONSTANT_Class)); + } + + /** + * 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; + rva.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false))); + } else if (attr instanceof RuntimeInvisibleAnnotations) { + final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr; + ria.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false))); + } + } + return annotationGenObjs.toArray(AnnotationEntryGen.EMPTY_ARRAY); + } + + /** + * 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 they have finished editing the object. + */ + public void update() { + if (observers != null) { + for (final ClassObserver observer : observers) { + observer.notify(this); + } + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGenException.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGenException.java new file mode 100644 index 000000000..8dfbde810 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGenException.java @@ -0,0 +1,41 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Thrown on internal exceptions. + */ +public class ClassGenException extends RuntimeException { + + private static final long serialVersionUID = 7247369755051242791L; + + public ClassGenException() { + } + + public ClassGenException(final String s) { + super(s); + } + + public ClassGenException(final String s, final Throwable initCause) { + super(s, initCause); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassObserver.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassObserver.java new file mode 100644 index 000000000..64f2c44c4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Implement this interface if you're interested in changes to a ClassGen object and register yourself with + * addObserver(). + */ +public interface ClassObserver { + + void notify(ClassGen clazz); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java new file mode 100644 index 000000000..fa660954d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java @@ -0,0 +1,180 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.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. + * + * @see MethodGen + * @see CodeException + * @see InstructionHandle + */ +public final class CodeExceptionGen implements InstructionTargeter, Cloneable { + + static final CodeExceptionGen[] EMPTY_ARRAY = {}; + + private InstructionHandle startPc; + private InstructionHandle endPc; + private InstructionHandle handlerPc; + private ObjectType catchType; + + /** + * Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling + * is done. + * + * @param startPc Start of handled region (inclusive) + * @param endPc End of handled region (inclusive) + * @param handlerPc Where handling is done + * @param catchType which exception is handled, null for ANY + */ + public CodeExceptionGen(final InstructionHandle startPc, final InstructionHandle endPc, final InstructionHandle handlerPc, final ObjectType catchType) { + setStartPC(startPc); + setEndPC(endPc); + setHandlerPC(handlerPc); + this.catchType = catchType; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return true, if ih is target of this handler + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + return startPc == ih || endPc == ih || handlerPc == ih; + } + + /** Gets the type of the Exception to catch, 'null' for ANY. */ + public ObjectType getCatchType() { + return catchType; + } + + /** + * Get CodeException object.
    + * + * This relies on that the instruction list has already been dumped to byte code 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(startPc.getPosition(), endPc.getPosition() + endPc.getInstruction().getLength(), handlerPc.getPosition(), + catchType == null ? 0 : cp.addClass(catchType)); + } + + /** + * @return end of handled region (inclusive) + */ + public InstructionHandle getEndPC() { + return endPc; + } + + /** + * @return start of handler + */ + public InstructionHandle getHandlerPC() { + return handlerPc; + } + + /** + * @return start of handled region (inclusive) + */ + public InstructionHandle getStartPC() { + return startPc; + } + + /** Sets the type of the Exception to catch. Set 'null' for ANY. */ + public void setCatchType(final ObjectType catchType) { + this.catchType = catchType; + } + + /* + * Set end of handler + * + * @param endPc End of handled region (inclusive) + */ + public void setEndPC(final InstructionHandle endPc) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.endPc, endPc, this); + this.endPc = endPc; + } + + /* + * Set handler code + * + * @param handlerPc Start of handler + */ + public void setHandlerPC(final InstructionHandle handlerPc) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.handlerPc, handlerPc, this); + this.handlerPc = handlerPc; + } + + /* + * Set start of handler + * + * @param startPc Start of handled region (inclusive) + */ + public void setStartPC(final InstructionHandle startPc) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.startPc, startPc, this); + this.startPc = startPc; + } + + @Override + public String toString() { + return "CodeExceptionGen(" + startPc + ", " + endPc + ", " + handlerPc + ")"; + } + + /** + * @param oldIh old target, either start or end + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + boolean targeted = false; + if (startPc == oldIh) { + targeted = true; + setStartPC(newIh); + } + if (endPc == oldIh) { + targeted = true; + setEndPC(newIh); + } + if (handlerPc == oldIh) { + targeted = true; + setHandlerPC(newIh); + } + if (!targeted) { + throw new ClassGenException("Not targeting " + oldIh + ", but {" + startPc + ", " + endPc + ", " + handlerPc + "}"); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java new file mode 100644 index 000000000..40fc722d0 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java @@ -0,0 +1,38 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 arbitrary argument and produces the appropriate 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 possibility for the user to write 'templates' or 'macros' for such reusable code patterns. + * + * @see PUSH + * @see SWITCH + */ +public interface CompoundInstruction { + + InstructionList getInstructionList(); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java new file mode 100644 index 000000000..b07fef8f9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java @@ -0,0 +1,788 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantClass; +import com.sun.org.apache.bcel.internal.classfile.ConstantDouble; +import com.sun.org.apache.bcel.internal.classfile.ConstantDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref; +import com.sun.org.apache.bcel.internal.classfile.ConstantFloat; +import com.sun.org.apache.bcel.internal.classfile.ConstantInteger; +import com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInvokeDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantLong; +import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantString; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * 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. + * + * @see Constant + * @LastModified: Feb 2023 + */ +public class ConstantPoolGen { + + private static final int DEFAULT_BUFFER_SIZE = 256; + + 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 + + /** + * @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 final Map stringTable = new HashMap<>(); + + private final Map classTable = new HashMap<>(); + + private final Map utf8Table = new HashMap<>(); + + private final Map natTable = new HashMap<>(); + + private final Map cpTable = new HashMap<>(); + + /** + * Constructs a new empty constant pool. + */ + public ConstantPoolGen() { + size = DEFAULT_BUFFER_SIZE; + constants = new Constant[size]; + } + + /** + * Constructs a new instance with the given array of constants. + * + * @param cs array of given constants, new ones will be appended + */ + public ConstantPoolGen(final Constant[] cs) { + /* + * To be logically/programmatically correct, the size of the constant pool + * shall not exceed the size limit as the code below does a copy and then + * walk through the whole array. + * This is however, not used by XSLT (or the java.xml implementation), + * and only happens when BCELifier is called (see BCELifier). + */ + if (cs.length > Const.MAX_CP_ENTRIES) { + throw new IllegalStateException("The number of constants " + cs.length + + " is over the size limit of the constant pool: " + + Const.MAX_CP_ENTRIES); + } + + final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); + + size = Math.min(Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64), Const.MAX_CP_ENTRIES); + 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 (!stringTable.containsKey(key)) { + stringTable.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantClass) { + final ConstantClass s = (ConstantClass) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + final String key = u8.getBytes(); + if (!classTable.containsKey(key)) { + classTable.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantNameAndType) { + final ConstantNameAndType n = (ConstantNameAndType) c; + final ConstantUtf8 u8NameIdx = (ConstantUtf8) constants[n.getNameIndex()]; + final ConstantUtf8 u8SigIdx = (ConstantUtf8) constants[n.getSignatureIndex()]; + + sb.append(u8NameIdx.getBytes()); + sb.append(NAT_DELIM); + sb.append(u8SigIdx.getBytes()); + final String key = sb.toString(); + sb.delete(0, sb.length()); + + if (!natTable.containsKey(key)) { + natTable.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantUtf8) { + final ConstantUtf8 u = (ConstantUtf8) c; + final String key = u.getBytes(); + if (!utf8Table.containsKey(key)) { + utf8Table.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantCP) { + final ConstantCP m = (ConstantCP) c; + String className; + ConstantUtf8 u8; + + if (c instanceof ConstantInvokeDynamic) { + className = Integer.toString(((ConstantInvokeDynamic) m).getBootstrapMethodAttrIndex()); + } else if (c instanceof ConstantDynamic) { + className = Integer.toString(((ConstantDynamic) m).getBootstrapMethodAttrIndex()); + } else { + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; + className = Utility.pathToPackage(u8.getBytes()); + } + + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final String methodName = u8.getBytes(); + u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final String signature = u8.getBytes(); + + // Since name cannot begin with digit, we can use METHODREF_DELIM without fear of duplicates + String delim = METHODREF_DELIM; + if (c instanceof ConstantInterfaceMethodref) { + delim = IMETHODREF_DELIM; + } else if (c instanceof ConstantFieldref) { + delim = FIELDREF_DELIM; + } + + sb.append(className); + sb.append(delim); + sb.append(methodName); + sb.append(delim); + sb.append(signature); + final String key = sb.toString(); + sb.delete(0, sb.length()); + + if (!cpTable.containsKey(key)) { + cpTable.put(key, Integer.valueOf(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 com.sun.org.apache.bcel.internal.classfile.ConstantMethodType) { +// // TODO should this be handled somehow? +// } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantMethodHandle) { +// // TODO should this be handled somehow? +// } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantModule) { +// // TODO should this be handled somehow? +// } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantPackage) { +// // TODO should this be handled somehow? +// } else { +// // Not helpful, should throw an exception. +// assert false : "Unexpected constant type: " + c.getClass().getName(); +// } + } + } + + /** + * Constructs a new instance with the given constant pool. + * + * @param cp the constant pool. + */ + public ConstantPoolGen(final ConstantPool cp) { + this(cp.getConstantPool()); + } + + /** + * 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()); + } + + /** + * 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 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_(Utility.packageToPath(str)); + } + + private int addClass_(final String clazz) { + final int cpRet; + if ((cpRet = lookupClass(clazz)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final ConstantClass c = new ConstantClass(addUtf8(clazz)); + final int ret = index; + constants[index++] = c; + return computeIfAbsent(classTable, clazz, ret); + } + + /** + * Adds a constant from another ConstantPool and returns the new index. + * + * @param constant The constant to add. + * @param cpGen Source pool. + * @return index of entry + */ + public int addConstant(final Constant constant, final ConstantPoolGen cpGen) { + final Constant[] constants = cpGen.getConstantPool().getConstantPool(); + switch (constant.getTag()) { + case Const.CONSTANT_String: { + final ConstantString s = (ConstantString) constant; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; + return addString(u8.getBytes()); + } + case Const.CONSTANT_Class: { + final ConstantClass s = (ConstantClass) constant; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + return addClass(u8.getBytes()); + } + case Const.CONSTANT_NameAndType: { + final ConstantNameAndType n = (ConstantNameAndType) constant; + 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) constant).getBytes()); + case Const.CONSTANT_Double: + return addDouble(((ConstantDouble) constant).getBytes()); + case Const.CONSTANT_Float: + return addFloat(((ConstantFloat) constant).getBytes()); + case Const.CONSTANT_Long: + return addLong(((ConstantLong) constant).getBytes()); + case Const.CONSTANT_Integer: + return addInteger(((ConstantInteger) constant).getBytes()); + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Methodref: + case Const.CONSTANT_Fieldref: { + final ConstantCP m = (ConstantCP) constant; + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; + final String className = Utility.pathToPackage(u8.getBytes()); + u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final String name = u8.getBytes(); + u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final String signature = u8.getBytes(); + switch (constant.getTag()) { + case Const.CONSTANT_InterfaceMethodref: + return addInterfaceMethodref(className, name, signature); + case Const.CONSTANT_Methodref: + return addMethodref(className, name, signature); + case Const.CONSTANT_Fieldref: + return addFieldref(className, name, signature); + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + constant); + } + } + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + constant); + } + } + + /** + * 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; + } + + /** + * Add a new Fieldref constant to the ConstantPool, if it is not already in there. + * + * @param className class name string to add + * @param fieldName field name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addFieldref(final String className, final String fieldName, final String signature) { + final int cpRet; + if ((cpRet = lookupFieldref(className, fieldName, signature)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final int classIndex = addClass(className); + final int nameAndTypeIndex = addNameAndType(fieldName, signature); + final int ret = index; + constants[index++] = new ConstantFieldref(classIndex, nameAndTypeIndex); + return computeIfAbsent(cpTable, className + FIELDREF_DELIM + fieldName + FIELDREF_DELIM + signature, ret); + } + + /** + * 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; + } + + /** + * 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; + } + + public int addInterfaceMethodref(final MethodGen method) { + return addInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already in there. + * + * @param className class name string to add + * @param methodName method name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addInterfaceMethodref(final String className, final String methodName, final String signature) { + final int cpRet; + if ((cpRet = lookupInterfaceMethodref(className, methodName, signature)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final int classIndex = addClass(className); + final int nameAndTypeIndex = addNameAndType(methodName, signature); + final int ret = index; + constants[index++] = new ConstantInterfaceMethodref(classIndex, nameAndTypeIndex); + return computeIfAbsent(cpTable, className + IMETHODREF_DELIM + methodName + IMETHODREF_DELIM + signature, ret); + } + + /** + * 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; + } + public int addMethodref(final MethodGen method) { + return addMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Add a new Methodref constant to the ConstantPool, if it is not already in there. + * + * @param className class name string to add + * @param methodName method name string to add + * @param signature method signature string to add + * @return index of entry + */ + public int addMethodref(final String className, final String methodName, final String signature) { + final int cpRet; + if ((cpRet = lookupMethodref(className, methodName, signature)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final int nameAndTypeIndex = addNameAndType(methodName, signature); + final int classIndex = addClass(className); + final int ret = index; + constants[index++] = new ConstantMethodref(classIndex, nameAndTypeIndex); + return computeIfAbsent(cpTable, className + METHODREF_DELIM + methodName + METHODREF_DELIM + signature, ret); + } + + /** + * 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; + if ((ret = lookupNameAndType(name, signature)) != -1) { + return ret; // Already in CP + } + adjustSize(); + final int nameIndex = addUtf8(name); + final int signatureIndex = addUtf8(signature); + ret = index; + constants[index++] = new ConstantNameAndType(nameIndex, signatureIndex); + return computeIfAbsent(natTable, name + NAT_DELIM + signature, ret); + } + + /** + * 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; + return computeIfAbsent(stringTable, str, ret); + } + + /** + * 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); + return computeIfAbsent(utf8Table, n, ret); + } + + /** + * Resize internal array of constants. + */ + protected void adjustSize() { + // 3 extra spaces are needed as some entries may take 3 slots + if (index + 3 >= Const.MAX_CP_ENTRIES) { + throw new IllegalStateException("The number of constants " + (index + 3) + + " is over the size limit of the constant pool: " + + Const.MAX_CP_ENTRIES); + } + + if (index + 3 >= size) { + final Constant[] cs = constants; + size *= 2; + // the constant array shall not exceed the size of the constant pool + size = Math.min(size, Const.MAX_CP_ENTRIES); + constants = new Constant[size]; + System.arraycopy(cs, 0, constants, 0, index); + } + } + + private int computeIfAbsent(final Map map, final String key, final int value) { + return map.computeIfAbsent(key, k -> Integer.valueOf(value)); + } + + /** + * @param i index in constant pool + * @return constant pool entry at index i + */ + public Constant getConstant(final int i) { + return constants[i]; + } + + /** + * @return intermediate constant pool + */ + public ConstantPool getConstantPool() { + return new ConstantPool(constants); + } + + /** + * @return constant pool with proper length + */ + public ConstantPool getFinalConstantPool() { + return new ConstantPool(Arrays.copyOf(constants, index)); + } + + private int getIndex(final Map map, final String key) { + return toIndex(map.get(key)); + } + + /** + * @return current size of constant pool + */ + public int getSize() { + return index; + } + + /** + * 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) { + return getIndex(classTable, Utility.packageToPath(str)); + } + + /** + * 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; + } + + /** + * Look for ConstantFieldref in ConstantPool. + * + * @param className Where to find method + * @param fieldName Guess what + * @param signature return and argument types + * @return index on success, -1 otherwise + */ + public int lookupFieldref(final String className, final String fieldName, final String signature) { + return getIndex(cpTable, className + FIELDREF_DELIM + fieldName + FIELDREF_DELIM + signature); + } + + /** + * 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; + } + + /** + * 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; + } + + public int lookupInterfaceMethodref(final MethodGen method) { + return lookupInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Look for ConstantInterfaceMethodref in ConstantPool. + * + * @param className Where to find method + * @param methodName Guess what + * @param signature return and argument types + * @return index on success, -1 otherwise + */ + public int lookupInterfaceMethodref(final String className, final String methodName, final String signature) { + return getIndex(cpTable, className + IMETHODREF_DELIM + methodName + IMETHODREF_DELIM + signature); + } + + /** + * 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; + } + + public int lookupMethodref(final MethodGen method) { + return lookupMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Look for ConstantMethodref in ConstantPool. + * + * @param className Where to find method + * @param methodName Guess what + * @param signature return and argument types + * @return index on success, -1 otherwise + */ + public int lookupMethodref(final String className, final String methodName, final String signature) { + return getIndex(cpTable, className + METHODREF_DELIM + methodName + METHODREF_DELIM + signature); + } + + /** + * 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) { + return getIndex(natTable, name + NAT_DELIM + signature); + } + + /** + * 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) { + return getIndex(stringTable, str); + } + + /** + * Look for ConstantUtf8 in ConstantPool. + * + * @param n Utf8 string to look for + * @return index on success, -1 otherwise + */ + public int lookupUtf8(final String n) { + return getIndex(utf8Table, n); + } + + /** + * 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; + } + + private int toIndex(final Integer index) { + return index != null ? index.intValue() : -1; + } + + /** + * @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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java new file mode 100644 index 000000000..69114bf46 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java @@ -0,0 +1,34 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes a push instruction that produces a literal on the stack such as SIPUSH, BIPUSH, ICONST, etc. + * + * + * @see ICONST + * @see SIPUSH + */ +public interface ConstantPushInstruction extends PushInstruction, TypedInstruction { + + Number getValue(); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java new file mode 100644 index 000000000..7937bbe46 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java @@ -0,0 +1,77 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Super class for the x2y family of instructions. + */ +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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2F.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2F.java new file mode 100644 index 000000000..45ee7158c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2F.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * D2F - Convert double to float + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result
    + * 
    + */ +public class D2F extends ConversionInstruction { + + /** + * Convert double to float + */ + public D2F() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2I.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2I.java new file mode 100644 index 000000000..343076d71 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2I.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * D2I - Convert double to int + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result
    + * 
    + */ +public class D2I extends ConversionInstruction { + + /** + * Convert double to int + */ + public D2I() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2L.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2L.java new file mode 100644 index 000000000..0a8b09c1d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2L.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * D2L - Convert double to long + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
    + * 
    + */ +public class D2L extends ConversionInstruction { + + /** + * Convert double to long + */ + public D2L() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DADD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DADD.java new file mode 100644 index 000000000..55c6e05fe --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DADD.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DADD - Add doubles + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result1.word2 + */ +public class DADD extends ArithmeticInstruction { + + /** + * Add doubles + */ + public DADD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DALOAD.java new file mode 100644 index 000000000..e875b3517 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DALOAD - Load double from array + * + *
    + * Stack: ..., arrayref, index -> ..., result.word1, result.word2
    + * 
    + */ +public class DALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load double from array + */ + public DALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DASTORE.java new file mode 100644 index 000000000..63a855900 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DASTORE - Store into double array + * + *
    + * Stack: ..., arrayref, index, value.word1, value.word2 -> ...
    + * 
    + */ +public class DASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store double into array + */ + public DASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPG.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPG.java new file mode 100644 index 000000000..aa1353ef5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPG.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DCMPG - Compare doubles: value1 > value2 + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result
    + * 
    + */ +public class DCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public DCMPG() { + super(com.sun.org.apache.bcel.internal.Const.DCMPG, (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.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPG(this); + } + + /** + * @return Type.DOUBLE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.DOUBLE; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPL.java new file mode 100644 index 000000000..b43380bdb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPL.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DCMPL - Compare doubles: value1 < value2 + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result
    + * 
    + */ +public class DCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public DCMPL() { + super(com.sun.org.apache.bcel.internal.Const.DCMPL, (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.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPL(this); + } + + /** + * @return Type.DOUBLE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.DOUBLE; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCONST.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCONST.java new file mode 100644 index 000000000..313277185 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCONST.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DCONST - Push 0.0 or 1.0, other values cause an exception + * + *
    + * Stack: ... -> ...,
    + * 
    + * @LastModified: Jan 2020 + */ +public class DCONST extends Instruction implements ConstantPushInstruction { + + private final double value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + DCONST() { + this(0); + } + + public DCONST(final double f) { + super(com.sun.org.apache.bcel.internal.Const.DCONST_0, (short) 1); + if (f == 0.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.DCONST_0); + } else if (f == 1.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.DCONST_1); + } else { + throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f); + } + value = f; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * @return Type.DOUBLE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.DOUBLE; + } + + @Override + public Number getValue() { + return Double.valueOf(value); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DDIV.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DDIV.java new file mode 100644 index 000000000..29c008e7c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DDIV.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DDIV - Divide doubles + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class DDIV extends ArithmeticInstruction { + + /** + * Divide doubles + */ + public DDIV() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DLOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DLOAD.java new file mode 100644 index 000000000..9b61fd669 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DLOAD.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DLOAD - Load double from local variable + * + *
    + * Stack ... -> ..., result.word1, result.word2
    + * 
    + */ +public class DLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + DLOAD() { + super(com.sun.org.apache.bcel.internal.Const.DLOAD, com.sun.org.apache.bcel.internal.Const.DLOAD_0); + } + + /** + * Load double from local variable + * + * @param n index of local variable + */ + public DLOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.DLOAD, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DMUL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DMUL.java new file mode 100644 index 000000000..6dc65ffa0 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DMUL.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DMUL - Multiply doubles + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class DMUL extends ArithmeticInstruction { + + /** + * Multiply doubles + */ + public DMUL() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DNEG.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DNEG.java new file mode 100644 index 000000000..8999f6fba --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DNEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DNEG - Negate double + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
    + * 
    + */ +public class DNEG extends ArithmeticInstruction { + + public DNEG() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DREM.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DREM.java new file mode 100644 index 000000000..b478f6ca9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DREM.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DREM - Remainder of doubles + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class DREM extends ArithmeticInstruction { + + /** + * Remainder of doubles + */ + public DREM() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DRETURN.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DRETURN.java new file mode 100644 index 000000000..749d92246 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DRETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DRETURN - Return double from method + * + *
    + * Stack: ..., value.word1, value.word2 -> <empty>
    + * 
    + */ +public class DRETURN extends ReturnInstruction { + + /** + * Return double from method + */ + public DRETURN() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSTORE.java new file mode 100644 index 000000000..bd4e130c7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSTORE.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DSTORE - Store double into local variable + * + *
    + * Stack: ..., value.word1, value.word2 -> ...
    + * 
    + */ +public class DSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + DSTORE() { + super(com.sun.org.apache.bcel.internal.Const.DSTORE, com.sun.org.apache.bcel.internal.Const.DSTORE_0); + } + + /** + * Store double into local variable + * + * @param n index of local variable + */ + public DSTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.DSTORE, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSUB.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSUB.java new file mode 100644 index 000000000..080a325d7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSUB.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DSUB - Substract doubles + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class DSUB extends ArithmeticInstruction { + + /** + * Substract doubles + */ + public DSUB() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP.java new file mode 100644 index 000000000..30cc6821c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP - Duplicate top operand stack word + * + *
    + * Stack: ..., word -> ..., word, word
    + * 
    + */ +public class DUP extends StackInstruction implements PushInstruction { + + public DUP() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2.java new file mode 100644 index 000000000..8b01a0606 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP2 - Duplicate two top operand stack words + * + *
    + * Stack: ..., word2, word1 -> ..., word2, word1, word2, word1
    + * 
    + */ +public class DUP2 extends StackInstruction implements PushInstruction { + + public DUP2() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java new file mode 100644 index 000000000..69043ab87 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP2_X1 - Duplicate two top operand stack words and put three down + * + *
    + * Stack: ..., word3, word2, word1 -> ..., word2, word1, word3, word2, word1
    + * 
    + */ +public class DUP2_X1 extends StackInstruction { + + public DUP2_X1() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java new file mode 100644 index 000000000..e9b807ffc --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP2_X2 - Duplicate two top operand stack words and put four down + * + *
    + * Stack: ..., word4, word3, word2, word1 -> ..., word2, word1, word4, word3, word2, word1
    + * 
    + */ +public class DUP2_X2 extends StackInstruction { + + public DUP2_X2() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X1.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X1.java new file mode 100644 index 000000000..ce2316baa --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X1.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP_X1 - Duplicate top operand stack word and put two down + * + *
    + * Stack: ..., word2, word1 -> ..., word1, word2, word1
    + * 
    + */ +public class DUP_X1 extends StackInstruction { + + public DUP_X1() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X2.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X2.java new file mode 100644 index 000000000..735437e1f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X2.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP_X2 - Duplicate top operand stack word and put three down + * + *
    + * Stack: ..., word3, word2, word1 -> ..., word1, word3, word2, word1
    + * 
    + */ +public class DUP_X2 extends StackInstruction { + + public DUP_X2() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java new file mode 100644 index 000000000..11b6b014a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.AnnotationElementValue; +import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.ArrayElementValue; +import com.sun.org.apache.bcel.internal.classfile.ClassElementValue; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.classfile.EnumElementValue; +import com.sun.org.apache.bcel.internal.classfile.SimpleElementValue; + +/** + * @since 6.0 + * @LastModified: May 2021 + */ +public abstract class ElementValueGen { + 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'; + + /** + * 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 UnsupportedOperationException("Not implemented yet! (" + value.getElementValueType() + ")"); + } + } + + 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 IllegalArgumentException("Unexpected element value kind in annotation: " + type); + } + } + + /** + * @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; + } + + public abstract void dump(DataOutputStream dos) throws IOException; + + protected ConstantPoolGen getConstantPool() { + return cpGen; + } + + /** + * Subtypes return an immutable variant of the ElementValueGen + */ + public abstract ElementValue getElementValue(); + + public int getElementValueType() { + return type; + } + + public abstract String stringifyValue(); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java new file mode 100644 index 000000000..bdc9c517a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java @@ -0,0 +1,101 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.classfile.ElementValuePair; + +/** + * @since 6.0 + */ +public class ElementValuePairGen { + private final int nameIdx; + + private final ElementValueGen value; + + private final ConstantPoolGen constantPoolGen; + + public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + this.constantPoolGen = cpool; + // J5ASSERT: + // Could assert nvp.getNameString() points to the same thing as + // constantPoolGen.getConstant(nvp.getNameIndex()) + // if + // (!nvp.getNameString().equals(((ConstantUtf8)constantPoolGen.getConstant(nvp.getNameIndex())).getBytes())) + // { + // throw new IllegalArgumentException("envp buggered"); + // } + if (copyPoolEntries) { + nameIdx = cpool.addUtf8(nvp.getNameString()); + } else { + nameIdx = nvp.getNameIndex(); + } + value = ElementValueGen.copy(nvp.getValue(), cpool, copyPoolEntries); + } + + protected ElementValuePairGen(final int idx, final ElementValueGen value, final ConstantPoolGen cpool) { + this.nameIdx = idx; + this.value = value; + this.constantPoolGen = cpool; + } + + public ElementValuePairGen(final String name, final ElementValueGen value, final ConstantPoolGen cpool) { + this.nameIdx = cpool.addUtf8(name); + this.value = value; + this.constantPoolGen = cpool; + } + + protected void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(nameIdx); // u2 name of the element + value.dump(dos); + } + + /** + * Retrieve an immutable version of this ElementNameValuePairGen + */ + public ElementValuePair getElementNameValuePair() { + final ElementValue immutableValue = value.getElementValue(); + return new ElementValuePair(nameIdx, immutableValue, constantPoolGen.getConstantPool()); + } + + public int getNameIndex() { + return nameIdx; + } + + public final String getNameString() { + // ConstantString cu8 = (ConstantString)constantPoolGen.getConstant(nameIdx); + return ((ConstantUtf8) constantPoolGen.getConstant(nameIdx)).getBytes(); + } + + public final ElementValueGen getValue() { + return value; + } + + @Override + public String toString() { + return "ElementValuePair:[" + getNameString() + "=" + value.stringifyValue() + "]"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java new file mode 100644 index 000000000..b76944416 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java @@ -0,0 +1,755 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Supplies empty method bodies to be overridden by subclasses. + */ +public abstract class EmptyVisitor implements Visitor { + + @Override + public void visitAALOAD(final AALOAD obj) { + } + + @Override + public void visitAASTORE(final AASTORE obj) { + } + + @Override + public void visitACONST_NULL(final ACONST_NULL obj) { + } + + @Override + public void visitAllocationInstruction(final AllocationInstruction obj) { + } + + @Override + public void visitALOAD(final ALOAD obj) { + } + + @Override + public void visitANEWARRAY(final ANEWARRAY obj) { + } + + @Override + public void visitARETURN(final ARETURN obj) { + } + + @Override + public void visitArithmeticInstruction(final ArithmeticInstruction obj) { + } + + @Override + public void visitArrayInstruction(final ArrayInstruction obj) { + } + + @Override + public void visitARRAYLENGTH(final ARRAYLENGTH obj) { + } + + @Override + public void visitASTORE(final ASTORE obj) { + } + + @Override + public void visitATHROW(final ATHROW obj) { + } + + @Override + public void visitBALOAD(final BALOAD obj) { + } + + @Override + public void visitBASTORE(final BASTORE obj) { + } + + @Override + public void visitBIPUSH(final BIPUSH obj) { + } + + @Override + public void visitBranchInstruction(final BranchInstruction obj) { + } + + @Override + public void visitBREAKPOINT(final BREAKPOINT obj) { + } + + @Override + public void visitCALOAD(final CALOAD obj) { + } + + @Override + public void visitCASTORE(final CASTORE obj) { + } + + @Override + public void visitCHECKCAST(final CHECKCAST obj) { + } + + @Override + public void visitConstantPushInstruction(final ConstantPushInstruction obj) { + } + + @Override + public void visitConversionInstruction(final ConversionInstruction obj) { + } + + @Override + public void visitCPInstruction(final CPInstruction obj) { + } + + @Override + public void visitD2F(final D2F obj) { + } + + @Override + public void visitD2I(final D2I obj) { + } + + @Override + public void visitD2L(final D2L obj) { + } + + @Override + public void visitDADD(final DADD obj) { + } + + @Override + public void visitDALOAD(final DALOAD obj) { + } + + @Override + public void visitDASTORE(final DASTORE obj) { + } + + @Override + public void visitDCMPG(final DCMPG obj) { + } + + @Override + public void visitDCMPL(final DCMPL obj) { + } + + @Override + public void visitDCONST(final DCONST obj) { + } + + @Override + public void visitDDIV(final DDIV obj) { + } + + @Override + public void visitDLOAD(final DLOAD obj) { + } + + @Override + public void visitDMUL(final DMUL obj) { + } + + @Override + public void visitDNEG(final DNEG obj) { + } + + @Override + public void visitDREM(final DREM obj) { + } + + @Override + public void visitDRETURN(final DRETURN obj) { + } + + @Override + public void visitDSTORE(final DSTORE obj) { + } + + @Override + public void visitDSUB(final DSUB obj) { + } + + @Override + public void visitDUP(final DUP obj) { + } + + @Override + public void visitDUP_X1(final DUP_X1 obj) { + } + + @Override + public void visitDUP_X2(final DUP_X2 obj) { + } + + @Override + public void visitDUP2(final DUP2 obj) { + } + + @Override + public void visitDUP2_X1(final DUP2_X1 obj) { + } + + @Override + public void visitDUP2_X2(final DUP2_X2 obj) { + } + + @Override + public void visitExceptionThrower(final ExceptionThrower obj) { + } + + @Override + public void visitF2D(final F2D obj) { + } + + @Override + public void visitF2I(final F2I obj) { + } + + @Override + public void visitF2L(final F2L obj) { + } + + @Override + public void visitFADD(final FADD obj) { + } + + @Override + public void visitFALOAD(final FALOAD obj) { + } + + @Override + public void visitFASTORE(final FASTORE obj) { + } + + @Override + public void visitFCMPG(final FCMPG obj) { + } + + @Override + public void visitFCMPL(final FCMPL obj) { + } + + @Override + public void visitFCONST(final FCONST obj) { + } + + @Override + public void visitFDIV(final FDIV obj) { + } + + @Override + public void visitFieldInstruction(final FieldInstruction obj) { + } + + @Override + public void visitFieldOrMethod(final FieldOrMethod obj) { + } + + @Override + public void visitFLOAD(final FLOAD obj) { + } + + @Override + public void visitFMUL(final FMUL obj) { + } + + @Override + public void visitFNEG(final FNEG obj) { + } + + @Override + public void visitFREM(final FREM obj) { + } + + @Override + public void visitFRETURN(final FRETURN obj) { + } + + @Override + public void visitFSTORE(final FSTORE obj) { + } + + @Override + public void visitFSUB(final FSUB obj) { + } + + @Override + public void visitGETFIELD(final GETFIELD obj) { + } + + @Override + public void visitGETSTATIC(final GETSTATIC obj) { + } + + @Override + public void visitGOTO(final GOTO obj) { + } + + @Override + public void visitGOTO_W(final GOTO_W obj) { + } + + @Override + public void visitGotoInstruction(final GotoInstruction obj) { + } + + @Override + public void visitI2B(final I2B obj) { + } + + @Override + public void visitI2C(final I2C obj) { + } + + @Override + public void visitI2D(final I2D obj) { + } + + @Override + public void visitI2F(final I2F obj) { + } + + @Override + public void visitI2L(final I2L obj) { + } + + @Override + public void visitI2S(final I2S obj) { + } + + @Override + public void visitIADD(final IADD obj) { + } + + @Override + public void visitIALOAD(final IALOAD obj) { + } + + @Override + public void visitIAND(final IAND obj) { + } + + @Override + public void visitIASTORE(final IASTORE obj) { + } + + @Override + public void visitICONST(final ICONST obj) { + } + + @Override + public void visitIDIV(final IDIV obj) { + } + + @Override + public void visitIF_ACMPEQ(final IF_ACMPEQ obj) { + } + + @Override + public void visitIF_ACMPNE(final IF_ACMPNE obj) { + } + + @Override + public void visitIF_ICMPEQ(final IF_ICMPEQ obj) { + } + + @Override + public void visitIF_ICMPGE(final IF_ICMPGE obj) { + } + + @Override + public void visitIF_ICMPGT(final IF_ICMPGT obj) { + } + + @Override + public void visitIF_ICMPLE(final IF_ICMPLE obj) { + } + + @Override + public void visitIF_ICMPLT(final IF_ICMPLT obj) { + } + + @Override + public void visitIF_ICMPNE(final IF_ICMPNE obj) { + } + + @Override + public void visitIFEQ(final IFEQ obj) { + } + + @Override + public void visitIFGE(final IFGE obj) { + } + + @Override + public void visitIFGT(final IFGT obj) { + } + + @Override + public void visitIfInstruction(final IfInstruction obj) { + } + + @Override + public void visitIFLE(final IFLE obj) { + } + + @Override + public void visitIFLT(final IFLT obj) { + } + + @Override + public void visitIFNE(final IFNE obj) { + } + + @Override + public void visitIFNONNULL(final IFNONNULL obj) { + } + + @Override + public void visitIFNULL(final IFNULL obj) { + } + + @Override + public void visitIINC(final IINC obj) { + } + + @Override + public void visitILOAD(final ILOAD obj) { + } + + @Override + public void visitIMPDEP1(final IMPDEP1 obj) { + } + + @Override + public void visitIMPDEP2(final IMPDEP2 obj) { + } + + @Override + public void visitIMUL(final IMUL obj) { + } + + @Override + public void visitINEG(final INEG obj) { + } + + @Override + public void visitINSTANCEOF(final INSTANCEOF obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC obj) { + } + + @Override + public void visitInvokeInstruction(final InvokeInstruction obj) { + } + + @Override + public void visitINVOKEINTERFACE(final INVOKEINTERFACE obj) { + } + + @Override + public void visitINVOKESPECIAL(final INVOKESPECIAL obj) { + } + + @Override + public void visitINVOKESTATIC(final INVOKESTATIC obj) { + } + + @Override + public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL obj) { + } + + @Override + public void visitIOR(final IOR obj) { + } + + @Override + public void visitIREM(final IREM obj) { + } + + @Override + public void visitIRETURN(final IRETURN obj) { + } + + @Override + public void visitISHL(final ISHL obj) { + } + + @Override + public void visitISHR(final ISHR obj) { + } + + @Override + public void visitISTORE(final ISTORE obj) { + } + + @Override + public void visitISUB(final ISUB obj) { + } + + @Override + public void visitIUSHR(final IUSHR obj) { + } + + @Override + public void visitIXOR(final IXOR obj) { + } + + @Override + public void visitJSR(final JSR obj) { + } + + @Override + public void visitJSR_W(final JSR_W obj) { + } + + @Override + public void visitJsrInstruction(final JsrInstruction obj) { + } + + @Override + public void visitL2D(final L2D obj) { + } + + @Override + public void visitL2F(final L2F obj) { + } + + @Override + public void visitL2I(final L2I obj) { + } + + @Override + public void visitLADD(final LADD obj) { + } + + @Override + public void visitLALOAD(final LALOAD obj) { + } + + @Override + public void visitLAND(final LAND obj) { + } + + @Override + public void visitLASTORE(final LASTORE obj) { + } + + @Override + public void visitLCMP(final LCMP obj) { + } + + @Override + public void visitLCONST(final LCONST obj) { + } + + @Override + public void visitLDC(final LDC obj) { + } + + @Override + public void visitLDC2_W(final LDC2_W obj) { + } + + @Override + public void visitLDIV(final LDIV obj) { + } + + @Override + public void visitLLOAD(final LLOAD obj) { + } + + @Override + public void visitLMUL(final LMUL obj) { + } + + @Override + public void visitLNEG(final LNEG obj) { + } + + @Override + public void visitLoadClass(final LoadClass obj) { + } + + @Override + public void visitLoadInstruction(final LoadInstruction obj) { + } + + @Override + public void visitLocalVariableInstruction(final LocalVariableInstruction obj) { + } + + @Override + public void visitLOOKUPSWITCH(final LOOKUPSWITCH obj) { + } + + @Override + public void visitLOR(final LOR obj) { + } + + @Override + public void visitLREM(final LREM obj) { + } + + @Override + public void visitLRETURN(final LRETURN obj) { + } + + @Override + public void visitLSHL(final LSHL obj) { + } + + @Override + public void visitLSHR(final LSHR obj) { + } + + @Override + public void visitLSTORE(final LSTORE obj) { + } + + @Override + public void visitLSUB(final LSUB obj) { + } + + @Override + public void visitLUSHR(final LUSHR obj) { + } + + @Override + public void visitLXOR(final LXOR obj) { + } + + @Override + public void visitMONITORENTER(final MONITORENTER obj) { + } + + @Override + public void visitMONITOREXIT(final MONITOREXIT obj) { + } + + @Override + public void visitMULTIANEWARRAY(final MULTIANEWARRAY obj) { + } + + @Override + public void visitNEW(final NEW obj) { + } + + @Override + public void visitNEWARRAY(final NEWARRAY obj) { + } + + @Override + public void visitNOP(final NOP obj) { + } + + @Override + public void visitPOP(final POP obj) { + } + + @Override + public void visitPOP2(final POP2 obj) { + } + + @Override + public void visitPopInstruction(final PopInstruction obj) { + } + + @Override + public void visitPushInstruction(final PushInstruction obj) { + } + + @Override + public void visitPUTFIELD(final PUTFIELD obj) { + } + + @Override + public void visitPUTSTATIC(final PUTSTATIC obj) { + } + + @Override + public void visitRET(final RET obj) { + } + + @Override + public void visitRETURN(final RETURN obj) { + } + + @Override + public void visitReturnInstruction(final ReturnInstruction obj) { + } + + @Override + public void visitSALOAD(final SALOAD obj) { + } + + @Override + public void visitSASTORE(final SASTORE obj) { + } + + @Override + public void visitSelect(final Select obj) { + } + + @Override + public void visitSIPUSH(final SIPUSH obj) { + } + + @Override + public void visitStackConsumer(final StackConsumer obj) { + } + + @Override + public void visitStackInstruction(final StackInstruction obj) { + } + + @Override + public void visitStackProducer(final StackProducer obj) { + } + + @Override + public void visitStoreInstruction(final StoreInstruction obj) { + } + + @Override + public void visitSWAP(final SWAP obj) { + } + + @Override + public void visitTABLESWITCH(final TABLESWITCH obj) { + } + + @Override + public void visitTypedInstruction(final TypedInstruction obj) { + } + + @Override + public void visitUnconditionalBranch(final UnconditionalBranch obj) { + } + + @Override + public void visitVariableLengthInstruction(final VariableLengthInstruction obj) { + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java new file mode 100644 index 000000000..95ac794f2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.classfile.EnumElementValue; + +/** + * @since 6.0 + */ +public class EnumElementValueGen extends ElementValueGen { + // For enum types, these two indices point to the type and value + private final int typeIdx; + + private final int valueIdx; + + 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(); + } + } + + /** + * 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 IllegalArgumentException("Only element values of type enum can be built with this ctor - type specified: " + super.getElementValueType()); + } + this.typeIdx = typeIdx; + this.valueIdx = valueIdx; + } + + 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); + } + + @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 + } + + /** + * 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()); + } + + // 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 getTypeIndex() { + return typeIdx; + } + + public int getValueIndex() { + return valueIdx; + } + + @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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java new file mode 100644 index 000000000..86a0cad25 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java @@ -0,0 +1,38 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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. + */ +public interface ExceptionThrower { + + Class[] getExceptions(); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2D.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2D.java new file mode 100644 index 000000000..3697ae379 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2D.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * F2D - Convert float to double + * + *
    + * Stack: ..., value -> ..., result.word1, result.word2
    + * 
    + */ +public class F2D extends ConversionInstruction { + + /** + * Convert float to double + */ + public F2D() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2I.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2I.java new file mode 100644 index 000000000..552ab176a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2I.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * F2I - Convert float to int + * + *
    + * Stack: ..., value -> ..., result
    + * 
    + */ +public class F2I extends ConversionInstruction { + + /** + * Convert float to int + */ + public F2I() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2L.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2L.java new file mode 100644 index 000000000..73b4edf7a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2L.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * F2L - Convert float to long + * + *
    + * Stack: ..., value -> ..., result.word1, result.word2
    + * 
    + */ +public class F2L extends ConversionInstruction { + + /** + * Convert float to long + */ + public F2L() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FADD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FADD.java new file mode 100644 index 000000000..a1e4e466b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FADD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FADD - Add floats + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class FADD extends ArithmeticInstruction { + + /** + * Add floats + */ + public FADD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FALOAD.java new file mode 100644 index 000000000..7d00b4c57 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FALOAD - Load float from array + * + *
    + * Stack: ..., arrayref, index -> ..., value
    + * 
    + */ +public class FALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load float from array + */ + public FALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FASTORE.java new file mode 100644 index 000000000..0215fd74b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FASTORE - Store into float array + * + *
    + * Stack: ..., arrayref, index, value -> ...
    + * 
    + */ +public class FASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store float into array + */ + public FASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPG.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPG.java new file mode 100644 index 000000000..bbeb1e2ed --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPG.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FCMPG - Compare floats: value1 > value2 + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class FCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public FCMPG() { + super(com.sun.org.apache.bcel.internal.Const.FCMPG, (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.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPG(this); + } + + /** + * @return Type.FLOAT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.FLOAT; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPL.java new file mode 100644 index 000000000..0b7cec093 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPL.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FCMPL - Compare floats: value1 < value2 + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class FCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public FCMPL() { + super(com.sun.org.apache.bcel.internal.Const.FCMPL, (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.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPL(this); + } + + /** + * @return Type.FLOAT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.FLOAT; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCONST.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCONST.java new file mode 100644 index 000000000..7c8116e8c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCONST.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception + * + *
    + * Stack: ... -> ...,
    + * 
    + * @LastModified: Jan 2020 + */ +public class FCONST extends Instruction implements ConstantPushInstruction { + + private final float value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FCONST() { + this(0); + } + + public FCONST(final float f) { + super(com.sun.org.apache.bcel.internal.Const.FCONST_0, (short) 1); + if (f == 0.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_0); + } else if (f == 1.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_1); + } else if (f == 2.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_2); + } else { + throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); + } + value = f; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * @return Type.FLOAT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.FLOAT; + } + + @Override + public Number getValue() { + return Float.valueOf(value); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FDIV.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FDIV.java new file mode 100644 index 000000000..010c9d996 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FDIV.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FDIV - Divide floats + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class FDIV extends ArithmeticInstruction { + + /** + * Divide floats + */ + public FDIV() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FLOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FLOAD.java new file mode 100644 index 000000000..e8abc13d6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FLOAD.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FLOAD - Load float from local variable + * + *
    + * Stack ... -> ..., result
    + * 
    + */ +public class FLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FLOAD() { + super(com.sun.org.apache.bcel.internal.Const.FLOAD, com.sun.org.apache.bcel.internal.Const.FLOAD_0); + } + + /** + * Load float from local variable + * + * @param n index of local variable + */ + public FLOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.FLOAD, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FMUL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FMUL.java new file mode 100644 index 000000000..a1d671477 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FMUL.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FMUL - Multiply floats + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class FMUL extends ArithmeticInstruction { + + /** + * Multiply floats + */ + public FMUL() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FNEG.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FNEG.java new file mode 100644 index 000000000..eb134d994 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FNEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FNEG - Negate float + * + *
    + * Stack: ..., value -> ..., result
    + * 
    + */ +public class FNEG extends ArithmeticInstruction { + + public FNEG() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FREM.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FREM.java new file mode 100644 index 000000000..39e0740cf --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FREM.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FREM - Remainder of floats + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class FREM extends ArithmeticInstruction { + + /** + * Remainder of floats + */ + public FREM() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FRETURN.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FRETURN.java new file mode 100644 index 000000000..3f7ba0c9a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FRETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FRETURN - Return float from method + * + *
    + * Stack: ..., value -> <empty>
    + * 
    + */ +public class FRETURN extends ReturnInstruction { + + /** + * Return float from method + */ + public FRETURN() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSTORE.java new file mode 100644 index 000000000..868f9211f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSTORE.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FSTORE - Store float into local variable + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class FSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FSTORE() { + super(com.sun.org.apache.bcel.internal.Const.FSTORE, com.sun.org.apache.bcel.internal.Const.FSTORE_0); + } + + /** + * Store float into local variable + * + * @param n index of local variable + */ + public FSTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.FSTORE, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSUB.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSUB.java new file mode 100644 index 000000000..9f2a3607a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSUB.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FSUB - Substract floats + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class FSUB extends ArithmeticInstruction { + + /** + * Substract floats + */ + public FSUB() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGen.java new file mode 100644 index 000000000..9d1f4d41d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGen.java @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Annotations; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantObject; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantValue; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.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). + * + * @see Field + * @LastModified: May 2021 + */ +public class FieldGen extends FieldGenOrMethodGen { + + 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 Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final FieldGen THIS = (FieldGen) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + private Object value; + + private List observers; + + /** + * 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; + runtimeAnnotations.forEach(element -> addAnnotationEntry(new AnnotationEntryGen(element, cp, false))); + } else { + addAttribute(attr); + } + } + } + + /** + * 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 accessFlags access qualifiers + * @param type field type + * @param name field name + * @param cp constant pool + */ + public FieldGen(final int accessFlags, final Type type, final String name, final ConstantPoolGen cp) { + super(accessFlags); + setType(type); + setName(name); + setConstantPool(cp); + } + + private void addAnnotationsAsAttribute(final ConstantPoolGen cp) { + Stream.of(AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries())).forEach(this::addAttribute); + } + + 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 IllegalStateException("Unhandled : " + super.getType().getType()); // sic + } + } + + /** + * Add observer for this object. + */ + public void addObserver(final FieldObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + /** + * 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); + } + } + + /** + * @return deep copy of this field + */ + public FieldGen copy(final ConstantPoolGen cp) { + final FieldGen fg = (FieldGen) clone(); + fg.setConstantPool(cp); + return fg; + } + + /** + * 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 Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * Get field object after having set up all necessary values. + */ + public Field getField() { + final String signature = getSignature(); + final int nameIndex = super.getConstantPool().addUtf8(super.getName()); + final int signatureIndex = 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(), nameIndex, signatureIndex, getAttributes(), super.getConstantPool().getConstantPool()); // sic + } + + public String getInitValue() { + if (value != null) { + return value.toString(); + } + return null; + } + + @Override + public String getSignature() { + return super.getType().getSignature(); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the field's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final FieldObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + public void setInitValue(final boolean b) { + checkType(Type.BOOLEAN); + if (b) { + value = Integer.valueOf(1); + } + } + + public void setInitValue(final byte b) { + checkType(Type.BYTE); + if (b != 0) { + value = Integer.valueOf(b); + } + } + + public void setInitValue(final char c) { + checkType(Type.CHAR); + if (c != 0) { + value = Integer.valueOf(c); + } + } + + public void setInitValue(final double d) { + checkType(Type.DOUBLE); + if (d != 0.0) { + value = Double.valueOf(d); + } + } + + public void setInitValue(final float f) { + checkType(Type.FLOAT); + if (f != 0.0) { + value = Float.valueOf(f); + } + } + + public void setInitValue(final int i) { + checkType(Type.INT); + if (i != 0) { + value = Integer.valueOf(i); + } + } + + public void setInitValue(final long l) { + checkType(Type.LONG); + if (l != 0L) { + value = Long.valueOf(l); + } + } + + public void setInitValue(final short s) { + checkType(Type.SHORT); + if (s != 0) { + value = Integer.valueOf(s); + } + } + + /** + * 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; + } + } + + private void setValue(final int index) { + final ConstantPool cp = super.getConstantPool().getConstantPool(); + final Constant c = cp.getConstant(index); + value = ((ConstantObject) c).getConstantValue(cp); + } + + /** + * 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(); + } + + /** + * 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 they have finished editing the object. + */ + public void update() { + if (observers != null) { + for (final FieldObserver observer : observers) { + observer.notify(this); + } + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java new file mode 100644 index 000000000..6555392e9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.AccessFlags; +import com.sun.org.apache.bcel.internal.classfile.Attribute; + +/** + * Super class for FieldGen and MethodGen objects, since they have some methods in common! + * + * @LastModified: May 2021 + */ +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 attributeList = new ArrayList<>(); + + // @since 6.0 + private final List annotationList = new ArrayList<>(); + + protected FieldGenOrMethodGen() { + } + + /** + * @since 6.0 + */ + protected FieldGenOrMethodGen(final int accessFlags) { // TODO could this be package protected? + super(accessFlags); + } + + protected void addAll(final Attribute[] attrs) { + Collections.addAll(attributeList, attrs); + } + + /** + * @since 6.0 + */ + public void addAnnotationEntry(final AnnotationEntryGen ag) { + annotationList.add(ag); + } + + /** + * 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) { + attributeList.add(a); + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + public AnnotationEntryGen[] getAnnotationEntries() { + return annotationList.toArray(AnnotationEntryGen.EMPTY_ARRAY); + } + + /** + * @return all attributes of this method. + */ + public Attribute[] getAttributes() { + return attributeList.toArray(Attribute.EMPTY_ARRAY); + } + + public ConstantPoolGen getConstantPool() { + return cp; + } + + /** + * @return name of method/field. + */ + @Override + public String getName() { + return name; + } + + /** + * @return signature of method/field. + */ + public abstract String getSignature(); + + @Override + public Type getType() { + return type; + } + + /** + * @since 6.0 + */ + public void removeAnnotationEntries() { + annotationList.clear(); + } + + /** + * @since 6.0 + */ + public void removeAnnotationEntry(final AnnotationEntryGen ag) { + annotationList.remove(ag); + } + + /** + * Remove an attribute. + */ + public void removeAttribute(final Attribute a) { + attributeList.remove(a); + } + + /** + * Remove all attributes. + */ + public void removeAttributes() { + attributeList.clear(); + } + + public void setConstantPool(final ConstantPoolGen cp) { // TODO could be package-protected? + this.cp = cp; + } + + @Override + public void setName(final String name) { // TODO could be package-protected? + this.name = name; + } + + @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; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java new file mode 100644 index 000000000..368d07ec9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; + +/** + * Super class for the GET/PUTxxx family of instructions. + */ +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 name of referenced field. + */ + public String getFieldName(final ConstantPoolGen cpg) { + return getName(cpg); + } + + /** + * @return size of field (1 or 2) + */ + protected int getFieldSize(final ConstantPoolGen cpg) { + return Type.size(Type.getTypeSize(getSignature(cpg))); + } + + /** + * @return type of field + */ + public Type getFieldType(final ConstantPoolGen cpg) { + return Type.getType(getSignature(cpg)); + } + + /** + * @return return type of referenced field + */ + @Override + public Type getType(final ConstantPoolGen cpg) { + return getFieldType(cpg); + } + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString(final ConstantPool cp) { + return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + cp.constantToString(super.getIndex(), com.sun.org.apache.bcel.internal.Const.CONSTANT_Fieldref); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldObserver.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldObserver.java new file mode 100644 index 000000000..a207a0985 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Imnplement this interface if you're interested in changes to a FieldGen object and register yourself with + * addObserver(). + */ +public interface FieldObserver { + + void notify(FieldGen field); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java new file mode 100644 index 000000000..1c646f482 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java @@ -0,0 +1,132 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Super class for InvokeInstruction and FieldInstruction, since they have some methods in common! + */ +public abstract class FieldOrMethod extends CPInstruction implements LoadClass { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FieldOrMethod() { + // no init + } + + /** + * @param index to constant pool + */ + protected FieldOrMethod(final short opcode, final int index) { + super(opcode, index); + } + + /** + * @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 Utility.pathToPackage(className); + } + + /** + * @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)); + } + + /** + * Gets 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.getClass().getCanonicalName() + " " + rt.getSignature() + " does not represent an ObjectType"); + } + + /** + * @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(); + } + + /** + * Gets 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 = Utility.pathToPackage(className); + return ObjectType.getInstance(className); + } + + /** + * @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(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETFIELD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETFIELD.java new file mode 100644 index 000000000..bc4e5b116 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETFIELD.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * GETFIELD - Fetch field from object + * + *
    + * Stack: ..., objectref -> ..., value
    + * 
    + * + * OR + * + *
    + * Stack: ..., objectref -> ..., value.word1, value.word2
    + * 
    + */ +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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + @Override + public int produceStack(final ConstantPoolGen cpg) { + return getFieldSize(cpg); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java new file mode 100644 index 000000000..b8c4a4a35 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * GETSTATIC - Fetch static field from class + * + *
    + * Stack: ..., -> ..., value
    + * 
    + * + * OR + * + *
    + * Stack: ..., -> ..., value.word1, value.word2
    + * 
    + */ +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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + @Override + public int produceStack(final ConstantPoolGen cpg) { + return getFieldSize(cpg); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO.java new file mode 100644 index 000000000..cd76aae79 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO.java @@ -0,0 +1,95 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * GOTO - Branch always (to relative offset, not absolute address) + */ +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(com.sun.org.apache.bcel.internal.Const.GOTO, 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.visitVariableLengthInstruction(this); + v.visitUnconditionalBranch(this); + v.visitBranchInstruction(this); + v.visitGotoInstruction(this); + v.visitGOTO(this); + } + + /** + * 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 == com.sun.org.apache.bcel.internal.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 maxOffset 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 maxOffset) { + 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 - maxOffset) { // to large for short (estimate) + super.setOpcode(com.sun.org.apache.bcel.internal.Const.GOTO_W); + final short oldLength = (short) super.getLength(); + super.setLength(5); + return super.getLength() - oldLength; + } + return 0; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO_W.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO_W.java new file mode 100644 index 000000000..df4c06be0 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO_W.java @@ -0,0 +1,79 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * GOTO_W - Branch always (to relative offset, not absolute address) + */ +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(com.sun.org.apache.bcel.internal.Const.GOTO_W, target); + 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); + } + + /** + * 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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java new file mode 100644 index 000000000..b261ca584 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java @@ -0,0 +1,38 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for GOTO + */ +public abstract class GotoInstruction extends BranchInstruction implements UnconditionalBranch { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + GotoInstruction() { + } + + GotoInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2B.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2B.java new file mode 100644 index 000000000..0b8c9dd52 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2B.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2B - Convert int to byte + * + *
    + * Stack: ..., value -> ..., result
    + * 
    + */ +public class I2B extends ConversionInstruction { + + /** + * Convert int to byte + */ + public I2B() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2C.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2C.java new file mode 100644 index 000000000..b5c6532a5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2C.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2C - Convert int to char + * + *
    + * Stack: ..., value -> ..., result
    + * 
    + */ +public class I2C extends ConversionInstruction { + + /** + * Convert int to char + */ + public I2C() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2D.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2D.java new file mode 100644 index 000000000..e73270a58 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2D.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2D - Convert int to double + * + *
    + * Stack: ..., value -> ..., result.word1, result.word2
    + * 
    + */ +public class I2D extends ConversionInstruction { + + /** + * Convert int to double + */ + public I2D() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2F.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2F.java new file mode 100644 index 000000000..dc7df8c6d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2F.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2F - Convert int to float + * + *
    + * Stack: ..., value -> ..., result
    + * 
    + */ +public class I2F extends ConversionInstruction { + + /** + * Convert int to float + */ + public I2F() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2L.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2L.java new file mode 100644 index 000000000..e0a8e81e1 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2L.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2L - Convert int to long + * + *
    + * Stack: ..., value -> ..., result.word1, result.word2
    + * 
    + */ +public class I2L extends ConversionInstruction { + + /** + * Convert int to long + */ + public I2L() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2S.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2S.java new file mode 100644 index 000000000..04fa0e62a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2S.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2S - Convert int to short + * + *
    + * Stack: ..., value -> ..., result
    + * 
    + */ +public class I2S extends ConversionInstruction { + + public I2S() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IADD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IADD.java new file mode 100644 index 000000000..ad5e109af --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IADD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IADD - Add ints + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class IADD extends ArithmeticInstruction { + + /** + * Add ints + */ + public IADD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IALOAD.java new file mode 100644 index 000000000..b9f39c13d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IALOAD - Load int from array + * + *
    + * Stack: ..., arrayref, index -> ..., value
    + * 
    + */ +public class IALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load int from array + */ + public IALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IAND.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IAND.java new file mode 100644 index 000000000..4fe036cc5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IAND.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IAND - Bitwise AND int + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class IAND extends ArithmeticInstruction { + + public IAND() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IASTORE.java new file mode 100644 index 000000000..62cded23f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IASTORE - Store into int array + * + *
    + * Stack: ..., arrayref, index, value -> ...
    + * 
    + */ +public class IASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store into int array + */ + public IASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ICONST.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ICONST.java new file mode 100644 index 000000000..5effd7edc --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ICONST.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * ICONST - Push value between -1, ..., 5, other values cause an exception + * + *
    + * Stack: ... -> ...,
    + * 
    + * + */ +public class ICONST extends Instruction implements ConstantPushInstruction { + + private final int value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ICONST() { + this(0); + } + + public ICONST(final int i) { + super(com.sun.org.apache.bcel.internal.Const.ICONST_0, (short) 1); + if (i < -1 || i > 5) { + throw new ClassGenException("ICONST can be used only for value between -1 and 5: " + i); + } + super.setOpcode((short) (com.sun.org.apache.bcel.internal.Const.ICONST_0 + i)); // Even works for i == -1 + value = i; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * @return Type.INT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.INT; + } + + @Override + public Number getValue() { + return Integer.valueOf(value); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IDIV.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IDIV.java new file mode 100644 index 000000000..e23968c9a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IDIV.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * IDIV - Divide ints + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + * @LastModified: Jan 2020 + */ +public class IDIV extends ArithmeticInstruction implements ExceptionThrower { + + /** + * Divide ints + */ + public IDIV() { + super(com.sun.org.apache.bcel.internal.Const.IDIV); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFEQ.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFEQ.java new file mode 100644 index 000000000..c44d0f57d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFEQ.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFEQ - Branch if int comparison with zero succeeds + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class IFEQ extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFEQ() { + } + + public IFEQ(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFEQ(this); + } + + /** + * @return negation of instruction, e.g. IFEQ.negate() == IFNE + */ + @Override + public IfInstruction negate() { + return new IFNE(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGE.java new file mode 100644 index 000000000..53e32a57b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFGE - Branch if int comparison with zero succeeds + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class IFGE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFGE() { + } + + public IFGE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFGE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFLT(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGT.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGT.java new file mode 100644 index 000000000..23ab44754 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFGT - Branch if int comparison with zero succeeds + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class IFGT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFGT() { + } + + public IFGT(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFGT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFLE(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLE.java new file mode 100644 index 000000000..0bd68bd1b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFLE - Branch if int comparison with zero succeeds + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class IFLE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFLE() { + } + + public IFLE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFLE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFGT(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLT.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLT.java new file mode 100644 index 000000000..0c1589e95 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFLT - Branch if int comparison with zero succeeds + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class IFLT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFLT() { + } + + public IFLT(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFLT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFGE(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNE.java new file mode 100644 index 000000000..91075bc66 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFNE - Branch if int comparison with zero succeeds + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class IFNE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFNE() { + } + + public IFNE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFEQ(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java new file mode 100644 index 000000000..342779a9b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFNONNULL - Branch if reference is not null + * + *
    + * Stack: ..., reference -> ...
    + * 
    + */ +public class IFNONNULL extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFNONNULL() { + } + + public IFNONNULL(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNONNULL(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFNULL(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNULL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNULL.java new file mode 100644 index 000000000..b68003309 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNULL.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFNULL - Branch if reference is not null + * + *
    + * Stack: ..., reference -> ...
    + * 
    + */ +public class IFNULL extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFNULL() { + } + + public IFNULL(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNULL(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFNONNULL(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java new file mode 100644 index 000000000..9f14fb589 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ACMPEQ - Branch if reference comparison succeeds + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ACMPEQ(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ACMPNE(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java new file mode 100644 index 000000000..536abe40d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ACMPNE - Branch if reference comparison doesn't succeed + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ACMPNE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ACMPEQ(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java new file mode 100644 index 000000000..a3fa883df --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPEQ - Branch if int comparison succeeds + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPEQ(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPNE(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java new file mode 100644 index 000000000..8848da01b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPGE - Branch if int comparison succeeds + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPGE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPLT(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java new file mode 100644 index 000000000..b1145cc94 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPGT - Branch if int comparison succeeds + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPGT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPLE(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java new file mode 100644 index 000000000..54eed6174 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPLE - Branch if int comparison succeeds + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPLE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPGT(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java new file mode 100644 index 000000000..7c159f4b5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPLT - Branch if int comparison succeeds + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPLT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPGE(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java new file mode 100644 index 000000000..1c1f9800a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPNE - Branch if int comparison doesn't succeed + * + *
    + * Stack: ..., value1, value2 -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPNE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPEQ(super.getTarget()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IINC.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IINC.java new file mode 100644 index 000000000..aeaa2d8cd --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IINC.java @@ -0,0 +1,163 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * IINC - Increment local variable by constant + */ +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) { + // Default behavior of LocalVariableInstruction causes error + super.setOpcode(Const.IINC); + super.setLength((short) 3); + setIndex(n); // May set wide as side effect + setIncrement(c); + } + + /** + * Calls corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * Dumps 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 (wide) { + out.writeShort(super.getIndex()); + out.writeShort(c); + } else { + out.writeByte(super.getIndex()); + out.writeByte(c); + } + } + + /** + * @return increment factor + */ + public final int getIncrement() { + return c; + } + + /** + * @return int type + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.INT; + } + + /** + * Reads 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(); + } + } + + /** + * Sets increment factor. + */ + public final void setIncrement(final int c) { + this.c = c; + setWide(); + } + + /** + * Sets 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(); + } + + private void setWide() { + wide = super.getIndex() > 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); + } + } + + /** + * Returns mnemonic for instruction. + * + * @return mnemonic for instruction. + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + c; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ILOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ILOAD.java new file mode 100644 index 000000000..1ecc3aae4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ILOAD.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ILOAD - Load int from local variable onto stack + * + *
    + * Stack: ... -> ..., result
    + * 
    + */ +public class ILOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ILOAD() { + super(com.sun.org.apache.bcel.internal.Const.ILOAD, com.sun.org.apache.bcel.internal.Const.ILOAD_0); + } + + /** + * Load int from local variable + * + * @param n index of local variable + */ + public ILOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ILOAD, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java new file mode 100644 index 000000000..62fc89299 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java @@ -0,0 +1,43 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IMPDEP1 - Implementation dependent + */ +public class IMPDEP1 extends Instruction { + + public IMPDEP1() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java new file mode 100644 index 000000000..cef4e08c7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java @@ -0,0 +1,43 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IMPDEP2 - Implementation dependent + */ +public class IMPDEP2 extends Instruction { + + public IMPDEP2() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMUL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMUL.java new file mode 100644 index 000000000..9f7ff3dbf --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMUL.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IMUL - Multiply ints + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class IMUL extends ArithmeticInstruction { + + /** + * Multiply ints + */ + public IMUL() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INEG.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INEG.java new file mode 100644 index 000000000..d881260b6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * INEG - Negate int + * + *
    + * Stack: ..., value -> ..., result
    + * 
    + */ +public class INEG extends ArithmeticInstruction { + + public INEG() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java new file mode 100644 index 000000000..10d5f2c0f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java @@ -0,0 +1,75 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INSTANCEOF - Determine if object is of given type + * + *
    + * Stack: ..., objectref -> ..., result
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.INSTANCEOF, 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 + */ + @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); + } + + @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; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java new file mode 100644 index 000000000..2865a158d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.classfile.ConstantInvokeDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.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. + * + * @see The + * invokedynamic instruction in The Java Virtual Machine Specification + * @since 6.0 + * @LastModified: Feb 2023 + */ +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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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); + } + + /** + * Override the parent method because our class name is held elsewhere. + * + * Note: Contrary to this method's name it does not return the class name of the invoke target; rather it returns the + * name of the method that will be used to invoke the Lambda method generated by this invoke dynamic instruction. + */ + @Override + @Deprecated + public String getClassName( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantInvokeDynamic cid = cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic, ConstantInvokeDynamic.class); + return cp.getConstant(cid.getNameAndTypeIndex(), ConstantNameAndType.class).getName(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); + } + + /** + * 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()); + } + + /** + * 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 + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java new file mode 100644 index 000000000..7f1858c57 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java @@ -0,0 +1,129 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * INVOKEINTERFACE - Invoke interface method + * + *
    + * Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
    + * 
    + * + * @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; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + @Override + public int consumeStack(final ConstantPoolGen cpg) { // nargs is given in byte-code + return nargs; // nargs includes this reference + } + + /** + * 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; + } + + @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); + } + + /** + * 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; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java new file mode 100644 index 000000000..4fdff3942 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java @@ -0,0 +1,88 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INVOKESPECIAL - Invoke instance method; special handling for superclass, private and instance initialization method + * invocations + * + *
    + * Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
    + * 
    + * + * @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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java new file mode 100644 index 000000000..c9c7dcdab --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java @@ -0,0 +1,87 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INVOKESTATIC - Invoke a class (static) method + * + *
    + * Stack: ..., [arg1, [arg2 ...]] -> ...
    + * 
    + * + * @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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java new file mode 100644 index 000000000..09961236e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java @@ -0,0 +1,87 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INVOKEVIRTUAL - Invoke instance method; dispatch based on class + * + *
    + * Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
    + * 
    + * + * @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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IOR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IOR.java new file mode 100644 index 000000000..9f9ee094e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IOR - Bitwise OR int + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class IOR extends ArithmeticInstruction { + + public IOR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IREM.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IREM.java new file mode 100644 index 000000000..34b11f42d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IREM.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * IREM - Remainder of int + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + * @LastModified: Jan 2020 + */ +public class IREM extends ArithmeticInstruction implements ExceptionThrower { + + /** + * Remainder of ints + */ + public IREM() { + super(com.sun.org.apache.bcel.internal.Const.IREM); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IRETURN.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IRETURN.java new file mode 100644 index 000000000..80c3bfba7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IRETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IRETURN - Return int from method + * + *
    + * Stack: ..., value -> <empty>
    + * 
    + */ +public class IRETURN extends ReturnInstruction { + + /** + * Return int from method + */ + public IRETURN() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHL.java new file mode 100644 index 000000000..2e762db89 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHL.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISHL - Arithmetic shift left int + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class ISHL extends ArithmeticInstruction { + + public ISHL() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHR.java new file mode 100644 index 000000000..c5e390617 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISHR - Arithmetic shift right int + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class ISHR extends ArithmeticInstruction { + + public ISHR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISTORE.java new file mode 100644 index 000000000..76d8f930f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISTORE.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISTORE - Store int from stack into local variable + * + *
    + * Stack: ..., value -> ...
    + * 
    + */ +public class ISTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ISTORE() { + super(com.sun.org.apache.bcel.internal.Const.ISTORE, com.sun.org.apache.bcel.internal.Const.ISTORE_0); + } + + /** + * Store int into local variable + * + * @param n index of local variable + */ + public ISTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ISTORE, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISUB.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISUB.java new file mode 100644 index 000000000..571751ce3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISUB.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISUB - Substract ints + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + */ +public class ISUB extends ArithmeticInstruction { + + /** + * Substract ints + */ + public ISUB() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IUSHR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IUSHR.java new file mode 100644 index 000000000..89236a0af --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IUSHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IUSHR - Logical shift right int + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class IUSHR extends ArithmeticInstruction { + + public IUSHR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IXOR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IXOR.java new file mode 100644 index 000000000..1006f3d38 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IXOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IXOR - Bitwise XOR int + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class IXOR extends ArithmeticInstruction { + + public IXOR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IfInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IfInstruction.java new file mode 100644 index 000000000..b4be83ebd --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IfInstruction.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for the IFxxx family of instructions. + */ +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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java new file mode 100644 index 000000000..f98462976 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java @@ -0,0 +1,32 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote entity that refers to an index, e.g. local variable instructions, RET, CPInstruction, etc. + */ +public interface IndexedInstruction { + + int getIndex(); + + void setIndex(int index); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Instruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Instruction.java new file mode 100644 index 000000000..16c8e2444 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Instruction.java @@ -0,0 +1,601 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Abstract super class for all Java byte codes. + * + * @LastModified: Feb 2023 + */ +public abstract class Instruction implements Cloneable { + + static final Instruction[] EMPTY_ARRAY = {}; + + private static InstructionComparator cmp = InstructionComparator.DEFAULT; + + /** + * Gets 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; + } + + /** + * Tests 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; + } + + /** + * Tests 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; + } + + /** + * Reads an instruction from (byte code) input stream and return the appropriate 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 + * @throws IOException Thrown when an I/O exception of some sort has occurred. + * @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 RET)) { + throw new ClassGenException("Illegal opcode after wide: " + opcode); + } + obj.setOpcode(opcode); + obj.initFromFile(bytes, wide); // Do further initializations, if any + return obj; + } + + /** + * Sets 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; + } + + /** + * @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 + + /** + * 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; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then 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); + + /** + * 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); + } + + /** + * 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; + } + + /** + * Some instructions may be reused, so don't do anything by default. + */ + void dispose() { + } + + /** + * Dumps instruction as byte code to stream out. + * + * @param out Output stream + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(opcode); // Common for all instructions + } + + /** + * Tests 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); + } + + /** + * @return length (in bytes) of instruction + */ + public int getLength() { + return length; + } + + /** + * @return name of instruction, i.e., opcode name + */ + public String getName() { + return Const.getOpcodeName(opcode); + } + + /** + * @return this instructions opcode + */ + public short getOpcode() { + return opcode; + } + + /** + * Gets the hashCode of this object. + * + * @return the hashCode + * @since 6.0 + */ + @Override + public int hashCode() { + return opcode; + } + + /** + * Reads 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 + */ + @SuppressWarnings("unused") // thrown by subclasses + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + } + + /** + * 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); + } + + /** + * Needed in readInstruction and subclasses in this package + * + * @since 6.0 + */ + final void setLength(final int length) { + this.length = (short) length; // TODO check range? + } + + /** + * Needed in readInstruction and subclasses in this package + */ + void setOpcode(final short opcode) { + this.opcode = opcode; + } + + /** + * @return mnemonic for instruction in verbose format + */ + @Override + public String toString() { + return toString(true); + } + + /** + * 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 with sumbolic references resolved + */ + public String toString(final ConstantPool cp) { + return toString(false); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java new file mode 100644 index 000000000..9f806a2d3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 + */ +public interface InstructionComparator { + + InstructionComparator DEFAULT = (i1, 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 + } + if (i1 instanceof ConstantPushInstruction) { + return ((ConstantPushInstruction) i1).getValue().equals(((ConstantPushInstruction) i2).getValue()); + } + if (i1 instanceof IndexedInstruction) { + return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2).getIndex(); + } + if (i1 instanceof NEWARRAY) { + return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2).getTypecode(); + } + return true; + } + return false; + }; + + boolean equals(Instruction i1, Instruction i2); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionConst.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionConst.java new file mode 100644 index 000000000..439268e35 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionConst.java @@ -0,0 +1,299 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * 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); + *

    + */ +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. + */ + 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; + } + + /** + * 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]; + } + + private InstructionConst() { + } // non-instantiable +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java new file mode 100644 index 000000000..5e9220354 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java @@ -0,0 +1,739 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.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. + *

    + * + * @see Const + * @see InstructionConst + * @LastModified: Feb 2023 + */ +public class InstructionFactory { + + private static class MethodObject { + + final Type[] argTypes; + final Type resultType; + final String className; + final String name; + + MethodObject(final String c, final String n, final Type r, final Type[] a) { + this.className = c; + this.name = n; + this.resultType = r; + this.argTypes = a; + } + } + + private static final String APPEND = "append"; + + private static final String FQCN_STRING_BUFFER = "java.lang.StringBuffer"; + + // N.N. These must agree with the order of Constants.T_CHAR through T_LONG + private static final String[] shortNames = {"C", "F", "D", "B", "S", "I", "L"}; + + private static final MethodObject[] appendMethodObjects = { + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.STRING }), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.OBJECT }), null, null, // indices 2, 3 + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.BOOLEAN }), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.CHAR }), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.FLOAT }), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.DOUBLE }), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.INT }), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.INT }), // No append(byte) + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.INT }), // No append(short) + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.LONG })}; + + /** + * @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 IllegalArgumentException("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 IllegalArgumentException("Invalid type " + type); + } + } + + 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 IllegalArgumentException("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 IllegalArgumentException("Invalid operand " + op); + } + } + + 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 IllegalArgumentException("Invalid operand " + op); + } + } + + /** + * 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 argTypes argument types of method + * @see Const + */ + + /* + * createInvokeDynamic only needed if instrumentation code wants to generate a new invokedynamic instruction. I don't + * think we need. + * + * public InvokeInstruction createInvokeDynamic( int bootstrap_index, String name, Type ret_type, Type[] argTypes) { + * int index; int nargs = 0; String signature = Type.getMethodSignature(ret_type, argTypes); for (int i = 0; i < + * argTypes.length; i++) { nargs += argTypes[i].getSize(); } // UNDONE - needs to be added to ConstantPoolGen //index + * = cp.addInvokeDynamic(bootstrap_index, name, signature); index = 0; return new INVOKEDYNAMIC(index); } + */ + + 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 IllegalArgumentException("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 IllegalArgumentException("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 IllegalArgumentException("Invalid opcode: " + opcode); + } + } + + /** + * @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_1(final int size) { + return size == 2 ? InstructionConst.DUP2_X1 : InstructionConst.DUP_X1; + } + + /** + * @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 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 IllegalArgumentException("Invalid type " + type); + } + } + + /** + * 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 IllegalArgumentException("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; + } + + /** + * 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 IllegalArgumentException("Invalid type: " + type); + } + } + + /** + * @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 IllegalArgumentException("Invalid type " + type); + } + } + + /** + * Create reference to 'this' + */ + public static Instruction createThis() { + return new ALOAD(0); + } + + private static boolean isString(final Type type) { + return type instanceof ObjectType && ((ObjectType) type).getClassName().equals("java.lang.String"); + } + + /** + * @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; + + /** + * Initialize with ClassGen object + */ + public InstructionFactory(final ClassGen cg) { + this(cg, cg.getConstantPool()); + } + + public InstructionFactory(final ClassGen cg, final ConstantPoolGen cp) { + this.cg = cg; + this.cp = cp; + } + + /** + * Initialize just with ConstantPoolGen object + */ + public InstructionFactory(final ConstantPoolGen cp) { + this(null, cp); + } + + public Instruction createAppend(final Type type) { + final byte t = type.getType(); + if (isString(type)) { + return createInvoke(appendMethodObjects[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(appendMethodObjects[t], Const.INVOKEVIRTUAL); + case Const.T_ARRAY: + case Const.T_OBJECT: + return createInvoke(appendMethodObjects[1], Const.INVOKEVIRTUAL); + default: + throw new IllegalArgumentException("No append for this 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 srcType, final Type destType) { + if (srcType instanceof BasicType && destType instanceof BasicType) { + final byte dest = destType.getType(); + byte src = srcType.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 = "com.sun.org.apache.bcel.internal.generic." + shortNames[src - Const.T_CHAR] + "2" + shortNames[dest - Const.T_CHAR]; + Instruction i = null; + try { + i = (Instruction) Class.forName(name).getDeclaredConstructor().newInstance();; + } catch (final Exception e) { + throw new IllegalArgumentException("Could not find instruction: " + name, e); + } + return i; + } + if (!(srcType instanceof ReferenceType) || !(destType instanceof ReferenceType)) { + throw new IllegalArgumentException("Cannot cast " + srcType + " to " + destType); + } + if (destType instanceof ArrayType) { + return new CHECKCAST(cp.addArrayClass((ArrayType) destType)); + } + return new CHECKCAST(cp.addClass(((ObjectType) destType).getClassName())); + } + + public CHECKCAST createCheckCast(final ReferenceType t) { + if (t instanceof ArrayType) { + return new CHECKCAST(cp.addArrayClass((ArrayType) t)); + } + return new CHECKCAST(cp.addClass((ObjectType) t)); + } + + /** + * 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(); + } + + /** + * Create a field instruction. + * + * @param className 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 className, final String name, final Type type, final short kind) { + int index; + final String signature = type.getSignature(); + index = cp.addFieldref(className, 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 IllegalArgumentException("Unknown getfield kind:" + kind); + } + } + + public GETFIELD createGetField(final String className, final String name, final Type t) { + return new GETFIELD(cp.addFieldref(className, name, t.getSignature())); + } + + public GETSTATIC createGetStatic(final String className, final String name, final Type t) { + return new GETSTATIC(cp.addFieldref(className, name, t.getSignature())); + } + + public INSTANCEOF createInstanceOf(final ReferenceType t) { + if (t instanceof ArrayType) { + return new INSTANCEOF(cp.addArrayClass((ArrayType) t)); + } + return new INSTANCEOF(cp.addClass((ObjectType) t)); + } + + private InvokeInstruction createInvoke(final MethodObject m, final short kind) { + return createInvoke(m.className, m.name, m.resultType, m.argTypes, kind); + } + + /** + * Create an invoke instruction. (Except for invokedynamic.) + * + * @param className name of the called class + * @param name name of the called method + * @param retType return type of method + * @param argTypes argument types of method + * @param kind how to invoke, i.e., INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL + * @see Const + */ + public InvokeInstruction createInvoke(final String className, final String name, final Type retType, final Type[] argTypes, final short kind) { + return createInvoke(className, name, retType, argTypes, kind, kind == Const.INVOKEINTERFACE); + } + + /** + * Create an invoke instruction. (Except for invokedynamic.) + * + * @param className name of the called class + * @param name name of the called method + * @param retType return type of method + * @param argTypes argument types of method + * @param kind how to invoke: INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL + * @param useInterface force use of InterfaceMethodref + * @return A new InvokeInstruction. + * @since 6.5.0 + */ + public InvokeInstruction createInvoke(final String className, final String name, final Type retType, final Type[] argTypes, final short kind, + final boolean useInterface) { + if (kind != Const.INVOKESPECIAL && kind != Const.INVOKEVIRTUAL && kind != Const.INVOKESTATIC && kind != Const.INVOKEINTERFACE + && kind != Const.INVOKEDYNAMIC) { + throw new IllegalArgumentException("Unknown invoke kind: " + kind); + } + int index; + int nargs = 0; + final String signature = Type.getMethodSignature(retType, argTypes); + for (final Type argType : argTypes) { + nargs += argType.getSize(); + } + if (useInterface) { + index = cp.addInterfaceMethodref(className, name, signature); + } else { + index = cp.addMethodref(className, 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: + // Can't happen + throw new IllegalStateException("Unknown invoke kind: " + kind); + } + } + + 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)); + } + if (t instanceof ArrayType) { + return new ANEWARRAY(cp.addArrayClass((ArrayType) t)); + } + 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 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(); + il.append(createGetStatic("java.lang.System", "out", Type.getType("Ljava/io/PrintStream;"))); + il.append(new PUSH(cp, s)); + final MethodObject methodObject = new MethodObject("java.io.PrintStream", "println", Type.VOID, new Type[] { Type.getType("Ljava/lang/String;") }); + il.append(createInvoke(methodObject, Const.INVOKEVIRTUAL)); + return il; + } + + public PUTFIELD createPutField(final String className, final String name, final Type t) { + return new PUTFIELD(cp.addFieldref(className, name, t.getSignature())); + } + + public PUTSTATIC createPutStatic(final String className, final String name, final Type t) { + return new PUTSTATIC(cp.addFieldref(className, name, t.getSignature())); + } + + public ClassGen getClassGen() { + return cg; + } + + public ConstantPoolGen getConstantPool() { + return cp; + } + + public void setClassGen(final ClassGen c) { + cg = c; + } + + public void setConstantPool(final ConstantPoolGen c) { + cp = c; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java new file mode 100644 index 000000000..5e962354d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.sun.org.apache.bcel.internal.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(). + * + * @see Instruction + * @see BranchHandle + * @see InstructionList + * @LastModified: May 2021 + */ +public class InstructionHandle { + + /** + * Empty array. + * + * @since 6.6.0 + */ + public static final InstructionHandle[] EMPTY_ARRAY = {}; + + /** + * Empty array. + */ + static final InstructionTargeter[] EMPTY_INSTRUCTION_TARGETER_ARRAY = {}; + + /** + * Factory method. + */ + static InstructionHandle getInstructionHandle(final Instruction i) { + return new InstructionHandle(i); + } + + 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; + + protected InstructionHandle(final Instruction i) { + setInstruction(i); + } + + /** + * Convenience method, simply calls accept() on the contained instruction. + * + * @param v Visitor object + */ + public void accept(final Visitor v) { + instruction.accept(v); + } + + /** + * 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); + } + + /** + * Does nothing. + * + * @deprecated Does nothing as of 6.3.1. + */ + @Deprecated + protected void addHandle() { + // noop + } + + /** + * 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); + } + + /** + * Delete contents, i.e., remove user access. + */ + void dispose() { + next = prev = null; + instruction.dispose(); + instruction = null; + i_position = -1; + attributes = null; + removeAllTargeters(); + } + + /** + * 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(); + } + + public final Instruction getInstruction() { + return instruction; + } + + public final InstructionHandle getNext() { + return next; + } + + /** + * @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; + } + + public final InstructionHandle getPrev() { + return prev; + } + + /** + * @return null, if there are no targeters + */ + public InstructionTargeter[] getTargeters() { + if (!hasTargeters()) { + return EMPTY_INSTRUCTION_TARGETER_ARRAY; + } + final InstructionTargeter[] t = new InstructionTargeter[targeters.size()]; + targeters.toArray(t); + return t; + } + + public boolean hasTargeters() { + return targeters != null && !targeters.isEmpty(); + } + + /** + * Remove all targeters, if any. + */ + public void removeAllTargeters() { + if (targeters != null) { + targeters.clear(); + } + } + + /** + * 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); + } + } + + /** + * Denote this handle isn't referenced anymore by t. + */ + public void removeTargeter(final InstructionTargeter t) { + if (targeters != null) { + targeters.remove(t); + } + } + + /** + * 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; + } + + /** + * @param next the next to set + * @since 6.0 + */ + final InstructionHandle setNext(final InstructionHandle next) { + this.next = next; + return next; + } + + /** + * Set the position, i.e., the byte code offset of the contained instruction. + */ + void setPosition(final int pos) { + i_position = pos; + } + + /** + * @param prev the prev to set + * @since 6.0 + */ + final InstructionHandle setPrev(final InstructionHandle prev) { + this.prev = prev; + return prev; + } + + /** + * 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; + } + + /** + * @return a string representation of the contained instruction. + */ + @Override + public String toString() { + return toString(true); + } + + /** + * @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); + } + + /** + * 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 maxOffset 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 maxOffset) { + i_position += offset; + return 0; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionList.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionList.java new file mode 100644 index 000000000..7ffc3a822 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionList.java @@ -0,0 +1,1194 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.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. + * + * @see Instruction + * @see InstructionHandle + * @see BranchHandle + * @LastModified: Feb 2023 + */ +public class InstructionList implements Iterable { + + /** + * 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 >>> 1; + final int j = pos[i]; + if (j == target) { + return ihs[i]; + } + if (target < j) { + r = i - 1; + } else { + l = i + 1; + } + } while (l <= r); + return null; + } + + private InstructionHandle start; + private InstructionHandle end; + private int length; // number of elements in list + + private int[] bytePositions; // byte code offsets corresponding to instructions + + private List observers; + + /** + * Create (empty) instruction list. + */ + public InstructionList() { + } + + /** + * Create instruction list containing one instruction. + * + * @param i initial instruction + */ + public InstructionList(final BranchInstruction i) { + append(i); + } + + /** + * 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); + } + bytePositions = Arrays.copyOf(pos, count); // Trim to proper size + /* + * 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 + } + } + } + } + } + + /** + * 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()); + } + + /** + * Create instruction list containing one instruction. + * + * @param i initial instruction + */ + public InstructionList(final Instruction i) { + append(i); + } + + /** + * Add observer for this object. + */ + public void addObserver(final InstructionListObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + /** + * 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 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 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 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 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 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 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 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; + } + + /** + * 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 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 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 + } + + private void clear() { + start = end = null; + length = 0; + } + + public boolean contains(final Instruction i) { + return findInstruction1(i) != 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; + } + + /** + * @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; + } + + /** + * 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 Instruction from, final Instruction to) throws TargetLostException { + InstructionHandle fromIh; + InstructionHandle toIh; + if ((fromIh = findInstruction1(from)) == null) { + throw new ClassGenException("Instruction " + from + " is not contained in this list."); + } + if ((toIh = findInstruction2(to)) == null) { + throw new ClassGenException("Instruction " + to + " is not contained in this list."); + } + delete(fromIh, toIh); + } + + /** + * 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 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()); + } + + /** + * 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(); + } + + /** + * 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 = bytePositions; + InstructionHandle ih = start; + for (int i = 0; i < length; i++) { + if (positions[i] == pos) { + return ih; + } + ih = ih.getNext(); + } + return null; + } + + /** + * 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; + } + + /** + * 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 Const.EMPTY_BYTE_ARRAY; + } + return b.toByteArray(); + } + + /** + * @return end of list + */ + public InstructionHandle getEnd() { + return end; + } + + /** + * @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 bytePositions; + } + + /** + * @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(Instruction.EMPTY_ARRAY); + } + + /** + * @return length of list (Number of instructions, not bytes) + */ + public int getLength() { + return length; + } + + /** + * @return start of list + */ + public InstructionHandle getStart() { + return start; + } + + /** + * 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 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 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 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 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 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 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 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; + } + + /** + * 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 InstructionHandle insert(final InstructionHandle ih, final Instruction i) { + return insert(ih, new InstructionList(i)); + } + + /** + * 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); + } + + /** + * Test for empty list. + */ + public boolean isEmpty() { + return start == null; + } // && end == null + + /** + * @return iterator that lists all instructions (handles) + */ + @Override + public Iterator iterator() { + return new Iterator() { + + private InstructionHandle ih = start; + + @Override + public boolean hasNext() { + return ih != null; + } + + @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(); + } + }; + } + + /** + * 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); + } + + /** + * 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); + } + 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; + } + } + } + + /** + * Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions. + * + * @param oldTarget the old target instruction handle + * @param newTarget the new target instruction handle + */ + public void redirectBranches(final InstructionHandle oldTarget, final InstructionHandle newTarget) { + 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 == oldTarget) { + b.setTarget(newTarget); + } + 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] == oldTarget) { + ((Select) b).setTarget(j, newTarget); + } + } + } + } + } + } + + /** + * Redirect all references of exception handlers from oldTarget to newTarget. + * + * @param exceptions array of exception handlers + * @param oldTarget the old target instruction handle + * @param newTarget the new target instruction handle + * @see MethodGen + */ + public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle oldTarget, final InstructionHandle newTarget) { + for (final CodeExceptionGen exception : exceptions) { + if (exception.getStartPC() == oldTarget) { + exception.setStartPC(newTarget); + } + if (exception.getEndPC() == oldTarget) { + exception.setEndPC(newTarget); + } + if (exception.getHandlerPC() == oldTarget) { + exception.setHandlerPC(newTarget); + } + } + } + + /** + * Redirect all references of local variables from oldTarget to newTarget. + * + * @param lg array of local variables + * @param oldTarget the old target instruction handle + * @param newTarget the new target instruction handle + * @see MethodGen + */ + public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle oldTarget, final InstructionHandle newTarget) { + for (final LocalVariableGen element : lg) { + final InstructionHandle start = element.getStart(); + final InstructionHandle end = element.getEnd(); + if (start == oldTarget) { + element.setStart(newTarget); + } + if (end == oldTarget) { + element.setEnd(newTarget); + } + } + } + + /** + * 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 targetList = 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? + targetList.add(ih); + buf.append(ih.toString(true)).append(" "); + ih.setNext(ih.setPrev(null)); + } else { + ih.dispose(); + } + } + buf.append("}"); + if (!targetList.isEmpty()) { + throw new TargetLostException(targetList.toArray(InstructionHandle.EMPTY_ARRAY), buf.toString()); + } + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final InstructionListObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + /** + * Replace all references to the old constant pool with references to the new constant pool + */ + public void replaceConstantPool(final ConstantPoolGen oldCp, final ConstantPoolGen newCp) { + 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 = oldCp.getConstant(ci.getIndex()); + ci.setIndex(newCp.addConstant(c, oldCp)); + } + } + } + + 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 maxAdditionalBytes = 0; + int additionalBytes = 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: + maxAdditionalBytes += 2; + break; + case Const.TABLESWITCH: + case Const.LOOKUPSWITCH: + maxAdditionalBytes += 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()) { + additionalBytes += ih.updatePosition(additionalBytes, maxAdditionalBytes); + } + /* + * 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(); + } + bytePositions = new int[count]; // Trim to proper size + System.arraycopy(pos, 0, bytePositions, 0, count); + } + + /** + * @return length of list (Number of instructions, not bytes) + */ + public int size() { + return length; + } + + @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(); + } + + /** + * 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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java new file mode 100644 index 000000000..758c455d6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Implement this interface if you're interested in changes to an InstructionList object and register yourself with + * addObserver(). + */ +public interface InstructionListObserver { + + void notify(InstructionList list); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java new file mode 100644 index 000000000..5146408ef --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote that a class targets InstructionHandles within an InstructionList. Namely the following implementers: + * + * @see BranchHandle + * @see LocalVariableGen + * @see CodeExceptionGen + */ +public interface InstructionTargeter { + + // static final InstructionTargeter[] EMPTY_ARRAY = new InstructionTargeter[0]; + + /** + * 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 oldIh the old handle + * @param newIh the new handle + * @throws ClassGenException if oldIh is not targeted by this object + */ + void updateTarget(InstructionHandle oldIh, InstructionHandle newIh) throws ClassGenException; +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java new file mode 100644 index 000000000..0daa3abfc --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.StringTokenizer; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Super class for the INVOKExxx family of instructions. + * + * @LastModified: Feb 2023 + */ +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); + } + + /** + * 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; + } + + /** + * @return argument types of referenced method. + */ + public Type[] getArgumentTypes(final ConstantPoolGen cpg) { + return Type.getArgumentTypes(getSignature(cpg)); + } + + /** + * 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 + @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); + return Utility.pathToPackage(className); + } + + /** + * @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 return type of referenced method. + */ + @Override + public Type getType(final ConstantPoolGen cpg) { + return getReturnType(cpg); + } + + /** + * 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); + } + + /** + * @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)); + + final String opcodeName = Const.getOpcodeName(super.getOpcode()); + + final StringBuilder sb = new StringBuilder(opcodeName); + if (tok.hasMoreTokens()) { + sb.append(" "); + sb.append(Utility.packageToPath(tok.nextToken())); + if (tok.hasMoreTokens()) { + sb.append(tok.nextToken()); + } + } + + return sb.toString(); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR.java new file mode 100644 index 000000000..548b321d0 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR.java @@ -0,0 +1,86 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * JSR - Jump to subroutine + */ +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(com.sun.org.apache.bcel.internal.Const.JSR, 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.visitStackProducer(this); + v.visitVariableLengthInstruction(this); + v.visitBranchInstruction(this); + v.visitJsrInstruction(this); + v.visitJSR(this); + } + + /** + * 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() == com.sun.org.apache.bcel.internal.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 maxOffset) { + 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 - maxOffset) { // to large for short (estimate) + super.setOpcode(com.sun.org.apache.bcel.internal.Const.JSR_W); + final short oldLength = (short) super.getLength(); + super.setLength(5); + return super.getLength() - oldLength; + } + return 0; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR_W.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR_W.java new file mode 100644 index 000000000..b51d05c67 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR_W.java @@ -0,0 +1,79 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * JSR_W - Jump to subroutine + */ +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(com.sun.org.apache.bcel.internal.Const.JSR_W, target); + 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); + } + + /** + * 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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java new file mode 100644 index 000000000..1ecd736d3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java @@ -0,0 +1,74 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for JSR - Jump to subroutine + */ +public abstract class JsrInstruction extends BranchInstruction implements UnconditionalBranch, TypedInstruction, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + JsrInstruction() { + } + + JsrInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } + + /** + * @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 IllegalStateException("physicalSuccessor() called on a shared JsrInstruction."); + } + } + // Return the physical successor + return toThis.getNext(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2D.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2D.java new file mode 100644 index 000000000..b82861f17 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2D.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * L2D - Convert long to double + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
    + * 
    + */ +public class L2D extends ConversionInstruction { + + public L2D() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2F.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2F.java new file mode 100644 index 000000000..a264f8c3b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2F.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * L2F - Convert long to float + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result
    + * 
    + */ +public class L2F extends ConversionInstruction { + + public L2F() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2I.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2I.java new file mode 100644 index 000000000..a6fb12158 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2I.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * L2I - Convert long to int + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result
    + * 
    + */ +public class L2I extends ConversionInstruction { + + public L2I() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LADD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LADD.java new file mode 100644 index 000000000..0f8163f6f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LADD.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LADD - Add longs + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class LADD extends ArithmeticInstruction { + + public LADD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LALOAD.java new file mode 100644 index 000000000..70fd5255a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LALOAD - Load long from array + * + *
    + * Stack: ..., arrayref, index -> ..., value1, value2
    + * 
    + */ +public class LALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load long from array + */ + public LALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LAND.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LAND.java new file mode 100644 index 000000000..75c18f9c4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LAND.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LAND - Bitwise AND longs + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class LAND extends ArithmeticInstruction { + + public LAND() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LASTORE.java new file mode 100644 index 000000000..96f3a9511 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LASTORE - Store into long array + * + *
    + * Stack: ..., arrayref, index, value.word1, value.word2 -> ...
    + * 
    + */ +public class LASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store long into array + */ + public LASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCMP.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCMP.java new file mode 100644 index 000000000..c517b492f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCMP.java @@ -0,0 +1,59 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LCMP - Compare longs: + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result <= -1, 0, 1>
    + * 
    + * + */ +public class LCMP extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public LCMP() { + super(com.sun.org.apache.bcel.internal.Const.LCMP, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitLCMP(this); + } + + /** + * @return Type.LONG + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.LONG; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCONST.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCONST.java new file mode 100644 index 000000000..76ff4a26e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCONST.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LCONST - Push 0 or 1, other values cause an exception + * + *
    + * Stack: ... -> ...,
    + * 
    + */ +public class LCONST extends Instruction implements ConstantPushInstruction { + + private final long value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LCONST() { + this(0); + } + + public LCONST(final long l) { + super(com.sun.org.apache.bcel.internal.Const.LCONST_0, (short) 1); + if (l == 0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LCONST_0); + } else if (l == 1) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LCONST_1); + } else { + throw new ClassGenException("LCONST can be used only for 0 and 1: " + l); + } + value = l; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * @return Type.LONG + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.LONG; + } + + @Override + public Number getValue() { + return Long.valueOf(value); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC.java new file mode 100644 index 000000000..d95bade23 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * LDC - Push item from constant pool. + * + *
    + * Stack: ... -> ..., item
    + * 
    + * @LastModified: May 2021 + */ +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(com.sun.org.apache.bcel.internal.Const.LDC_W, index); + setSize(); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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()); + } + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_STRING_RESOLUTION); + } + + @Override + public Type getType(final ConstantPoolGen cpg) { + switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_String: + return Type.STRING; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float: + return Type.FLOAT; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer: + return Type.INT; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class: + return Type.CLASS; + default: // Never reached + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); + } + } + + public Object getValue(final ConstantPoolGen cpg) { + com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + switch (c.getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_String: + final int i = ((com.sun.org.apache.bcel.internal.classfile.ConstantString) c).getStringIndex(); + c = cpg.getConstantPool().getConstant(i); + return ((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes(); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float: + return Float.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantFloat) c).getBytes()); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer: + return Integer.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantInteger) c).getBytes()); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class: + final int nameIndex = ((com.sun.org.apache.bcel.internal.classfile.ConstantClass) c).getNameIndex(); + c = cpg.getConstantPool().getConstant(nameIndex); + return Type.getType(((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes()); + default: // Never reached + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); + } + } + + /** + * 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()); + } + + /** + * Set the index to constant pool and adjust size. + */ + @Override + public final void setIndex(final int index) { + super.setIndex(index); + setSize(); + } + + // Adjust to proper size + protected final void setSize() { + if (super.getIndex() <= com.sun.org.apache.bcel.internal.Const.MAX_BYTE) { // Fits in one byte? + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC); + super.setLength(2); + } else { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC_W); + super.setLength(3); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC2_W.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC2_W.java new file mode 100644 index 000000000..dc2ef43be --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC2_W.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LDC2_W - Push long or double from constant pool + * + *
    + * Stack: ... -> ..., item.word1, item.word2
    + * 
    + * @LastModified: May 2021 + */ +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(com.sun.org.apache.bcel.internal.Const.LDC2_W, 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 + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitLDC2_W(this); + } + + @Override + public Type getType(final ConstantPoolGen cpg) { + switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long: + return Type.LONG; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double: + return Type.DOUBLE; + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + super.getOpcode()); + } + } + + public Number getValue(final ConstantPoolGen cpg) { + final com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + switch (c.getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long: + return Long.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes()); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double: + return Double.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes()); + default: // Never reached + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC_W.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC_W.java new file mode 100644 index 000000000..07ea06e37 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC_W.java @@ -0,0 +1,57 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * LDC_W - Push item from constant pool (wide index) + * + *
    + * Stack: ... -> ..., item.word1, item.word2
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.LDC_W); + super.setLength(3); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDIV.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDIV.java new file mode 100644 index 000000000..819e98dc1 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDIV.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * LDIV - Divide longs + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + * @LastModified: Jan 2020 + */ +public class LDIV extends ArithmeticInstruction implements ExceptionThrower { + + public LDIV() { + super(com.sun.org.apache.bcel.internal.Const.LDIV); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LLOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LLOAD.java new file mode 100644 index 000000000..7ae6dc550 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LLOAD.java @@ -0,0 +1,55 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LLOAD - Load long from local variable + * + *
    + * Stack ... -> ..., result.word1, result.word2
    + * 
    + */ +public class LLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LLOAD() { + super(com.sun.org.apache.bcel.internal.Const.LLOAD, com.sun.org.apache.bcel.internal.Const.LLOAD_0); + } + + public LLOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.LLOAD, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LMUL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LMUL.java new file mode 100644 index 000000000..86972264f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LMUL.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LMUL - Multiply longs + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class LMUL extends ArithmeticInstruction { + + public LMUL() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LNEG.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LNEG.java new file mode 100644 index 000000000..69c0d3572 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LNEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LNEG - Negate long + * + *
    + * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
    + * 
    + */ +public class LNEG extends ArithmeticInstruction { + + public LNEG() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java new file mode 100644 index 000000000..b8e153ca2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java @@ -0,0 +1,101 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * LOOKUPSWITCH - Switch with unordered set of values + * + * @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(com.sun.org.apache.bcel.internal.Const.LOOKUPSWITCH, match, targets, defaultTarget); + /* alignment remainder assumed 0 here, until dump time. */ + final short length = (short) (9 + getMatchLength() * 8); + super.setLength(length); + setFixedLength(length); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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 matchLength = getMatchLength(); + out.writeInt(matchLength); // npairs + for (int i = 0; i < matchLength; 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 matchLength = bytes.readInt(); + setMatchLength(matchLength); + final short fixedLength = (short) (9 + matchLength * 8); + setFixedLength(fixedLength); + final short length = (short) (matchLength + super.getPadding()); + super.setLength(length); + super.setMatches(new int[matchLength]); + super.setIndices(new int[matchLength]); + super.setTargets(new InstructionHandle[matchLength]); + for (int i = 0; i < matchLength; i++) { + super.setMatch(i, bytes.readInt()); + super.setIndices(i, bytes.readInt()); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOR.java new file mode 100644 index 000000000..53d4e9bc1 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LOR - Bitwise OR long + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class LOR extends ArithmeticInstruction { + + public LOR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LREM.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LREM.java new file mode 100644 index 000000000..17a535df2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LREM.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * LREM - Remainder of long + * + *
    + * Stack: ..., value1, value2 -> result
    + * 
    + * @LastModified: Jan 2020 + */ +public class LREM extends ArithmeticInstruction implements ExceptionThrower { + + public LREM() { + super(com.sun.org.apache.bcel.internal.Const.LREM); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LRETURN.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LRETURN.java new file mode 100644 index 000000000..9d40c14f8 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LRETURN.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LRETURN - Return long from method + * + *
    + * Stack: ..., value.word1, value.word2 -> <empty>
    + * 
    + */ +public class LRETURN extends ReturnInstruction { + + public LRETURN() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHL.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHL.java new file mode 100644 index 000000000..72c2aeed2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHL.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSHL - Arithmetic shift left long + * + *
    + * Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
    + * 
    + */ +public class LSHL extends ArithmeticInstruction { + + public LSHL() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHR.java new file mode 100644 index 000000000..d7a51d3cf --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSHR - Arithmetic shift right long + * + *
    + * Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
    + * 
    + */ +public class LSHR extends ArithmeticInstruction { + + public LSHR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSTORE.java new file mode 100644 index 000000000..0b49912db --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSTORE.java @@ -0,0 +1,55 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSTORE - Store long into local variable + * + *
    + * Stack: ..., value.word1, value.word2 -> ...
    + * 
    + */ +public class LSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LSTORE() { + super(com.sun.org.apache.bcel.internal.Const.LSTORE, com.sun.org.apache.bcel.internal.Const.LSTORE_0); + } + + public LSTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.LSTORE, com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSUB.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSUB.java new file mode 100644 index 000000000..8ffdf4fc5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSUB.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSUB - Substract longs + * + *
    + * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
    + * 
    + * + * ..., result.word1, result.word2 + */ +public class LSUB extends ArithmeticInstruction { + + public LSUB() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LUSHR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LUSHR.java new file mode 100644 index 000000000..0d9d2eab5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LUSHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LUSHR - Logical shift right long + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class LUSHR extends ArithmeticInstruction { + + public LUSHR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LXOR.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LXOR.java new file mode 100644 index 000000000..cf6ac4807 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LXOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LXOR - Bitwise XOR long + * + *
    + * Stack: ..., value1, value2 -> ..., result
    + * 
    + */ +public class LXOR extends ArithmeticInstruction { + + public LXOR() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java new file mode 100644 index 000000000..3773c21e7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java @@ -0,0 +1,108 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.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. + * + * @see LineNumber + * @see MethodGen + */ +public class LineNumberGen implements InstructionTargeter, Cloneable { + + static final LineNumberGen[] EMPTY_ARRAY = {}; + + private InstructionHandle ih; + private int srcLine; + + /** + * Create a line number. + * + * @param ih instruction handle to reference + */ + public LineNumberGen(final InstructionHandle ih, final int srcLine) { + setInstruction(ih); + setSourceLine(srcLine); + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return true, if ih is target of this line number + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + return this.ih == ih; + } + + public InstructionHandle getInstruction() { + return ih; + } + + /** + * Get LineNumber attribute. + * + * This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods + * has been called for the instruction list. + */ + public LineNumber getLineNumber() { + return new LineNumber(ih.getPosition(), srcLine); + } + + public int getSourceLine() { + return srcLine; + } + + public void setInstruction(final InstructionHandle instructionHandle) { // TODO could be package-protected? + Objects.requireNonNull(instructionHandle, "instructionHandle"); + BranchInstruction.notifyTarget(this.ih, instructionHandle, this); + this.ih = instructionHandle; + } + + public void setSourceLine(final int srcLine) { // TODO could be package-protected? + this.srcLine = srcLine; + } + + /** + * @param oldIh old target + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + if (oldIh != ih) { + throw new ClassGenException("Not targeting " + oldIh + ", but " + ih + "}"); + } + setInstruction(newIh); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadClass.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadClass.java new file mode 100644 index 000000000..9fad1d159 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadClass.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes that an instruction may start the process of loading and resolving the referenced class in the Virtual Machine. + */ +public interface LoadClass { + + /** + * Returns the {@link ObjectType} of the referenced class or interface that may be loaded and resolved. + * + * @param cpg A ConstantPoolGen + * @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, {@link 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, {@code null} is returned. An example for this is an {@link NEWARRAY} instruction that creates an + * {@code int[][]}. + * + * @param cpg A ConstantPoolGen + * @return the type associated with this instruction. + * @see #getLoadClassType(ConstantPoolGen) + */ + Type getType(ConstantPoolGen cpg); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java new file mode 100644 index 000000000..faaf9fad5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to load a value from a local variable, e.g. ILOAD. + */ +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 canonTag, final short cTag) { + super(canonTag, cTag); + } + + /** + * @param opcode Instruction opcode + * @param cTag Instruction number for compact version, ALOAD_0, e.g. + * @param n local variable index (unsigned short) + */ + protected LoadInstruction(final short opcode, final short cTag, final int n) { + super(opcode, cTag, 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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java new file mode 100644 index 000000000..830564d42 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java @@ -0,0 +1,236 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.LocalVariable; + +/** + * 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. + * + * @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 origIndex; // never changes; used to match up with LocalVariableTypeTable entries + private boolean liveToEnd; + + /** + * 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); + } + this.name = name; + this.type = type; + this.index = index; + setStart(start); + setEnd(end); + this.origIndex = index; + this.liveToEnd = end == null; + } + + /** + * Generates 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 origIndex 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 origIndex) { + this(index, name, type, start, end); + this.origIndex = origIndex; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return true, if ih is target of this variable + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + return start == ih || end == ih; + } + + /** + * Clear the references from and to this variable when it's removed. + */ + void dispose() { + setStart(null); + setEnd(null); + } + + /** + * 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; + } + + public InstructionHandle getEnd() { + return end; + } + + public int getIndex() { + return index; + } + + public boolean getLiveToEnd() { + return liveToEnd; + } + + /** + * Gets LocalVariable object. + * + * This relies on that the instruction list has already been dumped to byte code 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 liveToEnd flag to differentiate between these two cases. + * + * @param cp constant pool + */ + public LocalVariable getLocalVariable(final ConstantPoolGen cp) { + int startPc = 0; + int length = 0; + if (start != null && end != null) { + startPc = start.getPosition(); + length = end.getPosition() - startPc; + if (end.getNext() == null && liveToEnd) { + length += end.getInstruction().getLength(); + } + } + final int nameIndex = cp.addUtf8(name); + final int signatureIndex = cp.addUtf8(type.getSignature()); + return new LocalVariable(startPc, length, nameIndex, signatureIndex, index, cp.getConstantPool(), origIndex); + } + + @Override + public String getName() { + return name; + } + + public int getOrigIndex() { + return origIndex; + } + + public InstructionHandle getStart() { + return start; + } + + @Override + public Type getType() { + return type; + } + + @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(); + } + + public void setEnd(final InstructionHandle end) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.end, end, this); + this.end = end; + } + + public void setIndex(final int index) { + this.index = index; + } + + public void setLiveToEnd(final boolean liveToEnd) { + this.liveToEnd = liveToEnd; + } + + @Override + public void setName(final String name) { + this.name = name; + } + + public void setStart(final InstructionHandle start) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.start, start, this); + this.start = start; + } + + @Override + public void setType(final Type type) { + this.type = type; + } + + @Override + public String toString() { + return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")"; + } + + /** + * @param oldIh old target, either start or end + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + boolean targeted = false; + if (start == oldIh) { + targeted = true; + setStart(newIh); + } + if (end == oldIh) { + targeted = true; + setEnd(newIh); + } + if (!targeted) { + throw new ClassGenException("Not targeting " + oldIh + ", but {" + start + ", " + end + "}"); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java new file mode 100644 index 000000000..67184c0b9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Abstract super class for instructions dealing with local variables. + * + * @LastModified: May 2021 + */ +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 cTag = -1; // compact version, such as ILOAD_0 + private short canonTag = -1; // canonical tag such as ILOAD + + /** + * Empty constructor needed for Instruction.readInstruction. Also used by IINC()! + */ + LocalVariableInstruction() { + } + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in + * readInstruction and initFromFile, respectively. + */ + LocalVariableInstruction(final short canonTag, final short cTag) { + this.canonTag = canonTag; + this.cTag = cTag; + } + + /** + * @param opcode Instruction opcode + * @param cTag Instruction number for compact version, ALOAD_0, e.g. + * @param n local variable index (unsigned short) + */ + protected LocalVariableInstruction(final short opcode, final short cTag, final int n) { + super(opcode, (short) 2); + this.cTag = cTag; + canonTag = 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); + } + } + } + + /** + * @return canonical tag for instruction, e.g., ALOAD for ALOAD_0 + */ + public short getCanonicalTag() { + return canonTag; + } + + /** + * @return local variable index (n) referred by this instruction. + */ + @Override + public final int getIndex() { + return n; + } + + /** + * 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 (canonTag) { + 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("Unknown case in switch" + canonTag); + } + } + + /** + * 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; + } else { // Assert ISTORE_0 <= tag <= ASTORE_3 + n = (opcode - Const.ISTORE_0) % 4; + } + super.setLength(1); + } + } + } + + /** + * 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) (cTag + n)); + super.setLength(1); + } else { + super.setOpcode(canonTag); + if (wide()) { + super.setLength(4); + } else { + super.setLength(2); + } + } + } + + /** + * Sets the index of the referenced variable (n) only + * + * @since 6.0 + * @see #setIndex(int) + */ + final void setIndexOnly(final int n) { + this.n = 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; + } + + private boolean wide() { + return n > Const.MAX_BYTE; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java new file mode 100644 index 000000000..6ea4f9185 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * MONITORENTER - Enter monitor for object + * + *
    + * Stack: ..., objectref -> ...
    + * 
    + * @LastModified: Jan 2020 + */ +public class MONITORENTER extends Instruction implements ExceptionThrower, StackConsumer { + + public MONITORENTER() { + super(com.sun.org.apache.bcel.internal.Const.MONITORENTER, (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.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITORENTER(this); + } + + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.NULL_POINTER_EXCEPTION}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java new file mode 100644 index 000000000..40daeb13b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * MONITOREXIT - Exit monitor for object + * + *
    + * Stack: ..., objectref -> ...
    + * 
    + * @LastModified: Jan 2020 + */ +public class MONITOREXIT extends Instruction implements ExceptionThrower, StackConsumer { + + public MONITOREXIT() { + super(com.sun.org.apache.bcel.internal.Const.MONITOREXIT, (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.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITOREXIT(this); + } + + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.NULL_POINTER_EXCEPTION}; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java new file mode 100644 index 000000000..9f83842d2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java @@ -0,0 +1,142 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * MULTIANEWARRAY - Create new mutidimensional array of references + * + *
    + * Stack: ..., count1, [count2, ...] -> ..., arrayref
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.MULTIANEWARRAY, index); + if (dimensions < 1) { + throw new ClassGenException("Invalid dimensions value: " + dimensions); + } + this.dimensions = dimensions; + super.setLength(4); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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; + } + + /** + * 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); + } + + /** + * @return number of dimensions to be created + */ + public final short getDimensions() { + 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; + } + + /** + * 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 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; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodGen.java new file mode 100644 index 000000000..f6e8333be --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodGen.java @@ -0,0 +1,1175 @@ +/* + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import java.util.Stack; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.Annotations; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.CodeException; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.LineNumber; +import com.sun.org.apache.bcel.internal.classfile.LineNumberTable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTypeTable; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.ParameterAnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.ParameterAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleParameterAnnotations; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.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. + * + * @see InstructionList + * @see Method + * @LastModified: Feb 2023 + */ +public class MethodGen extends FieldGenOrMethodGen { + + static final class BranchStack { + + private final Stack branchTargets = new Stack<>(); + private final HashMap visitedTargets = new HashMap<>(); + + public BranchTarget pop() { + if (!branchTargets.empty()) { + return branchTargets.pop(); + } + return null; + } + + public void push(final InstructionHandle target, final int stackDepth) { + if (visited(target)) { + return; + } + branchTargets.push(visit(target, stackDepth)); + } + + 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; + } + } + + static final class BranchTarget { + + final InstructionHandle target; + final int stackDepth; + + BranchTarget(final InstructionHandle target, final int stackDepth) { + this.target = target; + this.stackDepth = stackDepth; + } + } + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o1; + final FieldGenOrMethodGen THAT = (FieldGenOrMethodGen) o2; + return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + private static byte[] getByteCodes(final Method method) { + final Code code = method.getCode(); + if (code == null) { + throw new IllegalStateException(String.format("The method '%s' has no code.", method)); + } + return code.getCode(); + } + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * 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 handlerPc = element.getHandlerPC(); + if (handlerPc != null) { + branchTargets.push(handlerPc, 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; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + private String className; + private Type[] argTypes; + private String[] argNames; + private int maxLocals; + private int maxStack; + private InstructionList il; + + private boolean stripAttributes; + private LocalVariableTypeTable localVariableTypeTable; + private final List variableList = new ArrayList<>(); + + private final List lineNumberList = new ArrayList<>(); + + private final List exceptionList = new ArrayList<>(); + + private final List throwsList = new ArrayList<>(); + + private final List codeAttrsList = new ArrayList<>(); + + private List[] paramAnnotations; // Array of lists containing AnnotationGen objects + + private boolean hasParameterAnnotations; + + private boolean haveUnpackedParameterAnnotations; + + private List observers; + + /** + * 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 they 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 accessFlags access qualifiers + * @param returnType method type + * @param argTypes argument types + * @param argNames argument names (if this is null, default names will be provided for them) + * @param methodName name of method + * @param className 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 accessFlags, final Type returnType, final Type[] argTypes, String[] argNames, final String methodName, final String className, + final InstructionList il, final ConstantPoolGen cp) { + super(accessFlags); + setType(returnType); + setArgumentTypes(argTypes); + setArgumentNames(argNames); + setName(methodName); + setClassName(className); + 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() && className != null) { // Instance method -> 'this' is local var 0 + addLocalVariable("this", ObjectType.getInstance(className), start, end); + } + } + if (argTypes != null) { + final int size = argTypes.length; + for (final Type argType : argTypes) { + if (Type.VOID == argType) { + throw new ClassGenException("'void' is an illegal argument type for a method"); + } + } + if (argNames != null) { // Names for variables provided? + if (size != argNames.length) { + throw new ClassGenException("Mismatch in argument array lengths: " + size + " vs. " + argNames.length); + } + } else { // Give them dummy names + argNames = new String[size]; + for (int i = 0; i < size; i++) { + argNames[i] = "arg" + i; + } + setArgumentNames(argNames); + } + if (!abstract_) { + for (int i = 0; i < size; i++) { + addLocalVariable(argNames[i], argTypes[i], start, end); + } + } + } + } + + /** + * Instantiate from existing method. + * + * @param method method + * @param className class name containing this method + * @param cp constant pool + */ + public MethodGen(final Method method, final String className, final ConstantPoolGen cp) { + this(method.getAccessFlags(), Type.getReturnType(method.getSignature()), Type.getArgumentTypes(method.getSignature()), + null /* may be overridden anyway */ + , method.getName(), className, + (method.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0 ? new InstructionList(getByteCodes(method)) : null, cp); + final Attribute[] attributes = method.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 cType = null; + if (type > 0) { + final String cen = method.getConstantPool().getConstantString(type, Const.CONSTANT_Class); + cType = ObjectType.getInstance(cen); + } + final int endPc = ce.getEndPC(); + final int length = getByteCodes(method).length; + InstructionHandle end; + if (length == endPc) { // May happen, because end_pc is exclusive + end = il.getEnd(); + } else { + end = il.findHandle(endPc); + end = end.getPrev(); // Make it inclusive + } + addExceptionHandler(il.findHandle(ce.getStartPC()), end, il.findHandle(ce.getHandlerPC()), cType); + } + } + final Attribute[] cAttributes = c.getAttributes(); + for (final Attribute cAttribute : cAttributes) { + a = cAttribute; + if (a instanceof LineNumberTable) { + ((LineNumberTable) a).forEach(l -> { + 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.localVariableTypeTable = (LocalVariableTypeTable) a.copy(cp.getConstantPool()); + } else { + addCodeAttribute(a); + } + } + } else if (a instanceof ExceptionTable) { + Collections.addAll(throwsList, ((ExceptionTable) a).getExceptionNames()); + } else if (a instanceof Annotations) { + final Annotations runtimeAnnotations = (Annotations) a; + runtimeAnnotations.forEach(element -> addAnnotationEntry(new AnnotationEntryGen(element, cp, false))); + } else { + addAttribute(a); + } + } + } + + /** + * @since 6.0 + */ + public void addAnnotationsAsAttribute(final ConstantPoolGen cp) { + addAll(AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries())); + } + + /** + * 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) { + codeAttrsList.add(a); + } + + /** + * Add an exception possibly thrown by this method. + * + * @param className (fully qualified) name of exception + */ + public void addException(final String className) { + throwsList.add(className); + } + + /** + * Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling + * is done. + * + * @param startPc Start of region (inclusive) + * @param endPc End of region (inclusive) + * @param handlerPc Where handling is done + * @param catchType class type of handled exception or null if any exception is handled + * @return new exception handler object + */ + public CodeExceptionGen addExceptionHandler(final InstructionHandle startPc, final InstructionHandle endPc, final InstructionHandle handlerPc, + final ObjectType catchType) { + if (startPc == null || endPc == null || handlerPc == null) { + throw new ClassGenException("Exception handler target is null instruction"); + } + final CodeExceptionGen c = new CodeExceptionGen(startPc, endPc, handlerPc, catchType); + exceptionList.add(c); + return c; + } + + /** + * 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 srcLine) { + final LineNumberGen l = new LineNumberGen(ih, srcLine); + lineNumberList.add(l); + return l; + } + + /** + * Adds a local variable to this method and assigns an index automatically. + * + * @param name variable name + * @param type variable type + * @param start from where the variable is valid, if this is null, it is valid from the start + * @param end until where the variable is valid, if this is null, it is valid to the end + * @return new local variable object + * @see LocalVariable + */ + public LocalVariableGen addLocalVariable(final String name, final Type type, final InstructionHandle start, final InstructionHandle end) { + return addLocalVariable(name, type, maxLocals, start, end); + } + + /** + * 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. + * + * @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 origIndex 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 origIndex) { + final byte t = type.getType(); + if (t != Const.T_ADDRESS) { + final int add = type.getSize(); + if (slot + add > maxLocals) { + maxLocals = slot + add; + } + final LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end, origIndex); + int i; + if ((i = variableList.indexOf(l)) >= 0) { + variableList.set(i, l); + } else { + variableList.add(l); + } + return l; + } + throw new IllegalArgumentException("Can not use " + type + " as type for local variable"); + } + + /** + * Add observer for this object. + */ + public void addObserver(final MethodObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + public void addParameterAnnotation(final int parameterIndex, final AnnotationEntryGen annotation) { + ensureExistingParameterAnnotationsUnpacked(); + if (!hasParameterAnnotations) { + @SuppressWarnings({"rawtypes", "unchecked"}) + final List[] parmList = (List[])new List[argTypes.length]; + paramAnnotations = parmList; + hasParameterAnnotations = true; + } + final List existingAnnotations = paramAnnotations[parameterIndex]; + if (existingAnnotations != null) { + existingAnnotations.add(annotation); + } else { + final List l = new ArrayList<>(); + l.add(annotation); + paramAnnotations[parameterIndex] = l; + } + } + + /** + * @since 6.0 + */ + public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { + if (!hasParameterAnnotations) { + return; + } + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); + if (attrs != null) { + addAll(attrs); + } + } + + private Attribute[] addRuntimeAnnotationsAsAttribute(final ConstantPoolGen cp) { + final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); + addAll(attrs); + return attrs; + } + + private Attribute[] addRuntimeParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { + if (!hasParameterAnnotations) { + return Attribute.EMPTY_ARRAY; + } + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); + addAll(attrs); + return attrs; + } + + private void adjustLocalVariableTypeTable(final LocalVariableTable lvt) { + final LocalVariable[] lv = lvt.getLocalVariableTable(); + for (final LocalVariable element : localVariableTypeTable.getLocalVariableTypeTable()) { + 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; + } + } + } + } + + /** + * @return deep copy of this method + */ + public MethodGen copy(final String className, final ConstantPoolGen cp) { + final Method m = ((MethodGen) clone()).getMethod(); + final MethodGen mg = new MethodGen(m, className, super.getConstantPool()); + if (super.getConstantPool() != cp) { + mg.setConstantPool(cp); + mg.getInstructionList().replaceConstantPool(super.getConstantPool(), cp); + } + return mg; + } + + /** + * 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 paramAnnotations + if (!hasParameterAnnotations) { + @SuppressWarnings({"rawtypes", "unchecked"}) + final List[] parmList = (List[])new List[argTypes.length]; + paramAnnotations = parmList; + Arrays.setAll(paramAnnotations, i -> 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 + paramAnnotations[j].addAll(mutable); + } + } + } + if (paramAnnVisAttr != null) { + removeAttribute(paramAnnVisAttr); + } + if (paramAnnInvisAttr != null) { + removeAttribute(paramAnnInvisAttr); + } + haveUnpackedParameterAnnotations = true; + } + + /** + * 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 Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + // J5TODO: Should paramAnnotations 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 > argTypes.length) { + return null; + } + return paramAnnotations[i]; + } + + public String getArgumentName(final int i) { + return argNames[i]; + } + + public String[] getArgumentNames() { + return argNames.clone(); + } + + public Type getArgumentType(final int i) { + return argTypes[i]; + } + + public Type[] getArgumentTypes() { + return argTypes.clone(); + } + + /** + * @return class that contains this method + */ + public String getClassName() { + return className; + } + + /** + * @return all attributes of this method. + */ + public Attribute[] getCodeAttributes() { + return codeAttrsList.toArray(Attribute.EMPTY_ARRAY); + } + + /** + * @return code exceptions for 'Code' attribute + */ + private CodeException[] getCodeExceptions() { + final int size = exceptionList.size(); + final CodeException[] cExc = new CodeException[size]; + Arrays.setAll(cExc, i -> exceptionList.get(i).getCodeException(super.getConstantPool())); + return cExc; + } + + /* + * @return array of declared exception handlers + */ + public CodeExceptionGen[] getExceptionHandlers() { + return exceptionList.toArray(CodeExceptionGen.EMPTY_ARRAY); + } + + /* + * @return array of thrown exceptions + */ + public String[] getExceptions() { + return throwsList.toArray(Const.EMPTY_STRING_ARRAY); + } + + /** + * @return 'Exceptions' attribute of all the exceptions thrown by this method. + */ + private ExceptionTable getExceptionTable(final ConstantPoolGen cp) { + final int size = throwsList.size(); + final int[] ex = new int[size]; + Arrays.setAll(ex, i -> cp.addClass(throwsList.get(i))); + return new ExceptionTable(cp.addUtf8("Exceptions"), 2 + 2 * size, ex, cp.getConstantPool()); + } + + public InstructionList getInstructionList() { + return il; + } + + /* + * @return array of line numbers + */ + public LineNumberGen[] getLineNumbers() { + return lineNumberList.toArray(LineNumberGen.EMPTY_ARRAY); + } + + /** + * @return 'LineNumberTable' attribute of all the local variables of this method. + */ + public LineNumberTable getLineNumberTable(final ConstantPoolGen cp) { + final int size = lineNumberList.size(); + final LineNumber[] ln = new LineNumber[size]; + Arrays.setAll(ln, i -> lineNumberList.get(i).getLineNumber()); + return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp.getConstantPool()); + } + + /* + * 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 = variableList.size(); + final LocalVariableGen[] lg = new LocalVariableGen[size]; + variableList.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, Comparator.comparingInt(LocalVariableGen::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]; + Arrays.setAll(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 localVariableTypeTable; + } + + public int getMaxLocals() { + return maxLocals; + } + + public int getMaxStack() { + return maxStack; + } + + /** + * 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 nameIndex = cp.addUtf8(super.getName()); + final int signatureIndex = cp.addUtf8(signature); + /* + * Also updates positions of instructions, i.e., their indices + */ + final byte[] byteCode = il != null ? il.getByteCode() : null; + LineNumberTable lnt = null; + LocalVariableTable lvt = null; + /* + * Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.) + */ + if (!variableList.isEmpty() && !stripAttributes) { + updateLocalVariableTable(getLocalVariableTable(cp)); + addCodeAttribute(lvt = getLocalVariableTable(cp)); + } + if (localVariableTypeTable != null) { + // LocalVariable length in LocalVariableTypeTable is not updated automatically. It's a difference with + // LocalVariableTable. + if (lvt != null) { + adjustLocalVariableTypeTable(lvt); + } + addCodeAttribute(localVariableTypeTable); + } + if (!lineNumberList.isEmpty() && !stripAttributes) { + addCodeAttribute(lnt = getLineNumberTable(cp)); + } + final Attribute[] codeAttrs = getCodeAttributes(); + /* + * Each attribute causes 6 additional header bytes + */ + int attrsLen = 0; + for (final Attribute codeAttr : codeAttrs) { + attrsLen += codeAttr.getLength() + 6; + } + final CodeException[] cExc = getCodeExceptions(); + final int excLen = cExc.length * 8; // Every entry takes 8 bytes + Code code = null; + if (byteCode != 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 + byteCode.length + // prologue byte code + 2 + excLen + // exceptions + 2 + attrsLen, // attributes + maxStack, maxLocals, byteCode, cExc, codeAttrs, cp.getConstantPool()); + addAttribute(code); + } + final Attribute[] annotations = addRuntimeAnnotationsAsAttribute(cp); + final Attribute[] parameterAnnotations = addRuntimeParameterAnnotationsAsAttribute(cp); + ExceptionTable et = null; + if (!throwsList.isEmpty()) { + addAttribute(et = getExceptionTable(cp)); + // Add 'Exceptions' if there are "throws" clauses + } + final Method m = new Method(super.getAccessFlags(), nameIndex, signatureIndex, getAttributes(), cp.getConstantPool()); + // Undo effects of adding attributes + if (lvt != null) { + removeCodeAttribute(lvt); + } + if (localVariableTypeTable != null) { + removeCodeAttribute(localVariableTypeTable); + } + if (lnt != null) { + removeCodeAttribute(lnt); + } + if (code != null) { + removeAttribute(code); + } + if (et != null) { + removeAttribute(et); + } + removeRuntimeAttributes(annotations); + removeRuntimeAttributes(parameterAnnotations); + return m; + } + + public Type getReturnType() { + return getType(); + } + + @Override + public String getSignature() { + return Type.getMethodSignature(super.getType(), argTypes); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the method's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + 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; + } + + /** + * Remove a code attribute. + */ + public void removeCodeAttribute(final Attribute a) { + codeAttrsList.remove(a); + } + + /** + * Remove all code attributes. + */ + public void removeCodeAttributes() { + localVariableTypeTable = null; + codeAttrsList.clear(); + } + + /** + * Remove an exception. + */ + public void removeException(final String c) { + throwsList.remove(c); + } + + /** + * Remove an exception handler. + */ + public void removeExceptionHandler(final CodeExceptionGen c) { + exceptionList.remove(c); + } + + /** + * Remove all line numbers. + */ + public void removeExceptionHandlers() { + exceptionList.clear(); + } + + /** + * Remove all exceptions. + */ + public void removeExceptions() { + throwsList.clear(); + } + + /** + * Remove a line number. + */ + public void removeLineNumber(final LineNumberGen l) { + lineNumberList.remove(l); + } + + /** + * Remove all line numbers. + */ + public void removeLineNumbers() { + lineNumberList.clear(); + } + + /** + * 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) { + variableList.remove(l); + } + + /** + * Remove all local variables. + */ + public void removeLocalVariables() { + variableList.clear(); + } + + /** + * Remove the LocalVariableTypeTable + */ + public void removeLocalVariableTypeTable() { + localVariableTypeTable = null; + } + + /** + * 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); + } + } + } + } + } + } + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final MethodObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + /** + * Would prefer to make this private, but need a way to test if client is using BCEL version 6.5.0 or later that + * contains fix for BCEL-329. + * + * @since 6.5.0 + */ + public void removeRuntimeAttributes(final Attribute[] attrs) { + for (final Attribute attr : attrs) { + removeAttribute(attr); + } + } + + public void setArgumentName(final int i, final String name) { + argNames[i] = name; + } + + public void setArgumentNames(final String[] argNames) { + this.argNames = argNames; + } + + public void setArgumentType(final int i, final Type type) { + argTypes[i] = type; + } + + public void setArgumentTypes(final Type[] argTypes) { + this.argTypes = argTypes; + } + + public void setClassName(final String className) { // TODO could be package-protected? + this.className = className; + } + + public void setInstructionList(final InstructionList il) { // TODO could be package-protected? + this.il = il; + } + + /** + * 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 (argTypes != null) { + for (final Type argType : argTypes) { + max += argType.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; + } + } + } + maxLocals = max; + } else { + maxLocals = 0; + } + } + + /** + * Set maximum number of local variables. + */ + public void setMaxLocals(final int m) { + maxLocals = m; + } + + /** + * 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) { + maxStack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); + } else { + maxStack = 0; + } + } + + /** + * Set maximum stack size for this method. + */ + public void setMaxStack(final int m) { // TODO could be package-protected? + maxStack = m; + } + + public void setReturnType(final Type returnType) { + setType(returnType); + } + + /** + * Do not/Do produce attributes code attributesLineNumberTable and LocalVariableTable, like javac -O + */ + public void stripAttributes(final boolean flag) { + stripAttributes = flag; + } + + /** + * 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(), argTypes); + 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 (!throwsList.isEmpty()) { + for (final String throwsDescriptor : throwsList) { + buf.append("\n\t\tthrows ").append(throwsDescriptor); + } + } + return buf.toString(); + } + + /** + * 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 they have finished editing the object. + */ + public void update() { + if (observers != null) { + for (final MethodObserver observer : observers) { + observer.notify(this); + } + } + } + + private void updateLocalVariableTable(final LocalVariableTable a) { + removeLocalVariables(); + for (final LocalVariable l : a.getLocalVariableTable()) { + 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()); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodObserver.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodObserver.java new file mode 100644 index 000000000..22e773ea4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Implement this interface if you're interested in changes to a MethodGen object and register yourself with + * addObserver(). + */ +public interface MethodObserver { + + void notify(MethodGen method); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEW.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEW.java new file mode 100644 index 000000000..53b938581 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEW.java @@ -0,0 +1,72 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * NEW - Create new object + * + *
    + * Stack: ... -> ..., objectref
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.NEW, 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 + */ + @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); + } + + @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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java new file mode 100644 index 000000000..be2c64a09 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * NEWARRAY - Create new array of basic type (int, short, ...) + * + *
    + * Stack: ..., count -> ..., arrayref
    + * 
    + * + * type must be one of T_INT, T_SHORT, ... + * @LastModified: Jan 2020 + */ +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 BasicType type) { + this(type.getType()); + } + + public NEWARRAY(final byte type) { + super(com.sun.org.apache.bcel.internal.Const.NEWARRAY, (short) 2); + this.type = type; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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); + } + + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION}; + } + + /** + * @return type of constructed array + */ + public final Type getType() { + return new ArrayType(BasicType.getType(type), 1); + } + + /** + * @return numeric code for basic element type + */ + public final byte getTypecode() { + return 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); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + com.sun.org.apache.bcel.internal.Const.getTypeName(type); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NOP.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NOP.java new file mode 100644 index 000000000..37f73953e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NOP.java @@ -0,0 +1,43 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * NOP - Do nothing + */ +public class NOP extends Instruction { + + public NOP() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java new file mode 100644 index 000000000..3b79c8219 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java @@ -0,0 +1,67 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; + +/** + * Super class for FieldOrMethod and INVOKEDYNAMIC, since they both have names and signatures + * + * @since 6.0 + */ +public abstract class NameSignatureInstruction extends CPInstruction { + + public NameSignatureInstruction() { + } + + public NameSignatureInstruction(final short opcode, final int index) { + super(opcode, index); + } + + /** + * @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(); + } + + 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(); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java new file mode 100644 index 000000000..a46e7aa2d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java @@ -0,0 +1,36 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote entity that has both name and type. This is true for local variables, methods and fields. + */ +public interface NamedAndTyped { + + String getName(); + + Type getType(); + + void setName(String name); + + void setType(Type type); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ObjectType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ObjectType.java new file mode 100644 index 000000000..46378a1b7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ObjectType.java @@ -0,0 +1,159 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.Repository; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Denotes reference such as java.lang.String. + */ +public class ObjectType extends ReferenceType { + + /** + * Constructs a new instance. + * + * @param className fully qualified class name, e.g. java.lang.String + * @return a new instance. + * @since 6.0 + */ + public static ObjectType getInstance(final String className) { + return new ObjectType(className); + } + + private final String className; // Class name of type + + /** + * Constructs a new instance. + * + * @param className fully qualified class name, e.g. java.lang.String + */ + public ObjectType(final String className) { + super(Const.T_REFERENCE, "L" + Utility.packageToPath(className) + ";"); + this.className = Utility.pathToPackage(className); + } + + /** + * 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(className); + if (jc.isPublic()) { + return true; + } + final JavaClass acc = Repository.lookupClass(accessor.className); + return acc.getPackageName().equals(jc.getPackageName()); + } + + /** + * @return true if both type objects refer to the same class. + */ + @Override + public boolean equals(final Object type) { + return type instanceof ObjectType && ((ObjectType) type).className.equals(className); + } + + /** + * @return name of referenced class + */ + @Override + public String getClassName() { + return className; + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + return className.hashCode(); + } + + /** + * 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(className); + 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(className); + return jc.isClass(); + } + + /** + * 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(className); + return !jc.isClass(); + } catch (final ClassNotFoundException e) { + return false; + } + } + + /** + * 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(className); + 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.className, superclass.className); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP.java new file mode 100644 index 000000000..e826dd78c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * POP - Pop top operand stack word + * + *
    + * Stack: ..., word -> ...
    + * 
    + */ +public class POP extends StackInstruction implements PopInstruction { + + public POP() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP2.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP2.java new file mode 100644 index 000000000..5124f4177 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP2.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * POP2 - Pop two top operand stack words + * + *
    + * Stack: ..., word2, word1 -> ...
    + * 
    + */ +public class POP2 extends StackInstruction implements PopInstruction { + + public POP2() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUSH.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUSH.java new file mode 100644 index 000000000..cac202758 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUSH.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Wrapper class for push operations, which are implemented either as BIPUSH, LDC or xCONST_n instructions. + * @LastModified: Feb 2023 + */ +public final class PUSH implements CompoundInstruction, VariableLengthInstruction { + + private final Instruction instruction; + + /** + * Pushes an array type constant, for example {@code int[].class}, {@code String[].class}, and so on. + * + * @param cp generated constant pool. + * @param value to be pushed. + * @since 6.7.0 + */ + public PUSH(final ConstantPoolGen cp, final ArrayType value) { + if (value == null) { + instruction = InstructionConst.ACONST_NULL; + } else { + instruction = new LDC(cp.addArrayClass(value)); + } + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final boolean value) { + Objects.requireNonNull(cp, "cp"); + instruction = InstructionConst.getInstruction(Const.ICONST_0 + (value ? 1 : 0)); + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final Boolean value) { + this(cp, value.booleanValue()); + } + + /** + * 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 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 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)); + } + } + + /** + * 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 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 Number value) { + if (value instanceof Integer || value instanceof Short || value instanceof Byte) { + instruction = new PUSH(cp, value.intValue()).instruction; + } else if (value instanceof Double) { + instruction = new PUSH(cp, value.doubleValue()).instruction; + } else if (value instanceof Float) { + instruction = new PUSH(cp, value.floatValue()).instruction; + } else if (value instanceof Long) { + instruction = new PUSH(cp, value.longValue()).instruction; + } else { + throw new ClassGenException("What's this: " + value); + } + } + + /** + * + * @param cp + * @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 String value) { + if (value == null) { + instruction = InstructionConst.ACONST_NULL; + } else { + instruction = new LDC(cp.addString(value)); + } + } + + public Instruction getInstruction() { + return instruction; + } + + @Override + public InstructionList getInstructionList() { + return new InstructionList(instruction); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString() { + return instruction + " (PUSH)"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java new file mode 100644 index 000000000..185a01477 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java @@ -0,0 +1,81 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * PUTFIELD - Put field in object + * + *
    + * Stack: ..., objectref, value -> ...
    + * 
    + * + * OR + * + *
    + * Stack: ..., objectref, value.word1, value.word2 -> ...
    + * 
    + */ +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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + @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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java new file mode 100644 index 000000000..f74ec347e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * PUTSTATIC - Put static field in class + * + *
    + * Stack: ..., value -> ...
    + * 
    + * + * OR + * + *
    + * Stack: ..., value.word1, value.word2 -> ...
    + * 
    + */ +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); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + @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); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PopInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PopInstruction.java new file mode 100644 index 000000000..206299930 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PopInstruction.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to pop a value on top from the stack, such as ISTORE, POP, PUTSTATIC. + * + * @see ISTORE + * @see POP + */ +public interface PopInstruction extends StackConsumer { +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PushInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PushInstruction.java new file mode 100644 index 000000000..e792b38a8 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PushInstruction.java @@ -0,0 +1,37 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to produce a value on top of the stack, such as ILOAD, LDC, SIPUSH, DUP, + * ICONST, etc. + * + * + * @see ILOAD + * @see ICONST + * @see LDC + * @see DUP + * @see SIPUSH + * @see GETSTATIC + */ +public interface PushInstruction extends StackProducer { +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RET.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RET.java new file mode 100644 index 000000000..a7cacc7c1 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RET.java @@ -0,0 +1,140 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * RET - Return from subroutine + * + *
    + * Stack: ... -> ...
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.RET, (short) 2); + setIndex(index); // May set wide as side effect + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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(com.sun.org.apache.bcel.internal.Const.WIDE); + } + out.writeByte(super.getOpcode()); + if (wide) { + out.writeShort(index); + } else { + out.writeByte(index); + } + } + + /** + * @return index of local variable containg the return address + */ + @Override + public final int getIndex() { + return index; + } + + /** + * @return return address type + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return ReturnaddressType.NO_TARGET; + } + + /** + * 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); + } + } + + /** + * 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(); + } + + private void setWide() { + wide = index > com.sun.org.apache.bcel.internal.Const.MAX_BYTE; + if (wide) { + super.setLength(4); // Including the wide byte + } else { + super.setLength(2); + } + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + index; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RETURN.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RETURN.java new file mode 100644 index 000000000..0e6b594fa --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RETURN.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * RETURN - Return from void method + * + *
    + * Stack: ... -> <empty>
    + * 
    + */ +public class RETURN extends ReturnInstruction { + + public RETURN() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReferenceType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReferenceType.java new file mode 100644 index 000000000..fe75792e2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReferenceType.java @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.Repository; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Super class for object and array types. + */ +public abstract class ReferenceType extends Type { + + /** + * Class is non-abstract but not instantiable from the outside + */ + ReferenceType() { + super(Const.T_OBJECT, ""); + } + + protected ReferenceType(final byte t, final String s) { + super(t, s); + } + + /** + * 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) || 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? + } + return getFirstCommonSuperclassInternal(t); + } + + /** + * 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) || 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? + } + return getFirstCommonSuperclassInternal(t); + } + + private ReferenceType getFirstCommonSuperclassInternal(final ReferenceType t) throws ClassNotFoundException { + 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[] thizSups = Repository.getSuperClasses(thiz.getClassName()); + final JavaClass[] otherSups = Repository.getSuperClasses(other.getClassName()); + if (thizSups == null || otherSups == null) { + return null; + } + // Waaahh... + final JavaClass[] thisSups = new JavaClass[thizSups.length + 1]; + final JavaClass[] tSups = new JavaClass[otherSups.length + 1]; + System.arraycopy(thizSups, 0, thisSups, 1, thizSups.length); + System.arraycopy(otherSups, 0, tSups, 1, otherSups.length); + thisSups[0] = Repository.lookupClass(thiz.getClassName()); + tSups[0] = Repository.lookupClass(other.getClassName()); + for (final JavaClass tSup : tSups) { + for (final JavaClass thisSup : thisSups) { + if (thisSup.equals(tSup)) { + return ObjectType.getInstance(thisSup.getClassName()); + } + } + } + // Huh? Did you ask for Type.OBJECT's superclass?? + return null; + } + + /** + * 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 explicitly 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() + && (this.equals(T) || 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() + && 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() && 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() + && (this.equals(T) || 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() && 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. + } + + /** + * 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. + */ + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java new file mode 100644 index 000000000..0e132f431 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * Super class for the xRETURN family of instructions. + * + * @LastModified: Feb 2023 + */ +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); + } + + @Override + public Class[] getExceptions() { + return new Class[] {ExceptionConst.ILLEGAL_MONITOR_STATE}; + } + + 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); + } + } + + /** + * @return type associated with the instruction + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return getType(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java new file mode 100644 index 000000000..a35e83d26 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java @@ -0,0 +1,83 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Returnaddress, the type JSR or JSR_W instructions push upon the stack. + * + * see vmspec2 3.3.3 + */ +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; + } + + /** + * 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; + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + if (returnTarget == null) { + return 0; + } + return returnTarget.hashCode(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SALOAD.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SALOAD.java new file mode 100644 index 000000000..9499e5660 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SALOAD.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * SALOAD - Load short from array + * + *
    + * Stack: ..., arrayref, index -> ..., value
    + * 
    + */ +public class SALOAD extends ArrayInstruction implements StackProducer { + + public SALOAD() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SASTORE.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SASTORE.java new file mode 100644 index 000000000..c9c42d3d3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SASTORE.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * SASTORE - Store into short array + * + *
    + * Stack: ..., arrayref, index, value -> ...
    + * 
    + */ +public class SASTORE extends ArrayInstruction implements StackConsumer { + + public SASTORE() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SIPUSH.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SIPUSH.java new file mode 100644 index 000000000..513495e06 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SIPUSH.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * SIPUSH - Push short + * + *
    + * Stack: ... -> ..., value
    + * 
    + */ +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(com.sun.org.apache.bcel.internal.Const.SIPUSH, (short) 3); + this.b = b; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * Dump instruction as short code to stream out. + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.dump(out); + out.writeShort(b); + } + + /** + * @return Type.SHORT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.SHORT; + } + + @Override + public Number getValue() { + return Integer.valueOf(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(); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + b; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWAP.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWAP.java new file mode 100644 index 000000000..e3c0a46de --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWAP.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * SWAP - Swa top operand stack word + * + *
    + * Stack: ..., word2, word1 -> ..., word1, word2
    + * 
    + */ +public class SWAP extends StackInstruction implements StackConsumer, StackProducer { + + public SWAP() { + super(com.sun.org.apache.bcel.internal.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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWITCH.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWITCH.java new file mode 100644 index 000000000..aed1626ec --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWITCH.java @@ -0,0 +1,139 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Arrays; + +/** + * 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. + */ +public final class SWITCH implements CompoundInstruction { + + /** + * @return match is sorted in ascending order with no gap bigger than maxGap? + */ + private static boolean matchIsOrdered(final int[] match, final int matchLength, final int maxGap) { + for (int i = 1; i < matchLength; i++) { + if (match[i] - match[i - 1] > maxGap) { + return false; + } + } + return true; + } + + /** + * Sorts match and targets array with QuickSort. + */ + private static void sort(final int l, final int r, final int[] match, final InstructionHandle[] targets) { + int i = l; + int j = r; + int h; + final int m = match[l + r >>> 1]; + 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, match, targets); + } + if (i < r) { + sort(i, r, match, targets); + } + } + + private final Select instruction; + + public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target) { + this(match, targets, target, 1); + } + + /** + * Template for switch() constructs. If the match array can be sorted in ascending order with gaps no larger than + * maxGap 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 maxGap maximum gap that may between case branches + */ + public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int maxGap) { + int[] matchClone = match.clone(); + final InstructionHandle[] targetsClone = targets.clone(); + final int matchLength = match.length; + if (matchLength < 2) { + instruction = new TABLESWITCH(match, targets, target); + } else { + sort(0, matchLength - 1, matchClone, targetsClone); + if (matchIsOrdered(matchClone, matchLength, maxGap)) { + final int maxSize = matchLength + matchLength * maxGap; + final int[] mVec = new int[maxSize]; + final InstructionHandle[] tVec = new InstructionHandle[maxSize]; + int count = 1; + mVec[0] = match[0]; + tVec[0] = targets[0]; + for (int i = 1; i < matchLength; i++) { + final int prev = match[i - 1]; + final int gap = match[i] - prev; + for (int j = 1; j < gap; j++) { + mVec[count] = prev + j; + tVec[count] = target; + count++; + } + mVec[count] = match[i]; + tVec[count] = targets[i]; + count++; + } + instruction = new TABLESWITCH(Arrays.copyOf(mVec, count), Arrays.copyOf(tVec, count), target); + } else { + instruction = new LOOKUPSWITCH(matchClone, targetsClone, target); + } + } + } + + public Instruction getInstruction() { + return instruction; + } + + @Override + public InstructionList getInstructionList() { + return new InstructionList(instruction); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Select.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Select.java new file mode 100644 index 000000000..a90e795e9 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Select.java @@ -0,0 +1,372 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. + * + *

    + * We use our super's {@code target} property as the default target. + * + * @see LOOKUPSWITCH + * @see TABLESWITCH + * @see InstructionList + * @LastModified: May 2021 + */ +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; // 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]; + } + + @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; + } + + /** + * @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; + } + + /** + * Inform targets that they're not targeted anymore. + */ + @Override + void dispose() { + super.dispose(); + for (final InstructionHandle target2 : targets) { + target2.removeTargeter(this); + } + } + + /** + * 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()); + } + + /** + * @return the fixed_length + * @since 6.0 + */ + final int getFixedLength() { + return fixed_length; + } + + /** + * @return array of match target offsets + */ + public int[] getIndices() { + return indices; + } + + /** + * @return index entry from indices + * @since 6.0 + */ + final int getIndices(final int index) { + return indices[index]; + } + + /** + * @return match entry + * @since 6.0 + */ + final int getMatch(final int index) { + return match[index]; + } + + /** + * @return the match_length + * @since 6.0 + */ + final int getMatchLength() { + return match_length; + } + + /** + * @return array of match indices + */ + public int[] getMatchs() { + return match; + } + + /** + * + * @return the padding + * @since 6.0 + */ + final int getPadding() { + return padding; + } + + /** + * @return target entry + * @since 6.0 + */ + final InstructionHandle getTarget(final int index) { + return targets[index]; + } + + /** + * @return array of match targets + */ + public InstructionHandle[] getTargets() { + return targets; + } + + /** + * 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()); + } + + /** + * @param fixedLength the fixed_length to set + * @since 6.0 + */ + final void setFixedLength(final int fixedLength) { + this.fixed_length = fixedLength; + } + + /** @since 6.0 */ + final int setIndices(final int i, final int value) { + indices[i] = value; + return value; // Allow use in nested calls + } + + /** + * + * @param array + * @since 6.0 + */ + final void setIndices(final int[] array) { + indices = array; + } + + /** + * + * @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 setMatches(final int[] array) { + match = array; + } + + /** + * @param matchLength the match_length to set + * @since 6.0 + */ + final int setMatchLength(final int matchLength) { + this.match_length = matchLength; + return matchLength; + } + + /** + * 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 array + * @since 6.0 + */ + final void setTargets(final InstructionHandle[] array) { + targets = array; + } + + /** + * @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(); + } + + /** + * 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 maxOffset 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 maxOffset) { + setPosition(getPosition() + offset); // Additional offset caused by preceding SWITCHs, GOTOs, etc. + final short oldLength = (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() - oldLength; + } + + /** + * @param oldIh old target + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + boolean targeted = false; + if (super.getTarget() == oldIh) { + targeted = true; + setTarget(newIh); + } + for (int i = 0; i < targets.length; i++) { + if (targets[i] == oldIh) { + targeted = true; + setTarget(i, newIh); + } + } + if (!targeted) { + throw new ClassGenException("Not targeting " + oldIh); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java new file mode 100644 index 000000000..a4de20315 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java @@ -0,0 +1,239 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ConstantDouble; +import com.sun.org.apache.bcel.internal.classfile.ConstantFloat; +import com.sun.org.apache.bcel.internal.classfile.ConstantInteger; +import com.sun.org.apache.bcel.internal.classfile.ConstantLong; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.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 final int idx; + + 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 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 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 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 short value) { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final String value) { + super(type, cpGen); + idx = getConstantPool().addUtf8(value); + } + + // 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; + } + + /** + * 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 IllegalArgumentException("SimpleElementValueGen class does not know how to copy this 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 IllegalStateException("SimpleElementValueGen doesnt know how to write out type " + super.getElementValueType()); + } + } + + /** + * Return immutable variant + */ + @Override + public ElementValue getElementValue() { + return new SimpleElementValue(super.getElementValueType(), idx, getConstantPool().getConstantPool()); + } + + public int getIndex() { + return idx; + } + + public int getValueInt() { + if (super.getElementValueType() != PRIMITIVE_INT) { + throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx); + return c.getBytes(); + } + + public String getValueString() { + if (super.getElementValueType() != STRING) { + throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantUtf8 c = (ConstantUtf8) 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 IllegalStateException("SimpleElementValueGen class does not know how to stringify type " + super.getElementValueType()); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackConsumer.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackConsumer.java new file mode 100644 index 000000000..c0709a46b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackConsumer.java @@ -0,0 +1,33 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote an instruction that may consume a value from the stack. + */ +public interface StackConsumer { + + /** + * @return how many words are consumed from stack + */ + int consumeStack(ConstantPoolGen cpg); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackInstruction.java new file mode 100644 index 000000000..313215122 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackInstruction.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for stack operations like DUP and POP. + */ +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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackProducer.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackProducer.java new file mode 100644 index 000000000..f660e3b32 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackProducer.java @@ -0,0 +1,33 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an instruction that may produce a value on top of the stack (this excludes DUP_X1, e.g.) + */ +public interface StackProducer { + + /** + * @return how many words are produced on stack + */ + int produceStack(ConstantPoolGen cpg); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java new file mode 100644 index 000000000..ceef3a8b7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to store a value into a local variable, e.g. ISTORE. + */ +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 canonTag, final short cTag) { + super(canonTag, cTag); + } + + /** + * @param opcode Instruction opcode + * @param cTag Instruction number for compact version, ASTORE_0, e.g. + * @param n local variable index (unsigned short) + */ + protected StoreInstruction(final short opcode, final short cTag, final int n) { + super(opcode, cTag, 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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java new file mode 100644 index 000000000..e38da5eec --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java @@ -0,0 +1,109 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * TABLESWITCH - Switch within given range of values, i.e., low..high + * + * @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(com.sun.org.apache.bcel.internal.Const.TABLESWITCH, match, targets, defaultTarget); + /* Alignment remainder assumed 0 here, until dump time */ + final short length = (short) (13 + getMatchLength() * 4); + super.setLength(length); + setFixedLength(length); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, 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); + } + + /** + * 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 matchLength = getMatchLength(); + final int low = matchLength > 0 ? super.getMatch(0) : 0; + out.writeInt(low); + final int high = matchLength > 0 ? super.getMatch(matchLength - 1) : 0; + out.writeInt(high); + for (int i = 0; i < matchLength; 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 matchLength = high - low + 1; + setMatchLength(matchLength); + final short fixedLength = (short) (13 + matchLength * 4); + setFixedLength(fixedLength); + super.setLength((short) (fixedLength + super.getPadding())); + super.setMatches(new int[matchLength]); + super.setIndices(new int[matchLength]); + super.setTargets(new InstructionHandle[matchLength]); + for (int i = 0; i < matchLength; i++) { + super.setMatch(i, low + i); + super.setIndices(i, bytes.readInt()); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TargetLostException.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TargetLostException.java new file mode 100644 index 000000000..30310356f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TargetLostException.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 explicitly 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 + * @LastModified: Feb 2023 + */ +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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Type.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Type.java new file mode 100644 index 000000000..ea20710af --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Type.java @@ -0,0 +1,399 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ClassFormatException; +import com.sun.org.apache.bcel.internal.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[] + * @LastModified: May 2021 + */ +public abstract class Type { + + /** + * 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"); + + /** + * Empty array. + */ + public static final Type[] NO_ARGS = {}; + public static final ReferenceType NULL = new ReferenceType() { + }; + + public static final Type UNKNOWN = new Type(Const.T_UNKNOWN, "") { + }; + + private static final ThreadLocal CONSUMED_CHARS = ThreadLocal.withInitial(() -> Integer.valueOf(0)); + + // int consumed_chars=0; // Remember position in string, see getArgumentTypes + static int consumed(final int coded) { + return coded >> 2; + } + + static int encode(final int size, final int consumed) { + return consumed << 2 | size; + } + + /** + * 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; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + 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); + } + final Type[] types = new Type[vec.size()]; + vec.toArray(types); + return types; + } + + static int getArgumentTypesSize(final String signature) { + int res = 0; + int index; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + 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; + } + + /** + * Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I + * + * @param returnType what the method returns + * @param argTypes what are the argument types + * @return method signature for given type(s). + */ + public static String getMethodSignature(final Type returnType, final Type[] argTypes) { + final StringBuilder buf = new StringBuilder("("); + if (argTypes != null) { + for (final Type argType : argTypes) { + buf.append(argType.getSignature()); + } + } + buf.append(')'); + buf.append(returnType.getSignature()); + return buf.toString(); + } + + /** + * 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); + } + } + + static int getReturnTypeSize(final String signature) { + final int index = signature.lastIndexOf(')') + 1; + return Type.size(getTypeSize(signature.substring(index))); + } + + 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(); + } + + /** + * Convert runtime java.lang.Class to BCEL Type object. + * + * @param cls Java class + * @return corresponding Type object + */ + public static Type getType(final Class cls) { + Objects.requireNonNull(cls, "cls"); + /* + * That's an amzingly easy case, because getName() returns the signature. That's what we would have liked anyway. + */ + if (cls.isArray()) { + return getType(cls.getName()); + } + if (!cls.isPrimitive()) { // "Real" class + return ObjectType.getInstance(cls.getName()); + } + if (cls == Integer.TYPE) { + return INT; + } + if (cls == Void.TYPE) { + return VOID; + } + if (cls == Double.TYPE) { + return DOUBLE; + } + if (cls == Float.TYPE) { + return FLOAT; + } + if (cls == Boolean.TYPE) { + return BOOLEAN; + } + if (cls == Byte.TYPE) { + return BYTE; + } + if (cls == Short.TYPE) { + return SHORT; + } + if (cls == Long.TYPE) { + return LONG; + } + if (cls == Character.TYPE) { + return CHAR; + } + throw new IllegalStateException("Unknown primitive type " + cls); + } + + /** + * Convert signature to a Type object. + * + * @param signature signature string such as Ljava/lang/String; + * @return type object + */ + 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); + } + if (type != Const.T_ARRAY) { // type == T_REFERENCE + // Utility.typeSignatureToString understands how to parse generic types. + final String parsedSignature = Utility.typeSignatureToString(signature, false); + wrap(CONSUMED_CHARS, parsedSignature.length() + 2); // "Lblabla;" 'L' and ';' are removed + return ObjectType.getInstance(Utility.pathToPackage(parsedSignature)); + } + 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); + } + + /** + * 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 Class[] classes) { + final Type[] ret = new Type[classes.length]; + Arrays.setAll(ret, i -> getType(classes[i])); + return ret; + } + + 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); + } + 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); + } + final int index = signature.indexOf(';'); // Look for closing ';' + if (index < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + return encode(1, index + 1); + } + + static int size(final int coded) { + return coded & 3; + } + + 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)); + } + + /** + * @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 + + protected Type(final byte type, final String signature) { + this.type = type; + this.signature = signature; + } + + /** + * @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; + } + + public String getClassName() { + return toString(); + } + + /** + * @return signature for given type. + */ + public String getSignature() { + return signature; + } + + /** + * @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 as defined in Constants + */ + public byte getType() { + return type; + } + + /** + * @return hashcode of Type + */ + @Override + public int hashCode() { + return type ^ signature.hashCode(); + } + + /** + * 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; + } + + /* + * 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; + } + + /** + * @return Type string, e.g. 'int[]' + */ + @Override + public String toString() { + return this.equals(Type.NULL) || type >= Const.T_UNKNOWN ? signature : Utility.signatureToString(signature, false); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java new file mode 100644 index 000000000..5a22942a6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java @@ -0,0 +1,30 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Get the type associated with an instruction, int for ILOAD, or the type of the field of a PUTFIELD instruction, e.g.. + */ +public interface TypedInstruction { + + Type getType(ConstantPoolGen cpg); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java new file mode 100644 index 000000000..8ccd7313e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR. + * + * @see GOTO + * @see JSR + */ +public interface UnconditionalBranch { +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java new file mode 100644 index 000000000..63504550e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java @@ -0,0 +1,34 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an instruction to be a variable length instruction, such as GOTO, JSR, LOOKUPSWITCH and TABLESWITCH. + * + * + * @see GOTO + * @see JSR + * @see LOOKUPSWITCH + * @see TABLESWITCH + */ +public interface VariableLengthInstruction { +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Visitor.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Visitor.java new file mode 100644 index 000000000..fd70e8cd5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Visitor.java @@ -0,0 +1,394 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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. + */ +public interface Visitor { + + void visitAALOAD(AALOAD obj); + + void visitAASTORE(AASTORE obj); + + void visitACONST_NULL(ACONST_NULL obj); + + void visitAllocationInstruction(AllocationInstruction obj); + + void visitALOAD(ALOAD obj); + + void visitANEWARRAY(ANEWARRAY obj); + + void visitARETURN(ARETURN obj); + + void visitArithmeticInstruction(ArithmeticInstruction obj); + + void visitArrayInstruction(ArrayInstruction obj); + + void visitARRAYLENGTH(ARRAYLENGTH obj); + + void visitASTORE(ASTORE obj); + + void visitATHROW(ATHROW obj); + + void visitBALOAD(BALOAD obj); + + void visitBASTORE(BASTORE obj); + + void visitBIPUSH(BIPUSH obj); + + void visitBranchInstruction(BranchInstruction obj); + + void visitBREAKPOINT(BREAKPOINT obj); + + void visitCALOAD(CALOAD obj); + + void visitCASTORE(CASTORE obj); + + void visitCHECKCAST(CHECKCAST obj); + + void visitConstantPushInstruction(ConstantPushInstruction obj); + + void visitConversionInstruction(ConversionInstruction obj); + + void visitCPInstruction(CPInstruction obj); + + void visitD2F(D2F obj); + + void visitD2I(D2I obj); + + void visitD2L(D2L obj); + + void visitDADD(DADD obj); + + void visitDALOAD(DALOAD obj); + + void visitDASTORE(DASTORE obj); + + void visitDCMPG(DCMPG obj); + + void visitDCMPL(DCMPL obj); + + void visitDCONST(DCONST obj); + + void visitDDIV(DDIV obj); + + void visitDLOAD(DLOAD obj); + + void visitDMUL(DMUL obj); + + void visitDNEG(DNEG obj); + + void visitDREM(DREM obj); + + void visitDRETURN(DRETURN obj); + + void visitDSTORE(DSTORE obj); + + void visitDSUB(DSUB obj); + + void visitDUP(DUP obj); + + void visitDUP_X1(DUP_X1 obj); + + void visitDUP_X2(DUP_X2 obj); + + void visitDUP2(DUP2 obj); + + void visitDUP2_X1(DUP2_X1 obj); + + void visitDUP2_X2(DUP2_X2 obj); + + void visitExceptionThrower(ExceptionThrower obj); + + void visitF2D(F2D obj); + + void visitF2I(F2I obj); + + void visitF2L(F2L obj); + + void visitFADD(FADD obj); + + void visitFALOAD(FALOAD obj); + + void visitFASTORE(FASTORE obj); + + void visitFCMPG(FCMPG obj); + + void visitFCMPL(FCMPL obj); + + void visitFCONST(FCONST obj); + + void visitFDIV(FDIV obj); + + void visitFieldInstruction(FieldInstruction obj); + + void visitFieldOrMethod(FieldOrMethod obj); + + void visitFLOAD(FLOAD obj); + + void visitFMUL(FMUL obj); + + void visitFNEG(FNEG obj); + + void visitFREM(FREM obj); + + void visitFRETURN(FRETURN obj); + + void visitFSTORE(FSTORE obj); + + void visitFSUB(FSUB obj); + + void visitGETFIELD(GETFIELD obj); + + void visitGETSTATIC(GETSTATIC obj); + + void visitGOTO(GOTO obj); + + void visitGOTO_W(GOTO_W obj); + + void visitGotoInstruction(GotoInstruction obj); + + void visitI2B(I2B obj); + + void visitI2C(I2C obj); + + void visitI2D(I2D obj); + + void visitI2F(I2F obj); + + void visitI2L(I2L obj); + + void visitI2S(I2S obj); + + void visitIADD(IADD obj); + + void visitIALOAD(IALOAD obj); + + void visitIAND(IAND obj); + + void visitIASTORE(IASTORE obj); + + void visitICONST(ICONST obj); + + void visitIDIV(IDIV obj); + + void visitIF_ACMPEQ(IF_ACMPEQ obj); + + void visitIF_ACMPNE(IF_ACMPNE obj); + + void visitIF_ICMPEQ(IF_ICMPEQ obj); + + void visitIF_ICMPGE(IF_ICMPGE obj); + + void visitIF_ICMPGT(IF_ICMPGT obj); + + void visitIF_ICMPLE(IF_ICMPLE obj); + + void visitIF_ICMPLT(IF_ICMPLT obj); + + void visitIF_ICMPNE(IF_ICMPNE obj); + + void visitIFEQ(IFEQ obj); + + void visitIFGE(IFGE obj); + + void visitIFGT(IFGT obj); + + void visitIfInstruction(IfInstruction obj); + + void visitIFLE(IFLE obj); + + void visitIFLT(IFLT obj); + + void visitIFNE(IFNE obj); + + void visitIFNONNULL(IFNONNULL obj); + + void visitIFNULL(IFNULL obj); + + void visitIINC(IINC obj); + + void visitILOAD(ILOAD obj); + + void visitIMPDEP1(IMPDEP1 obj); + + void visitIMPDEP2(IMPDEP2 obj); + + void visitIMUL(IMUL obj); + + void visitINEG(INEG obj); + + void visitINSTANCEOF(INSTANCEOF obj); + + /** + * @since 6.0 + */ + void visitINVOKEDYNAMIC(INVOKEDYNAMIC obj); + + void visitInvokeInstruction(InvokeInstruction obj); + + void visitINVOKEINTERFACE(INVOKEINTERFACE obj); + + void visitINVOKESPECIAL(INVOKESPECIAL obj); + + void visitINVOKESTATIC(INVOKESTATIC obj); + + void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj); + + void visitIOR(IOR obj); + + void visitIREM(IREM obj); + + void visitIRETURN(IRETURN obj); + + void visitISHL(ISHL obj); + + void visitISHR(ISHR obj); + + void visitISTORE(ISTORE obj); + + void visitISUB(ISUB obj); + + void visitIUSHR(IUSHR obj); + + void visitIXOR(IXOR obj); + + void visitJSR(JSR obj); + + void visitJSR_W(JSR_W obj); + + void visitJsrInstruction(JsrInstruction obj); + + void visitL2D(L2D obj); + + void visitL2F(L2F obj); + + void visitL2I(L2I obj); + + void visitLADD(LADD obj); + + void visitLALOAD(LALOAD obj); + + void visitLAND(LAND obj); + + void visitLASTORE(LASTORE obj); + + void visitLCMP(LCMP obj); + + void visitLCONST(LCONST obj); + + void visitLDC(LDC obj); + + void visitLDC2_W(LDC2_W obj); + + void visitLDIV(LDIV obj); + + void visitLLOAD(LLOAD obj); + + void visitLMUL(LMUL obj); + + void visitLNEG(LNEG obj); + + void visitLoadClass(LoadClass obj); + + void visitLoadInstruction(LoadInstruction obj); + + void visitLocalVariableInstruction(LocalVariableInstruction obj); + + void visitLOOKUPSWITCH(LOOKUPSWITCH obj); + + void visitLOR(LOR obj); + + void visitLREM(LREM obj); + + void visitLRETURN(LRETURN obj); + + void visitLSHL(LSHL obj); + + void visitLSHR(LSHR obj); + + void visitLSTORE(LSTORE obj); + + void visitLSUB(LSUB obj); + + void visitLUSHR(LUSHR obj); + + void visitLXOR(LXOR obj); + + void visitMONITORENTER(MONITORENTER obj); + + void visitMONITOREXIT(MONITOREXIT obj); + + void visitMULTIANEWARRAY(MULTIANEWARRAY obj); + + void visitNEW(NEW obj); + + void visitNEWARRAY(NEWARRAY obj); + + void visitNOP(NOP obj); + + void visitPOP(POP obj); + + void visitPOP2(POP2 obj); + + void visitPopInstruction(PopInstruction obj); + + void visitPushInstruction(PushInstruction obj); + + void visitPUTFIELD(PUTFIELD obj); + + void visitPUTSTATIC(PUTSTATIC obj); + + void visitRET(RET obj); + + void visitRETURN(RETURN obj); + + void visitReturnInstruction(ReturnInstruction obj); + + void visitSALOAD(SALOAD obj); + + void visitSASTORE(SASTORE obj); + + void visitSelect(Select obj); + + void visitSIPUSH(SIPUSH obj); + + void visitStackConsumer(StackConsumer obj); + + void visitStackInstruction(StackInstruction obj); + + void visitStackProducer(StackProducer obj); + + void visitStoreInstruction(StoreInstruction obj); + + void visitSWAP(SWAP obj); + + void visitTABLESWITCH(TABLESWITCH obj); + + void visitTypedInstruction(TypedInstruction obj); + + void visitUnconditionalBranch(UnconditionalBranch obj); + + void visitVariableLengthInstruction(VariableLengthInstruction obj); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/package.html new file mode 100644 index 000000000..d8a276d06 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/package.html new file mode 100644 index 000000000..2b6dd18ef --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Args.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Args.java new file mode 100644 index 000000000..a61d9d35d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Args.java @@ -0,0 +1,148 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ClassFormatException; + +/** + * Argument validation. + * + * @since 6.7.0 + */ +public class Args { + + /** + * Requires a specific value. + * + * @param value The value to test. + * @param required The required value. + * @param message The message prefix + * @return The value to test. + */ + public static int require(final int value, final int required, final String message) { + if (value != required) { + throw new ClassFormatException(String.format("%s [Value must be 0: %,d]", message, value)); + } + return value; + } + + /** + * Requires a 0 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int require0(final int value, final String message) { + return require(value, 0, message); + } + + /** + * Requires a u1 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU1(final int value, final String message) { + if (value < 0 || value > Const.MAX_BYTE) { + throw new ClassFormatException(String.format("%s [Value out of range (0 - %,d) for type u1: %,d]", message, Const.MAX_BYTE, value)); + } + return value; + } + + /** + * Requires a u2 value of at least {@code min} and not above {@code max}. + * + * @param value The value to test. + * @param min The minimum required u2 value. + * @param max The maximum required u2 value. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU2(final int value, final int min, final int max, final String message) { + if (max > Const.MAX_SHORT) { + throw new IllegalArgumentException(String.format("%s programming error: max %,d > %,d", message, max, Const.MAX_SHORT)); + } + if (min < 0) { + throw new IllegalArgumentException(String.format("%s programming error: min %,d < 0", message, min)); + } + if (value < min || value > max) { + throw new ClassFormatException(String.format("%s [Value out of range (%,d - %,d) for type u2: %,d]", message, min, Const.MAX_SHORT, value)); + } + return value; + } + + /** + * Requires a u2 value of at least {@code min}. + * + * @param value The value to test. + * @param min The minimum required value. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU2(final int value, final int min, final String message) { + return requireU2(value, min, Const.MAX_SHORT, message); + } + + /** + * Requires a u2 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU2(final int value, final String message) { + return requireU2(value, 0, message); + } + + /** + * Requires a u4 value of at least {@code min}. + * + * @param value The value to test. + * @param min The minimum required value. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU4(final int value, final int min, final String message) { + if (min < 0) { + throw new IllegalArgumentException(String.format("%s programming error: min %,d < 0", message, min)); + } + if (value < min) { + throw new ClassFormatException( + String.format("%s [Value out of range (%,d - %,d) for type u2: %,d]", message, min, Integer.MAX_VALUE, value & 0xFFFFFFFFL)); + } + return value; + } + + /** + * Requires a u4 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU4(final int value, final String message) { + return requireU4(value, 0, message); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/AttributeHTML.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/AttributeHTML.java new file mode 100644 index 000000000..4a84901fc --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/AttributeHTML.java @@ -0,0 +1,195 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.Closeable; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.CodeException; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantValue; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.InnerClass; +import com.sun.org.apache.bcel.internal.classfile.InnerClasses; +import com.sun.org.apache.bcel.internal.classfile.LineNumber; +import com.sun.org.apache.bcel.internal.classfile.LineNumberTable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable; +import com.sun.org.apache.bcel.internal.classfile.SourceFile; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert found attributes into HTML file. + */ +final class AttributeHTML implements Closeable { + + private final String className; // name of current class + private final PrintWriter printWriter; // file to write to + private int attrCount; + private final ConstantHTML constantHtml; + private final ConstantPool constantPool; + + AttributeHTML(final String dir, final String className, final ConstantPool constantPool, final ConstantHTML constantHtml, final Charset charset) + throws FileNotFoundException, UnsupportedEncodingException { + this.className = className; + this.constantPool = constantPool; + this.constantHtml = constantHtml; + printWriter = new PrintWriter(dir + className + "_attributes.html", charset.name()); + printWriter.print(""); + printWriter.println("
    "); + } + + @Override + public void close() { + printWriter.println("
    "); + printWriter.close(); + } + + private String codeLink(final int link, final int methodNumber) { + return "" + link + ""; + } + + void writeAttribute(final Attribute attribute, final String anchor) { + writeAttribute(attribute, anchor, 0); + } + + void writeAttribute(final Attribute attribute, final String anchor, final int methodNumber) { + final byte tag = attribute.getTag(); + int index; + if (tag == Const.ATTR_UNKNOWN) { + return; + } + attrCount++; // Increment number of attributes found so far + if (attrCount % 2 == 0) { + printWriter.print(""); + } else { + printWriter.print(""); + } + printWriter.println("

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

    "); + /* + * Handle different attributes + */ + switch (tag) { + case Const.ATTR_CODE: + final Code c = (Code) attribute; + // Some directly printable values + printWriter.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) { + printWriter.print("

    Exceptions handled

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

    "); + for (int i = 0; i < lineNumbers.length; i++) { + printWriter.print("(" + lineNumbers[i].getStartPC() + ", " + lineNumbers[i].getLineNumber() + ")"); + if (i < lineNumbers.length - 1) { + printWriter.print(", "); // breakable + } + } + break; + case Const.ATTR_LOCAL_VARIABLE_TABLE: + // List name, range and type + printWriter.print("

      "); + ((LocalVariableTable) attribute).forEach(var -> { + final int sigIdx = var.getSignatureIndex(); + String signature = constantPool.getConstantUtf8(sigIdx).getBytes(); + signature = Utility.signatureToString(signature, false); + final int start = var.getStartPC(); + final int end = start + var.getLength(); + printWriter.println("
    • " + Class2HTML.referenceType(signature) + " " + var.getName() + " in slot %" + var.getIndex() + + "
      Valid from lines " + "" + start + + " to " + "" + end + "
    • "); + }); + printWriter.print("
    \n"); + break; + case Const.ATTR_INNER_CLASSES: + // List inner classes + printWriter.print("
      "); + for (final InnerClass clazz : ((InnerClasses) attribute).getInnerClasses()) { + final String name; + final String access; + index = clazz.getInnerNameIndex(); + if (index > 0) { + name = constantPool.getConstantUtf8(index).getBytes(); + } else { + name = "<anonymous>"; + } + access = Utility.accessToString(clazz.getInnerAccessFlags()); + printWriter.print("
    • " + access + " " + constantHtml.referenceConstant(clazz.getInnerClassIndex()) + + " in class " + constantHtml.referenceConstant(clazz.getOuterClassIndex()) + " named " + name + "
    • \n"); + } + printWriter.print("
    \n"); + break; + default: // Such as Unknown attribute or Deprecated + printWriter.print("

    " + attribute); + } + printWriter.println(""); + printWriter.flush(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELComparator.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELComparator.java new file mode 100644 index 000000000..2e663bfda --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELComparator.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +/** + * Used for BCEL comparison strategy + * + * @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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELFactory.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELFactory.java new file mode 100644 index 000000000..c931fb1e4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELFactory.java @@ -0,0 +1,340 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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 com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.generic.AllocationInstruction; +import com.sun.org.apache.bcel.internal.generic.ArrayInstruction; +import com.sun.org.apache.bcel.internal.generic.ArrayType; +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.BranchInstruction; +import com.sun.org.apache.bcel.internal.generic.CHECKCAST; +import com.sun.org.apache.bcel.internal.generic.CPInstruction; +import com.sun.org.apache.bcel.internal.generic.CodeExceptionGen; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ConstantPushInstruction; +import com.sun.org.apache.bcel.internal.generic.EmptyVisitor; +import com.sun.org.apache.bcel.internal.generic.FieldInstruction; +import com.sun.org.apache.bcel.internal.generic.IINC; +import com.sun.org.apache.bcel.internal.generic.INSTANCEOF; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionConst; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InvokeInstruction; +import com.sun.org.apache.bcel.internal.generic.LDC; +import com.sun.org.apache.bcel.internal.generic.LDC2_W; +import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction; +import com.sun.org.apache.bcel.internal.generic.MULTIANEWARRAY; +import com.sun.org.apache.bcel.internal.generic.MethodGen; +import com.sun.org.apache.bcel.internal.generic.NEWARRAY; +import com.sun.org.apache.bcel.internal.generic.ObjectType; +import com.sun.org.apache.bcel.internal.generic.RET; +import com.sun.org.apache.bcel.internal.generic.ReturnInstruction; +import com.sun.org.apache.bcel.internal.generic.Select; +import com.sun.org.apache.bcel.internal.generic.Type; + +/** + * Factory creates il.append() statements, and sets instruction targets. A helper class for BCELifier. + * + * @see BCELifier + * @LastModified: Feb 2023 + */ +class BCELFactory extends EmptyVisitor { + + private static final String CONSTANT_PREFIX = Const.class.getSimpleName() + "."; + private final MethodGen methodGen; + private final PrintWriter printWriter; + private final ConstantPoolGen constantPoolGen; + + private final Map branchMap = new HashMap<>(); + + // Memorize BranchInstructions that need an update + private final List branches = new ArrayList<>(); + + BCELFactory(final MethodGen mg, final PrintWriter out) { + methodGen = mg; + constantPoolGen = mg.getConstantPool(); + printWriter = out; + } + + 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) { + final Float f = (Float) value; + if (Float.isNaN(f)) { + embed = "Float.NaN"; + } else if (f == Float.POSITIVE_INFINITY) { + embed = "Float.POSITIVE_INFINITY"; + } else if (f == Float.NEGATIVE_INFINITY) { + embed = "Float.NEGATIVE_INFINITY"; + } else { + embed += "f"; + } + } else if (value instanceof Double) { + final Double d = (Double) value; + if (Double.isNaN(d)) { + embed = "Double.NaN"; + } else if (d == Double.POSITIVE_INFINITY) { + embed = "Double.POSITIVE_INFINITY"; + } else if (d == Double.NEGATIVE_INFINITY) { + embed = "Double.NEGATIVE_INFINITY"; + } else { + embed += "d"; + } + } else if (value instanceof Long) { + embed += "L"; + } else if (value instanceof ObjectType) { + final ObjectType ot = (ObjectType) value; + embed = "new ObjectType(\"" + ot.getClassName() + "\")"; + } else if (value instanceof ArrayType) { + final ArrayType at = (ArrayType) value; + embed = "new ArrayType(" + BCELifier.printType(at.getBasicType()) + ", " + at.getDimensions() + ")"; + } + + printWriter.println("il.append(new PUSH(_cp, " + embed + "));"); + } + + public void start() { + if (!methodGen.isAbstract() && !methodGen.isNative()) { + for (InstructionHandle ih = methodGen.getInstructionList().getStart(); ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof BranchInstruction) { + branchMap.put(i, ih); // memorize container + } + if (ih.hasTargeters()) { + if (i instanceof BranchInstruction) { + printWriter.println(" InstructionHandle ih_" + ih.getPosition() + ";"); + } else { + printWriter.print(" InstructionHandle ih_" + ih.getPosition() + " = "); + } + } else { + printWriter.print(" "); + } + if (!visitInstruction(i)) { + i.accept(this); + } + } + updateBranchTargets(); + updateExceptionHandlers(); + } + } + + private void updateBranchTargets() { + branches.forEach(bi -> { + final BranchHandle bh = (BranchHandle) branchMap.get(bi); + final int pos = bh.getPosition(); + final String name = bi.getName() + "_" + pos; + int targetPos = bh.getTarget().getPosition(); + printWriter.println(" " + name + ".setTarget(ih_" + targetPos + ");"); + if (bi instanceof Select) { + final InstructionHandle[] ihs = ((Select) bi).getTargets(); + for (int j = 0; j < ihs.length; j++) { + targetPos = ihs[j].getPosition(); + printWriter.println(" " + name + ".setTarget(" + j + ", ih_" + targetPos + ");"); + } + } + }); + } + + private void updateExceptionHandlers() { + final CodeExceptionGen[] handlers = methodGen.getExceptionHandlers(); + for (final CodeExceptionGen h : handlers) { + final String type = h.getCatchType() == null ? "null" : BCELifier.printType(h.getCatchType()); + printWriter.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + ", " + "ih_" + h.getEndPC().getPosition() + ", " + + "ih_" + h.getHandlerPC().getPosition() + ", " + type + ");"); + } + } + + @Override + @SuppressWarnings("fallthrough") // by design for case Const.ANEWARRAY + public void visitAllocationInstruction(final AllocationInstruction i) { + Type type; + if (i instanceof CPInstruction) { + type = ((CPInstruction) i).getType(constantPoolGen); + } else { + type = ((NEWARRAY) i).getType(); + } + final short opcode = ((Instruction) i).getOpcode(); + int dim = 1; + switch (opcode) { + case Const.NEW: + printWriter.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName() + "\"));"); + break; + case Const.MULTIANEWARRAY: + dim = ((MULTIANEWARRAY) i).getDimensions(); + //$FALL-THROUGH$ + case Const.NEWARRAY: + if (type instanceof ArrayType) { + type = ((ArrayType) type).getBasicType(); + } + //$FALL-THROUGH$ + case Const.ANEWARRAY: + printWriter.println("il.append(_factory.createNewArray(" + BCELifier.printType(type) + ", (short) " + dim + "));"); + break; + default: + throw new IllegalArgumentException("Unhandled opcode: " + opcode); + } + } + + @Override + public void visitArrayInstruction(final ArrayInstruction i) { + final short opcode = i.getOpcode(); + final Type type = i.getType(constantPoolGen); + final String kind = opcode < Const.IASTORE ? "Load" : "Store"; + printWriter.println("il.append(_factory.createArray" + kind + "(" + BCELifier.printType(type) + "));"); + } + + @Override + public void visitBranchInstruction(final BranchInstruction bi) { + final BranchHandle bh = (BranchHandle) branchMap.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(" }"); + printWriter.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH) + "(" + args + ", new InstructionHandle[] { "); + for (int i = 0; i < matchs.length; i++) { + printWriter.print("null"); + if (i < matchs.length - 1) { + printWriter.print(", "); + } + } + printWriter.println(" }, null);"); + } else { + final int tPos = bh.getTarget().getPosition(); + String target; + if (pos > tPos) { + target = "ih_" + tPos; + } else { + branches.add(bi); + target = "null"; + } + printWriter.println(" BranchInstruction " + name + " = _factory.createBranchInstruction(" + CONSTANT_PREFIX + + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target + ");"); + } + if (bh.hasTargeters()) { + printWriter.println(" ih_" + pos + " = il.append(" + name + ");"); + } else { + printWriter.println(" il.append(" + name + ");"); + } + } + + @Override + public void visitCHECKCAST(final CHECKCAST i) { + final Type type = i.getType(constantPoolGen); + printWriter.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));"); + } + + @Override + public void visitConstantPushInstruction(final ConstantPushInstruction i) { + createConstant(i.getValue()); + } + + @Override + public void visitFieldInstruction(final FieldInstruction i) { + final short opcode = i.getOpcode(); + final String className = i.getReferenceType(constantPoolGen).getClassName(); + final String fieldName = i.getFieldName(constantPoolGen); + final Type type = i.getFieldType(constantPoolGen); + printWriter.println("il.append(_factory.createFieldAccess(\"" + className + "\", \"" + fieldName + "\", " + BCELifier.printType(type) + ", " + + CONSTANT_PREFIX + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));"); + } + + @Override + public void visitINSTANCEOF(final INSTANCEOF i) { + final Type type = i.getType(constantPoolGen); + printWriter.println("il.append(_factory.createInstanceOf(" + BCELifier.printType(type) + "));"); + } + + private boolean visitInstruction(final Instruction i) { + final short opcode = i.getOpcode(); + if (InstructionConst.getInstruction(opcode) != null && !(i instanceof ConstantPushInstruction) && !(i instanceof ReturnInstruction)) { // Handled below + printWriter.println("il.append(InstructionConst." + i.getName().toUpperCase(Locale.ENGLISH) + ");"); + return true; + } + return false; + } + + @Override + public void visitInvokeInstruction(final InvokeInstruction i) { + final short opcode = i.getOpcode(); + final String className = i.getReferenceType(constantPoolGen).getClassName(); + final String methodName = i.getMethodName(constantPoolGen); + final Type type = i.getReturnType(constantPoolGen); + final Type[] argTypes = i.getArgumentTypes(constantPoolGen); + printWriter.println("il.append(_factory.createInvoke(\"" + className + "\", \"" + methodName + "\", " + BCELifier.printType(type) + ", " + + BCELifier.printArgumentTypes(argTypes) + ", " + CONSTANT_PREFIX + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));"); + } + + @Override + public void visitLDC(final LDC i) { + createConstant(i.getValue(constantPoolGen)); + } + + @Override + public void visitLDC2_W(final LDC2_W i) { + createConstant(i.getValue(constantPoolGen)); + } + + @Override + public void visitLocalVariableInstruction(final LocalVariableInstruction i) { + final short opcode = i.getOpcode(); + final Type type = i.getType(constantPoolGen); + if (opcode == Const.IINC) { + printWriter.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() + "));"); + } else { + final String kind = opcode < Const.ISTORE ? "Load" : "Store"; + printWriter.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + ", " + i.getIndex() + "));"); + } + } + + @Override + public void visitRET(final RET i) { + printWriter.println("il.append(new RET(" + i.getIndex() + "));"); + } + + @Override + public void visitReturnInstruction(final ReturnInstruction i) { + final Type type = i.getType(constantPoolGen); + printWriter.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELifier.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELifier.java new file mode 100644 index 000000000..151083ea7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELifier.java @@ -0,0 +1,322 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.Locale; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.Repository; +import com.sun.org.apache.bcel.internal.classfile.ClassParser; +import com.sun.org.apache.bcel.internal.classfile.ConstantValue; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.generic.ArrayType; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.MethodGen; +import com.sun.org.apache.bcel.internal.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. + * + * @LastModified: Feb 2023 + */ +public class BCELifier extends com.sun.org.apache.bcel.internal.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() + "."; + + // Needs to be accessible from unit test code + static JavaClass getJavaClass(final String name) throws ClassNotFoundException, IOException { + JavaClass javaClass; + if ((javaClass = Repository.lookupClass(name)) == null) { + javaClass = new ClassParser(name).parse(); // May throw IOException + } + return javaClass; + } + + /** + * 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 BCELifier bcelifier = new BCELifier(getJavaClass(argv[0]), System.out); + bcelifier.start(); + } + + static String printArgumentTypes(final Type[] argTypes) { + if (argTypes.length == 0) { + return "Type.NO_ARGS"; + } + final StringBuilder args = new StringBuilder(); + for (int i = 0; i < argTypes.length; i++) { + args.append(printType(argTypes[i])); + if (i < argTypes.length - 1) { + args.append(", "); + } + } + return "new Type[] { " + args.toString() + " }"; + } + + 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; i++) { + if ((flags & pow) != 0) { + if (pow == Const.ACC_SYNCHRONIZED && location == FLAGS.CLASS) { + buf.append(CONSTANT_PREFIX).append("ACC_SUPER | "); + } else if (pow == Const.ACC_VOLATILE && location == FLAGS.METHOD) { + buf.append(CONSTANT_PREFIX).append("ACC_BRIDGE | "); + } else if (pow == Const.ACC_TRANSIENT && location == FLAGS.METHOD) { + buf.append(CONSTANT_PREFIX).append("ACC_VARARGS | "); + } else if (i < Const.ACCESS_NAMES_LENGTH) { + buf.append(CONSTANT_PREFIX).append("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 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); + } + if (type.toString().equals("java.lang.String")) { + return "Type.STRING"; + } + if (type.toString().equals("java.lang.Object")) { + return "Type.OBJECT"; + } + if (type.toString().equals("java.lang.StringBuffer")) { + return "Type.STRINGBUFFER"; + } + if (type instanceof ArrayType) { + final ArrayType at = (ArrayType) type; + return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions() + ")"; + } + return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")"; + } + + static String printType(final Type type) { + return printType(type.getSignature()); + } + + private final JavaClass clazz; + + private final PrintWriter printWriter; + + private final ConstantPoolGen constantPoolGen; + + /** + * Constructs a new instance. + * + * @param clazz Java class to "decompile". + * @param out where to print the Java program in UTF-8. + */ + public BCELifier(final JavaClass clazz, final OutputStream out) { + this.clazz = clazz; + this.printWriter = new PrintWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8), false); + this.constantPoolGen = new ConstantPoolGen(this.clazz.getConstantPool()); + } + + private void printCreate() { + printWriter.println(" public void create(OutputStream out) throws IOException {"); + final Field[] fields = clazz.getFields(); + if (fields.length > 0) { + printWriter.println(" createFields();"); + } + final Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + printWriter.println(" createMethod_" + i + "();"); + } + printWriter.println(" _cg.getJavaClass().dump(out);"); + printWriter.println(" }"); + printWriter.println(); + } + + private void printMain() { + final String className = clazz.getClassName(); + printWriter.println(" public static void main(String[] args) throws Exception {"); + printWriter.println(" " + className + "Creator creator = new " + className + "Creator();"); + printWriter.println(" creator.create(new FileOutputStream(\"" + className + ".class\"));"); + printWriter.println(" }"); + } + + /** + * Start Java code generation + */ + public void start() { + visitJavaClass(clazz); + printWriter.flush(); + } + + @Override + public void visitField(final Field field) { + printWriter.println(); + printWriter.println( + " field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", " + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);"); + final ConstantValue cv = field.getConstantValue(); + if (cv != null) { + printWriter.print(" field.setInitValue("); + if (field.getType() == Type.CHAR) { + printWriter.print("(char)"); + } + if (field.getType() == Type.SHORT) { + printWriter.print("(short)"); + } + if (field.getType() == Type.BYTE) { + printWriter.print("(byte)"); + } + printWriter.print(cv); + if (field.getType() == Type.LONG) { + printWriter.print("L"); + } + if (field.getType() == Type.FLOAT) { + printWriter.print("F"); + } + if (field.getType() == Type.DOUBLE) { + printWriter.print("D"); + } + printWriter.println(");"); + } + printWriter.println(" _cg.addField(field.getField());"); + } + + @Override + public void visitJavaClass(final JavaClass clazz) { + String className = clazz.getClassName(); + final String superName = clazz.getSuperclassName(); + final String packageName = clazz.getPackageName(); + final String inter = Utility.printArray(clazz.getInterfaceNames(), false, true); + if (packageName != null && !packageName.trim().isEmpty()) { + className = className.substring(packageName.length() + 1); + printWriter.println("package " + packageName + ";"); + printWriter.println(); + } + printWriter.println("import " + BASE_PACKAGE + ".generic.*;"); + printWriter.println("import " + BASE_PACKAGE + ".classfile.*;"); + printWriter.println("import " + BASE_PACKAGE + ".*;"); + printWriter.println("import java.io.*;"); + printWriter.println(); + printWriter.println("public class " + className + "Creator {"); + printWriter.println(" private InstructionFactory _factory;"); + printWriter.println(" private ConstantPoolGen _cp;"); + printWriter.println(" private ClassGen _cg;"); + printWriter.println(); + printWriter.println(" public " + className + "Creator() {"); + printWriter.println(" _cg = new ClassGen(\"" + (packageName.isEmpty() ? className : packageName + "." + className) + "\", \"" + superName + + "\", " + "\"" + clazz.getSourceFileName() + "\", " + printFlags(clazz.getAccessFlags(), FLAGS.CLASS) + ", " + "new String[] { " + inter + " });"); + printWriter.println(" _cg.setMajor(" + clazz.getMajor() + ");"); + printWriter.println(" _cg.setMinor(" + clazz.getMinor() + ");"); + printWriter.println(); + printWriter.println(" _cp = _cg.getConstantPool();"); + printWriter.println(" _factory = new InstructionFactory(_cg, _cp);"); + printWriter.println(" }"); + printWriter.println(); + printCreate(); + final Field[] fields = clazz.getFields(); + if (fields.length > 0) { + printWriter.println(" private void createFields() {"); + printWriter.println(" FieldGen field;"); + for (final Field field : fields) { + field.accept(this); + } + printWriter.println(" }"); + printWriter.println(); + } + final Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + printWriter.println(" private void createMethod_" + i + "() {"); + methods[i].accept(this); + printWriter.println(" }"); + printWriter.println(); + } + printMain(); + printWriter.println("}"); + } + + @Override + public void visitMethod(final Method method) { + final MethodGen mg = new MethodGen(method, clazz.getClassName(), constantPoolGen); + printWriter.println(" InstructionList il = new InstructionList();"); + printWriter.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);"); + final ExceptionTable exceptionTable = method.getExceptionTable(); + if (exceptionTable != null) { + final String[] exceptionNames = exceptionTable.getExceptionNames(); + for (final String exceptionName : exceptionNames) { + printWriter.print(" method.addException(\""); + printWriter.print(exceptionName); + printWriter.println("\");"); + } + } + printWriter.println(); + final BCELFactory factory = new BCELFactory(mg, printWriter); + factory.start(); + printWriter.println(" method.setMaxStack();"); + printWriter.println(" method.setMaxLocals();"); + printWriter.println(" _cg.addMethod(method.getMethod());"); + printWriter.println(" il.dispose();"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ByteSequence.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ByteSequence.java new file mode 100644 index 000000000..65dfd3f3e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ByteSequence.java @@ -0,0 +1,65 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.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. + */ +public final class ByteSequence extends DataInputStream { + + private static final class ByteArrayStream extends ByteArrayInputStream { + + ByteArrayStream(final byte[] bytes) { + super(bytes); + } + + int getPosition() { + // pos is protected in ByteArrayInputStream + return pos; + } + + void unreadByte() { + if (pos > 0) { + pos--; + } + } + } + + private final ByteArrayStream byteStream; + + public ByteSequence(final byte[] bytes) { + super(new ByteArrayStream(bytes)); + byteStream = (ByteArrayStream) in; + } + + public int getIndex() { + return byteStream.getPosition(); + } + + void unreadByte() { + byteStream.unreadByte(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Class2HTML.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Class2HTML.java new file mode 100644 index 000000000..f644c698b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Class2HTML.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Set; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.ClassParser; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.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. + * + * @LastModified: Feb 2023 + */ +public class Class2HTML { + + private static String classPackage; // name of package, unclean to make it static, but ... + private static String className; // name of current class, dito + private static ConstantPool constantPool; + private static final Set basicTypes = new HashSet<>(); + static { + basicTypes.add("int"); + basicTypes.add("short"); + basicTypes.add("boolean"); + basicTypes.add("void"); + basicTypes.add("char"); + basicTypes.add("byte"); + basicTypes.add("long"); + basicTypes.add("double"); + basicTypes.add("float"); + } + + public static void _main(final String[] argv) throws IOException { + final String[] fileName = new String[argv.length]; + int files = 0; + ClassParser parser = null; + JavaClass javaClass = null; + String zipFile = 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 && !store.isDirectory()) { + System.out.println("Tried to create the directory " + dir + " but failed"); + } + } + } else if (argv[i].equals("-zip")) { + zipFile = argv[++i]; + } else { + System.out.println("Unknown option " + argv[i]); + } + } else { + fileName[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 " + fileName[i] + "..."); + if (zipFile == null) { + parser = new ClassParser(fileName[i]); // Create parser object from file + } else { + parser = new ClassParser(zipFile, fileName[i]); // Create parser object from zip file + } + javaClass = parser.parse(); + new Class2HTML(javaClass, 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 = constantPool.getConstantString(index, Const.CONSTANT_Class); + str = Utility.compactClassName(str); + str = Utility.compactClassName(str, classPackage + ".", true); + return "" + str + ""; + } + + static String referenceType(final String type) { + String shortType = Utility.compactClassName(type); + shortType = Utility.compactClassName(shortType, classPackage + ".", true); + final int index = type.indexOf('['); // Type is an array? + String baseType = type; + if (index > -1) { + baseType = type.substring(0, index); // Tack of the '[' + } + // test for basic type + if (basicTypes.contains(baseType)) { + return "" + type + ""; + } + return "" + shortType + ""; + } + + 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 final JavaClass javaClass; // current class object + + private final String dir; + + /** + * Write contents of the given JavaClass into HTML files. + * + * @param javaClass The class to write + * @param dir The directory to put the files in + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public Class2HTML(final JavaClass javaClass, final String dir) throws IOException { + this(javaClass, dir, StandardCharsets.UTF_8); + } + + private Class2HTML(final JavaClass javaClass, final String dir, final Charset charset) throws IOException { + final Method[] methods = javaClass.getMethods(); + this.javaClass = javaClass; + this.dir = dir; + className = javaClass.getClassName(); // Remember full name + constantPool = javaClass.getConstantPool(); + // Get package name by tacking off everything after the last '.' + final int index = className.lastIndexOf('.'); + if (index > -1) { + classPackage = className.substring(0, index); + } else { + classPackage = ""; // default package + } + final ConstantHTML constantHtml = new ConstantHTML(dir, className, classPackage, methods, constantPool, charset); + /* + * Attributes can't be written in one step, so we just open a file which will be written consequently. + */ + try (AttributeHTML attributeHtml = new AttributeHTML(dir, className, constantPool, constantHtml, charset)) { + new MethodHTML(dir, className, methods, javaClass.getFields(), constantHtml, attributeHtml, charset); + // Write main file (with frames, yuk) + writeMainHTML(attributeHtml, charset); + new CodeHTML(dir, className, methods, constantPool, constantHtml, charset); + } + } + + private void writeMainHTML(final AttributeHTML attributeHtml, final Charset charset) throws FileNotFoundException, UnsupportedEncodingException { + try (PrintWriter file = new PrintWriter(dir + className + ".html", charset.name())) { + file.println("\n" + "Documentation for " + className + "" + "\n" + "\n" + + "\n" + "\n" + "\n" + "\n" + + "\n" + "\n" + "\n" + ""); + } + final Attribute[] attributes = javaClass.getAttributes(); + for (int i = 0; i < attributes.length; i++) { + attributeHtml.writeAttribute(attributes[i], "class" + i); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassQueue.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassQueue.java new file mode 100644 index 000000000..82c4e5216 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassQueue.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import java.util.LinkedList; + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Utility class implementing a (typesafe) queue of JavaClass objects. + * @LastModified: Jan 2020 + */ +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 JavaClass dequeue() { + return vec.removeFirst(); + } + + public boolean empty() { + return vec.isEmpty(); + } + + public void enqueue(final JavaClass clazz) { + vec.addLast(clazz); + } + + @Override + public String toString() { + return vec.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassSet.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassSet.java new file mode 100644 index 000000000..178ccc786 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassSet.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import com.sun.org.apache.bcel.internal.Const; +import java.util.HashMap; +import java.util.Map; + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Utility class implementing a (type-safe) set of JavaClass objects. Since JavaClass has no equals() method, the name of the class is used for comparison. + * + * @see ClassStack + * @LastModified: Feb 2023 + */ +public class ClassSet { + + private final Map map = new HashMap<>(); + + public boolean add(final JavaClass clazz) { + return map.putIfAbsent(clazz.getClassName(), clazz) != null; + } + + public boolean empty() { + return map.isEmpty(); + } + + public String[] getClassNames() { + return map.keySet().toArray(Const.EMPTY_STRING_ARRAY); + } + + public void remove(final JavaClass clazz) { + map.remove(clazz.getClassName()); + } + + public JavaClass[] toArray() { + return map.values().toArray(JavaClass.EMPTY_ARRAY); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassStack.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassStack.java new file mode 100644 index 000000000..cc07acf7d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassStack.java @@ -0,0 +1,52 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.util.Stack; + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Utility class implementing a (typesafe) stack of JavaClass objects. + * + * @see Stack + */ +public class ClassStack { + + private final Stack stack = new Stack<>(); + + public boolean empty() { + return stack.empty(); + } + + public JavaClass pop() { + return stack.pop(); + } + + public void push(final JavaClass clazz) { + stack.push(clazz); + } + + public JavaClass top() { + return stack.peek(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/CodeHTML.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/CodeHTML.java new file mode 100644 index 000000000..723fc0750 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/CodeHTML.java @@ -0,0 +1,565 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.util.BitSet; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.CodeException; +import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInvokeDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert code into HTML file. + */ +final class CodeHTML { + + private static boolean wide; + private final String className; // name of current class + // private Method[] methods; // Methods to print + private final PrintWriter printWriter; // file to write to + private BitSet gotoSet; + private final ConstantPool constantPool; + private final ConstantHTML constantHtml; + + CodeHTML(final String dir, final String className, final Method[] methods, final ConstantPool constantPool, final ConstantHTML constantHtml, + final Charset charset) throws IOException { + this.className = className; +// this.methods = methods; + this.constantPool = constantPool; + this.constantHtml = constantHtml; + try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_code.html", charset.name())) { + printWriter = newPrintWriter; + printWriter.print(""); + printWriter.println(""); + for (int i = 0; i < methods.length; i++) { + writeMethod(methods[i], i); + } + printWriter.println(""); + } + } + + /** + * 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 methodNumber) throws IOException { + final short opcode = (short) bytes.readUnsignedByte(); + String name; + String signature; + int defaultOffset = 0; + int low; + int high; + int index; + int classIndex; + int vindex; + int constant; + int[] jumpTable; + int noPadBytes = 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; + noPadBytes = remainder == 0 ? 0 : 4 - remainder; + for (int i = 0; i < noPadBytes; i++) { + bytes.readByte(); + } + // Both cases have a field default_offset in common + defaultOffset = bytes.readInt(); + } + switch (opcode) { + case Const.TABLESWITCH: + low = bytes.readInt(); + high = bytes.readInt(); + offset = bytes.getIndex() - 12 - noPadBytes - 1; + defaultOffset += offset; + buf.append(""); + // Print switch indices in first row (and default) + jumpTable = new int[high - low + 1]; + for (int i = 0; i < jumpTable.length; i++) { + jumpTable[i] = offset + bytes.readInt(); + buf.append(""); + } + buf.append("\n"); + // Print target and default indices in second row + for (final int element : jumpTable) { + buf.append(""); + } + buf.append("\n
    ").append(low + i).append("default
    ").append(element).append("").append(defaultOffset) + .append("
    \n"); + break; + /* + * Lookup switch has variable length arguments. + */ + case Const.LOOKUPSWITCH: + final int npairs = bytes.readInt(); + offset = bytes.getIndex() - 8 - noPadBytes - 1; + jumpTable = new int[npairs]; + defaultOffset += offset; + buf.append(""); + // Print switch indices in first row (and default) + for (int i = 0; i < npairs; i++) { + final int match = bytes.readInt(); + jumpTable[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(jumpTable[i]) + .append("").append(defaultOffset) + .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 = constantPool.getConstant(index, Const.CONSTANT_Fieldref, ConstantFieldref.class); + classIndex = c1.getClassIndex(); + name = constantPool.getConstantString(classIndex, Const.CONSTANT_Class); + name = Utility.compactClassName(name, false); + index = c1.getNameAndTypeIndex(); + final String fieldName = constantPool.constantToString(index, Const.CONSTANT_NameAndType); + if (name.equals(className)) { // Local field + buf.append("").append(fieldName) + .append("\n"); + } else { + buf.append(constantHtml.referenceConstant(classIndex)).append(".").append(fieldName); + } + break; + /* + * Operands are references to classes in constant pool + */ + case Const.CHECKCAST: + case Const.INSTANCEOF: + case Const.NEW: + index = bytes.readShort(); + buf.append(constantHtml.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 mIndex = 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 = constantPool.getConstant(mIndex, Const.CONSTANT_InterfaceMethodref, ConstantInterfaceMethodref.class); + classIndex = c.getClassIndex(); + index = c.getNameAndTypeIndex(); + name = Class2HTML.referenceClass(classIndex); + } else if (opcode == Const.INVOKEDYNAMIC) { // Special treatment needed + bytes.readUnsignedByte(); // Reserved + bytes.readUnsignedByte(); // Reserved + final ConstantInvokeDynamic c = constantPool.getConstant(mIndex, Const.CONSTANT_InvokeDynamic, ConstantInvokeDynamic.class); + 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 = constantPool.getConstant(mIndex, Const.CONSTANT_Methodref, ConstantMethodref.class); + classIndex = c.getClassIndex(); + index = c.getNameAndTypeIndex(); + name = Class2HTML.referenceClass(classIndex); + } + str = Class2HTML.toHTML(constantPool.constantToString(constantPool.getConstant(index, Const.CONSTANT_NameAndType))); + // Get signature, i.e., types + final ConstantNameAndType c2 = constantPool.getConstant(index, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + signature = constantPool.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(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))).append(""); + break; + case Const.LDC: + index = bytes.readUnsignedByte(); + buf.append("") + .append(Class2HTML.toHTML(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))).append(""); + break; + /* + * Array of references. + */ + case Const.ANEWARRAY: + index = bytes.readShort(); + buf.append(constantHtml.referenceConstant(index)); + break; + /* + * Multidimensional array of references. + */ + case Const.MULTIANEWARRAY: + index = bytes.readShort(); + final int dimensions = bytes.readByte(); + buf.append(constantHtml.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; + gotoSet = 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) { + gotoSet.set(cex.getStartPC()); + gotoSet.set(cex.getEndPC()); + gotoSet.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) { + ((LocalVariableTable) attribute).forEach(var -> { + final int start = var.getStartPC(); + gotoSet.set(start); + gotoSet.set(start + var.getLength()); + }); + break; + } + } + } + // Get target addresses from GOTO, JSR, TABLESWITCH, etc. + while (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 noPadBytes = remainder == 0 ? 0 : 4 - remainder; + int defaultOffset; + int offset; + for (int j = 0; j < noPadBytes; j++) { + bytes.readByte(); + } + // Both cases have a field default_offset in common + defaultOffset = bytes.readInt(); + if (opcode == Const.TABLESWITCH) { + final int low = bytes.readInt(); + final int high = bytes.readInt(); + offset = bytes.getIndex() - 12 - noPadBytes - 1; + defaultOffset += offset; + gotoSet.set(defaultOffset); + for (int j = 0; j < high - low + 1; j++) { + index = offset + bytes.readInt(); + gotoSet.set(index); + } + } else { // LOOKUPSWITCH + final int npairs = bytes.readInt(); + offset = bytes.getIndex() - 8 - noPadBytes - 1; + defaultOffset += offset; + gotoSet.set(defaultOffset); + for (int j = 0; j < npairs; j++) { +// int match = bytes.readInt(); + bytes.readInt(); + index = offset + bytes.readInt(); + gotoSet.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; + gotoSet.set(index); + break; + case Const.GOTO_W: + case Const.JSR_W: + // bytes.readByte(); // Skip already read byte + index = bytes.getIndex() + bytes.readInt() - 1; + gotoSet.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 methodNumber) 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 htmlName = 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(); + printWriter.print("

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

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

    Attributes

      \n"); + for (int i = 0; i < attributes.length; i++) { + byte tag = attributes[i].getTag(); + if (tag != Const.ATTR_UNKNOWN) { + printWriter.print("
    • " + + Const.getAttributeName(tag) + "
    • \n"); + } else { + printWriter.print("
    • " + attributes[i] + "
    • "); + } + if (tag == Const.ATTR_CODE) { + c = (Code) attributes[i]; + final Attribute[] attributes2 = c.getAttributes(); + code = c.getCode(); + printWriter.print(""); + } + } + printWriter.println("
    "); + } + if (code != null) { // No code, an abstract method, e.g. + // System.out.println(name + "\n" + Utility.codeToString(code, constantPool, 0, -1)); + // Print the byte code + try (ByteSequence stream = new ByteSequence(code)) { + stream.mark(stream.available()); + findGotos(stream, c); + stream.reset(); + printWriter.println("" + ""); + while (stream.available() > 0) { + final int offset = stream.getIndex(); + final String str = codeToHTML(stream, methodNumber); + 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 (gotoSet.get(offset)) { + anchor = ""; + } + String anchor2; + if (stream.getIndex() == code.length) { + anchor2 = "" + offset + ""; + } else { + anchor2 = "" + offset; + } + printWriter.println(""); + } + } + // Mark last line, may be targetted from Attributes window + printWriter.println(""); + printWriter.println("
    Byte
    offset
    InstructionArgument
    " + anchor2 + "" + anchor + str + "
    "); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ConstantHTML.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ConstantHTML.java new file mode 100644 index 000000000..b3197f6d4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ConstantHTML.java @@ -0,0 +1,203 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantClass; +import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantString; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert constant pool into HTML file. + */ +final class ConstantHTML { + + private final String className; // name of current class + private final String classPackage; // name of package + private final ConstantPool constantPool; // reference to constant pool + private final PrintWriter printWriter; // file to write to + private final String[] constantRef; // 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 className, final String classPackage, final Method[] methods, final ConstantPool constantPool, + final Charset charset) throws FileNotFoundException, UnsupportedEncodingException { + this.className = className; + this.classPackage = classPackage; + this.constantPool = constantPool; + this.methods = methods; + this.constants = constantPool.getConstantPool(); + try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_cp.html", charset.name())) { + printWriter = newPrintWriter; + constantRef = new String[constants.length]; + constantRef[0] = "<unknown>"; + printWriter.print(""); + printWriter.println(""); + // Loop through constants, constants[0] is reserved + for (int i = 1; i < constants.length; i++) { + if (i % 2 == 0) { + printWriter.print("\n"); + } + printWriter.println("
    "); + } else { + printWriter.print("
    "); + } + if (constants[i] != null) { + writeConstant(i); + } + printWriter.print("
    "); + } + } + + 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; + } + + String referenceConstant(final int index) { + return constantRef[index]; + } + + private void writeConstant(final int index) { + final byte tag = constants[index].getTag(); + int classIndex; + int nameIndex; + String ref; + // The header is always the same + printWriter.println("

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

    "); + /* + * For every constant type get the needed parameters and print them appropriately + */ + 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 = constantPool.getConstant(index, Const.CONSTANT_Methodref, ConstantMethodref.class); + classIndex = c.getClassIndex(); + nameIndex = c.getNameAndTypeIndex(); + } else { + final ConstantInterfaceMethodref c1 = constantPool.getConstant(index, Const.CONSTANT_InterfaceMethodref, ConstantInterfaceMethodref.class); + classIndex = c1.getClassIndex(); + nameIndex = c1.getNameAndTypeIndex(); + } + // Get method name and its class + final String methodName = constantPool.constantToString(nameIndex, Const.CONSTANT_NameAndType); + final String htmlMethodName = Class2HTML.toHTML(methodName); + // Partially compacted class name, i.e., / -> . + final String methodClass = constantPool.constantToString(classIndex, Const.CONSTANT_Class); + String shortMethodClass = Utility.compactClassName(methodClass); // I.e., remove java.lang. + shortMethodClass = Utility.compactClassName(shortMethodClass, classPackage + ".", true); // Remove class package prefix + // Get method signature + final ConstantNameAndType c2 = constantPool.getConstant(nameIndex, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + final String signature = constantPool.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 retType = 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 argTypes = buf.toString(); + if (methodClass.equals(className)) { + ref = "" + htmlMethodName + ""; + } else { + ref = "" + shortMethodClass + "." + htmlMethodName; + } + constantRef[index] = retType + " " + shortMethodClass + + "." + htmlMethodName + " " + argTypes; + printWriter.println("

    " + retType + " " + ref + argTypes + " \n

    "); + break; + case Const.CONSTANT_Fieldref: + // Get class_index and name_and_type_index + final ConstantFieldref c3 = constantPool.getConstant(index, Const.CONSTANT_Fieldref, ConstantFieldref.class); + classIndex = c3.getClassIndex(); + nameIndex = c3.getNameAndTypeIndex(); + // Get method name and its class (compacted) + final String fieldClass = constantPool.constantToString(classIndex, Const.CONSTANT_Class); + String shortFieldClass = Utility.compactClassName(fieldClass); // I.e., remove java.lang. + shortFieldClass = Utility.compactClassName(shortFieldClass, classPackage + ".", true); // Remove class package prefix + final String fieldName = constantPool.constantToString(nameIndex, Const.CONSTANT_NameAndType); + if (fieldClass.equals(className)) { + ref = "" + fieldName + ""; + } else { + ref = "" + shortFieldClass + "." + fieldName + "\n"; + } + constantRef[index] = "" + shortFieldClass + "." + fieldName + ""; + printWriter.println("

    " + ref + "
    \n" + "

    "); + break; + case Const.CONSTANT_Class: + final ConstantClass c4 = constantPool.getConstant(index, Const.CONSTANT_Class, ConstantClass.class); + nameIndex = c4.getNameIndex(); + final String className2 = constantPool.constantToString(index, tag); // / -> . + String shortClassName = Utility.compactClassName(className2); // I.e., remove java.lang. + shortClassName = Utility.compactClassName(shortClassName, classPackage + ".", true); // Remove class package prefix + ref = "" + shortClassName + ""; + constantRef[index] = "" + shortClassName + ""; + printWriter.println("

    " + ref + "

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

    " + str + "

    \n"); + break; + case Const.CONSTANT_NameAndType: + final ConstantNameAndType c6 = constantPool.getConstant(index, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + nameIndex = c6.getNameIndex(); + final int signatureIndex = c6.getSignatureIndex(); + printWriter.println("

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

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

    " + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "\n"); + } // switch + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/InstructionFinder.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/InstructionFinder.java new file mode 100644 index 000000000..5b045bf08 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/InstructionFinder.java @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.util.ArrayList; +import java.util.Arrays; +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 com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.generic.ClassGenException; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.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]);
    + *   ...
    + *   }
    + *
    + *
    + * 
    + * + * @see com.sun.org.apache.bcel.internal.generic.Instruction + * @see InstructionList + * @LastModified: May 2021 + */ +public class InstructionFinder { + + /** + * 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); + } + + 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<>(); + + // 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 + map.forEach((key, value) -> { + 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()); + } + + /** + * Replace symbolic names of instructions with the appropriate 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) { + break; + } + ch = lower.charAt(i); + } + i--; + buf.append(mapName(name.toString())); + } else if (!Character.isWhitespace(ch)) { + buf.append(ch); + } + } + return buf.toString(); + } + + /** + * Convert opcode number to char. + */ + private static char makeChar(final short opcode) { + return (char) (opcode + OFFSET); + } + + /** + * 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 String.valueOf(makeChar(i)); + } + } + throw new IllegalArgumentException("Instruction unknown: " + pattern); + } + + 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(); + } + + private final InstructionList il; + + private String ilString; // 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(); + } + + /** + * @return the inquired instruction list + */ + public final InstructionList getInstructionList() { + return il; + } + + /** + * @return the matched piece of code as an array of instruction (handles) + */ + private InstructionHandle[] getMatch(final int matchedFrom, final int matchLength) { + return Arrays.copyOfRange(handles, matchedFrom, matchedFrom + matchLength); + } + + /** + * 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()); + } + ilString = new String(buf); + } + + /** + * 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 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); + } + + /** + * 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); + } + + /** + * 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(ilString); + while (start < ilString.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(); + } + + /* + * 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/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/MethodHTML.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/MethodHTML.java new file mode 100644 index 000000000..a75a58bed --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/MethodHTML.java @@ -0,0 +1,152 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert methods and fields into HTML file. + */ +final class MethodHTML { + + private final String className; // name of current class + private final PrintWriter printWriter; // file to write to + private final ConstantHTML constantHtml; + private final AttributeHTML attributeHtml; + + MethodHTML(final String dir, final String className, final Method[] methods, final Field[] fields, final ConstantHTML constantHtml, + final AttributeHTML attributeHtml, final Charset charset) throws FileNotFoundException, UnsupportedEncodingException { + this.className = className; + this.attributeHtml = attributeHtml; + this.constantHtml = constantHtml; + try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_methods.html", charset.name())) { + printWriter = newPrintWriter; + printWriter.print(""); + printWriter.println(""); + printWriter.println("" + ""); + for (final Field field : fields) { + writeField(field); + } + printWriter.println("
    Access flagsTypeField name
    "); + printWriter.println("" + + "" + ""); + for (int i = 0; i < methods.length; i++) { + writeMethod(methods[i], i); + } + printWriter.println("
    Access flagsReturn typeMethod nameArguments
    "); + } + } + + /** + * Print field of class. + * + * @param field field to print + */ + private void writeField(final Field field) { + final String type = Utility.signatureToString(field.getSignature()); + final String name = field.getName(); + String access = Utility.accessToString(field.getAccessFlags()); + Attribute[] attributes; + access = Utility.replace(access, " ", " "); + printWriter.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++) { + attributeHtml.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 = attributes[i].toString(); + // Reference attribute in _attributes.html + printWriter.print("= " + str + "\n"); + break; + } + } + printWriter.println(""); + } + + private void writeMethod(final Method method, final int methodNumber) { + // 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 htmlName; + // 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, " ", " "); + htmlName = Class2HTML.toHTML(name); + printWriter.print("" + access + ""); + printWriter.print("" + Class2HTML.referenceType(type) + "" + "" + + htmlName + "\n("); + for (int i = 0; i < args.length; i++) { + printWriter.print(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + printWriter.print(", "); + } + } + printWriter.print(")"); + // Check for thrown exceptions + for (int i = 0; i < attributes.length; i++) { + attributeHtml.writeAttribute(attributes[i], "method" + methodNumber + "@" + i, methodNumber); + final byte tag = attributes[i].getTag(); + if (tag == Const.ATTR_EXCEPTIONS) { + printWriter.print("throws"); + final int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable(); + for (int j = 0; j < exceptions.length; j++) { + printWriter.print(constantHtml.referenceConstant(exceptions[j])); + if (j < exceptions.length - 1) { + printWriter.print(", "); + } + } + printWriter.println(""); + } else if (tag == Const.ATTR_CODE) { + final Attribute[] attributeArray = ((Code) attributes[i]).getAttributes(); + for (int j = 0; j < attributeArray.length; j++) { + attributeHtml.writeAttribute(attributeArray[j], "method" + methodNumber + "@" + i + "@" + j, methodNumber); + } + } + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java new file mode 100644 index 000000000..fd7cd0d2d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java @@ -0,0 +1,142 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.util; + +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.DirectoryStream; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Wraps a Java 9 JEP 220 modular runtime image. Requires the JRT NIO file system. + * + * @since 6.3 + */ +public class ModularRuntimeImage implements Closeable { + + static final String MODULES_PATH = File.separator + "modules"; + static final String PACKAGES_PATH = File.separator + "packages"; + + private final URLClassLoader classLoader; + private final FileSystem fileSystem; + + /** + * Constructs a default instance. + */ + @SuppressWarnings("resource") // See #close() + public ModularRuntimeImage() { + this(null, FileSystems.getFileSystem(URI.create("jrt:/"))); + } + + /** + * Constructs an instance using the JRT file system implementation from a specific Java Home. + * + * @param javaHome Path to a Java 9 or greater home. + * + * @throws IOException an I/O error occurs accessing the file system + */ + public ModularRuntimeImage(final String javaHome) throws IOException { + final Map emptyMap = Collections.emptyMap(); + final Path jrePath = Paths.get(javaHome); + final Path jrtFsPath = jrePath.resolve("lib").resolve("jrt-fs.jar"); + this.classLoader = URLClassLoader.newInstance(new URL[] {jrtFsPath.toUri().toURL()}); + this.fileSystem = FileSystems.newFileSystem(URI.create("jrt:/"), emptyMap, classLoader); + } + + private ModularRuntimeImage(final URLClassLoader cl, final FileSystem fs) { + this.classLoader = cl; + this.fileSystem = fs; + } + + @Override + public void close() throws IOException { + if (classLoader != null) { + classLoader.close(); + } + if (fileSystem != null) { + fileSystem.close(); + } + } + + public FileSystem getFileSystem() { + return fileSystem; + } + + /** + * Lists all entries in the given directory. + * + * @param dirPath directory path. + * @return a list of dir entries if an I/O error occurs + * @throws IOException an I/O error occurs accessing the file system + */ + public List list(final Path dirPath) throws IOException { + final List list = new ArrayList<>(); + try (DirectoryStream ds = Files.newDirectoryStream(dirPath)) { + ds.forEach(list::add); + } + return list; + } + + /** + * Lists all entries in the given directory. + * + * @param dirName directory path. + * @return a list of dir entries if an I/O error occurs + * @throws IOException an I/O error occurs accessing the file system + */ + public List list(final String dirName) throws IOException { + return list(fileSystem.getPath(dirName)); + } + + /** + * Lists all modules. + * + * @return a list of modules + * @throws IOException an I/O error occurs accessing the file system + */ + public List modules() throws IOException { + return list(MODULES_PATH); + } + + /** + * Lists all packages. + * + * @return a list of modules + * @throws IOException an I/O error occurs accessing the file system + */ + public List packages() throws IOException { + return list(PACKAGES_PATH); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Repository.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Repository.java new file mode 100644 index 000000000..8d1ddf493 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Repository.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import com.sun.org.apache.bcel.internal.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 + * @LastModified: Feb 2023 + */ +public interface Repository { + + /** + * Clears all entries from cache. + */ + void clear(); + + /** + * Finds the class with the name provided, if the class isn't there, return NULL. + */ + JavaClass findClass(String className); + + /** + * Finds the JavaClass instance for the given run-time class object. + * + * @throws ClassNotFoundException if the class can't be found. + */ + JavaClass loadClass(Class clazz) throws ClassNotFoundException; + + /** + * Finds the class with the name provided, if the class isn't there, make an attempt to load it. + * + * @throws ClassNotFoundException if the class can't be found. + */ + JavaClass loadClass(String className) throws ClassNotFoundException; + + /** + * Removes class from repository + */ + void removeClass(JavaClass clazz); + + /** + * Stores the provided class under "clazz.getClassName()" + */ + void storeClass(JavaClass clazz); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java new file mode 100644 index 000000000..470c6ea17 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import java.io.IOException; +import java.io.InputStream; + +import com.sun.org.apache.bcel.internal.classfile.ClassParser; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import java.lang.ref.SoftReference; +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 com.sun.org.apache.bcel.internal.Repository + * + * @LastModified: Feb 2023 + */ +public class SyntheticRepository implements Repository { + + // CLASSNAME X JAVACLASS + private final Map> loadedClasses = new HashMap<>(); + + private SyntheticRepository() { + } + + public static SyntheticRepository getInstance() { + return new SyntheticRepository(); + } + + /** + * Clear all entries from cache. + */ + @Override + public void clear() { + loadedClasses.clear(); + } + + /** + * Find an already defined (cached) JavaClass object by name. + */ + @Override + public JavaClass findClass(final String className) { + final SoftReference ref = loadedClasses.get(className); + return ref == null ? null : ref.get(); + } + + /** + * Remove class from repository + */ + @Override + public void removeClass(final JavaClass clazz) { + loadedClasses.remove(clazz.getClassName()); + } + + /** + * Store a new JavaClass instance into this Repository. + */ + @Override + public void storeClass(final JavaClass clazz) { + // Not calling super.storeClass because this subclass maintains the mapping. + loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz)); + clazz.setRepository(this); + } + + /** + * Finds 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); + } + + try (InputStream clsStream = clazz.getResourceAsStream(name + JavaClass.EXTENSION)) { + return loadClass(clsStream, className); + } catch (final IOException e) { + return null; + } + } + + private JavaClass loadClass(final InputStream inputStream, final String className) throws ClassNotFoundException { + try { + if (inputStream != null) { + final ClassParser parser = new ClassParser(inputStream, 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); + } + throw new ClassNotFoundException("ClassRepository could not load " + className); + } + + /** + * Finds 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 = Utility.pathToPackage(className); // Just in case, canonical form + final JavaClass clazz = findClass(className); + if (clazz != null) { + return clazz; + } + IOException e = new IOException("Couldn't find: " + className + ".class"); + throw new ClassNotFoundException("Exception while looking for class " + + className + ": " + e, e); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/package.html new file mode 100644 index 000000000..e710072cb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/bcel/internal/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/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/ExpressionContext.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/ExpressionContext.java new file mode 100644 index 000000000..b6f5a7ff5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/ExpressionContext.java @@ -0,0 +1,94 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.extensions; + +import javax.xml.transform.ErrorListener; + +import com.sun.org.apache.xpath.internal.objects.XObject; +import org.w3c.dom.Node; +import org.w3c.dom.traversal.NodeIterator; + +/** + * An object that implements this interface can supply + * information about the current XPath expression context. + */ +public interface ExpressionContext +{ + + /** + * Get the current context node. + * @return The current context node. + */ + public Node getContextNode(); + + /** + * Get the current context node list. + * @return An iterator for the current context list, as + * defined in XSLT. + */ + public NodeIterator getContextNodes(); + + /** + * Get the error listener. + * @return The registered error listener. + */ + public ErrorListener getErrorListener(); + + /** + * Get the value of a node as a number. + * @param n Node to be converted to a number. May be null. + * @return value of n as a number. + */ + public double toNumber(Node n); + + /** + * Get the value of a node as a string. + * @param n Node to be converted to a string. May be null. + * @return value of n as a string, or an empty string if n is null. + */ + public String toString(Node n); + + /** + * Get a variable based on it's qualified name. + * + * @param qname The qualified name of the variable. + * + * @return The evaluated value of the variable. + * + * @throws javax.xml.transform.TransformerException + */ + public XObject getVariableOrParam(com.sun.org.apache.xml.internal.utils.QName qname) + throws javax.xml.transform.TransformerException; + + /** + * Get the XPathContext that owns this ExpressionContext. + * + * Note: exslt:function requires the XPathContext to access + * the variable stack and TransformerImpl. + * + * @return The current XPathContext. + * @throws javax.xml.transform.TransformerException + */ + public com.sun.org.apache.xpath.internal.XPathContext getXPathContext() + throws javax.xml.transform.TransformerException; + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/package.html new file mode 100644 index 000000000..8d1d37960 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/package.html @@ -0,0 +1,28 @@ + + + + + Xalan Extension Mechanism Package. + +

    Implementation of Xalan Extension Mechanism.

    + + + + diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltBase.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltBase.java new file mode 100644 index 000000000..0b99ee447 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltBase.java @@ -0,0 +1,85 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * The base class for some EXSLT extension classes. + * It contains common utility methods to be used by the sub-classes. + */ +public abstract class ExsltBase +{ + /** + * Return the string value of a Node + * + * @param n The Node. + * @return The string value of the Node + */ + protected static String toString(Node n) + { + if (n instanceof DTMNodeProxy) + return ((DTMNodeProxy)n).getStringValue(); + else + { + String value = n.getNodeValue(); + if (value == null) + { + NodeList nodelist = n.getChildNodes(); + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < nodelist.getLength(); i++) + { + Node childNode = nodelist.item(i); + buf.append(toString(childNode)); + } + return buf.toString(); + } + else + return value; + } + } + + /** + * Convert the string value of a Node to a number. + * Return NaN if the string is not a valid number. + * + * @param n The Node. + * @return The number value of the Node + */ + protected static double toNumber(Node n) + { + double d = 0.0; + String str = toString(n); + try + { + d = Double.valueOf(str).doubleValue(); + } + catch (NumberFormatException e) + { + d= Double.NaN; + } + return d; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltCommon.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltCommon.java new file mode 100644 index 000000000..e272192ec --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltCommon.java @@ -0,0 +1,107 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xml.internal.dtm.DTMIterator; +import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeIterator; +import com.sun.org.apache.xpath.internal.NodeSet; + +/** + * This class contains EXSLT common extension functions. + * It is accessed by specifying a namespace URI as follows: + *

    + *    xmlns:exslt="http://exslt.org/common"
    + * 
    + * + * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @see EXSLT + * @xsl.usage general + */ +public class ExsltCommon +{ + /** + * The exsl:object-type function returns a string giving the type of the object passed + * as the argument. The possible object types are: 'string', 'number', 'boolean', + * 'node-set', 'RTF', or 'external'. + * + * Most XSLT object types can be coerced to each other without error. However, there are + * certain coercions that raise errors, most importantly treating anything other than a + * node set as a node set. Authors of utilities such as named templates or user-defined + * extension functions may wish to give some flexibility in the parameter and argument values + * that are accepted by the utility; the exsl:object-type function enables them to do so. + * + * The Xalan extensions MethodResolver converts 'object-type' to 'objectType'. + * + * @param obj The object to be typed. + * @return objectType 'string', 'number', 'boolean', 'node-set', 'RTF', or 'external'. + * + * @see EXSLT + */ + public static String objectType (Object obj) + { + if (obj instanceof String) + return "string"; + else if (obj instanceof Boolean) + return "boolean"; + else if (obj instanceof Number) + return "number"; + else if (obj instanceof DTMNodeIterator) + { + DTMIterator dtmI = ((DTMNodeIterator)obj).getDTMIterator(); + if (dtmI instanceof com.sun.org.apache.xpath.internal.axes.RTFIterator) + return "RTF"; + else + return "node-set"; + } + else + return "unknown"; + } + + /** + * The exsl:node-set function converts a result tree fragment (which is what you get + * when you use the content of xsl:variable rather than its select attribute to give + * a variable value) into a node set. This enables you to process the XML that you create + * within a variable, and therefore do multi-step processing. + * + * You can also use this function to turn a string into a text node, which is helpful + * if you want to pass a string to a function that only accepts a node set. + * + * The Xalan extensions MethodResolver converts 'node-set' to 'nodeSet'. + * + * @param myProcessor is passed in by the Xalan extension processor + * @param rtf The result tree fragment to be converted to a node-set. + * + * @return node-set with the contents of the result tree fragment. + * + * Note: Already implemented in the xalan namespace as nodeset. + * + * @see EXSLT + */ + public static NodeSet nodeSet(ExpressionContext myProcessor, Object rtf) + { + return Extensions.nodeset(myProcessor, rtf); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java new file mode 100644 index 000000000..f8ce5a924 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java @@ -0,0 +1,1120 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import com.sun.org.apache.xpath.internal.objects.XBoolean; +import com.sun.org.apache.xpath.internal.objects.XNumber; +import com.sun.org.apache.xpath.internal.objects.XObject; + +/** + * This class contains EXSLT dates and times extension functions. + * It is accessed by specifying a namespace URI as follows: + *
    + *    xmlns:datetime="http://exslt.org/dates-and-times"
    + * 
    + * + * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @see EXSLT + * @xsl.usage general + * @LastModified: Nov 2017 + */ + +public class ExsltDatetime +{ + // Datetime formats (era and zone handled separately). + static final String dt = "yyyy-MM-dd'T'HH:mm:ss"; + static final String d = "yyyy-MM-dd"; + static final String gym = "yyyy-MM"; + static final String gy = "yyyy"; + static final String gmd = "--MM-dd"; + static final String gm = "--MM--"; + static final String gd = "---dd"; + static final String t = "HH:mm:ss"; + static final String EMPTY_STR = ""; + + /** + * The date:date-time function returns the current date and time as a date/time string. + * The date/time string that's returned must be a string in the format defined as the + * lexical representation of xs:dateTime in + * [3.2.7 dateTime] of + * [XML Schema Part 2: Datatypes]. + * The date/time format is basically CCYY-MM-DDThh:mm:ss, although implementers should consult + * [XML Schema Part 2: Datatypes] and + * [ISO 8601] for details. + * The date/time string format must include a time zone, either a Z to indicate Coordinated + * Universal Time or a + or - followed by the difference between the difference from UTC + * represented as hh:mm. + */ + public static String dateTime() + { + Calendar cal = Calendar.getInstance(); + Date datetime = cal.getTime(); + // Format for date and time. + SimpleDateFormat dateFormat = new SimpleDateFormat(dt); + + StringBuffer buff = new StringBuffer(dateFormat.format(datetime)); + // Must also include offset from UTF. + // Get the offset (in milliseconds). + int offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); + // If there is no offset, we have "Coordinated + // Universal Time." + if (offset == 0) + buff.append("Z"); + else + { + // Convert milliseconds to hours and minutes + int hrs = offset/(60*60*1000); + // In a few cases, the time zone may be +/-hh:30. + int min = offset%(60*60*1000); + char posneg = hrs < 0? '-': '+'; + buff.append(posneg).append(formatDigits(hrs)).append(':').append(formatDigits(min)); + } + return buff.toString(); + } + + /** + * Represent the hours and minutes with two-digit strings. + * @param q hrs or minutes. + * @return two-digit String representation of hrs or minutes. + */ + private static String formatDigits(int q) + { + String dd = String.valueOf(Math.abs(q)); + return dd.length() == 1 ? '0' + dd : dd; + } + + /** + * The date:date function returns the date specified in the date/time string given + * as the argument. If no argument is given, then the current local date/time, as + * returned by date:date-time is used as a default argument. + * The date/time string that's returned must be a string in the format defined as the + * lexical representation of xs:dateTime in + * [3.2.7 dateTime] of + * [XML Schema Part 2: Datatypes]. + * If the argument is not in either of these formats, date:date returns an empty string (''). + * The date/time format is basically CCYY-MM-DDThh:mm:ss, although implementers should consult + * [XML Schema Part 2: Datatypes] and + * [ISO 8601] for details. + * The date is returned as a string with a lexical representation as defined for xs:date in + * [3.2.9 date] of [XML Schema Part 2: Datatypes]. The date format is basically CCYY-MM-DD, + * although implementers should consult [XML Schema Part 2: Datatypes] and [ISO 8601] for details. + * If no argument is given or the argument date/time specifies a time zone, then the date string + * format must include a time zone, either a Z to indicate Coordinated Universal Time or a + or - + * followed by the difference between the difference from UTC represented as hh:mm. If an argument + * is specified and it does not specify a time zone, then the date string format must not include + * a time zone. + */ + public static String date(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String leader = edz[0]; + String datetime = edz[1]; + String zone = edz[2]; + if (datetime == null || zone == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d}; + String formatOut = d; + Date date = testFormats(datetime, formatsIn); + if (date == null) return EMPTY_STR; + + SimpleDateFormat dateFormat = new SimpleDateFormat(formatOut); + dateFormat.setLenient(false); + String dateOut = dateFormat.format(date); + if (dateOut.length() == 0) + return EMPTY_STR; + else + return (leader + dateOut + zone); + } + + + /** + * See above. + */ + public static String date() + { + String datetime = dateTime().toString(); + String date = datetime.substring(0, datetime.indexOf("T")); + String zone = datetime.substring(getZoneStart(datetime)); + return (date + zone); + } + + /** + * The date:time function returns the time specified in the date/time string given + * as the argument. If no argument is given, then the current local date/time, as + * returned by date:date-time is used as a default argument. + * The date/time string that's returned must be a string in the format defined as the + * lexical representation of xs:dateTime in + * [3.2.7 dateTime] of + * [XML Schema Part 2: Datatypes]. + * If the argument string is not in this format, date:time returns an empty string (''). + * The date/time format is basically CCYY-MM-DDThh:mm:ss, although implementers should consult + * [XML Schema Part 2: Datatypes] and + * [ISO 8601] for details. + * The date is returned as a string with a lexical representation as defined for xs:time in + * [3.2.8 time] of [XML Schema Part 2: Datatypes]. + * The time format is basically hh:mm:ss, although implementers should consult [XML Schema Part 2: + * Datatypes] and [ISO 8601] for details. + * If no argument is given or the argument date/time specifies a time zone, then the time string + * format must include a time zone, either a Z to indicate Coordinated Universal Time or a + or - + * followed by the difference between the difference from UTC represented as hh:mm. If an argument + * is specified and it does not specify a time zone, then the time string format must not include + * a time zone. + */ + public static String time(String timeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(timeIn); + String time = edz[1]; + String zone = edz[2]; + if (time == null || zone == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d, t}; + String formatOut = t; + Date date = testFormats(time, formatsIn); + if (date == null) return EMPTY_STR; + SimpleDateFormat dateFormat = new SimpleDateFormat(formatOut); + String out = dateFormat.format(date); + return (out + zone); + } + + /** + * See above. + */ + public static String time() + { + String datetime = dateTime().toString(); + String time = datetime.substring(datetime.indexOf("T")+1); + + // The datetime() function returns the zone on the datetime string. If we + // append it, we get the zone substring duplicated. + // Fix for JIRA 2013 + + // String zone = datetime.substring(getZoneStart(datetime)); + // return (time + zone); + return (time); + } + + /** + * The date:year function returns the year of a date as a number. If no + * argument is given, then the current local date/time, as returned by + * date:date-time is used as a default argument. + * The date/time string specified as the first argument must be a right-truncated + * string in the format defined as the lexical representation of xs:dateTime in one + * of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gYear (CCYY) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double year(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + boolean ad = edz[0].length() == 0; // AD (Common Era -- empty leader) + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d, gym, gy}; + double yr = getNumber(datetime, formats, Calendar.YEAR); + if (ad || yr == Double.NaN) + return yr; + else + return -yr; + } + + /** + * See above. + */ + public static double year() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.YEAR); + } + + /** + * The date:month-in-year function returns the month of a date as a number. If no argument + * is given, then the current local date/time, as returned by date:date-time is used + * as a default argument. + * The date/time string specified as the first argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime in one of + * the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gMonth (--MM--) + * xs:gMonthDay (--MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double monthInYear(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d, gym, gm, gmd}; + return getNumber(datetime, formats, Calendar.MONTH) + 1; + } + + /** + * See above. + */ + public static double monthInYear() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.MONTH) + 1; + } + + /** + * The date:week-in-year function returns the week of the year as a number. If no argument + * is given, then the current local date/time, as returned by date:date-time is used as the + * default argument. For the purposes of numbering, counting follows ISO 8601: week 1 in a year + * is the week containing the first Thursday of the year, with new weeks beginning on a Monday. + * The date/time string specified as the argument is a right-truncated string in the format + * defined as the lexical representation of xs:dateTime in one of the formats defined in + * [XML Schema Part 2: Datatypes]. The + * permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double weekInYear(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.WEEK_OF_YEAR); + } + + /** + * See above. + */ + public static double weekInYear() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.WEEK_OF_YEAR); + } + + /** + * The date:day-in-year function returns the day of a date in a year + * as a number. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double dayInYear(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.DAY_OF_YEAR); + } + + /** + * See above. + */ + public static double dayInYear() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_YEAR); + } + + + /** + * The date:day-in-month function returns the day of a date as a number. + * If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gMonthDay (--MM-DD) + * xs:gDay (---DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double dayInMonth(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + String[] formats = {dt, d, gmd, gd}; + double day = getNumber(datetime, formats, Calendar.DAY_OF_MONTH); + return day; + } + + /** + * See above. + */ + public static double dayInMonth() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_MONTH); + } + + /** + * The date:day-of-week-in-month function returns the day-of-the-week + * in a month of a date as a number (e.g. 3 for the 3rd Tuesday in May). + * If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated string + * in the format defined as the lexical representation of xs:dateTime in one + * of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double dayOfWeekInMonth(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.DAY_OF_WEEK_IN_MONTH); + } + + /** + * See above. + */ + public static double dayOfWeekInMonth() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_WEEK_IN_MONTH); + } + + + /** + * The date:day-in-week function returns the day of the week given in a + * date as a number. If no argument is given, then the current local date/time, + * as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated string + * in the format defined as the lexical representation of xs:dateTime in one + * of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + The numbering of days of the week starts at 1 for Sunday, 2 for Monday and so on up to 7 for Saturday. + */ + public static double dayInWeek(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.DAY_OF_WEEK); + } + + /** + * See above. + */ + public static double dayInWeek() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_WEEK); + } + + /** + * The date:hour-in-day function returns the hour of the day as a number. + * If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:time (hh:mm:ss) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double hourInDay(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, t}; + return getNumber(datetime, formats, Calendar.HOUR_OF_DAY); + } + + /** + * See above. + */ + public static double hourInDay() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.HOUR_OF_DAY); + } + + /** + * The date:minute-in-hour function returns the minute of the hour + * as a number. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:time (hh:mm:ss) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double minuteInHour(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt,t}; + return getNumber(datetime, formats, Calendar.MINUTE); + } + + /** + * See above. + */ + public static double minuteInHour() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.MINUTE); + } + + /** + * The date:second-in-minute function returns the second of the minute + * as a number. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:time (hh:mm:ss) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double secondInMinute(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, t}; + return getNumber(datetime, formats, Calendar.SECOND); + } + + /** + * See above. + */ + public static double secondInMinute() + { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.SECOND); + } + + /** + * The date:leap-year function returns true if the year given in a date + * is a leap year. If no argument is given, then the current local + * date/time, as returned by date:date-time is used as a default argument. + * The date/time string specified as the first argument must be a + * right-truncated string in the format defined as the lexical representation + * of xs:dateTime in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gYear (CCYY) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static XObject leapYear(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return new XNumber(Double.NaN); + + String[] formats = {dt, d, gym, gy}; + double dbl = getNumber(datetime, formats, Calendar.YEAR); + if (dbl == Double.NaN) + return new XNumber(Double.NaN); + int yr = (int)dbl; + return new XBoolean(yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0)); + } + + /** + * See above. + */ + public static boolean leapYear() + { + Calendar cal = Calendar.getInstance(); + int yr = cal.get(Calendar.YEAR); + return (yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0)); + } + + /** + * The date:month-name function returns the full name of the month of a date. + * If no argument is given, then the current local date/time, as returned by + * date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime in + * one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gMonth (--MM--) + * If the date/time string is not in one of these formats, then an empty string ('') + * is returned. + * The result is an English month name: one of 'January', 'February', 'March', + * 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November' + * or 'December'. + */ + public static String monthName(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d, gym, gm}; + String formatOut = "MMMM"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String monthName() + { + Calendar cal = Calendar.getInstance(); + String format = "MMMM"; + return getNameOrAbbrev(format); + } + + /** + * The date:month-abbreviation function returns the abbreviation of the month of + * a date. If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime in + * one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gMonth (--MM--) + * If the date/time string is not in one of these formats, then an empty string ('') + * is returned. + * The result is a three-letter English month abbreviation: one of 'Jan', 'Feb', 'Mar', + * 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov' or 'Dec'. + * An implementation of this extension function in the EXSLT date namespace must conform + * to the behaviour described in this document. + */ + public static String monthAbbreviation(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d, gym, gm}; + String formatOut = "MMM"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String monthAbbreviation() + { + String format = "MMM"; + return getNameOrAbbrev(format); + } + + /** + * The date:day-name function returns the full name of the day of the week + * of a date. If no argument is given, then the current local date/time, + * as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then the empty string ('') + * is returned. + * The result is an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', + * 'Thursday' or 'Friday'. + * An implementation of this extension function in the EXSLT date namespace must conform + * to the behaviour described in this document. + */ + public static String dayName(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d}; + String formatOut = "EEEE"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String dayName() + { + String format = "EEEE"; + return getNameOrAbbrev(format); + } + + /** + * The date:day-abbreviation function returns the abbreviation of the day + * of the week of a date. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then the empty string + * ('') is returned. + * The result is a three-letter English day abbreviation: one of 'Sun', 'Mon', 'Tue', + * 'Wed', 'Thu' or 'Fri'. + * An implementation of this extension function in the EXSLT date namespace must conform + * to the behaviour described in this document. + */ + public static String dayAbbreviation(String datetimeIn) + throws ParseException + { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d}; + String formatOut = "EEE"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String dayAbbreviation() + { + String format = "EEE"; + return getNameOrAbbrev(format); + } + + /** + * Returns an array with the 3 components that a datetime input string + * may contain: - (for BC era), datetime, and zone. If the zone is not + * valid, return null for that component. + */ + private static String[] getEraDatetimeZone(String in) + { + String leader = ""; + String datetime = in; + String zone = ""; + if (in.charAt(0)=='-' && !in.startsWith("--")) + { + leader = "-"; // '+' is implicit , not allowed + datetime = in.substring(1); + } + int z = getZoneStart(datetime); + if (z > 0) + { + zone = datetime.substring(z); + datetime = datetime.substring(0, z); + } + else if (z == -2) + zone = null; + //System.out.println("'" + leader + "' " + datetime + " " + zone); + return new String[]{leader, datetime, zone}; + } + + /** + * Get the start of zone information if the input ends + * with 'Z' or +/-hh:mm. If a zone string is not + * found, return -1; if the zone string is invalid, + * return -2. + */ + private static int getZoneStart (String datetime) + { + if (datetime.indexOf("Z") == datetime.length()-1) + return datetime.length()-1; + else if (datetime.length() >=6 + && datetime.charAt(datetime.length()-3) == ':' + && (datetime.charAt(datetime.length()-6) == '+' + || datetime.charAt(datetime.length()-6) == '-')) + { + try + { + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm"); + dateFormat.setLenient(false); + Date d = dateFormat.parse(datetime.substring(datetime.length() -5)); + return datetime.length()-6; + } + catch (ParseException pe) + { + System.out.println("ParseException " + pe.getErrorOffset()); + return -2; // Invalid. + } + + } + return -1; // No zone information. + } + + /** + * Attempt to parse an input string with the allowed formats, returning + * null if none of the formats work. + */ + private static Date testFormats (String in, String[] formats) + throws ParseException + { + for (int i = 0; i + * The first argument to date:format-date specifies the date/time to be + * formatted. It must be right or left-truncated date/time strings in one of + * the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + *
      + *
    • xs:dateTime (CCYY-MM-DDThh:mm:ss) + *
    • xs:date (CCYY-MM-DD) + *
    • xs:time (hh:mm:ss) + *
    • xs:gYearMonth (CCYY-MM) + *
    • xs:gYear (CCYY) + *
    • xs:gMonthDay (--MM-DD) + *
    • xs:gMonth (--MM--) + *
    • xs:gDay (---DD) + *
    + * The second argument is a string that gives the format pattern used to + * format the date. The format pattern must be in the syntax specified by + * the JDK 1.1 SimpleDateFormat class. The format pattern string is + * interpreted as described for the JDK 1.1 SimpleDateFormat class. + *

    + * If the date/time format is right-truncated (i.e. in a format other than + * xs:time, or xs:dateTime) then any missing components are assumed to be as + * follows: if no month is specified, it is given a month of 01; if no day + * is specified, it is given a day of 01; if no time is specified, it is + * given a time of 00:00:00. + *

    + * If the date/time format is left-truncated (i.e. xs:time, xs:gMonthDay, + * xs:gMonth or xs:gDay) and the format pattern has a token that uses a + * component that is missing from the date/time format used, then that token + * is replaced with an empty string ('') within the result. + * + * The author is Helg Bredow (helg.bredow@kalido.com) + */ + public static String formatDate(String dateTime, String pattern) + { + final String yearSymbols = "Gy"; + final String monthSymbols = "M"; + final String daySymbols = "dDEFwW"; + TimeZone timeZone; + String zone; + + // Get the timezone information if it was supplied and modify the + // dateTime so that SimpleDateFormat will understand it. + if (dateTime.endsWith("Z") || dateTime.endsWith("z")) + { + timeZone = TimeZone.getTimeZone("GMT"); + dateTime = dateTime.substring(0, dateTime.length()-1) + "GMT"; + zone = "z"; + } + else if ((dateTime.length() >= 6) + && (dateTime.charAt(dateTime.length()-3) == ':') + && ((dateTime.charAt(dateTime.length()-6) == '+') + || (dateTime.charAt(dateTime.length()-6) == '-'))) + { + String offset = dateTime.substring(dateTime.length()-6); + + if ("+00:00".equals(offset) || "-00:00".equals(offset)) + { + timeZone = TimeZone.getTimeZone("GMT"); + } + else + { + timeZone = TimeZone.getTimeZone("GMT" + offset); + } + zone = "z"; + // Need to adjust it since SimpleDateFormat requires GMT+hh:mm but + // we have +hh:mm. + dateTime = dateTime.substring(0, dateTime.length()-6) + "GMT" + offset; + } + else + { + // Assume local time. + timeZone = TimeZone.getDefault(); + zone = ""; + // Leave off the timezone since SimpleDateFormat will assume local + // time if time zone is not included. + } + String[] formats = {dt + zone, d, gym, gy}; + + // Try the time format first. We need to do this to prevent + // SimpleDateFormat from interpreting a time as a year. i.e we just need + // to check if it's a time before we check it's a year. + try + { + SimpleDateFormat inFormat = new SimpleDateFormat(t + zone); + inFormat.setLenient(false); + Date d= inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip + (yearSymbols + monthSymbols + daySymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } + catch (ParseException pe) + { + } + + // Try the right truncated formats. + for (int i = 0; i < formats.length; i++) + { + try + { + SimpleDateFormat inFormat = new SimpleDateFormat(formats[i]); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(pattern); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } + catch (ParseException pe) + { + } + } + + // Now try the left truncated ones. The Java format() function doesn't + // return the correct strings in this case. We strip any pattern + // symbols that shouldn't be output so that they are not defaulted to + // inappropriate values in the output. + try + { + SimpleDateFormat inFormat = new SimpleDateFormat(gmd); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip(yearSymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } + catch (ParseException pe) + { + } + try + { + SimpleDateFormat inFormat = new SimpleDateFormat(gm); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip(yearSymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } + catch (ParseException pe) + { + } + try + { + SimpleDateFormat inFormat = new SimpleDateFormat(gd); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip(yearSymbols + monthSymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } + catch (ParseException pe) + { + } + return EMPTY_STR; + } + + /** + * Strips occurrences of the given character from a date format pattern. + * @param symbols list of symbols to strip. + * @param pattern + * @return + */ + private static String strip(String symbols, String pattern) + { + int quoteSemaphore = 0; + int i = 0; + StringBuffer result = new StringBuffer(pattern.length()); + + while (i < pattern.length()) + { + char ch = pattern.charAt(i); + if (ch == '\'') + { + // Assume it's an openening quote so simply copy the quoted + // text to the result. There is nothing to strip here. + int endQuote = pattern.indexOf('\'', i + 1); + if (endQuote == -1) + { + endQuote = pattern.length(); + } + result.append(pattern.substring(i, endQuote)); + i = endQuote++; + } + else if (symbols.indexOf(ch) > -1) + { + // The char needs to be stripped. + i++; + } + else + { + result.append(ch); + i++; + } + } + return result.toString(); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDynamic.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDynamic.java new file mode 100644 index 000000000..dc971990d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDynamic.java @@ -0,0 +1,612 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.TransformerException; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xalan.internal.res.XSLMessages; +import com.sun.org.apache.xalan.internal.res.XSLTErrorResources; +import com.sun.org.apache.xpath.internal.NodeSet; +import com.sun.org.apache.xpath.internal.NodeSetDTM; +import com.sun.org.apache.xpath.internal.XPath; +import com.sun.org.apache.xpath.internal.XPathContext; +import com.sun.org.apache.xpath.internal.objects.XBoolean; +import com.sun.org.apache.xpath.internal.objects.XNodeSet; +import com.sun.org.apache.xpath.internal.objects.XNumber; +import com.sun.org.apache.xpath.internal.objects.XObject; +import jdk.xml.internal.JdkXmlUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import org.xml.sax.SAXNotSupportedException; + +/** + * This class contains EXSLT dynamic extension functions. + * + * It is accessed by specifying a namespace URI as follows: + *

    + *    xmlns:dyn="http://exslt.org/dynamic"
    + * 
    + * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @see EXSLT + + * @xsl.usage general + */ +public class ExsltDynamic extends ExsltBase +{ + + public static final String EXSL_URI = "http://exslt.org/common"; + + /** + * The dyn:max function calculates the maximum value for the nodes passed as + * the first argument, where the value of each node is calculated dynamically + * using an XPath expression passed as a string as the second argument. + *

    + * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:max function itself, except for the following: + *

    + *

      + *
    • the context node is the node whose value is being calculated.
    • + *
    • the context position is the position of the node within the node set passed as + * the first argument to the dyn:max function, arranged in document order.
    • + *
    • the context size is the number of nodes passed as the first argument to the + * dyn:max function.
    • + *
    + *

    + * The dyn:max function returns the maximum of these values, calculated in exactly + * the same way as for math:max. + *

    + * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns NaN. + *

    + * This function must take a second argument. To calculate the maximum of a set of + * nodes based on their string values, you should use the math:max function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * + * @return The maximum evaluation value + */ + public static double max(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException + { + + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); + + if (expr == null || expr.length() == 0) + return Double.NaN; + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + double maxValue = - Double.MAX_VALUE; + for (int i = 0; i < contextNodes.getLength(); i++) + { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + double result = 0; + try + { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num(); + } + catch (TransformerException e) + { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return Double.NaN; + } + + xctxt.popCurrentNode(); + + if (result > maxValue) + maxValue = result; + } + + xctxt.popContextNodeList(); + return maxValue; + + } + + /** + * The dyn:min function calculates the minimum value for the nodes passed as the + * first argument, where the value of each node is calculated dynamically using + * an XPath expression passed as a string as the second argument. + *

    + * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:min function itself, except for the following: + *

    + *

      + *
    • the context node is the node whose value is being calculated.
    • + *
    • the context position is the position of the node within the node set passed + * as the first argument to the dyn:min function, arranged in document order.
    • + *
    • the context size is the number of nodes passed as the first argument to the + * dyn:min function.
    • + *
    + *

    + * The dyn:min function returns the minimum of these values, calculated in exactly + * the same way as for math:min. + *

    + * If the expression string passed as the second argument is an invalid XPath expression + * (including an empty string), this function returns NaN. + *

    + * This function must take a second argument. To calculate the minimum of a set of + * nodes based on their string values, you should use the math:min function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * + * @return The minimum evaluation value + */ + public static double min(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException + { + + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); + + if (expr == null || expr.length() == 0) + return Double.NaN; + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + double minValue = Double.MAX_VALUE; + for (int i = 0; i < nl.getLength(); i++) + { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + double result = 0; + try + { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num(); + } + catch (TransformerException e) + { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return Double.NaN; + } + + xctxt.popCurrentNode(); + + if (result < minValue) + minValue = result; + } + + xctxt.popContextNodeList(); + return minValue; + + } + + /** + * The dyn:sum function calculates the sum for the nodes passed as the first argument, + * where the value of each node is calculated dynamically using an XPath expression + * passed as a string as the second argument. + *

    + * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:sum function itself, except for the following: + *

    + *

      + *
    • the context node is the node whose value is being calculated.
    • + *
    • the context position is the position of the node within the node set passed as + * the first argument to the dyn:sum function, arranged in document order.
    • + *
    • the context size is the number of nodes passed as the first argument to the + * dyn:sum function.
    • + *
    + *

    + * The dyn:sum function returns the sumimum of these values, calculated in exactly + * the same way as for sum. + *

    + * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns NaN. + *

    + * This function must take a second argument. To calculate the sumimum of a set of + * nodes based on their string values, you should use the sum function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * + * @return The sum of the evaluation value on each node + */ + public static double sum(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException + { + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); + + if (expr == null || expr.length() == 0) + return Double.NaN; + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + double sum = 0; + for (int i = 0; i < nl.getLength(); i++) + { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + double result = 0; + try + { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num(); + } + catch (TransformerException e) + { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return Double.NaN; + } + + xctxt.popCurrentNode(); + + sum = sum + result; + + } + + xctxt.popContextNodeList(); + return sum; + } + + /** + * The dyn:map function evaluates the expression passed as the second argument for + * each of the nodes passed as the first argument, and returns a node set of those values. + *

    + * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:map function itself, except for the following: + *

    + *

      + *
    • The context node is the node whose value is being calculated.
    • + *
    • the context position is the position of the node within the node set passed + * as the first argument to the dyn:map function, arranged in document order.
    • + *
    • the context size is the number of nodes passed as the first argument to the + * dyn:map function.
    • + *
    + *

    + * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns an empty node set. + *

    + * If the XPath expression evaluates as a node set, the dyn:map function returns + * the union of the node sets returned by evaluating the expression for each of the + * nodes in the first argument. Note that this may mean that the node set resulting + * from the call to the dyn:map function contains a different number of nodes from + * the number in the node set passed as the first argument to the function. + *

    + * If the XPath expression evaluates as a number, the dyn:map function returns a + * node set containing one exsl:number element (namespace http://exslt.org/common) + * for each node in the node set passed as the first argument to the dyn:map function, + * in document order. The string value of each exsl:number element is the same as + * the result of converting the number resulting from evaluating the expression to + * a string as with the number function, with the exception that Infinity results + * in an exsl:number holding the highest number the implementation can store, and + * -Infinity results in an exsl:number holding the lowest number the implementation + * can store. + *

    + * If the XPath expression evaluates as a boolean, the dyn:map function returns a + * node set containing one exsl:boolean element (namespace http://exslt.org/common) + * for each node in the node set passed as the first argument to the dyn:map function, + * in document order. The string value of each exsl:boolean element is 'true' if the + * expression evaluates as true for the node, and '' if the expression evaluates as + * false. + *

    + * Otherwise, the dyn:map function returns a node set containing one exsl:string + * element (namespace http://exslt.org/common) for each node in the node set passed + * as the first argument to the dyn:map function, in document order. The string + * value of each exsl:string element is the same as the result of converting the + * result of evaluating the expression for the relevant node to a string as with + * the string function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * + * @return The node set after evaluation + */ + public static NodeList map(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException + { + XPathContext xctxt = null; + Document lDoc = null; + + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); + + if (expr == null || expr.length() == 0) + return new NodeSet(); + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + NodeSet resultSet = new NodeSet(); + resultSet.setShouldCacheNodes(true); + + for (int i = 0; i < nl.getLength(); i++) + { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + XObject object = null; + try + { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + object = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()); + + if (object instanceof XNodeSet) + { + NodeList nodelist = null; + nodelist = ((XNodeSet)object).nodelist(); + + for (int k = 0; k < nodelist.getLength(); k++) + { + Node n = nodelist.item(k); + if (!resultSet.contains(n)) + resultSet.addNode(n); + } + } + else + { + if (lDoc == null) + { + lDoc = JdkXmlUtils.getDOMDocument(); + } + + Element element = null; + if (object instanceof XNumber) + element = lDoc.createElementNS(EXSL_URI, "exsl:number"); + else if (object instanceof XBoolean) + element = lDoc.createElementNS(EXSL_URI, "exsl:boolean"); + else + element = lDoc.createElementNS(EXSL_URI, "exsl:string"); + + Text textNode = lDoc.createTextNode(object.str()); + element.appendChild(textNode); + resultSet.addNode(element); + } + } + catch (Exception e) + { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return new NodeSet(); + } + + xctxt.popCurrentNode(); + + } + + xctxt.popContextNodeList(); + return resultSet; + } + + /** + * The dyn:evaluate function evaluates a string as an XPath expression and returns + * the resulting value, which might be a boolean, number, string, node set, result + * tree fragment or external object. The sole argument is the string to be evaluated. + *

    + * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns an empty node set. + *

    + * You should only use this function if the expression must be constructed dynamically, + * otherwise it is much more efficient to use the expression literally. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param xpathExpr The XPath expression string + * + * @return The evaluation result + */ + public static XObject evaluate(ExpressionContext myContext, String xpathExpr) + throws SAXNotSupportedException + { + if (myContext instanceof XPathContext.XPathExpressionContext) + { + XPathContext xctxt = null; + try + { + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + + return dynamicXPath.execute(xctxt, myContext.getContextNode(), + xctxt.getNamespaceContext()); + } + catch (TransformerException e) + { + return new XNodeSet(xctxt.getDTMManager()); + } + } + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); //"Invalid context passed to evaluate " + } + + /** + * The dyn:closure function creates a node set resulting from transitive closure of + * evaluating the expression passed as the second argument on each of the nodes passed + * as the first argument, then on the node set resulting from that and so on until no + * more nodes are found. For example: + *

    +   *  dyn:closure(., '*')
    +   * 
    + * returns all the descendant elements of the node (its element children, their + * children, their children's children and so on). + *

    + * The expression is thus evaluated several times, each with a different node set + * acting as the context of the expression. The first time the expression is + * evaluated, the context node set is the first argument passed to the dyn:closure + * function. In other words, the node set for each node is calculated by evaluating + * the XPath expression with all context information being the same as that for + * the call to the dyn:closure function itself, except for the following: + *

    + *

      + *
    • the context node is the node whose value is being calculated.
    • + *
    • the context position is the position of the node within the node set passed + * as the first argument to the dyn:closure function, arranged in document order.
    • + *
    • the context size is the number of nodes passed as the first argument to the + * dyn:closure function.
    • + *
    • the current node is the node whose value is being calculated.
    • + *
    + *

    + * The result for a particular iteration is the union of the node sets resulting + * from evaluting the expression for each of the nodes in the source node set for + * that iteration. This result is then used as the source node set for the next + * iteration, and so on. The result of the function as a whole is the union of + * the node sets generated by each iteration. + *

    + * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string) or an expression that does not return a + * node set, this function returns an empty node set. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * + * @return The node set after evaluation + */ + public static NodeList closure(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException + { + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); + + if (expr == null || expr.length() == 0) + return new NodeSet(); + + NodeSet closureSet = new NodeSet(); + closureSet.setShouldCacheNodes(true); + + NodeList iterationList = nl; + do + { + + NodeSet iterationSet = new NodeSet(); + + NodeSetDTM contextNodes = new NodeSetDTM(iterationList, xctxt); + xctxt.pushContextNodeList(contextNodes); + + for (int i = 0; i < iterationList.getLength(); i++) + { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + XObject object = null; + try + { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + object = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()); + + if (object instanceof XNodeSet) + { + NodeList nodelist = null; + nodelist = ((XNodeSet)object).nodelist(); + + for (int k = 0; k < nodelist.getLength(); k++) + { + Node n = nodelist.item(k); + if (!iterationSet.contains(n)) + iterationSet.addNode(n); + } + } + else + { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return new NodeSet(); + } + } + catch (TransformerException e) + { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return new NodeSet(); + } + + xctxt.popCurrentNode(); + + } + + xctxt.popContextNodeList(); + + iterationList = iterationSet; + + for (int i = 0; i < iterationList.getLength(); i++) + { + Node n = iterationList.item(i); + if (!closureSet.contains(n)) + closureSet.addNode(n); + } + + } while(iterationList.getLength() > 0); + + return closureSet; + + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltMath.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltMath.java new file mode 100644 index 000000000..5f6358370 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltMath.java @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xpath.internal.NodeSet; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * This class contains EXSLT math extension functions. + * It is accessed by specifying a namespace URI as follows: + *

    + *    xmlns:math="http://exslt.org/math"
    + * 
    + * + * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @see EXSLT + + * @xsl.usage general + */ +public class ExsltMath extends ExsltBase +{ + // Constants + private static String PI = "3.1415926535897932384626433832795028841971693993751"; + private static String E = "2.71828182845904523536028747135266249775724709369996"; + private static String SQRRT2 = "1.41421356237309504880168872420969807856967187537694"; + private static String LN2 = "0.69314718055994530941723212145817656807550013436025"; + private static String LN10 = "2.302585092994046"; + private static String LOG2E = "1.4426950408889633"; + private static String SQRT1_2 = "0.7071067811865476"; + + /** + * The math:max function returns the maximum value of the nodes passed as the argument. + * The maximum value is defined as follows. The node set passed as an argument is sorted + * in descending order as it would be by xsl:sort with a data type of number. The maximum + * is the result of converting the string value of the first node in this sorted list to + * a number using the number function. + *

    + * If the node set is empty, or if the result of converting the string values of any of the + * nodes to a number is NaN, then NaN is returned. + * + * @param nl The NodeList for the node-set to be evaluated. + * + * @return the maximum value found, NaN if any node cannot be converted to a number. + * + * @see EXSLT + */ + public static double max (NodeList nl) + { + if (nl == null || nl.getLength() == 0) + return Double.NaN; + + double m = - Double.MAX_VALUE; + for (int i = 0; i < nl.getLength(); i++) + { + Node n = nl.item(i); + double d = toNumber(n); + if (Double.isNaN(d)) + return Double.NaN; + else if (d > m) + m = d; + } + + return m; + } + + /** + * The math:min function returns the minimum value of the nodes passed as the argument. + * The minimum value is defined as follows. The node set passed as an argument is sorted + * in ascending order as it would be by xsl:sort with a data type of number. The minimum + * is the result of converting the string value of the first node in this sorted list to + * a number using the number function. + *

    + * If the node set is empty, or if the result of converting the string values of any of + * the nodes to a number is NaN, then NaN is returned. + * + * @param nl The NodeList for the node-set to be evaluated. + * + * @return the minimum value found, NaN if any node cannot be converted to a number. + * + * @see EXSLT + */ + public static double min (NodeList nl) + { + if (nl == null || nl.getLength() == 0) + return Double.NaN; + + double m = Double.MAX_VALUE; + for (int i = 0; i < nl.getLength(); i++) + { + Node n = nl.item(i); + double d = toNumber(n); + if (Double.isNaN(d)) + return Double.NaN; + else if (d < m) + m = d; + } + + return m; + } + + /** + * The math:highest function returns the nodes in the node set whose value is the maximum + * value for the node set. The maximum value for the node set is the same as the value as + * calculated by math:max. A node has this maximum value if the result of converting its + * string value to a number as if by the number function is equal to the maximum value, + * where the equality comparison is defined as a numerical comparison using the = operator. + *

    + * If any of the nodes in the node set has a non-numeric value, the math:max function will + * return NaN. The definition numeric comparisons entails that NaN != NaN. Therefore if any + * of the nodes in the node set has a non-numeric value, math:highest will return an empty + * node set. + * + * @param nl The NodeList for the node-set to be evaluated. + * + * @return node-set with nodes containing the maximum value found, an empty node-set + * if any node cannot be converted to a number. + */ + public static NodeList highest (NodeList nl) + { + double maxValue = max(nl); + + NodeSet highNodes = new NodeSet(); + highNodes.setShouldCacheNodes(true); + + if (Double.isNaN(maxValue)) + return highNodes; // empty Nodeset + + for (int i = 0; i < nl.getLength(); i++) + { + Node n = nl.item(i); + double d = toNumber(n); + if (d == maxValue) + highNodes.addElement(n); + } + return highNodes; + } + + /** + * The math:lowest function returns the nodes in the node set whose value is the minimum value + * for the node set. The minimum value for the node set is the same as the value as calculated + * by math:min. A node has this minimum value if the result of converting its string value to + * a number as if by the number function is equal to the minimum value, where the equality + * comparison is defined as a numerical comparison using the = operator. + *

    + * If any of the nodes in the node set has a non-numeric value, the math:min function will return + * NaN. The definition numeric comparisons entails that NaN != NaN. Therefore if any of the nodes + * in the node set has a non-numeric value, math:lowest will return an empty node set. + * + * @param nl The NodeList for the node-set to be evaluated. + * + * @return node-set with nodes containing the minimum value found, an empty node-set + * if any node cannot be converted to a number. + * + */ + public static NodeList lowest (NodeList nl) + { + double minValue = min(nl); + + NodeSet lowNodes = new NodeSet(); + lowNodes.setShouldCacheNodes(true); + + if (Double.isNaN(minValue)) + return lowNodes; // empty Nodeset + + for (int i = 0; i < nl.getLength(); i++) + { + Node n = nl.item(i); + double d = toNumber(n); + if (d == minValue) + lowNodes.addElement(n); + } + return lowNodes; + } + + /** + * The math:abs function returns the absolute value of a number. + * + * @param num A number + * @return The absolute value of the number + */ + public static double abs(double num) + { + return Math.abs(num); + } + + /** + * The math:acos function returns the arccosine value of a number. + * + * @param num A number + * @return The arccosine value of the number + */ + public static double acos(double num) + { + return Math.acos(num); + } + + /** + * The math:asin function returns the arcsine value of a number. + * + * @param num A number + * @return The arcsine value of the number + */ + public static double asin(double num) + { + return Math.asin(num); + } + + /** + * The math:atan function returns the arctangent value of a number. + * + * @param num A number + * @return The arctangent value of the number + */ + public static double atan(double num) + { + return Math.atan(num); + } + + /** + * The math:atan2 function returns the angle ( in radians ) from the X axis to a point (y,x). + * + * @param num1 The X axis value + * @param num2 The Y axis value + * @return The angle (in radians) from the X axis to a point (y,x) + */ + public static double atan2(double num1, double num2) + { + return Math.atan2(num1, num2); + } + + /** + * The math:cos function returns cosine of the passed argument. + * + * @param num A number + * @return The cosine value of the number + */ + public static double cos(double num) + { + return Math.cos(num); + } + + /** + * The math:exp function returns e (the base of natural logarithms) raised to a power. + * + * @param num A number + * @return The value of e raised to the given power + */ + public static double exp(double num) + { + return Math.exp(num); + } + + /** + * The math:log function returns the natural logarithm of a number. + * + * @param num A number + * @return The natural logarithm of the number + */ + public static double log(double num) + { + return Math.log(num); + } + + /** + * The math:power function returns the value of a base expression taken to a specified power. + * + * @param num1 The base + * @param num2 The power + * @return The value of the base expression taken to the specified power + */ + public static double power(double num1, double num2) + { + return Math.pow(num1, num2); + } + + /** + * The math:random function returns a random number from 0 to 1. + * + * @return A random double from 0 to 1 + */ + public static double random() + { + return Math.random(); + } + + /** + * The math:sin function returns the sine of the number. + * + * @param num A number + * @return The sine value of the number + */ + public static double sin(double num) + { + return Math.sin(num); + } + + /** + * The math:sqrt function returns the square root of a number. + * + * @param num A number + * @return The square root of the number + */ + public static double sqrt(double num) + { + return Math.sqrt(num); + } + + /** + * The math:tan function returns the tangent of the number passed as an argument. + * + * @param num A number + * @return The tangent value of the number + */ + public static double tan(double num) + { + return Math.tan(num); + } + + /** + * The math:constant function returns the specified constant to a set precision. + * The possible constants are: + *

    +   *  PI
    +   *  E
    +   *  SQRRT2
    +   *  LN2
    +   *  LN10
    +   *  LOG2E
    +   *  SQRT1_2
    +   * 
    + * @param name The name of the constant + * @param precision The precision + * @return The value of the specified constant to the given precision + */ + public static double constant(String name, double precision) + { + String value = null; + if (name.equals("PI")) + value = PI; + else if (name.equals("E")) + value = E; + else if (name.equals("SQRRT2")) + value = SQRRT2; + else if (name.equals("LN2")) + value = LN2; + else if (name.equals("LN10")) + value = LN10; + else if (name.equals("LOG2E")) + value = LOG2E; + else if (name.equals("SQRT1_2")) + value = SQRT1_2; + + if (value != null) + { + int bits = (int)precision; + + if (bits <= value.length()) + value = value.substring(0, bits); + + return Double.parseDouble(value); + } + else + return Double.NaN; + + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltSets.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltSets.java new file mode 100644 index 000000000..3b90b0e14 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltSets.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: ExsltSets.java,v 1.1.2.1 2005/08/01 02:08:50 jeffsuttor Exp $ + */ +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xml.internal.utils.DOM2Helper; +import com.sun.org.apache.xpath.internal.NodeSet; +import java.util.HashMap; +import java.util.Map; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * This class contains EXSLT set extension functions. + * It is accessed by specifying a namespace URI as follows: + *
    + *    xmlns:set="http://exslt.org/sets"
    + * 
    + * + * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @see EXSLT + * @xsl.usage general + */ +public class ExsltSets extends ExsltBase +{ + /** + * The set:leading function returns the nodes in the node set passed as the first argument that + * precede, in document order, the first node in the node set passed as the second argument. If + * the first node in the second node set is not contained in the first node set, then an empty + * node set is returned. If the second node set is empty, then the first node set is returned. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that precede in document order the first + * node in nl2; an empty node-set if the first node in nl2 is not in nl1; all of nl1 if nl2 + * is empty. + * + * @see EXSLT + */ + public static NodeList leading (NodeList nl1, NodeList nl2) + { + if (nl2.getLength() == 0) + return nl1; + + NodeSet ns1 = new NodeSet(nl1); + NodeSet leadNodes = new NodeSet(); + Node endNode = nl2.item(0); + if (!ns1.contains(endNode)) + return leadNodes; // empty NodeSet + + for (int i = 0; i < nl1.getLength(); i++) + { + Node testNode = nl1.item(i); + if (DOM2Helper.isNodeAfter(testNode, endNode) + && !DOM2Helper.isNodeTheSame(testNode, endNode)) + leadNodes.addElement(testNode); + } + return leadNodes; + } + + /** + * The set:trailing function returns the nodes in the node set passed as the first argument that + * follow, in document order, the first node in the node set passed as the second argument. If + * the first node in the second node set is not contained in the first node set, then an empty + * node set is returned. If the second node set is empty, then the first node set is returned. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that follow in document order the first + * node in nl2; an empty node-set if the first node in nl2 is not in nl1; all of nl1 if nl2 + * is empty. + * + * @see EXSLT + */ + public static NodeList trailing (NodeList nl1, NodeList nl2) + { + if (nl2.getLength() == 0) + return nl1; + + NodeSet ns1 = new NodeSet(nl1); + NodeSet trailNodes = new NodeSet(); + Node startNode = nl2.item(0); + if (!ns1.contains(startNode)) + return trailNodes; // empty NodeSet + + for (int i = 0; i < nl1.getLength(); i++) + { + Node testNode = nl1.item(i); + if (DOM2Helper.isNodeAfter(startNode, testNode) + && !DOM2Helper.isNodeTheSame(startNode, testNode)) + trailNodes.addElement(testNode); + } + return trailNodes; + } + + /** + * The set:intersection function returns a node set comprising the nodes that are within + * both the node sets passed as arguments to it. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that are also + * in nl2. + * + * @see EXSLT + */ + public static NodeList intersection(NodeList nl1, NodeList nl2) + { + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + NodeSet inter = new NodeSet(); + + inter.setShouldCacheNodes(true); + + for (int i = 0; i < ns1.getLength(); i++) + { + Node n = ns1.elementAt(i); + + if (ns2.contains(n)) + inter.addElement(n); + } + + return inter; + } + + /** + * The set:difference function returns the difference between two node sets - those nodes that + * are in the node set passed as the first argument that are not in the node set passed as the + * second argument. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that are not in nl2. + * + * @see EXSLT + */ + public static NodeList difference(NodeList nl1, NodeList nl2) + { + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + + NodeSet diff = new NodeSet(); + + diff.setShouldCacheNodes(true); + + for (int i = 0; i < ns1.getLength(); i++) + { + Node n = ns1.elementAt(i); + + if (!ns2.contains(n)) + diff.addElement(n); + } + + return diff; + } + + /** + * The set:distinct function returns a subset of the nodes contained in the node-set NS passed + * as the first argument. Specifically, it selects a node N if there is no node in NS that has + * the same string value as N, and that precedes N in document order. + * + * @param nl NodeList for the node-set. + * @return a NodeList with nodes from nl containing distinct string values. + * In other words, if more than one node in nl contains the same string value, + * only include the first such node found. + * + * @see EXSLT + */ + public static NodeList distinct(NodeList nl) + { + NodeSet dist = new NodeSet(); + dist.setShouldCacheNodes(true); + + Map stringTable = new HashMap<>(); + + for (int i = 0; i < nl.getLength(); i++) + { + Node currNode = nl.item(i); + String key = toString(currNode); + + if (key == null) + dist.addElement(currNode); + else if (!stringTable.containsKey(key)) + { + stringTable.put(key, currNode); + dist.addElement(currNode); + } + } + + return dist; + } + + /** + * The set:has-same-node function returns true if the node set passed as the first argument shares + * any nodes with the node set passed as the second argument. If there are no nodes that are in both + * node sets, then it returns false. + * + * The Xalan extensions MethodResolver converts 'has-same-node' to 'hasSameNode'. + * + * Note: Not to be confused with hasSameNodes in the Xalan namespace, which returns true if + * the two node sets contain the exactly the same nodes (perhaps in a different order), + * otherwise false. + * + * @see EXSLT + */ + public static boolean hasSameNode(NodeList nl1, NodeList nl2) + { + + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + + for (int i = 0; i < ns1.getLength(); i++) + { + if (ns2.contains(ns1.elementAt(i))) + return true; + } + return false; + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java new file mode 100644 index 000000000..afc9eca9c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java @@ -0,0 +1,325 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import java.util.StringTokenizer; +import com.sun.org.apache.xpath.internal.NodeSet; +import jdk.xml.internal.JdkXmlUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +/** + * This class contains EXSLT strings extension functions. + * + * It is accessed by specifying a namespace URI as follows: + *
    + *    xmlns:str="http://exslt.org/strings"
    + * 
    + * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @see EXSLT + + * @xsl.usage general + */ +public class ExsltStrings extends ExsltBase +{ + + /** + * The str:align function aligns a string within another string. + *

    + * The first argument gives the target string to be aligned. The second argument gives + * the padding string within which it is to be aligned. + *

    + * If the target string is shorter than the padding string then a range of characters + * in the padding string are repaced with those in the target string. Which characters + * are replaced depends on the value of the third argument, which gives the type of + * alignment. It can be one of 'left', 'right' or 'center'. If no third argument is + * given or if it is not one of these values, then it defaults to left alignment. + *

    + * With left alignment, the range of characters replaced by the target string begins + * with the first character in the padding string. With right alignment, the range of + * characters replaced by the target string ends with the last character in the padding + * string. With center alignment, the range of characters replaced by the target string + * is in the middle of the padding string, such that either the number of unreplaced + * characters on either side of the range is the same or there is one less on the left + * than there is on the right. + *

    + * If the target string is longer than the padding string, then it is truncated to be + * the same length as the padding string and returned. + * + * @param targetStr The target string + * @param paddingStr The padding string + * @param type The type of alignment + * + * @return The string after alignment + */ + public static String align(String targetStr, String paddingStr, String type) + { + if (targetStr.length() >= paddingStr.length()) + return targetStr.substring(0, paddingStr.length()); + + if (type.equals("right")) + { + return paddingStr.substring(0, paddingStr.length() - targetStr.length()) + targetStr; + } + else if (type.equals("center")) + { + int startIndex = (paddingStr.length() - targetStr.length()) / 2; + return paddingStr.substring(0, startIndex) + targetStr + paddingStr.substring(startIndex + targetStr.length()); + } + // Default is left + else + { + return targetStr + paddingStr.substring(targetStr.length()); + } + } + + /** + * See above + */ + public static String align(String targetStr, String paddingStr) + { + return align(targetStr, paddingStr, "left"); + } + + /** + * The str:concat function takes a node set and returns the concatenation of the + * string values of the nodes in that node set. If the node set is empty, it returns + * an empty string. + * + * @param nl A node set + * @return The concatenation of the string values of the nodes in that node set + */ + public static String concat(NodeList nl) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < nl.getLength(); i++) + { + Node node = nl.item(i); + String value = toString(node); + + if (value != null && value.length() > 0) + sb.append(value); + } + + return sb.toString(); + } + + /** + * The str:padding function creates a padding string of a certain length. + * The first argument gives the length of the padding string to be created. + * The second argument gives a string to be used to create the padding. This + * string is repeated as many times as is necessary to create a string of the + * length specified by the first argument; if the string is more than a character + * long, it may have to be truncated to produce the required length. If no second + * argument is specified, it defaults to a space (' '). If the second argument is + * an empty string, str:padding returns an empty string. + * + * @param length The length of the padding string to be created + * @param pattern The string to be used as pattern + * + * @return A padding string of the given length + */ + public static String padding(double length, String pattern) + { + if (pattern == null || pattern.length() == 0) + return ""; + + StringBuffer sb = new StringBuffer(); + int len = (int)length; + int numAdded = 0; + int index = 0; + while (numAdded < len) + { + if (index == pattern.length()) + index = 0; + + sb.append(pattern.charAt(index)); + index++; + numAdded++; + } + + return sb.toString(); + } + + /** + * See above + */ + public static String padding(double length) + { + return padding(length, " "); + } + + /** + * The str:split function splits up a string and returns a node set of token + * elements, each containing one token from the string. + *

    + * The first argument is the string to be split. The second argument is a pattern + * string. The string given by the first argument is split at any occurrence of + * this pattern. For example: + *

    +   * str:split('a, simple, list', ', ') gives the node set consisting of:
    +   *
    +   * a
    +   * simple
    +   * list
    +   * 
    + * If the second argument is omitted, the default is the string ' ' (i.e. a space). + * + * @param str The string to be split + * @param pattern The pattern + * + * @return A node set of split tokens + */ + public static NodeList split(String str, String pattern) + { + + + NodeSet resultSet = new NodeSet(); + resultSet.setShouldCacheNodes(true); + + boolean done = false; + int fromIndex = 0; + int matchIndex = 0; + String token = null; + + while (!done && fromIndex < str.length()) + { + matchIndex = str.indexOf(pattern, fromIndex); + if (matchIndex >= 0) + { + token = str.substring(fromIndex, matchIndex); + fromIndex = matchIndex + pattern.length(); + } + else + { + done = true; + token = str.substring(fromIndex); + } + + Document doc = JdkXmlUtils.getDOMDocument(); + synchronized (doc) + { + Element element = doc.createElement("token"); + Text text = doc.createTextNode(token); + element.appendChild(text); + resultSet.addNode(element); + } + } + + return resultSet; + } + + /** + * See above + */ + public static NodeList split(String str) + { + return split(str, " "); + } + + /** + * The str:tokenize function splits up a string and returns a node set of token + * elements, each containing one token from the string. + *

    + * The first argument is the string to be tokenized. The second argument is a + * string consisting of a number of characters. Each character in this string is + * taken as a delimiting character. The string given by the first argument is split + * at any occurrence of any of these characters. For example: + *

    +   * str:tokenize('2001-06-03T11:40:23', '-T:') gives the node set consisting of:
    +   *
    +   * 2001
    +   * 06
    +   * 03
    +   * 11
    +   * 40
    +   * 23
    +   * 
    + * If the second argument is omitted, the default is the string ' ' + * (i.e. whitespace characters). + *

    + * If the second argument is an empty string, the function returns a set of token + * elements, each of which holds a single character. + *

    + * Note: This one is different from the tokenize extension function in the Xalan + * namespace. The one in Xalan returns a set of Text nodes, while this one wraps + * the Text nodes inside the token Element nodes. + * + * @param toTokenize The string to be tokenized + * @param delims The delimiter string + * + * @return A node set of split token elements + */ + public static NodeList tokenize(String toTokenize, String delims) + { + + + NodeSet resultSet = new NodeSet(); + + if (delims != null && delims.length() > 0) + { + StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims); + + Document doc = JdkXmlUtils.getDOMDocument(); + synchronized (doc) + { + while (lTokenizer.hasMoreTokens()) + { + Element element = doc.createElement("token"); + element.appendChild(doc.createTextNode(lTokenizer.nextToken())); + resultSet.addNode(element); + } + } + } + // If the delimiter is an empty string, create one token Element for + // every single character. + else + { + + Document doc = JdkXmlUtils.getDOMDocument(); + synchronized (doc) + { + for (int i = 0; i < toTokenize.length(); i++) + { + Element element = doc.createElement("token"); + element.appendChild(doc.createTextNode(toTokenize.substring(i, i+1))); + resultSet.addNode(element); + } + } + } + + return resultSet; + } + + /** + * See above + */ + public static NodeList tokenize(String toTokenize) + { + return tokenize(toTokenize, " \t\n\r"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/Extensions.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/Extensions.java new file mode 100644 index 000000000..e6c411fcb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/Extensions.java @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import java.util.StringTokenizer; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xpath.internal.NodeSet; +import com.sun.org.apache.xpath.internal.objects.XBoolean; +import com.sun.org.apache.xpath.internal.objects.XNumber; +import com.sun.org.apache.xpath.internal.objects.XObject; +import jdk.xml.internal.JdkXmlUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.DocumentFragment; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; +import org.w3c.dom.traversal.NodeIterator; + +import org.xml.sax.SAXNotSupportedException; + +/** + * This class contains many of the Xalan-supplied extensions. + * It is accessed by specifying a namespace URI as follows: + *

    + *    xmlns:xalan="http://xml.apache.org/xalan"
    + * 
    + * @xsl.usage general + */ +public class Extensions +{ + /** + * Constructor Extensions + * + */ + private Extensions(){} // Make sure class cannot be instantiated + + /** + * This method is an extension that implements as a Xalan extension + * the node-set function also found in xt and saxon. + * If the argument is a Result Tree Fragment, then nodeset + * returns a node-set consisting of a single root node as described in + * section 11.1 of the XSLT 1.0 Recommendation. If the argument is a + * node-set, nodeset returns a node-set. If the argument + * is a string, number, or boolean, then nodeset returns + * a node-set consisting of a single root node with a single text node + * child that is the result of calling the XPath string() function on the + * passed parameter. If the argument is anything else, then a node-set + * is returned consisting of a single root node with a single text node + * child that is the result of calling the java toString() + * method on the passed argument. + * Most of the + * actual work here is done in MethodResolver and + * XRTreeFrag. + * @param myProcessor Context passed by the extension processor + * @param rtf Argument in the stylesheet to the nodeset extension function + * + * NEEDSDOC ($objectName$) @return + */ + public static NodeSet nodeset(ExpressionContext myProcessor, Object rtf) + { + + String textNodeValue; + + if (rtf instanceof NodeIterator) + { + return new NodeSet((NodeIterator) rtf); + } + else + { + if (rtf instanceof String) + { + textNodeValue = (String) rtf; + } + else if (rtf instanceof Boolean) + { + textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str(); + } + else if (rtf instanceof Double) + { + textNodeValue = new XNumber(((Double) rtf).doubleValue()).str(); + } + else + { + textNodeValue = rtf.toString(); + } + + // This no longer will work right since the DTM. + // Document myDoc = myProcessor.getContextNode().getOwnerDocument(); + Document myDoc = JdkXmlUtils.getDOMDocument(); + + Text textNode = myDoc.createTextNode(textNodeValue); + DocumentFragment docFrag = myDoc.createDocumentFragment(); + + docFrag.appendChild(textNode); + + return new NodeSet(docFrag); + } + } + + /** + * Returns the intersection of two node-sets. + * + * @param nl1 NodeList for first node-set + * @param nl2 NodeList for second node-set + * @return a NodeList containing the nodes in nl1 that are also in nl2 + * + * Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT sets extension + * (http://exslt.org/sets). + */ + public static NodeList intersection(NodeList nl1, NodeList nl2) + { + return ExsltSets.intersection(nl1, nl2); + } + + /** + * Returns the difference between two node-sets. + * + * @param nl1 NodeList for first node-set + * @param nl2 NodeList for second node-set + * @return a NodeList containing the nodes in nl1 that are not in nl2 + * + * Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT sets extension + * (http://exslt.org/sets). + */ + public static NodeList difference(NodeList nl1, NodeList nl2) + { + return ExsltSets.difference(nl1, nl2); + } + + /** + * Returns node-set containing distinct string values. + * + * @param nl NodeList for node-set + * @return a NodeList with nodes from nl containing distinct string values. + * In other words, if more than one node in nl contains the same string value, + * only include the first such node found. + * + * Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT sets extension + * (http://exslt.org/sets). + */ + public static NodeList distinct(NodeList nl) + { + return ExsltSets.distinct(nl); + } + + /** + * Returns true if both node-sets contain the same set of nodes. + * + * @param nl1 NodeList for first node-set + * @param nl2 NodeList for second node-set + * @return true if nl1 and nl2 contain exactly the same set of nodes. + */ + public static boolean hasSameNodes(NodeList nl1, NodeList nl2) + { + + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + + if (ns1.getLength() != ns2.getLength()) + return false; + + for (int i = 0; i < ns1.getLength(); i++) + { + Node n = ns1.elementAt(i); + + if (!ns2.contains(n)) + return false; + } + + return true; + } + + /** + * Returns the result of evaluating the argument as a string containing + * an XPath expression. Used where the XPath expression is not known until + * run-time. The expression is evaluated as if the run-time value of the + * argument appeared in place of the evaluate function call at compile time. + * + * @param myContext an ExpressionContext passed in by the + * extension mechanism. This must be an XPathContext. + * @param xpathExpr The XPath expression to be evaluated. + * @return the XObject resulting from evaluating the XPath + * + * @throws SAXNotSupportedException + * + * Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT dynamic extension + * (http://exslt.org/dynamic). + */ + public static XObject evaluate(ExpressionContext myContext, String xpathExpr) + throws SAXNotSupportedException + { + return ExsltDynamic.evaluate(myContext, xpathExpr); + } + + /** + * Returns a NodeSet containing one text node for each token in the first argument. + * Delimiters are specified in the second argument. + * Tokens are determined by a call to StringTokenizer. + * If the first argument is an empty string or contains only delimiters, the result + * will be an empty NodeSet. + * + * Contributed to XalanJ1 by Benoit Cerrina. + * + * @param toTokenize The string to be split into text tokens. + * @param delims The delimiters to use. + * @return a NodeSet as described above. + */ + public static NodeList tokenize(String toTokenize, String delims) + { + + Document doc = JdkXmlUtils.getDOMDocument(); + + StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims); + NodeSet resultSet = new NodeSet(); + + synchronized (doc) + { + while (lTokenizer.hasMoreTokens()) + { + resultSet.addNode(doc.createTextNode(lTokenizer.nextToken())); + } + } + + return resultSet; + } + + /** + * Returns a NodeSet containing one text node for each token in the first argument. + * Delimiters are whitespace. That is, the delimiters that are used are tab ( ), + * linefeed ( ), return ( ), and space ( ). + * Tokens are determined by a call to StringTokenizer. + * If the first argument is an empty string or contains only delimiters, the result + * will be an empty NodeSet. + * + * Contributed to XalanJ1 by Benoit Cerrina. + * + * @param toTokenize The string to be split into text tokens. + * @return a NodeSet as described above. + */ + public static NodeList tokenize(String toTokenize) + { + return tokenize(toTokenize, " \t\n\r"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/NodeInfo.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/NodeInfo.java new file mode 100644 index 000000000..ed7b9ca1e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/NodeInfo.java @@ -0,0 +1,248 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import javax.xml.transform.SourceLocator; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * NodeInfo defines a set of XSLT extension functions to be + * used from stylesheets. + * + * @author Ovidiu Predescu + * @since May 24, 2001 + */ +public class NodeInfo +{ + /** + * systemId returns the system id of the current + * context node. + * + * @param context an ExpressionContext value + * @return a String value + */ + public static String systemId(ExpressionContext context) + { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getSystemId(); + else + return null; + } + + /** + * systemId returns the system id of the node passed as + * argument. If a node set is passed as argument, the system id of + * the first node in the set is returned. + * + * @param nodeList a NodeList value + * @return a String value + */ + public static String systemId(NodeList nodeList) + { + if (nodeList == null || nodeList.getLength() == 0) + return null; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getSystemId(); + else + return null; + } + + /** + * publicId returns the public identifier of the current + * context node. + * + * Xalan does not currently record this value, and will return null. + * + * @param context an ExpressionContext value + * @return a String value + */ + public static String publicId(ExpressionContext context) + { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getPublicId(); + else + return null; + } + + /** + * publicId returns the public identifier of the node passed as + * argument. If a node set is passed as argument, the public identifier of + * the first node in the set is returned. + * + * Xalan does not currently record this value, and will return null. + * + * @param nodeList a NodeList value + * @return a String value + */ + public static String publicId(NodeList nodeList) + { + if (nodeList == null || nodeList.getLength() == 0) + return null; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getPublicId(); + else + return null; + } + + /** + * lineNumber returns the line number of the current + * context node. + * + * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param context an ExpressionContext value + * @return an int value. This may be -1 to indicate that the + * line number is not known. + */ + public static int lineNumber(ExpressionContext context) + { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getLineNumber(); + else + return -1; + } + + /** + * lineNumber returns the line number of the node + * passed as argument. If a node set is passed as argument, the line + * number of the first node in the set is returned. + * + * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param nodeList a NodeList value + * @return an int value. This may be -1 to indicate that the + * line number is not known. + */ + public static int lineNumber(NodeList nodeList) + { + if (nodeList == null || nodeList.getLength() == 0) + return -1; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getLineNumber(); + else + return -1; + } + + /** + * columnNumber returns the column number of the + * current context node. + * + * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param context an ExpressionContext value + * @return an int value. This may be -1 to indicate that the + * column number is not known. + */ + public static int columnNumber(ExpressionContext context) + { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getColumnNumber(); + else + return -1; + } + + /** + * columnNumber returns the column number of the node + * passed as argument. If a node set is passed as argument, the line + * number of the first node in the set is returned. + * + * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param nodeList a NodeList value + * @return an int value. This may be -1 to indicate that the + * column number is not known. + */ + public static int columnNumber(NodeList nodeList) + { + if (nodeList == null || nodeList.getLength() == 0) + return -1; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy)node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getColumnNumber(); + else + return -1; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/package.html new file mode 100644 index 000000000..b6211681b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/package.html @@ -0,0 +1,29 @@ + + + + + Xalan and EXSLT Extensions. + +

    Extension elements and functions shipped with Xalan-Java, including EXSLT functions.

    +

    We are adding extensions to this package.

    + + + + diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLMessages.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLMessages.java new file mode 100644 index 000000000..ef84aa055 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLMessages.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import com.sun.org.apache.xpath.internal.res.XPATHMessages; +import java.util.ResourceBundle; +import jdk.xml.internal.SecuritySupport; + +/** + * Sets things up for issuing error messages. This class is misnamed, and should + * be called XalanMessages, or some such. + * + * @xsl.usage internal + * @LastModified: Sep 2017 + */ +public class XSLMessages extends XPATHMessages { + + /** + * The language specific resource object for Xalan messages. + */ + private static ResourceBundle XSLTBundle = null; + /** + * The class name of the Xalan error message string table. + */ + private static final String XSLT_ERROR_RESOURCES = + "com.sun.org.apache.xalan.internal.res.XSLTErrorResources"; + + /** + * Creates a message from the specified key and replacement arguments, + * localized to the given locale. + * + * @param msgKey The key for the message text. + * @param args The arguments to be used as replacement text in the message + * created. + * + * @return The formatted message string. + */ + public static String createMessage(String msgKey, Object args[]) //throws Exception + { + if (XSLTBundle == null) { + XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES); + } + + if (XSLTBundle != null) { + return createMsg(XSLTBundle, msgKey, args); + } else { + return "Could not load any resource bundles."; + } + } + + /** + * Creates a message from the specified key and replacement arguments, + * localized to the given locale. + * + * @param msgKey The key for the message text. + * @param args The arguments to be used as replacement text in the message + * created. + * + * @return The formatted warning string. + */ + public static String createWarning(String msgKey, Object args[]) //throws Exception + { + if (XSLTBundle == null) { + XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES); + } + + if (XSLTBundle != null) { + return createMsg(XSLTBundle, msgKey, args); + } else { + return "Could not load any resource bundles."; + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java new file mode 100644 index 000000000..e5b8aeabf --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + * @LastModified: May 2022 + */ +public class XSLTErrorResources extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "Error: Can not have '{' within expression"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} has an illegal attribute: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode is null in xsl:apply-imports!"}, + + {ER_CANNOT_ADD, + "Can not add {0} to {1}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode is null in handleApplyTemplatesInstruction!"}, + + { ER_NO_NAME_ATTRIB, + "{0} must have a name attribute."}, + + {ER_TEMPLATE_NOT_FOUND, + "Could not find template named: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Could not resolve name AVT in xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} requires attribute: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} must have a ''test'' attribute."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Bad value on level attribute: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction name can not be 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction name must be a valid NCName: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} must have a match attribute if it has a mode."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} requires either a name or a match attribute."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Can not resolve namespace prefix: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space has an illegal value: {0}"}, + + { ER_NO_OWNERDOC, + "Child node does not have an owner document!"}, + + { ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement error: {0}"}, + + { ER_NULL_CHILD, + "Trying to add a null child!"}, + + { ER_NEED_SELECT_ATTRIB, + "{0} requires a select attribute."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when must have a 'test' attribute."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param must have a 'name' attribute."}, + + { ER_NO_CONTEXT_OWNERDOC, + "context does not have an owner document!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Could not create XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: Process was not successful."}, + + { ER_NOT_SUCCESSFUL, + "Xalan: was not successful."}, + + { ER_ENCODING_NOT_SUPPORTED, + "Encoding not supported: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Could not create TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key requires a 'name' attribute!"}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key requires a 'match' attribute!"}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key requires a 'use' attribute!"}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} requires an ''elements'' attribute!"}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} attribute ''prefix'' is missing"}, + + { ER_BAD_STYLESHEET_URL, + "Stylesheet URL is bad: {0}"}, + + { ER_FILE_NOT_FOUND, + "Stylesheet file was not found: {0}"}, + + { ER_IOEXCEPTION, + "Had IO Exception with stylesheet file: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Could not find href attribute for {0}"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} is directly or indirectly including itself!"}, + + { ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude error, {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0} attribute ''lang'' is missing"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) misplaced {0} element?? Missing container element ''component''"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Can only output to an Element, DocumentFragment, Document, or PrintWriter."}, + + { ER_PROCESS_ERROR, + "StylesheetRoot.process error"}, + + { ER_UNIMPLNODE_ERROR, + "UnImplNode error: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "Error! Did not find xpath select expression (-select)."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Can not serialize an XSLProcessor!"}, + + { ER_NO_INPUT_STYLESHEET, + "Stylesheet input was not specified!"}, + + { ER_FAILED_PROCESS_STYLESHEET, + "Failed to process stylesheet!"}, + + { ER_COULDNT_PARSE_DOC, + "Could not parse {0} document!"}, + + { ER_COULDNT_FIND_FRAGMENT, + "Could not find fragment: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "Node pointed to by fragment identifier was not an element: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each must have either a match or name attribute"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates must have either a match or name attribute"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "No clone of a document fragment!"}, + + { ER_CANT_CREATE_ITEM, + "Can not create item in result tree: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space in the source XML has an illegal value: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "There is no xsl:key declaration for {0}!"}, + + { ER_CANT_CREATE_URL, + "Error! Cannot create url for: {0}"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions is unsupported"}, + + { ER_PROCESSOR_ERROR, + "XSLT TransformerFactory Error"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} not allowed inside a stylesheet!"}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns no longer supported! Use xsl:output instead."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space no longer supported! Use xsl:strip-space or xsl:preserve-space instead."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result no longer supported! Use xsl:output instead."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} has an illegal attribute: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "Unknown XSL element: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort can only be used with xsl:apply-templates or xsl:for-each."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) misplaced xsl:when!"}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when not parented by xsl:choose!"}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) misplaced xsl:otherwise!"}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise not parented by xsl:choose!"}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} is not allowed inside a template!"}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0} extension namespace prefix {1} unknown"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Imports can only occur as the first elements in the stylesheet!"}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} is directly or indirectly importing itself!"}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) " + "xml:space has an illegal value: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet not succesfull!"}, + + { ER_SAX_EXCEPTION, + "SAX Exception"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "Function not supported!"}, + + { ER_XSLT_ERROR, + "XSLT Error"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "currency sign is not allowed in format pattern string"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Document function not supported in Stylesheet DOM!"}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Can't resolve prefix of non-Prefix resolver!"}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "Redirect extension: Could not get filename - file or select attribute must return vald string."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Can not build FormatterListener in Redirect extension!"}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Prefix in exclude-result-prefixes is not valid: {0}"}, + + { ER_MISSING_NS_URI, + "Missing namespace URI for specified prefix"}, + + { ER_MISSING_ARG_FOR_OPTION, + "Missing argument for option: {0}"}, + + { ER_INVALID_OPTION, + "Invalid option: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "Malformed format string: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet requires a 'version' attribute!"}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "Attribute: {0} has an illegal value: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose requires an xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports not allowed in a xsl:for-each"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "Cannot use a DTMLiaison for an output DOM node... pass a com.sun.org.apache.xpath.internal.DOM2Helper instead!"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "Cannot use a DTMLiaison for a input DOM node... pass a com.sun.org.apache.xpath.internal.DOM2Helper instead!"}, + + { ER_CALL_TO_EXT_FAILED, + "Call to extension element failed: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "Prefix must resolve to a namespace: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "Invalid UTF-16 surrogate detected: {0} ?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} used itself, which will cause an infinite loop."}, + + { ER_CANNOT_MIX_XERCESDOM, + "Can not mix non Xerces-DOM input with Xerces-DOM output!"}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "In ElemTemplateElement.readObject: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "Found more than one template named: {0}"}, + + { ER_INVALID_KEY_CALL, + "Invalid function call: recursive key() calls are not allowed"}, + + { ER_REFERENCING_ITSELF, + "Variable {0} is directly or indirectly referencing itself!"}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "The input node can not be null for a DOMSource for newTemplates!"}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "Class file not found for option {0}"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "Required Element not found: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream cannot be null"}, + + { ER_URI_CANNOT_BE_NULL, + "URI cannot be null"}, + + { ER_FILE_CANNOT_BE_NULL, + "File cannot be null"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource cannot be null"}, + + { ER_CANNOT_INIT_BSFMGR, + "Could not initialize BSF Manager"}, + + { ER_CANNOT_CMPL_EXTENSN, + "Could not compile extension"}, + + { ER_CANNOT_CREATE_EXTENSN, + "Could not create extension: {0} because of: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "Instance method call to method {0} requires an Object instance as first argument"}, + + { ER_INVALID_ELEMENT_NAME, + "Invalid element name specified {0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "Element name method must be static {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "Extension function {0} : {1} is unknown"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "More than one best match for constructor for {0}"}, + + { ER_MORE_MATCH_METHOD, + "More than one best match for method {0}"}, + + { ER_MORE_MATCH_ELEMENT, + "More than one best match for element method {0}"}, + + { ER_INVALID_CONTEXT_PASSED, + "Invalid context passed to evaluate {0}"}, + + { ER_POOL_EXISTS, + "Pool already exists"}, + + { ER_NO_DRIVER_NAME, + "No driver Name specified"}, + + { ER_NO_URL, + "No URL specified"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "Pool size is less than one!"}, + + { ER_INVALID_DRIVER, + "Invalid driver name specified!"}, + + { ER_NO_STYLESHEETROOT, + "Did not find the stylesheet root!"}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "Illegal value for xml:space"}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode failed"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "The resource [ {0} ] could not load: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Buffer size <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Unknown error when calling extension"}, + + { ER_NO_NAMESPACE_DECL, + "Prefix {0} does not have a corresponding namespace declaration"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "Element content not allowed for lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "Stylesheet directed termination"}, + + { ER_ONE_OR_TWO, + "1 or 2"}, + + { ER_TWO_OR_THREE, + "2 or 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "Could not load {0} (check CLASSPATH), now using just the defaults"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Cannot initialize default templates"}, + + { ER_RESULT_NULL, + "Result should not be null"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "Result could not be set"}, + + { ER_NO_OUTPUT_SPECIFIED, + "No output specified"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Can''t transform to a Result of type {0}"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Can''t transform a Source of type {0}"}, + + { ER_NULL_CONTENT_HANDLER, + "Null content handler"}, + + { ER_NULL_ERROR_HANDLER, + "Null error handler"}, + + { ER_CANNOT_CALL_PARSE, + "parse can not be called if the ContentHandler has not been set"}, + + { ER_NO_PARENT_FOR_FILTER, + "No parent for filter"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "No stylesheet found in: {0}, media= {1}"}, + + { ER_NO_STYLESHEET_PI, + "No xml-stylesheet PI found in: {0}"}, + + { ER_NOT_SUPPORTED, + "Not supported: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "Value for property {0} should be a Boolean instance"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Could not get to external script at {0}"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "The resource [ {0} ] could not be found.\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Output property not recognized: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "Failed creating ElemLiteralResult instance"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "Value for {0} should contain a parsable number"}, + + { ER_VALUE_SHOULD_EQUAL, + "Value for {0} should equal yes or no"}, + + { ER_FAILED_CALLING_METHOD, + "Failed calling {0} method"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "Failed creating ElemTemplateElement instance"}, + + { ER_CHARS_NOT_ALLOWED, + "Characters are not allowed at this point in the document"}, + + { ER_ATTR_NOT_ALLOWED, + "\"{0}\" attribute is not allowed on the {1} element!"}, + + { ER_BAD_VALUE, + "{0} bad value {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "{0} attribute value not found "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} attribute value not recognized "}, + + { ER_NULL_URI_NAMESPACE, + "Attempting to generate a namespace prefix with a null URI"}, + + { ER_NUMBER_TOO_BIG, + "Attempting to format a number bigger than the largest Long integer"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "Cannot find SAX1 driver class {0}"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "SAX1 driver class {0} found but cannot be loaded"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1 driver class {0} loaded but cannot be instantiated"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 driver class {0} does not implement org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "System property org.xml.sax.parser not specified"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "Parser argument must not be null"}, + + { ER_FEATURE, + "Feature: {0}"}, + + { ER_PROPERTY, + "Property: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "Null entity resolver"}, + + { ER_NULL_DTD_HANDLER, + "Null DTD handler"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "No Driver Name Specified!"}, + + { ER_NO_URL_SPECIFIED, + "No URL Specified!"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "Pool size is less than 1!"}, + + { ER_INVALID_DRIVER_NAME, + "Invalid Driver Name Specified!"}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "Programmer's error! The expression has no ElemTemplateElement parent!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Programmer''s assertion in RedundentExprEliminator: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0} is not allowed in this position in the stylesheet!"}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Non-whitespace text is not allowed in this position in the stylesheet!"}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "Illegal value: {1} used for CHAR attribute: {0}. An attribute of type CHAR must be only 1 character!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "Illegal value: {1} used for QNAME attribute: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "Illegal value: {1} used for ENUM attribute: {0}. Valid values are: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "Illegal value: {1} used for NMTOKEN attribute: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "Illegal value: {1} used for NCNAME attribute: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Illegal value: {1} used for boolean attribute: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Illegal value: {1} used for number attribute: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "Argument to {0} in match pattern must be a literal."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "Duplicate global variable declaration."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "Duplicate variable declaration."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template must have a name or match attribute (or both)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "Prefix in exclude-result-prefixes is not valid: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "attribute-set named {0} does not exist"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "The function named {0} does not exist"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "The {0} element must not have both content and a select attribute."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "The value of param {0} must be a valid Java Object"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "The result-prefix attribute of an xsl:namespace-alias element has the value '#default', but there is no declaration of the default namespace in scope for the element"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "The result-prefix attribute of an xsl:namespace-alias element has the value ''{0}'', but there is no namespace declaration for the prefix ''{0}'' in scope for the element."}, + + { ER_SET_FEATURE_NULL_NAME, + "The feature name cannot be null in TransformerFactory.setFeature(String name, boolean value)."}, + + { ER_GET_FEATURE_NULL_NAME, + "The feature name cannot be null in TransformerFactory.getFeature(String name)."}, + + { ER_UNSUPPORTED_FEATURE, + "Cannot set the feature ''{0}'' on this TransformerFactory."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Use of the extension element ''{0}'' is not allowed when the secure processing feature is set to true."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Cannot get the prefix for a null namespace uri."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Cannot get the namespace uri for null prefix."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "The function name cannot be null."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "The arity cannot be negative."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "Found '}' but no attribute template open!"}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Warning: count attribute does not match an ancestor in xsl:number! Target = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Old syntax: The name of the 'expr' attribute has been changed to 'select'."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan doesn't yet handle the locale name in the format-number function."}, + + { WG_LOCALE_NOT_FOUND, + "Warning: Could not find locale for xml:lang={0}"}, + + { WG_CANNOT_MAKE_URL_FROM, + "Can not make URL from: {0}"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "Can not load requested doc: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "Could not find Collator for >>>>>> Xalan Version "}, + { "version2", "<<<<<<<"}, + { "yes", "yes"}, + { "line", "Line #"}, + { "column","Column #"}, + { "xsldone", "XSLProcessor: done"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Xalan-J command line Process class options:"}, + { "xslProc_invalid_xsltc_option", "The option {0} is not supported in XSLTC mode."}, + { "xslProc_invalid_xalan_option", "The option {0} can only be used with -XSLTC."}, + { "xslProc_no_input", "Error: No stylesheet or input xml is specified. Run this command without any option for usage instructions."}, + { "xslProc_common_options", "-Common Options-"}, + { "xslProc_xalan_options", "-Options for Xalan-"}, + { "xslProc_xsltc_options", "-Options for XSLTC-"}, + { "xslProc_return_to_continue", "(press to continue)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (use XSLTC for transformation)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER fully qualified class name of parser liaison]"}, + { "optionE", " [-E (Do not expand entity refs)]"}, + { "optionV", " [-E (Do not expand entity refs)]"}, + { "optionQC", " [-QC (Quiet Pattern Conflicts Warnings)]"}, + { "optionQ", " [-Q (Quiet Mode)]"}, + { "optionLF", " [-LF (Use linefeeds only on output {default is CR/LF})]"}, + { "optionCR", " [-CR (Use carriage returns only on output {default is CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (Which characters to escape {default is <>&\"\'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (Control how many spaces to indent {default is 0})]"}, + { "optionTT", " [-TT (Trace the templates as they are being called.)]"}, + { "optionTG", " [-TG (Trace each generation event.)]"}, + { "optionTS", " [-TS (Trace each selection event.)]"}, + { "optionTTC", " [-TTC (Trace the template children as they are being processed.)]"}, + { "optionTCLASS", " [-TCLASS (TraceListener class for trace extensions.)]"}, + { "optionVALIDATE", " [-VALIDATE (Set whether validation occurs. Validation is off by default.)]"}, + { "optionEDUMP", " [-EDUMP {optional filename} (Do stackdump on error.)]"}, + { "optionXML", " [-XML (Use XML formatter and add XML header.)]"}, + { "optionTEXT", " [-TEXT (Use simple Text formatter.)]"}, + { "optionHTML", " [-HTML (Use HTML formatter.)]"}, + { "optionPARAM", " [-PARAM name expression (Set a stylesheet parameter)]"}, + { "noParsermsg1", "XSL Process was not successful."}, + { "noParsermsg2", "** Could not find parser **"}, + { "noParsermsg3", "Please check your classpath."}, + { "noParsermsg4", "If you don't have IBM's XML Parser for Java, you can download it from"}, + { "noParsermsg5", "IBM's AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]"}, + { "optionLINENUMBERS", " [-L use line numbers for source document]"}, + { "optionSECUREPROCESSING", " [-SECURE (set the secure processing feature to true.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (use media attribute to find stylesheet associated with a document.)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (Print overall milliseconds transform took.)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (request incremental DTM construction by setting http://xml.apache.org/xalan/features/incremental true.)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (request no stylesheet optimization processing by setting http://xml.apache.org/xalan/features/optimize false.)]"}, + { "optionRL", " [-RL recursionlimit (assert numeric limit on stylesheet recursion depth.)]"}, + { "optionXO", " [-XO [transletName] (assign the name to the generated translet)]"}, + { "optionXD", " [-XD destinationDirectory (specify a destination directory for translet)]"}, + { "optionXJ", " [-XJ jarfile (packages translet classes into a jar file of name )]"}, + { "optionXP", " [-XP package (specifies a package name prefix for all generated translet classes)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (enables template inlining)]" }, + { "optionXX", " [-XX (turns on additional debugging message output)]"}, + { "optionXT" , " [-XT (use translet to transform if possible)]"}, + { "diagTiming"," --------- Transform of {0} via {1} took {2} ms" }, + { "recursionTooDeep","Template nesting too deep. nesting = {0}, template {1} {2}" }, + { "nameIs", "name is" }, + { "matchPatternIs", "match pattern is" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java new file mode 100644 index 000000000..f71357900 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_de extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "Fehler: \"{\" darf nicht im Ausdruck enthalten sein"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} hat ein ung\u00FCltiges Attribut: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode ist null in xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "{0} kann nicht zu {1} hinzugef\u00FCgt werden"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode ist null in handleApplyTemplatesInstruction."}, + + { ER_NO_NAME_ATTRIB, + "{0} muss \u00FCber ein \"name\"-Attribut verf\u00FCgen."}, + + {ER_TEMPLATE_NOT_FOUND, + "Vorlage mit Namen {0} konnte nicht gefunden werden"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Namens-AVT in xsl:call-template konnte nicht aufgel\u00F6st werden."}, + + {ER_REQUIRES_ATTRIB, + "{0} erfordert Attribut: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} muss \u00FCber ein \"test\"-Attribut verf\u00FCgen."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Ung\u00FCltiger Wert bei Ebenenattribut: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction-Name darf nicht \"xml\" lauten"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction-Name muss ein g\u00FCltiger NCName sein: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} muss \u00FCber ein \"match\"-Attribut verf\u00FCgen, wenn ein Modus vorhanden ist."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} erfordert entweder ein \"name\"- oder ein \"match\"-Attribut."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Namespace-Pr\u00E4fix kann nicht aufgel\u00F6st werden: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space hat einen ung\u00FCltigen Wert: {0}"}, + + { ER_NO_OWNERDOC, + "Der untergeordnete Knoten hat kein Eigent\u00FCmerdokument."}, + + { ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement-Fehler: {0}"}, + + { ER_NULL_CHILD, + "Es wird versucht, ein leeres untergeordnetes Element hinzuzuf\u00FCgen."}, + + { ER_NEED_SELECT_ATTRIB, + "{0} erfordert ein \"select\"-Attribut."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when muss \u00FCber ein \"test\"-Attribut verf\u00FCgen."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param muss \u00FCber ein \"name\"-Attribut verf\u00FCgen."}, + + { ER_NO_CONTEXT_OWNERDOC, + "Kontext hat kein Eigent\u00FCmerdokument."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "XML-TransformerFactory-Liaison konnte nicht erstellt werden: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: Prozess war nicht erfolgreich."}, + + { ER_NOT_SUCCESSFUL, + "Xalan: War nicht erfolgreich."}, + + { ER_ENCODING_NOT_SUPPORTED, + "Codierung nicht unterst\u00FCtzt: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "TraceListener konnte nicht erstellt werden: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key erfordert ein \"name\"-Attribut."}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key erfordert ein \"match\"-Attribut."}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key erfordert ein \"use\"-Attribut."}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} erfordert ein \"elements\"-Attribut."}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} Attribut \"prefix\" fehlt"}, + + { ER_BAD_STYLESHEET_URL, + "Stylesheet-URL ist ung\u00FCltig: {0}"}, + + { ER_FILE_NOT_FOUND, + "Stylesheet-Datei wurde nicht gefunden: {0}"}, + + { ER_IOEXCEPTION, + "IO-Ausnahme bei Stylesheet-Datei: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) \"href\"-Attribut f\u00FCr {0} konnte nicht gefunden werden"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} schlie\u00DFt sich direkt oder indirekt selbst mit ein."}, + + { ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude-Fehler, {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0}: Das Attribut \"lang\" fehlt"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) Element {0} an falscher Position?? Fehlendes Containerelement ''component''"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Ausgabe kann nur an ein Element, DocumentFragment, Dokument oder PrintWriter erfolgen."}, + + { ER_PROCESS_ERROR, + "StylesheetRoot.process-Fehler"}, + + { ER_UNIMPLNODE_ERROR, + "UnImplNode-Fehler: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "Fehler. xpath-Auswahlausdruck (-select) nicht gefunden."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "XSLProcessor kann nicht serialisiert werden."}, + + { ER_NO_INPUT_STYLESHEET, + "Stylesheet-Eingabe wurde nicht angegeben."}, + + { ER_FAILED_PROCESS_STYLESHEET, + "Verarbeitung des Stylesheet nicht erfolgreich."}, + + { ER_COULDNT_PARSE_DOC, + "{0}-Dokument konnte nicht geparst werden."}, + + { ER_COULDNT_FIND_FRAGMENT, + "Fragment konnte nicht gefunden werden: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "Fragment-ID verwies auf einen Knoten, der kein Element war: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each muss entweder ein \"match\"- oder ein \"name\"-Attribut haben"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "Vorlagen m\u00FCssen entweder ein \"match\"- oder ein \"name\"-Attribut haben"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Kein Clone eines Dokumentfragments."}, + + { ER_CANT_CREATE_ITEM, + "Element in Ergebnisbaum kann nicht erstellt werden: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space in Quell-XML hat einen ung\u00FCltigen Wert: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "Keine xsl:key-Deklaration f\u00FCr {0} vorhanden."}, + + { ER_CANT_CREATE_URL, + "Fehler. URL f\u00FCr {0} kann nicht erstellt werden"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions nicht unterst\u00FCtzt"}, + + { ER_PROCESSOR_ERROR, + "XSLT-TransformerFactory-Fehler"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} nicht zul\u00E4ssig in einem Stylesheet."}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns wird nicht mehr unterst\u00FCtzt. Verwenden Sie stattdessen xsl:output."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space wird nicht mehr unterst\u00FCtzt. Verwenden Sie stattdessen xsl:strip-space oder xsl:preserve-space."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result wird nicht mehr unterst\u00FCtzt. Verwenden Sie stattdessen xsl:output."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} hat ein ung\u00FCltiges Attribut: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "Unbekanntes XSL-Element: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort kann nur mit xsl:apply-templates oder xsl:for-each verwendet werden."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when steht an der falschen Position."}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when hat nicht das \u00FCbergeordnete Element xsl:choose."}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise steht an der falschen Position."}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise hat nicht das \u00FCbergeordnete Element xsl:choose."}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} nicht zul\u00E4ssig in einer Vorlage."}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0}: Erweiterung des Namespace-Pr\u00E4fixes {1} ist unbekannt"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Importe k\u00F6nnen nur als erste Elemente in einem Stylesheet auftreten."}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} importiert sich direkt oder indirekt selbst."}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space hat einen ung\u00FCltigen Wert: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet nicht erfolgreich."}, + + { ER_SAX_EXCEPTION, + "SAX-Ausnahme"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "Funktion nicht unterst\u00FCtzt."}, + + { ER_XSLT_ERROR, + "XSLT-Fehler"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "W\u00E4hrungssymbol nicht zul\u00E4ssig in Formatmuster-Zeichenfolge"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Dokumentfunktion nicht unterst\u00FCtzt in DOM-Stylesheet."}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Pr\u00E4fix eines Non-Pr\u00E4fix-Resolver kann nicht aufgel\u00F6st werden."}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "Umleitungserweiterung: Dateiname konnte nicht abgerufen werden. \"file\"- oder \"select\"-Attribut muss eine g\u00FCltige Zeichenfolge zur\u00FCckgeben."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "FormatterListener kann nicht in Umleitungserweiterung erstellt werden."}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Pr\u00E4fix in exclude-result-prefixes ist nicht g\u00FCltig: {0}"}, + + { ER_MISSING_NS_URI, + "Fehlender Namespace-URI f\u00FCr angegebenes Pr\u00E4fix"}, + + { ER_MISSING_ARG_FOR_OPTION, + "Fehlendes Argument f\u00FCr Option: {0}"}, + + { ER_INVALID_OPTION, + "Ung\u00FCltige Option: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "Fehlerhafte Formatzeichenfolge: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet erfordert ein \"version\"-Attribut."}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "Attribut {0} hat einen ung\u00FCltigen Wert: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose erfordert xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports nicht zul\u00E4ssig in xsl:for-each"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "DTMLiaison kann nicht f\u00FCr einen Ausgabe-DOM-Knoten verwendet werden. \u00DCbergeben Sie stattdessen einen com.sun.org.apache.xpath.internal.DOM2Helper."}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "DTMLiaison kann nicht f\u00FCr einen Eingabe-DOM-Knoten verwendet werden. \u00DCbergeben Sie stattdessen einen com.sun.org.apache.xpath.internal.DOM2Helper."}, + + { ER_CALL_TO_EXT_FAILED, + "Aufruf von Erweiterungselement nicht erfolgreich: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "Pr\u00E4fix muss in einen Namespace aufgel\u00F6st werden: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "Ung\u00FCltige UTF-16-Ersetzung festgestellt: {0}?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} hat sich selbst verwendet. Dies f\u00FChrt zu einer Endlosschleife."}, + + { ER_CANNOT_MIX_XERCESDOM, + "Nicht-Xerces-DOM-Eingabe kann nicht mit Xerces-DOM-Ausgabe gemischt werden."}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "In ElemTemplateElement.readObject: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "Mehrere Vorlagen mit den Namen {0} gefunden"}, + + { ER_INVALID_KEY_CALL, + "Ung\u00FCltiger Funktionsaufruf: Rekursive key()-Aufrufe sind nicht zul\u00E4ssig"}, + + { ER_REFERENCING_ITSELF, + "Variable {0} verweist direkt oder indirekt auf sich selbst."}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "Der Eingabeknoten darf nicht null sein f\u00FCr eine DOMSource f\u00FCr newTemplates."}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "Klassendatei nicht gefunden f\u00FCr Option {0}"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "Erforderliches Element nicht gefunden: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream darf nicht null sein"}, + + { ER_URI_CANNOT_BE_NULL, + "URI darf nicht null sein"}, + + { ER_FILE_CANNOT_BE_NULL, + "Datei darf nicht null sein"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource darf nicht null sein"}, + + { ER_CANNOT_INIT_BSFMGR, + "BSF-Manager konnte nicht initialisiert werden"}, + + { ER_CANNOT_CMPL_EXTENSN, + "Erweiterung konnte nicht kompiliert werden"}, + + { ER_CANNOT_CREATE_EXTENSN, + "Erweiterung {0} konnte nicht erstellt werden; Grund: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "Der Aufruf einer Instanzmethode von Methode {0} erfordert eine Objektinstanz als erstes Argument"}, + + { ER_INVALID_ELEMENT_NAME, + "Ung\u00FCltiger Elementname angegeben {0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "Elementnamenmethode muss statisch sein {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "Erweiterungsfunktion {0} : {1} ist unbekannt"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "Mehrere passende \u00DCbereinstimmungen f\u00FCr Constructor f\u00FCr {0}"}, + + { ER_MORE_MATCH_METHOD, + "Mehrere passende \u00DCbereinstimmungen f\u00FCr Methode {0}"}, + + { ER_MORE_MATCH_ELEMENT, + "Mehrere passende \u00DCbereinstimmungen f\u00FCr Elementmethode {0}"}, + + { ER_INVALID_CONTEXT_PASSED, + "Ung\u00FCltiger Kontext zur Auswertung von {0} \u00FCbergeben"}, + + { ER_POOL_EXISTS, + "Pool ist bereits vorhanden"}, + + { ER_NO_DRIVER_NAME, + "Kein Treibername angegeben"}, + + { ER_NO_URL, + "Keine URL angegeben"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "Poolgr\u00F6\u00DFe ist kleiner als eins."}, + + { ER_INVALID_DRIVER, + "Ung\u00FCltiger Treibername angegeben."}, + + { ER_NO_STYLESHEETROOT, + "Stylesheet-Root wurde nicht gefunden."}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "Ung\u00FCltiger Wert f\u00FCr xml:space"}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode nicht erfolgreich"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "Ressource [ {0} ] konnte nicht geladen werden: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Puffergr\u00F6\u00DFe <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Unbekannter Fehler bei Aufruf von Erweiterung"}, + + { ER_NO_NAMESPACE_DECL, + "Pr\u00E4fix {0} hat keine entsprechende Namespace-Deklaration"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "Element-Content nicht zul\u00E4ssig f\u00FCr lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "Stylesheet f\u00FChrte zu Abbruch"}, + + { ER_ONE_OR_TWO, + "1 oder 2"}, + + { ER_TWO_OR_THREE, + "2 oder 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "{0} konnte nicht geladen werden (CLASSPATH pr\u00FCfen); die Standardwerte werden verwendet"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Standardvorlagen k\u00F6nnen nicht initialisiert werden"}, + + { ER_RESULT_NULL, + "Ergebnis darf nicht null sein"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "Ergebnis konnte nicht festgelegt werden"}, + + { ER_NO_OUTPUT_SPECIFIED, + "Keine Ausgabe angegeben"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Transformation in ein Ergebnis mit Typ {0} nicht m\u00F6glich"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Transformation einer Quelle mit Typ {0} nicht m\u00F6glich"}, + + { ER_NULL_CONTENT_HANDLER, + "Null-Content-Handler"}, + + { ER_NULL_ERROR_HANDLER, + "Null-Error Handler"}, + + { ER_CANNOT_CALL_PARSE, + "Parsen kann nicht aufgerufen werden, wenn der ContentHandler nicht festgelegt wurde"}, + + { ER_NO_PARENT_FOR_FILTER, + "Kein \u00FCbergeordnetes Objekt f\u00FCr Filter"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "Kein Stylesheet gefunden in: {0}, Datentr\u00E4ger = {1}"}, + + { ER_NO_STYLESHEET_PI, + "Keine Verarbeitungsanweisung f\u00FCr xml-stylesheet gefunden in: {0}"}, + + { ER_NOT_SUPPORTED, + "Nicht unterst\u00FCtzt: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "Wert f\u00FCr Eigenschaft {0} muss eine boolesche Instanz sein"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Externes Skript bei {0} konnte nicht abgerufen werden"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "Ressource [ {0} ] konnte nicht gefunden werden.\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Ausgabeeigenschaft nicht erkannt: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "ElemLiteralResult-Instanz konnte nicht erstellt werden"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "Wert f\u00FCr {0} sollte eine parsef\u00E4hige Zahl enthalten"}, + + { ER_VALUE_SHOULD_EQUAL, + "Wert f\u00FCr {0} muss \"Ja\" oder \"Nein\" entsprechen"}, + + { ER_FAILED_CALLING_METHOD, + "{0}-Methode konnte nicht aufgerufen werden"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "ElemTemplateElement-Instanz konnte nicht erstellt werden"}, + + { ER_CHARS_NOT_ALLOWED, + "An dieser Stelle im Dokument sind keine Zeichen zul\u00E4ssig"}, + + { ER_ATTR_NOT_ALLOWED, + "\"{0}\"-Attribut ist nicht zul\u00E4ssig beim {1}-Element."}, + + { ER_BAD_VALUE, + "{0} ung\u00FCltiger Wert {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "{0}-Attributwert nicht gefunden "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0}-Attributwert nicht erkannt "}, + + { ER_NULL_URI_NAMESPACE, + "Versuch, ein Namespace-Pr\u00E4fix mit einem Null-URI zu generieren"}, + + { ER_NUMBER_TOO_BIG, + "Versuch, eine Zahl zu formatieren, die gr\u00F6\u00DFer als die gr\u00F6\u00DFte Long-Ganzzahl ist"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "SAX1-Treiberklasse {0} kann nicht gefunden werden"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "SAX1-Treiberklasse {0} gefunden, kann aber nicht geladen werden"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1-Treiberklasse {0} geladen, kann aber nicht instanziiert werden"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1-Treiberklasse {0} implementiert org.xml.sax.Parser nicht"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Systemeigenschaft \"org.xml.sax.parser\" nicht angegeben"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "Parserargument darf nicht null sein"}, + + { ER_FEATURE, + "Feature: {0}"}, + + { ER_PROPERTY, + "Eigenschaft: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "Null-Entity-Resolver"}, + + { ER_NULL_DTD_HANDLER, + "Null-DTD-Handler"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "Kein Treibername angegeben."}, + + { ER_NO_URL_SPECIFIED, + "Keine URL angegeben."}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "Poolgr\u00F6\u00DFe ist kleiner als 1."}, + + { ER_INVALID_DRIVER_NAME, + "Ung\u00FCltiger Treibername angegeben."}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "Programmiererfehler. Der Ausdruck hat kein \u00FCbergeordnetes ElemTemplateElement-Objekt."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Programmierer-Assertion in RedundentExprEliminator: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0} ist an dieser Position im Stylesheet nicht zul\u00E4ssig."}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Anderer Text als Leerstellen ist an dieser Position im Stylesheet nicht zul\u00E4ssig."}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "Ung\u00FCltiger Wert {1} f\u00FCr CHAR-Attribut {0} verwendet. Ein Attribut des Typs CHAR darf nur 1 Zeichen enthalten."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "Ung\u00FCltiger Wert {1} f\u00FCr QNAME-Attribut {0} verwendet"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "Ung\u00FCltiger Wert {1} f\u00FCr ENUM-Attribut {0} verwendet. G\u00FCltige Werte sind: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "Ung\u00FCltiger Wert {1} f\u00FCr NMTOKEN-Attribut {0} verwendet "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "Ung\u00FCltiger Wert {1} f\u00FCr NCNAME-Attribut {0} verwendet "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Ung\u00FCltiger Wert {1} f\u00FCr \"Boolean\"-Attribut {0} verwendet "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Ung\u00FCltiger Wert {1} f\u00FCr \"Number\"-Attribut {0} verwendet "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "Argument f\u00FCr {0} in Vergleichsmuster muss ein Literal sein."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "Doppelte Deklaration einer globalen Variable."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "Doppelte Variablendeklaration."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template muss ein \"name\"- oder \"match\"-Attribut (oder beides) haben"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "Pr\u00E4fix in exclude-result-prefixes ist nicht g\u00FCltig: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "attribute-set mit Namen {0} ist nicht vorhanden"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "Funktion mit Namen {0} ist nicht vorhanden"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0}-Element darf weder Content noch ein \"select\"-Attribut enthalten."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "Wert von Parameter {0} muss ein g\u00FCltiges Java-Objekt sein"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "Das result-prefix-Attribut eines xsl:namespace-alias-Elements hat den Wert \"#default\", es ist aber keine Deklaration des Standard-Namespace im G\u00FCltigkeitsbereich f\u00FCr das Element vorhanden"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "Das result-prefix-Attribut eines xsl:namespace-alias-Elements hat den Wert \"{0}\", es ist aber keine Namespace-Deklaration f\u00FCr das Pr\u00E4fix \"{0}\" im G\u00FCltigkeitsbereich f\u00FCr das Element vorhanden."}, + + { ER_SET_FEATURE_NULL_NAME, + "Der Featurename darf nicht null in TransformerFactory.setFeature(Zeichenfolgenname, boolescher Wert) sein."}, + + { ER_GET_FEATURE_NULL_NAME, + "Der Featurename darf nicht null in TransformerFactory.getFeature(Zeichenfolgenname) sein."}, + + { ER_UNSUPPORTED_FEATURE, + "Das Feature \"{0}\" kann nicht f\u00FCr diese TransformerFactory festgelegt werden."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Verwendung des Erweiterungselements \"{0}\" ist nicht zul\u00E4ssig, wenn das Feature f\u00FCr die sichere Verarbeitung auf \"true\" gesetzt ist."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Pr\u00E4fix f\u00FCr Null-Namespace-URI kann nicht abgerufen werden."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Namespace-URI f\u00FCr Nullpr\u00E4fix kann nicht abgerufen werden."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "Funktionsname darf nicht null sein."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "Argumentanzahl darf nicht negativ sein."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "\"}\" gefunden, aber keine Attributvorlage ist ge\u00F6ffnet."}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Warnung: \"count\"-Attribut entspricht keinem Vorg\u00E4nger in xsl:number. Ziel = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Alte Syntax: Der Name des \"expr\"-Attributs wurde in \"select\" ge\u00E4ndert."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan verarbeitet noch nicht den Gebietsschemanamen in der format-number-Funktion."}, + + { WG_LOCALE_NOT_FOUND, + "Warnung: Gebietsschema f\u00FCr xml:lang={0} konnte nicht gefunden werden"}, + + { WG_CANNOT_MAKE_URL_FROM, + "URL kann nicht erstellt werden aus: {0}"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "Angefordertes Dokument kann nicht geladen werden: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "Collator f\u00FCr >>>>>> Xalan-Version "}, + { "version2", "<<<<<<<"}, + { "yes", "Ja"}, + { "line", "Zeilennummer"}, + { "column","Spaltennummer"}, + { "xsldone", "XSLProcessor: Fertig"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Xalan-J-Befehlszeile - \"Process\"-Klassenoptionen:"}, + { "xslProc_option", "Xalan-J-Befehlszeile - \"Process\"-Klassenoptionen:"}, + { "xslProc_invalid_xsltc_option", "Option {0} wird im XSLTC-Modus nicht unterst\u00FCtzt."}, + { "xslProc_invalid_xalan_option", "Option {0} kann nur mit -XSLTC verwendet werden."}, + { "xslProc_no_input", "Fehler: Kein Stylesheet und keine Eingabe-XML angegeben. F\u00FChren Sie diesen Befehl ohne Optionen f\u00FCr Verwendungsanweisungen aus."}, + { "xslProc_common_options", "-Allgemeine Optionen-"}, + { "xslProc_xalan_options", "-Optionen f\u00FCr Xalan-"}, + { "xslProc_xsltc_options", "-Optionen f\u00FCr XSLTC-"}, + { "xslProc_return_to_continue", "(dr\u00FCcken Sie die , um fortzufahren)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (XSLTC f\u00FCr Transformation verwenden)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER fully qualified class name of parser liaison]"}, + { "optionE", " [-E (Entityreferenzen nicht einblenden)]"}, + { "optionV", " [-E (Entityreferenzen nicht einblenden)]"}, + { "optionQC", " [-QC (Stille Musterkonfliktwarnungen)]"}, + { "optionQ", " [-Q (Silent-Modus)]"}, + { "optionLF", " [-LF (Nur Zeilenvorsch\u00FCbe bei Ausgabe verwenden {Standard ist CR/LF})]"}, + { "optionCR", " [-CR (Nur Zeilenschaltungen bei Ausgabe verwenden {Standard ist CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (Escapezeichen {Standard ist <>&\"'\r\n}]"}, + { "optionINDENT", " [-INDENT (Steuern, wie viele Leerzeichen der Einzug enthalten soll {Standard ist 0})]"}, + { "optionTT", " [-TT (Vorlagen verfolgen, wenn diese aufgerufen werden.)]"}, + { "optionTG", " [-TG (Jedes Generierungsereignis verfolgen.)]"}, + { "optionTS", " [-TS (Jedes Auswahlereignis verfolgen.)]"}, + { "optionTTC", " [-TTC (Untergeordnete Vorlagen verfolgen, wenn diese verarbeitet werden.)]"}, + { "optionTCLASS", " [-TCLASS (TraceListener-Klasse f\u00FCr Traceerweiterungen.)]"}, + { "optionVALIDATE", " [-VALIDATE (Festlegen, ob die Validierung ausgef\u00FChrt wird. Validierung ist standardm\u00E4\u00DFig ausgeschaltet.)]"}, + { "optionEDUMP", " [-EDUMP {optionaler Dateiname} (Stack Dump bei Fehler vornehmen.)]"}, + { "optionXML", " [-XML (XML-Formatter verwenden und XML-Header hinzuf\u00FCgen.)]"}, + { "optionTEXT", " [-TEXT (Einfachen Text-Formatter verwenden.)]"}, + { "optionHTML", " [-HTML (HTML-Formatter verwenden.)]"}, + { "optionPARAM", " [-PARAM name expression (Stylesheet-Parameter festlegen)]"}, + { "noParsermsg1", "XSL-Prozess war nicht erfolgreich."}, + { "noParsermsg2", "** Parser konnte nicht gefunden werden **"}, + { "noParsermsg3", "Pr\u00FCfen Sie den Classpath."}, + { "noParsermsg4", "Wenn Sie nicht \u00FCber den XML-Parser f\u00FCr Java von IBM verf\u00FCgen, k\u00F6nnen Sie ihn hier herunterladen:"}, + { "noParsermsg5", "IBMs AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER full class name (URIResolver f\u00FCr die Aufl\u00F6sung von URIs)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER full class name (EntityResolver f\u00FCr die Aufl\u00F6sung von Entitys)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER full class name (ContentHandler f\u00FCr die Serialisierung der Ausgabe)]"}, + { "optionLINENUMBERS", " [-L use line numbers for source document]"}, + { "optionSECUREPROCESSING", " [-SECURE (Feature f\u00FCr die sichere Verarbeitung auf \"true\" setzen.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (\"media\"-Attribut verwenden, um mit einem Dokument verkn\u00FCpftes Stylesheet zu finden.)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (s2s=SAX oder d2d=DOM explizit f\u00FCr Transformation verwenden.)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (Gesamtdauer der Transformation in Millisekunden drucken.)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (inkrementelle DTM-Konstruktion anfordern, indem http://xml.apache.org/xalan/features/incremental auf \"true\" gesetzt wird.)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (keine Stylesheet-Optimierungsverarbeitung anfordern, indem http://xml.apache.org/xalan/features/optimize auf \"false\" gesetzt wird.)]"}, + { "optionRL", " [-RL recursionlimit (numerischen Grenzwert f\u00FCr Stylesheet-Rekursionstiefe bekannt machen.)]"}, + { "optionXO", " [-XO [transletName] (Name dem generierten Translet zuweisen)]"}, + { "optionXD", " [-XD destinationDirectory (Zielverzeichnis f\u00FCr Translet angeben)]"}, + { "optionXJ", " [-XJ jarfile (verpackt Translet-Klassen in einer JAR-Datei mit dem Namen )]"}, + { "optionXP", " [-XP package (gibt ein Packagenamenspr\u00E4fix f\u00FCr alle generierten Translet-Klassen an)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (aktiviert Vorlagen-Inlining)]" }, + { "optionXX", " [-XX (schaltet die zus\u00E4tzliche Debugging-Meldungsausgabe ein)]"}, + { "optionXT" , " [-XT (wenn m\u00F6glich, Translet f\u00FCr Transformation verwenden)]"}, + { "diagTiming"," --------- Transformation von {0} \u00FCber {1} dauerte {2} ms" }, + { "recursionTooDeep","Vorlagenverschachtelung zu tief. Verschachtelung = {0}, Vorlage {1} {2}" }, + { "nameIs", "Name ist" }, + { "matchPatternIs", "Vergleichsmuster ist" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_en.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_en.java new file mode 100644 index 000000000..0748aa379 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_en.java @@ -0,0 +1,32 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + + +/** + * Default implementation of XSLTErrorResources. This is just + * an empty class. + * @xsl.usage advanced + */ +public class XSLTErrorResources_en extends XSLTErrorResources +{ +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java new file mode 100644 index 000000000..c721fa82a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_es extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "Error: no puede haber'{' en la expresi\u00F3n"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} tiene un atributo no permitido: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode es nulo en xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "No se puede agregar {0} a {1}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode es nulo en handleApplyTemplatesInstruction"}, + + { ER_NO_NAME_ATTRIB, + "{0} debe tener un atributo name."}, + + {ER_TEMPLATE_NOT_FOUND, + "No se ha encontrado la plantilla llamada: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "No se ha podido resolver el AVT del nombre en xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} necesita el atributo: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} debe tener un atributo ''test''."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valor err\u00F3neo en el atributo level: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "el nombre de instrucci\u00F3n de procesamiento no puede ser 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "el nombre de instrucci\u00F3n de procesamiento debe ser un NCName v\u00E1lido: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} debe tener un atributo match si tiene un modo."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} necesita un atributo name o match."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "No se puede resolver el prefijo de espacio de nombres: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space tiene un valor no permitido: {0}"}, + + { ER_NO_OWNERDOC, + "El nodo secundario no tiene un documento de propietario."}, + + { ER_ELEMTEMPLATEELEM_ERR, + "Error de ElemTemplateElement: {0}"}, + + { ER_NULL_CHILD, + "Intentando agregar un secundario nulo."}, + + { ER_NEED_SELECT_ATTRIB, + "{0} necesita un atributo select."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when debe tener un atributo 'test'."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param debe tener un atributo 'name'."}, + + { ER_NO_CONTEXT_OWNERDOC, + "El contexto no tiene un documento de propietario."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "No se ha podido crear el enlace TransformerFactory XML: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: el proceso no se ha realizado correctamente."}, + + { ER_NOT_SUCCESSFUL, + "Xalan: no se ha realizado correctamente."}, + + { ER_ENCODING_NOT_SUPPORTED, + "Codificaci\u00F3n no soportada: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "No se ha podido crear TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key necesita un atributo 'name'."}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key necesita un atributo 'match'."}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key necesita un atributo 'use'."}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} necesita un atributo ''elements''."}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) Falta el valor de ''prefix'' del atributo {0}"}, + + { ER_BAD_STYLESHEET_URL, + "La URL de hoja de estilo no es v\u00E1lida: {0}"}, + + { ER_FILE_NOT_FOUND, + "No se ha encontrado el archivo de hoja de estilo: {0}"}, + + { ER_IOEXCEPTION, + "Ten\u00EDa una excepci\u00F3n de E/S con el archivo de hoja de estilo: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) No se ha encontrado el atributo href para {0}"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} se incluye directa o indirectamente."}, + + { ER_PROCESSINCLUDE_ERROR, + "Error de StylesheetHandler.processInclude, {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) Falta el atributo ''lang'' {0}"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) \u00BFElemento {0} mal colocado? Falta el elemento contenedor ''component''"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "La salida s\u00F3lo puede realizarse en Element, DocumentFragment, Document o PrintWriter."}, + + { ER_PROCESS_ERROR, + "Error de StylesheetRoot.process"}, + + { ER_UNIMPLNODE_ERROR, + "Error de UnImplNode: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "\u00A1Error! No se ha encontrado la expresi\u00F3n de selecci\u00F3n xpath (-select)."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "No se puede serializar un procesador XSL."}, + + { ER_NO_INPUT_STYLESHEET, + "No se ha especificado la entrada de hoja de estilo."}, + + { ER_FAILED_PROCESS_STYLESHEET, + "Fallo al procesar la hoja de estilo."}, + + { ER_COULDNT_PARSE_DOC, + "No se ha podido analizar el documento {0}."}, + + { ER_COULDNT_FIND_FRAGMENT, + "No se ha encontrado el fragmento: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "El nodo apuntado por el identificador de fragmento no era un elemento: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each debe tener un atributo name o match."}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "las plantillas deben tener un atributo name o match."}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "No hay ninguna clonaci\u00F3n de un fragmento de documento."}, + + { ER_CANT_CREATE_ITEM, + "No se puede crear el elemento en el \u00E1rbol de resultados: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space en el XML de origen tiene un valor no v\u00E1lido: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "No hay ninguna declaraci\u00F3n xsl:key para {0}."}, + + { ER_CANT_CREATE_URL, + "Error. No se puede crear la URL para: {0}"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions no est\u00E1 soportado"}, + + { ER_PROCESSOR_ERROR, + "Error de TransformerFactory de XSLT"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} no permitido en una hoja de estilo."}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns ya no est\u00E1 soportado. Utilice xsl:output en su lugar."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space ya no est\u00E1 soportado. Utilice xsl:strip-space o xsl:preserve-space en su lugar."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result ya no est\u00E1 soportado. Utilice xsl:output en su lugar."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} tiene un atributo no permitido: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "Elemento XSL desconocido: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort s\u00F3lo se puede utilizar con xsl:apply-templates o xsl:for-each."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) ha colocado xsl:when incorrectamente."}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when sin principal de xsl:choose."}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) ha colocado xsl:otherwise de forma incorrecta."}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise sin principal de xsl:choose."}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} no est\u00E1 permitido en una plantilla."}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) prefijo {1} de espacio de nombres de extensi\u00F3n {0} desconocido"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Las importaciones s\u00F3lo se pueden realizar como los primeros elementos en la hoja de estilo."}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} se est\u00E1 importando directa o indirectamente."}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space tiene un valor no permitido: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet no se ha realizado correctamente."}, + + { ER_SAX_EXCEPTION, + "Excepci\u00F3n SAX"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "Funci\u00F3n no soportada."}, + + { ER_XSLT_ERROR, + "Error de XSLT"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "el s\u00EDmbolo de moneda no est\u00E1 permitido en la cadena de patr\u00F3n de formato"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "La funci\u00F3n de documento no est\u00E1 soportada en DOM de la hoja de estilo."}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "No se puede resolver el prefijo del sistema de resoluci\u00F3n sin prefijo."}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "Extensi\u00F3n de redireccionamiento: no se ha podido obtener el nombre de archivo - el atributo file o select debe devolver una cadena v\u00E1lida."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "No se puede crear FormatterListener en la extensi\u00F3n de redireccionamiento."}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "El prefijo en exclude-result-prefixes no es v\u00E1lido: {0}"}, + + { ER_MISSING_NS_URI, + "Falta el URI del espacio de nombres para el prefijo especificado"}, + + { ER_MISSING_ARG_FOR_OPTION, + "Falta un argumento para la opci\u00F3n: {0}"}, + + { ER_INVALID_OPTION, + "Opci\u00F3n no v\u00E1lida: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "Cadena con formato incorrecto: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet necesita un atributo 'version'."}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "El atributo: {0} tiene un valor no permitido: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose necesita un xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports no permitido en un xsl:for-each"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "No se puede utilizar un DTMLiaison para un nodo DOM de salida... transfiera com.sun.org.apache.xpath.internal.DOM2Helper en su lugar,"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "No se puede utilizar un DTMLiaison para un nodo DOM de entrada... transfiera com.sun.org.apache.xpath.internal.DOM2Helper en su lugar,"}, + + { ER_CALL_TO_EXT_FAILED, + "Fallo de la llamada al elemento de extensi\u00F3n: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "El prefijo se debe resolver en un espacio de nombres: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "\u00BFSe ha detectado un sustituto UTF-16 no v\u00E1lido: {0}?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} se utiliza a s\u00ED mismo, lo que causar\u00E1 un bucle infinito."}, + + { ER_CANNOT_MIX_XERCESDOM, + "No se puede mezclar una entrada DOM que no es de Xerces con una salida DOM de Xerces."}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "En ElemTemplateElement.readObject: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "Se ha encontrado m\u00E1s de una plantilla con el nombre: {0}"}, + + { ER_INVALID_KEY_CALL, + "Llamada de funci\u00F3n no v\u00E1lida: las llamadas recursive key() no est\u00E1n permitidas"}, + + { ER_REFERENCING_ITSELF, + "La variable {0} hace referencia a s\u00ED misma de forma directa o indirecta."}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "El nodo de entrada no puede ser nulo para un DOMSource de nuevas plantillas."}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "No se ha encontrado el archivo de clase para la opci\u00F3n {0}"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "No se ha encontrado el elemento necesario: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream no puede ser nulo"}, + + { ER_URI_CANNOT_BE_NULL, + "El URI no puede ser nulo"}, + + { ER_FILE_CANNOT_BE_NULL, + "El archivo no puede ser nulo"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource no puede ser nulo"}, + + { ER_CANNOT_INIT_BSFMGR, + "No se ha podido inicializar el gestor de BSF"}, + + { ER_CANNOT_CMPL_EXTENSN, + "No se ha podido compilar la extensi\u00F3n"}, + + { ER_CANNOT_CREATE_EXTENSN, + "No se ha podido crear la extensi\u00F3n: {0} debido a: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "La llamada del m\u00E9todo de instancia al m\u00E9todo {0} necesita una instancia de objeto como primer argumento"}, + + { ER_INVALID_ELEMENT_NAME, + "Se ha especificado un nombre de elemento no v\u00E1lido {0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "El m\u00E9todo del nombre del elemento debe ser est\u00E1tico {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "La funci\u00F3n de extensi\u00F3n {0} : {1} es desconocida"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "Hay m\u00E1s de una mejor coincidencia para el constructor de {0}"}, + + { ER_MORE_MATCH_METHOD, + "Hay m\u00E1s de una mejor coincidencia para el m\u00E9todo {0}"}, + + { ER_MORE_MATCH_ELEMENT, + "Hay m\u00E1s de una mejor coincidencia para el m\u00E9todo de elemento {0}"}, + + { ER_INVALID_CONTEXT_PASSED, + "Se ha transferido un contexto no v\u00E1lido para evaluar {0}"}, + + { ER_POOL_EXISTS, + "El pool ya existe"}, + + { ER_NO_DRIVER_NAME, + "No se ha especificado ning\u00FAn nombre de controlador"}, + + { ER_NO_URL, + "No se ha especificado ninguna URL"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "El tama\u00F1o del pool es inferior a uno."}, + + { ER_INVALID_DRIVER, + "Se ha especificado un nombre de controlador no v\u00E1lido."}, + + { ER_NO_STYLESHEETROOT, + "No se ha encontrado la ra\u00EDz de la hoja de estilo."}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "Valor no permitido para xml:space"}, + + { ER_PROCESSFROMNODE_FAILED, + "Fallo de processFromNode"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "No se ha podido cargar el recurso [ {0} ]: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Tama\u00F1o de buffer menor o igual que 0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Error desconocido al llamar a la extensi\u00F3n"}, + + { ER_NO_NAMESPACE_DECL, + "El prefijo {0} no tiene una declaraci\u00F3n de espacio de nombres correspondiente"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "Contenido de elemento no permitido para lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "Terminaci\u00F3n dirigida de hoja de estilo"}, + + { ER_ONE_OR_TWO, + "1 o 2"}, + + { ER_TWO_OR_THREE, + "2 o 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "No se ha podido cargar {0} (marcar CLASSPATH), actualmente s\u00F3lo se utilizan los valores por defecto"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "No se pueden inicializar las plantillas por defecto"}, + + { ER_RESULT_NULL, + "El resultado no debe ser nulo"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "No se ha podido definir el resultado"}, + + { ER_NO_OUTPUT_SPECIFIED, + "No se ha especificado ninguna salida"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "No se puede transformar en un resultado de tipo {0}"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "No se puede transformar en un origen de tipo {0}"}, + + { ER_NULL_CONTENT_HANDLER, + "Manejador de contenido nulo"}, + + { ER_NULL_ERROR_HANDLER, + "Manejador de errores nulo"}, + + { ER_CANNOT_CALL_PARSE, + "no se puede realizar el an\u00E1lisis si no se ha definido el manejador de contenido"}, + + { ER_NO_PARENT_FOR_FILTER, + "Ning\u00FAn principal para el filtro"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "No se ha encontrado ninguna hoja de estilo en: {0}, soporte= {1}"}, + + { ER_NO_STYLESHEET_PI, + "No se ha encontrado ning\u00FAn PI de hoja de estilo XML en: {0}"}, + + { ER_NOT_SUPPORTED, + "No soportado: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "El valor para la propiedad {0} debe ser una instancia booleana"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "No se ha podido obtener un script externo en {0}"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "No se ha encontrado el recurso [ {0} ].\n{1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propiedad de salida no reconocida: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "Fallo al crear la instancia ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "El valor para {0} no debe contener un n\u00FAmero que pueda analizarse"}, + + { ER_VALUE_SHOULD_EQUAL, + "El valor para {0} debe ser igual a s\u00ED o no."}, + + { ER_FAILED_CALLING_METHOD, + "Fallo al llamar al m\u00E9todo {0}"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "Fallo al crear la instancia ElemTemplateElement"}, + + { ER_CHARS_NOT_ALLOWED, + "En este momento, no se permite el uso de caracteres en el documento"}, + + { ER_ATTR_NOT_ALLOWED, + "El atributo \"{0}\" no est\u00E1 permitido en el elemento {1}."}, + + { ER_BAD_VALUE, + "{0} valor incorrecto {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "No se ha encontrado el valor del atributo {0} "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "El valor del atributo {0} no se ha reconocido "}, + + { ER_NULL_URI_NAMESPACE, + "Se est\u00E1 intentando generar un prefijo de espacio de nombres con un URI nulo"}, + + { ER_NUMBER_TOO_BIG, + "Se est\u00E1 intentando formatear un n\u00FAmero superior al entero largo m\u00E1s grande"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "No se ha encontrado la clase de controlador SAX1 {0}"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "Se ha encontrado la clase de controlador SAX1 {0} pero no se puede cargar"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "Se ha cargado la clase de controlador SAX1 {0} pero no se puede instanciar"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "La clase de controlador SAX1 {0} no implanta org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "No se ha especificado la propiedad del sistema org.xml.sax.parser"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "El argumento del analizador no debe ser nulo"}, + + { ER_FEATURE, + "Funci\u00F3n: {0}"}, + + { ER_PROPERTY, + "Propiedad: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "Sistema de resoluci\u00F3n de entidades nulo"}, + + { ER_NULL_DTD_HANDLER, + "Manejador DTD nulo"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "No se ha especificado ning\u00FAn nombre de controlador"}, + + { ER_NO_URL_SPECIFIED, + "No se ha especificado ninguna URL"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "El tama\u00F1o del pool es inferior a 1."}, + + { ER_INVALID_DRIVER_NAME, + "Se ha especificado un nombre de controlador no v\u00E1lido."}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "Error del programador. La expresi\u00F3n no tiene el principal ElemTemplateElement."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Afirmaci\u00F3n del programador en RedundentExprEliminator: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0} no est\u00E1 permitido en esta posici\u00F3n de la hoja de estilo."}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "El texto distinto de un espacio en blanco no est\u00E1 permitido en esta posici\u00F3n de la hoja de estilo."}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "Valor no permitido: {1} utilizado para el atributo CHAR: {0}. Un atributo del tipo CHAR debe tener s\u00F3lo 1 car\u00E1cter."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "Valor no permitido: {1} utilizado para el atributo QNAME: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "Valor no permitido: {1} utilizado para el atributo ENUM: {0}. Los valores v\u00E1lidos son: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "Valor no permitido: {1} utilizado para el atributo NMTOKEN: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "Valor no permitido: {1} utilizado para el atributo NCNAME: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Valor no permitido: {1} utilizado para el atributo boolean: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Valor no permitido: {1} utilizado para el atributo number: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "El argumento para {0} en el patr\u00F3n de coincidencia no debe ser un valor literal."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "Duplicar declaraci\u00F3n de variable global."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "Duplicar declaraci\u00F3n de variable."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template debe tener un atributo name o match (o ambos)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "El prefijo en exclude-result-prefixes no es v\u00E1lido: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "El juego de atributos con el nombre {0} no existe"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "La funci\u00F3n con el nombre {0} no existe"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "El elemento {0} no debe tener contenido ni un atributo select."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "El valor del par\u00E1metro {0} debe tener un objeto Java v\u00E1lido"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "El atributo result-prefix de un elemento xsl:namespace-alias tiene el valor ''#default', pero no hay ninguna declaraci\u00F3n del espacio de nombres por defecto en el \u00E1mbito para el elemento"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "El atributo result-prefix de un elemento xsl:namespace-alias tiene el valor ''{0}'', pero no hay ninguna declaraci\u00F3n del espacio de nombres para el prefijo ''{0}'' en el \u00E1mbito para el elemento."}, + + { ER_SET_FEATURE_NULL_NAME, + "El nombre de funci\u00F3n no puede ser nulo en TransformerFactory.setFeature (nombre de cadena, valor booleano)."}, + + { ER_GET_FEATURE_NULL_NAME, + "El nombre de funci\u00F3n no puede ser nulo en TransformerFactory.getFeature (nombre de cadena)."}, + + { ER_UNSUPPORTED_FEATURE, + "No se puede definir la funci\u00F3n ''{0}''en esta f\u00E1brica del transformador."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "La utilizaci\u00F3n del elemento de extensi\u00F3n ''{0}'' no est\u00E1 permitida cuando la funci\u00F3n de procesamiento seguro se ha definido en true."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "No se puede obtener el prefijo para un URI de espacio de nombres nulo."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "No se puede obtener el URI de espacio de nombres para un prefijo nulo."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "El nombre de la funci\u00F3n no puede ser nulo."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "El n\u00FAmero de argumentos no puede ser negativo."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "Se han encontrado '}' pero no hay ninguna plantilla de atributos abierta."}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Advertencia: el atributo count no coincide con un ascendiente en el destino xsl:number! = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Sintaxis anterior: el nombre del atributo 'expr' se ha cambiado por el de 'select'."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan no maneja a\u00FAn el nombre de configuraci\u00F3n regional en la funci\u00F3n format-number."}, + + { WG_LOCALE_NOT_FOUND, + "Advertencia: no se ha encontrado la configuraci\u00F3n regional para xml:lang={0}"}, + + { WG_CANNOT_MAKE_URL_FROM, + "No se puede crear la URL desde: {0}"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "No se puede cargar el documento solicitado: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "No se ha encontrado el intercalador para >>>>>> Versi\u00F3n Xalan "}, + { "version2", "<<<<<<<"}, + { "yes", "s\u00ED"}, + { "line", "N\u00BA de L\u00EDnea"}, + { "column","N\u00BA de Columna"}, + { "xsldone", "XSLProcessor: listo"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Opciones de la clase Process de la l\u00EDnea de comandos Xalan-J :"}, + { "xslProc_option", "Opciones de la clase Process de la l\u00EDnea de comandos Xalan-J :"}, + { "xslProc_invalid_xsltc_option", "La opci\u00F3n {0} no est\u00E1 soportada en el modo XSLTC."}, + { "xslProc_invalid_xalan_option", "La opci\u00F3n {0} s\u00F3lo puede utilizarse con -XSLTC."}, + { "xslProc_no_input", "Error: no se ha especificado ninguna hoja de estilo o XML de entrada. Ejecute este comando sin ninguna opci\u00F3n para las instrucciones de uso."}, + { "xslProc_common_options", "-Opciones Comunes-"}, + { "xslProc_xalan_options", "-Opciones para Xalan-"}, + { "xslProc_xsltc_options", "-Opciones para XSLTC-"}, + { "xslProc_return_to_continue", "(pulse para continuar)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (utilizar XSLTC para la transformaci\u00F3n)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER nombre de clase totalmente cualificado de enlace de analizador]"}, + { "optionE", " [-E (No ampliar referencias de entidad)]"}, + { "optionV", " [-E (No ampliar referencias de entidad)]"}, + { "optionQC", " [-QC (Advertencias de Conflictos de Patr\u00F3n Silencioso)]"}, + { "optionQ", " [-Q (Modo Silencioso)]"}, + { "optionLF", " [-LF (Utilizar saltos de l\u00EDnea s\u00F3lo en la salida {el valor por defecto es CR/LF})]"}, + { "optionCR", " [-CR (Utilizar retornos de carro s\u00F3lo en la salida {el valor por defecto es CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (Caracteres para introducir escape {el valor por defecto es <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (Control del n\u00FAmero de espacios para el sangrado {el valor por defecto es 0})]"}, + { "optionTT", " [-TT (Rastrear las plantillas como si se estuviesen llamando.)]"}, + { "optionTG", " [-TG (Rastrear cada evento de generaci\u00F3n.)]"}, + { "optionTS", " [-TS (Rastrear cada evento de selecci\u00F3n.)]"}, + { "optionTTC", " [-TTC (Rastrear los secundarios de plantilla como si se estuviesen procesando.)]"}, + { "optionTCLASS", " [-TCLASS (Clase TraceListener para las extensiones de rastreo.)]"}, + { "optionVALIDATE", " [-VALIDATE (Determinar si se produce la validaci\u00F3n. La validaci\u00F3n est\u00E1 desactivada por defecto.)]"}, + { "optionEDUMP", " [-EDUMP {nombre de archivo opcional} (Realizar volcado de pila si se produce el error.)]"}, + { "optionXML", " [-XML (Utilizar el formateador XML y agregar una cabecera XML.)]"}, + { "optionTEXT", " [-TEXT (Utilizar el formateador de texto simple.)]"}, + { "optionHTML", " [-HTML (Utilizar el formateador HTML.)]"}, + { "optionPARAM", " [-PARAM expresi\u00F3n de nombre (Definir un par\u00E1metro de hoja de estilo)]"}, + { "noParsermsg1", "El proceso XSL no se ha realizado correctamente."}, + { "noParsermsg2", "** No se ha encontrado el analizador **"}, + { "noParsermsg3", "Compruebe la classpath."}, + { "noParsermsg4", "Si no tiene un analizador XML de IBM para Java, puede descargarlo de"}, + { "noParsermsg5", "AlphaWorks de IBM: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER nombre de clase completo (URIResolver se puede utilizar para resolver los URI)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER nombre de clase completo (EntityResolver utilizado para resolver entidades)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER nombre de clase completo (ContentHandler utilizado para serializar la salida)]"}, + { "optionLINENUMBERS", " [-L utilizar n\u00FAmeros de l\u00EDnea para el documento de origen]"}, + { "optionSECUREPROCESSING", " [-SECURE (definir la funci\u00F3n de procesamiento seguro en true.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (utilice el atributo media para buscar la hoja de estilo asociada a un documento.)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (Utilizar expl\u00EDcitamente s2s=SAX o d2d=DOM para realizar la transformaci\u00F3n.)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (Imprimir tiempo total en milisegundos para la transformaci\u00F3n.)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (para solicitar la construcci\u00F3n DTM incremental, defina http://xml.apache.org/xalan/features/incremental en true.)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (para solicitar que no se produzca ning\u00FAn procesamiento de optimizaci\u00F3n de hoja de estilo, defina http://xml.apache.org/xalan/features/optimize en false.)]"}, + { "optionRL", " [-RL recursionlimit (afirmar l\u00EDmite num\u00E9rico en la profundidad de recursi\u00F3n de la hoja de estilo.)]"}, + { "optionXO", " [-XO [transletName] (asignar el nombre al translet generado)]"}, + { "optionXD", " [-XD destinationDirectory (especificar un directorio de destino para translet)]"}, + { "optionXJ", " [-XJ jarfile (empaqueta las clases de translet en un archivo jar llamado )]"}, + { "optionXP", " [-XP package (especifica un prefijo de nombre de paquete para todas las clases de translet generadas)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (permite poner en l\u00EDnea la plantilla)]" }, + { "optionXX", " [-XX (activa una salida de mensaje de depuraci\u00F3n adicional)]"}, + { "optionXT" , " [-XT (utilizar translet para la transformaci\u00F3n si es posible)]"}, + { "diagTiming"," --------- La transformaci\u00F3n de {0} mediante {1} ha tardado {2} ms" }, + { "recursionTooDeep","El anidamiento de plantilla es demasiado profundo. Anidamiento = {0}, plantilla {1} {2}" }, + { "nameIs", "el nombre es" }, + { "matchPatternIs", "el patr\u00F3n de coincidencia es" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java new file mode 100644 index 000000000..60bc5675d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_fr extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "Erreur : l'expression ne peut pas contenir le caract\u00E8re '{'"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} a un attribut non admis : {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "La valeur de sourceNode est NULL dans xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "Impossible d''ajouter {0} \u00E0 {1}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "La valeur de sourceNode est NULL dans handleApplyTemplatesInstruction."}, + + { ER_NO_NAME_ATTRIB, + "{0} doit avoir un attribut ''name''."}, + + {ER_TEMPLATE_NOT_FOUND, + "Mod\u00E8le nomm\u00E9 {0} introuvable"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Impossible de r\u00E9soudre le nom AVT dans xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} exige l''attribut : {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} doit avoir un attribut ''test''."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valeur incorrecte sur l''attribut de niveau : {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "Le nom de processing-instruction ne peut pas \u00EAtre 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "Le nom de processing-instruction doit \u00EAtre un NCName valide : {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} doit avoir un attribut de correspondance s''il a un mode."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} exige un nom ou un attribut de correspondance."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Impossible de r\u00E9soudre le pr\u00E9fixe de l''espace de noms : {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space a une valeur non admise : {0}"}, + + { ER_NO_OWNERDOC, + "Le noeud enfant ne poss\u00E8de pas de document propri\u00E9taire."}, + + { ER_ELEMTEMPLATEELEM_ERR, + "Erreur ElemTemplateElement : {0}"}, + + { ER_NULL_CHILD, + "Tentative d'ajout d'un enfant NULL."}, + + { ER_NEED_SELECT_ATTRIB, + "{0} exige un attribut \"select\"."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when doit avoir un attribut \"test\"."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param doit avoir un attribut \"name\"."}, + + { ER_NO_CONTEXT_OWNERDOC, + "le contexte ne poss\u00E8de pas de document propri\u00E9taire."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Impossible de cr\u00E9er la liaison XML?? TransformerFactory : {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan : le processus a \u00E9chou\u00E9."}, + + { ER_NOT_SUCCESSFUL, + "Xalan : \u00E9chec."}, + + { ER_ENCODING_NOT_SUPPORTED, + "Encodage non pris en charge : {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Impossible de cr\u00E9er TraceListener : {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key exige un attribut \"name\"."}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key exige un attribut \"match\"."}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key exige un attribut \"use\"."}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} exige un attribut ''elements''."}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) L''attribut ''prefix'' {0} est manquant"}, + + { ER_BAD_STYLESHEET_URL, + "L''URL de feuille de style est incorrecte : {0}"}, + + { ER_FILE_NOT_FOUND, + "Fichier de feuille de style introuvable : {0}"}, + + { ER_IOEXCEPTION, + "Exception d''E/S avec le fichier de feuille de style : {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Attribut href introuvable pour {0}"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} s''inclut directement ou indirectement lui-m\u00EAme."}, + + { ER_PROCESSINCLUDE_ERROR, + "Erreur StylesheetHandler.processInclude, {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) L''attribut \"lang\" {0} est manquant"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) l''\u00E9l\u00E9ment {0} est-il mal plac\u00E9? El\u00E9ment ''component'' du conteneur manquant"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Sortie unique vers Element, DocumentFragment, Document ou PrintWriter."}, + + { ER_PROCESS_ERROR, + "Erreur StylesheetRoot.process"}, + + { ER_UNIMPLNODE_ERROR, + "Erreur UnImplNode : {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "Erreur : expression de s\u00E9lection Xpath introuvable (-select)."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Impossible de s\u00E9rialiser un processeur XSL."}, + + { ER_NO_INPUT_STYLESHEET, + "L'entr\u00E9e de feuille de style n'a pas \u00E9t\u00E9 sp\u00E9cifi\u00E9e."}, + + { ER_FAILED_PROCESS_STYLESHEET, + "Echec du traitement de la feuille de style."}, + + { ER_COULDNT_PARSE_DOC, + "Impossible d''analyser le document {0}."}, + + { ER_COULDNT_FIND_FRAGMENT, + "Fragment introuvable : {0}"}, + + { ER_NODE_NOT_ELEMENT, + "Le noeud sur lequel pointe l''identificateur de fragment n''\u00E9tait pas un \u00E9l\u00E9ment : {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "l'\u00E9l\u00E9ment for-each doit avoir un attribut de nom ou de correspondance"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "les mod\u00E8les doivent avoir un attribut de nom ou de correspondance"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Aucun clone d'un fragment de document."}, + + { ER_CANT_CREATE_ITEM, + "Impossible de cr\u00E9er l''\u00E9l\u00E9ment dans l''arborescence de r\u00E9sultats : {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space dans le fichier XML source a une valeur non admise : {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "Il n''existe aucune d\u00E9claration xsl:key pour {0}."}, + + { ER_CANT_CREATE_URL, + "Erreur : impossible de cr\u00E9er l''URL pour : {0}"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions n'est pas pris en charge"}, + + { ER_PROCESSOR_ERROR, + "Erreur TransformerFactory XSLT"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} non autoris\u00E9 dans une feuille de style."}, + + { ER_RESULTNS_NOT_SUPPORTED, + "\u00E9l\u00E9ment result-ns plus pris en charge. Utilisez plut\u00F4t xsl:output."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "\u00E9l\u00E9ment default-space plus pris en charge. Utilisez plut\u00F4t xsl:strip-space ou xsl:preserve-space."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "\u00E9l\u00E9ment indent-result plus pris en charge. Utilisez plut\u00F4t xsl:output."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} a un attribut non admis : {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "El\u00E9ment XSL inconnu : {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort ne peut \u00EAtre utilis\u00E9 qu'avec xsl:apply-templates ou xsl:for-each."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when mal plac\u00E9."}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:choose n'a affect\u00E9 aucun parent \u00E0 xsl:when."}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise mal plac\u00E9."}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:choose n'a affect\u00E9 aucun parent \u00E0 xsl:otherwise."}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} n''est pas autoris\u00E9 dans un mod\u00E8le."}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) Pr\u00E9fixe {1} de l''espace de noms de l''extension {0} inconnu"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Les imports ne peuvent s'appliquer que sur les premiers \u00E9l\u00E9ments de la feuille de style."}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} s''importe directement ou indirectement lui-m\u00EAme."}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space a une valeur non admise : {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "Echec de processStylesheet."}, + + { ER_SAX_EXCEPTION, + "Exception SAX"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "Fonction non prise en charge."}, + + { ER_XSLT_ERROR, + "Erreur XSLT"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "le symbole de devise n'est pas autoris\u00E9 dans la cha\u00EEne du mod\u00E8le de format"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Fonction de document non prise en charge dans l'objet DOM de la feuille de style."}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Impossible de r\u00E9soudre le pr\u00E9fixe du r\u00E9solveur non-Prefix."}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "Extension Redirect : impossible d'obtenir le nom de fichier. L'attribut \"file\" ou \"select\" doit renvoyer une cha\u00EEne valide."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Impossible de cr\u00E9er FormatterListener dans l'extension Redirect."}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Le pr\u00E9fixe de l''\u00E9l\u00E9ment exclude-result-prefixes n''est pas valide : {0}"}, + + { ER_MISSING_NS_URI, + "URI d'espace de noms manquant pour le pr\u00E9fixe sp\u00E9cifi\u00E9"}, + + { ER_MISSING_ARG_FOR_OPTION, + "Argument manquant pour l''option : {0}"}, + + { ER_INVALID_OPTION, + "Option non valide : {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "Format de cha\u00EEne incorrect : {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet exige un attribut de version."}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "L''attribut {0} a une valeur non admise : {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose exige un \u00E9l\u00E9ment xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports non autoris\u00E9 dans un \u00E9l\u00E9ment xsl:for-each"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "Impossible d'utiliser un \u00E9l\u00E9ment DTMLiaison pour un noeud DOM de sortie... Transmettez plut\u00F4t un \u00E9l\u00E9ment com.sun.org.apache.xpath.internal.DOM2Helper."}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "Impossible d'utiliser un \u00E9l\u00E9ment DTMLiaison pour un noeud DOM d'entr\u00E9e... Transmettez plut\u00F4t un \u00E9l\u00E9ment com.sun.org.apache.xpath.internal.DOM2Helper."}, + + { ER_CALL_TO_EXT_FAILED, + "Echec de l''appel de l''\u00E9l\u00E9ment d''extension : {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "Le pr\u00E9fixe doit \u00EAtre r\u00E9solu en espace de noms : {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "Substitut UTF-16 non valide d\u00E9tect\u00E9 : {0} ?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} s''est utilis\u00E9 lui-m\u00EAme, ce qui g\u00E9n\u00E8re une boucle sans fin."}, + + { ER_CANNOT_MIX_XERCESDOM, + "Impossible de combiner une entr\u00E9e non Xerces-DOM et une sortie Xerces-DOM."}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "Dans ElemTemplateElement.readObject : {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "Plusieurs mod\u00E8les nomm\u00E9s {0} ont \u00E9t\u00E9 trouv\u00E9s"}, + + { ER_INVALID_KEY_CALL, + "Appel de fonction non valide : les appels de touche r\u00E9cursive () ne sont pas autoris\u00E9s"}, + + { ER_REFERENCING_ITSELF, + "La variable {0} fait directement ou indirectement r\u00E9f\u00E9rence \u00E0 elle-m\u00EAme."}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "Le noeud d'entr\u00E9e ne peut pas \u00EAtre NULL pour un \u00E9l\u00E9ment DOMSource de newTemplates."}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "Fichier de classe introuvable pour l''option {0}"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "El\u00E9ment obligatoire introuvable : {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream ne peut pas \u00EAtre NULL"}, + + { ER_URI_CANNOT_BE_NULL, + "L'URI ne peut pas \u00EAtre NULL"}, + + { ER_FILE_CANNOT_BE_NULL, + "Le fichier ne peut pas \u00EAtre NULL"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource ne peut pas \u00EAtre NULL"}, + + { ER_CANNOT_INIT_BSFMGR, + "Impossible d'initialiser le gestionnaire BSF"}, + + { ER_CANNOT_CMPL_EXTENSN, + "Impossible de compiler l'extension"}, + + { ER_CANNOT_CREATE_EXTENSN, + "Impossible de cr\u00E9er l''extension {0}. Cause : {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "L''appel de la m\u00E9thode d''instance {0} exige une instance d''objet comme premier argument"}, + + { ER_INVALID_ELEMENT_NAME, + "Nom d''\u00E9l\u00E9ment sp\u00E9cifi\u00E9 {0} non valide"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "La m\u00E9thode du nom d''\u00E9l\u00E9ment doit \u00EAtre statique {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "La fonction d''extension {0} : {1} est inconnue"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "Plusieurs meilleures concordances du constructeur pour {0}"}, + + { ER_MORE_MATCH_METHOD, + "Plusieurs meilleures concordances pour la m\u00E9thode {0}"}, + + { ER_MORE_MATCH_ELEMENT, + "Plusieurs meilleures concordances pour la m\u00E9thode d''\u00E9l\u00E9ment {0}"}, + + { ER_INVALID_CONTEXT_PASSED, + "Contexte transmis pour \u00E9valuation {0} non valide"}, + + { ER_POOL_EXISTS, + "Le pool existe d\u00E9j\u00E0"}, + + { ER_NO_DRIVER_NAME, + "Aucun nom de pilote indiqu\u00E9"}, + + { ER_NO_URL, + "Aucune URL indiqu\u00E9e"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "La taille de pool est inf\u00E9rieure \u00E0 1."}, + + { ER_INVALID_DRIVER, + "Nom de pilote indiqu\u00E9 non valide."}, + + { ER_NO_STYLESHEETROOT, + "Racine de la feuille de style introuvable."}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "Valeur non admise pour xml:space"}, + + { ER_PROCESSFROMNODE_FAILED, + "Echec de processFromNode"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "La ressource [ {0} ] n''a pas pu charger : {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Taille du tampon <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Erreur inconnue lors de l'appel de l'extension"}, + + { ER_NO_NAMESPACE_DECL, + "Le pr\u00E9fixe {0} n''a pas de d\u00E9claration d''espace de noms correspondante"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "Contenu d''\u00E9l\u00E9ment non autoris\u00E9 pour lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "Fin du r\u00E9acheminement de la feuille de style"}, + + { ER_ONE_OR_TWO, + "1 ou 2"}, + + { ER_TWO_OR_THREE, + "2 ou 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "Impossible de charger {0} (v\u00E9rifier CLASSPATH), les valeurs par d\u00E9faut sont donc employ\u00E9es"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Impossible d'initialiser les mod\u00E8les default"}, + + { ER_RESULT_NULL, + "Le r\u00E9sultat ne doit pas \u00EAtre NULL"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "Le r\u00E9sultat n'a pas pu \u00EAtre d\u00E9fini"}, + + { ER_NO_OUTPUT_SPECIFIED, + "Aucune sortie sp\u00E9cifi\u00E9e"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Impossible de transformer le r\u00E9sultat en r\u00E9sultat de type {0}"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Impossible de transformer une source de type {0}"}, + + { ER_NULL_CONTENT_HANDLER, + "Gestionnaire de contenu NULL"}, + + { ER_NULL_ERROR_HANDLER, + "Gestionnaire d'erreurs NULL"}, + + { ER_CANNOT_CALL_PARSE, + "impossible d'appeler l'analyse si le gestionnaire de contenu n'est pas d\u00E9fini"}, + + { ER_NO_PARENT_FOR_FILTER, + "Aucun parent pour le filtre"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "Aucune feuille de style trouv\u00E9e dans : {0}, support = {1}"}, + + { ER_NO_STYLESHEET_PI, + "Aucune instruction de traitement (PI) xml-stylesheet trouv\u00E9e dans : {0}"}, + + { ER_NOT_SUPPORTED, + "Non pris en charge : {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "La valeur de la propri\u00E9t\u00E9 {0} doit \u00EAtre une instance Boolean"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Impossible d''acc\u00E9der au script externe \u00E0 {0}"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "La ressource [ {0} ] est introuvable.\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propri\u00E9t\u00E9 de sortie non reconnue : {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "Echec de la cr\u00E9ation de l'instance ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "La valeur de {0} doit contenir un nombre pouvant \u00EAtre analys\u00E9"}, + + { ER_VALUE_SHOULD_EQUAL, + "La valeur de {0} doit \u00EAtre \u00E9gale \u00E0 oui ou non"}, + + { ER_FAILED_CALLING_METHOD, + "Echec de l''appel de la m\u00E9thode {0}"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "Echec de la cr\u00E9ation de l'instance ElemTemplateElement"}, + + { ER_CHARS_NOT_ALLOWED, + "Les caract\u00E8res ne sont pas autoris\u00E9s \u00E0 ce point du document"}, + + { ER_ATTR_NOT_ALLOWED, + "L''attribut \"{0}\" n''est pas autoris\u00E9 sur l''\u00E9l\u00E9ment {1}."}, + + { ER_BAD_VALUE, + "Valeur incorrecte de {0} : {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "Valeur d''attribut {0} introuvable "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "Valeur d''attribut {0} non reconnue "}, + + { ER_NULL_URI_NAMESPACE, + "Tentative de g\u00E9n\u00E9ration d'un pr\u00E9fixe d'espace de noms avec un URI NULL"}, + + { ER_NUMBER_TOO_BIG, + "Tentative de formatage d'un nombre sup\u00E9rieur \u00E0 l'entier de type Long le plus grand"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "Classe de pilote SAX1 {0} introuvable"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "Classe de pilote SAX1 {0} trouv\u00E9e mais pas charg\u00E9e"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "Classe de pilote SAX1 {0} charg\u00E9e mais pas instanci\u00E9e"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "La classe de pilote SAX1 {0} n''impl\u00E9mente pas org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Propri\u00E9t\u00E9 syst\u00E8me org.xml.sax.parser non indiqu\u00E9e"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "L'argument d'analyseur ne doit pas \u00EAtre NULL"}, + + { ER_FEATURE, + "Fonctionnalit\u00E9 : {0}"}, + + { ER_PROPERTY, + "Propri\u00E9t\u00E9 : {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "R\u00E9solveur d'entit\u00E9 NULL"}, + + { ER_NULL_DTD_HANDLER, + "Gestionnaire DTD NULL"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "Aucun nom de pilote indiqu\u00E9."}, + + { ER_NO_URL_SPECIFIED, + "Aucune URL indiqu\u00E9e."}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "La taille de pool est inf\u00E9rieure \u00E0 1."}, + + { ER_INVALID_DRIVER_NAME, + "Nom de pilote indiqu\u00E9 non valide."}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "Erreur du programmeur. L'expression n'a pas de parent ElemTemplateElement."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Assertion du programmeur dans RedundentExprEliminator : {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0} n''est pas autoris\u00E9 \u00E0 cet emplacement de la feuille de style."}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Le texte imprimable n'est pas autoris\u00E9 \u00E0 cet emplacement de la feuille de style."}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "Valeur non admise {1} utilis\u00E9e pour l''attribut CHAR : {0}. Un attribut de type CHAR ne doit \u00EAtre compos\u00E9 que d''un caract\u00E8re."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "Valeur non admise {1} utilis\u00E9e pour l''attribut QNAME : {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "Valeur non admise {1} utilis\u00E9e pour l''attribut ENUM : {0}. Les valeurs valides sont les suivantes : {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "Valeur non admise {1} utilis\u00E9e pour l''attribut NMTOKEN : {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "Valeur non admise {1} utilis\u00E9e pour l''attribut NCNAME : {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Valeur non admise {1} utilis\u00E9e pour l''attribut \"boolean\" : {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Valeur non admise {1} utilis\u00E9e pour l''attribut \"number\" : {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "L''argument pour {0} dans le mod\u00E8le de recherche doit \u00EAtre un litt\u00E9ral."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "D\u00E9claration de variable globale en double."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "D\u00E9claration de variable en double."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template doit avoir un attribut \"name\" ou \"match\" (ou les deux)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "Le pr\u00E9fixe de l''\u00E9l\u00E9ment exclude-result-prefixes n''est pas valide : {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "L''ensemble d''attributs nomm\u00E9 {0} n''existe pas"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "La fonction nomm\u00E9e {0} n''existe pas"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "L''\u00E9l\u00E9ment {0} ne doit pas avoir \u00E0 la fois un attribut \"select\" et un attribut de contenu."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "La valeur du param\u00E8tre {0} doit \u00EAtre un objet Java valide"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "L'attribut result-prefix d'un \u00E9l\u00E9ment xsl:namespace-alias a la valeur \"#default\", mais il n'existe aucune d\u00E9claration de l'espace de noms par d\u00E9faut dans la port\u00E9e pour l'\u00E9l\u00E9ment"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "L''attribut result-prefix d''un \u00E9l\u00E9ment xsl:namespace-alias a la valeur ''{0}'', mais il n''existe aucune d\u00E9claration d''espace de noms pour le pr\u00E9fixe ''{0}'' dans la port\u00E9e pour l''\u00E9l\u00E9ment."}, + + { ER_SET_FEATURE_NULL_NAME, + "Le nom de la fonctionnalit\u00E9 ne peut pas \u00EAtre NULL dans TransformerFactory.setFeature (cha\u00EEne pour le nom, valeur bool\u00E9enne)."}, + + { ER_GET_FEATURE_NULL_NAME, + "Le nom de la fonctionnalit\u00E9 ne peut pas \u00EAtre NULL dans TransformerFactory.getFeature (cha\u00EEne pour le nom)."}, + + { ER_UNSUPPORTED_FEATURE, + "Impossible de d\u00E9finir la fonctionnalit\u00E9 ''{0}'' sur cette propri\u00E9t\u00E9 TransformerFactory."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "L''utilisation de l''\u00E9l\u00E9ment d''extension ''{0}'' n''est pas autoris\u00E9e lorsque la fonctionnalit\u00E9 de traitement s\u00E9curis\u00E9 est d\u00E9finie sur True."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Impossible d'obtenir le pr\u00E9fixe pour un URI d'espace de noms NULL."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Impossible d'obtenir l'URI d'espace de noms pour le pr\u00E9fixe NULL."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "Le nom de fonction ne peut pas \u00EAtre NULL."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "L'arit\u00E9 ne peut pas \u00EAtre n\u00E9gative."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "'}' trouv\u00E9 mais aucun mod\u00E8le d'attribut ouvert."}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Avertissement : l''attribut \"count\" ne correspond pas \u00E0 un anc\u00EAtre dans xsl:number ! Cible = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Ancienne syntaxe : le nom de l'attribut \"expr\" a \u00E9t\u00E9 modifi\u00E9 en \"select\"."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan ne g\u00E8re pas encore le nom de l'environnement local dans la fonction format-number."}, + + { WG_LOCALE_NOT_FOUND, + "Avertissement : environnement local introuvable pour xml:lang={0}"}, + + { WG_CANNOT_MAKE_URL_FROM, + "Impossible de cr\u00E9er une URL \u00E0 partir de : {0}"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "Impossible de charger le document demand\u00E9 : {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "Collator introuvable pour >>>>>> Version Xalan "}, + { "version2", "<<<<<<<"}, + { "yes", "oui"}, + { "line", "Ligne n\u00B0"}, + { "column","Colonne n\u00B0"}, + { "xsldone", "XSLProcessor : termin\u00E9"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Options de classe \"Process\" de ligne de commande Xalan-J :"}, + { "xslProc_option", "Options de classe \"Process\" de ligne de commande Xalan-J :"}, + { "xslProc_invalid_xsltc_option", "L''option {0} n''est pas prise en charge dans le mode XSLTC."}, + { "xslProc_invalid_xalan_option", "L''option {0} ne peut \u00EAtre utilis\u00E9e qu''avec -XSLTC."}, + { "xslProc_no_input", "Erreur : aucune feuille de style ou aucun fichier XML d'entr\u00E9e n'est sp\u00E9cifi\u00E9. Ex\u00E9cutez cette commande sans option concernant les instructions d'utilisation."}, + { "xslProc_common_options", "-Options communes-"}, + { "xslProc_xalan_options", "-Options pour Xalan-"}, + { "xslProc_xsltc_options", "-Options pour XSLTC-"}, + { "xslProc_return_to_continue", "(appuyez sur la touche pour continuer)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (utiliser XSLTC pour la transformation)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [Nom de classe qualifi\u00E9 complet -PARSER de liaison d'analyseur]"}, + { "optionE", " [-E (Ne pas d\u00E9velopper les r\u00E9f\u00E9rences d'entit\u00E9)]"}, + { "optionV", " [-E (Ne pas d\u00E9velopper les r\u00E9f\u00E9rences d'entit\u00E9)]"}, + { "optionQC", " [-QC (Avertissements de conflits de mod\u00E8les en mode silencieux)]"}, + { "optionQ", " [-Q (Mode silencieux)]"}, + { "optionLF", " [-LF (Utiliser les retours \u00E0 la ligne uniquement en sortie {valeur par d\u00E9faut : CR/LF})]"}, + { "optionCR", " [-CR (Utiliser les retours chariot uniquement en sortie {valeur par d\u00E9faut : CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (Avec caract\u00E8res d'espacement {valeur par d\u00E9faut : <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (Contr\u00F4ler le nombre d'espaces \u00E0 mettre en retrait {valeur par d\u00E9faut : 0})]"}, + { "optionTT", " [-TT (G\u00E9n\u00E9rer une trace des mod\u00E8les pendant qu'ils sont appel\u00E9s.)]"}, + { "optionTG", " [-TG (G\u00E9n\u00E9rer une trace de chaque \u00E9v\u00E9nement de g\u00E9n\u00E9ration.)]"}, + { "optionTS", " [-TS (G\u00E9n\u00E9rer une trace de chaque \u00E9v\u00E9nement de s\u00E9lection.)]"}, + { "optionTTC", " [-TTC (G\u00E9n\u00E9rer une trace des enfants de mod\u00E8le pendant qu'ils sont trait\u00E9s.)]"}, + { "optionTCLASS", " [-TCLASS (Classe TraceListener pour les extensions de trace.)]"}, + { "optionVALIDATE", " [-VALIDATE (D\u00E9finir si la validation est effectu\u00E9e. Par d\u00E9faut, la validation est d\u00E9sactiv\u00E9e.)]"}, + { "optionEDUMP", " [-EDUMP {nom de fichier facultatif} (Effectuer le vidage de la pile sur l'erreur.)]"}, + { "optionXML", " [-XML (Utiliser le programme de formatage XML et ajouter un en-t\u00EAte XML.)]"}, + { "optionTEXT", " [-TEXT (Utiliser le formatage de texte simple.)]"}, + { "optionHTML", " [-HTML (Utiliser le formatage HTML.)]"}, + { "optionPARAM", " [-PARAM Expression de nom (D\u00E9finir un param\u00E8tre de feuille de style)]"}, + { "noParsermsg1", "Echec du processus XSL."}, + { "noParsermsg2", "** Analyseur introuvable **"}, + { "noParsermsg3", "V\u00E9rifiez votre variable d'environnement CLASSPATH."}, + { "noParsermsg4", "Si vous ne disposez pas de l'analyseur XML pour Java d'IBM, vous pouvez le t\u00E9l\u00E9charger sur le site"}, + { "noParsermsg5", "AlphaWorks d'IBM : http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER Nom de classe complet (URIResolver \u00E0 utiliser pour r\u00E9soudre les URI)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER Nom de classe complet (EntityResolver \u00E0 utiliser pour r\u00E9soudre les entit\u00E9s)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER Nom de classe complet (ContentHandler \u00E0 utiliser pour s\u00E9rialiser la sortie)]"}, + { "optionLINENUMBERS", " [-L Utiliser les num\u00E9ros de ligne pour le document source]"}, + { "optionSECUREPROCESSING", " [-SECURE (D\u00E9finir la fonctionnalit\u00E9 de traitement s\u00E9curis\u00E9 sur True)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (Utiliser l'attribut de support pour trouver la feuille de style associ\u00E9e \u00E0 un document)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (Utiliser explicitement s2s=SAX ou d2d=DOM pour effectuer la transformation)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (Afficher la dur\u00E9e totale de la transformation, en millisecondes)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (Demander la construction DTM incr\u00E9mentielle en d\u00E9finissant http://xml.apache.org/xalan/features/incremental true)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (Ne demander aucune optimisation de la feuille de style en d\u00E9finissant http://xml.apache.org/xalan/features/optimize false)]"}, + { "optionRL", " [-RL recursionlimit (Assertion d'une limite num\u00E9rique sur la profondeur de r\u00E9cursivit\u00E9 de la feuille de style)]"}, + { "optionXO", " [-XO [transletName] (Affecter le nom au translet g\u00E9n\u00E9r\u00E9)]"}, + { "optionXD", " [-XD destinationDirectory (Indiquer un r\u00E9pertoire de destination pour le translet)]"}, + { "optionXJ", " [-XJ jarfile (Packager les classes de translet dans un fichier JAR nomm\u00E9 )]"}, + { "optionXP", " [-XP package (Indique un pr\u00E9fixe de nom de package pour toutes les classes de translet g\u00E9n\u00E9r\u00E9es)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (Activer automatiquement l'image \"inline\" du mod\u00E8le)]" }, + { "optionXX", " [-XX (Activer la sortie de messages de d\u00E9bogage suppl\u00E9mentaires)]"}, + { "optionXT" , " [-XT (Utiliser le translet pour la transformation si possible)]"}, + { "diagTiming"," --------- La transformation de {0} via {1} a pris {2} ms" }, + { "recursionTooDeep","Imbrication de mod\u00E8le trop profonde. Imbrication = {0}, mod\u00E8le {1} {2}" }, + { "nameIs", "le nom est" }, + { "matchPatternIs", "le mod\u00E8le de recherche est" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java new file mode 100644 index 000000000..4a3b688e7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_it extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "Errore: '{' non pu\u00F2 esistere nell'espressione"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} ha un attributo non valido: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode nullo in xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "Impossibile aggiungere {0} a {1}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode nullo in handleApplyTemplatesInstruction."}, + + { ER_NO_NAME_ATTRIB, + "{0} deve avere un attributo name."}, + + {ER_TEMPLATE_NOT_FOUND, + "Impossibile trovare il modello denominato {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Impossibile risolvere l'AVT del nome in xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} richiede l''attributo: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} deve avere un attributo \"test\"."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valore non valido per l''attributo level: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "il nome processing-instruction non pu\u00F2 essere 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "il nome processing-instruction deve essere un NCName valido: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} deve avere un attributo match se dispone di una modalit\u00E0."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} richiede un nome o un attributo match."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Impossibile risolvere il prefisso spazio di nomi {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space ha un valore non valido {0}"}, + + { ER_NO_OWNERDOC, + "Il nodo figlio non dispone di un documento proprietario."}, + + { ER_ELEMTEMPLATEELEM_ERR, + "Errore di ElemTemplateElement: {0}"}, + + { ER_NULL_CHILD, + "Tentativo di aggiungere un elemento figlio nullo."}, + + { ER_NEED_SELECT_ATTRIB, + "{0} richiede un attributo select."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when deve avere un attributo 'test'."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param deve avere un attributo 'name'."}, + + { ER_NO_CONTEXT_OWNERDOC, + "il contesto non dispone di un documento proprietario."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Impossibile creare la relazione TransformerFactory XML {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: processo non riuscito."}, + + { ER_NOT_SUCCESSFUL, + "Xalan: operazione non riuscita."}, + + { ER_ENCODING_NOT_SUPPORTED, + "Codifica non supportata: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Impossibile creare TraceListener {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key richiede un attributo 'name'."}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key richiede un attributo 'match'."}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key richiede un attributo 'use'."}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} richiede un attributo ''elements''."}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} attributo ''prefix'' mancante"}, + + { ER_BAD_STYLESHEET_URL, + "URL del foglio di stile non valido: {0}"}, + + { ER_FILE_NOT_FOUND, + "File del foglio di stile non trovato: {0}"}, + + { ER_IOEXCEPTION, + "Eccezione IO con il file foglio di stile: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Impossibile trovare l''attributo href per {0}"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} include s\u00E9 stesso direttamente o indirettamente."}, + + { ER_PROCESSINCLUDE_ERROR, + "Errore di StylesheetHandler.processInclude: {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0} attributo ''lang'' mancante"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) posizione errata dell''elemento {0}. Elemento ''component'' del contenitore mancante."}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "L'output pu\u00F2 essere eseguito solo su Element, DocumentFragment, Document o PrintWriter."}, + + { ER_PROCESS_ERROR, + "Errore di StylesheetRoot.process"}, + + { ER_UNIMPLNODE_ERROR, + "Errore di UnImplNode: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "Errore. L'espressione di selezione dell'xpath (-select) non \u00E8 stata trovata."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Impossibile serializzare un XSLProcessor."}, + + { ER_NO_INPUT_STYLESHEET, + "Input del foglio di stile non specificato."}, + + { ER_FAILED_PROCESS_STYLESHEET, + "Elaborazione del foglio di stile non riuscita."}, + + { ER_COULDNT_PARSE_DOC, + "Impossibile analizzare il documento {0}"}, + + { ER_COULDNT_FIND_FRAGMENT, + "Impossibile trovare il frammento {0}"}, + + { ER_NODE_NOT_ELEMENT, + "Il nodo a cui punta l''identificativo di frammento non \u00E8 un elemento: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each deve avere un attributo match o name"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates deve avere un attributo match o name"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Nessun duplicato di un frammento di documento."}, + + { ER_CANT_CREATE_ITEM, + "Impossibile creare una voce nella struttura dei risultati: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space nell''XML di origine ha un valore non valido {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "Nessuna dichiarazione xsl:key per {0}."}, + + { ER_CANT_CREATE_URL, + "Errore. Impossibile creare l''URL per {0}"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions non supportato"}, + + { ER_PROCESSOR_ERROR, + "Errore di TransformerFactory XSLT"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} non consentito in un foglio di stile."}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns non pi\u00F9 supportato. Utilizzare xsl:output."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space non pi\u00F9 supportato. Utilizzare xsl:strip-space o xsl:preserve-space."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result non pi\u00F9 supportato. Utilizzare xsl:output."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} ha un attributo non valido: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "Elemento XSL sconosciuto: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort pu\u00F2 essere utilizzato solo con xsl:apply-templates o xsl:for-each."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) posizione errata di xsl:when."}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when non associato da xsl:choose."}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) posizione errata di xsl:otherwise."}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise non associato da xsl:choose."}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} non consentito in un modello."}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0} prefisso spazio di nomi estensione {1} sconosciuto"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Le importazioni possono essere eseguite solo come primi elementi nel foglio di stile."}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} importa s\u00E9 stesso direttamente o indirettamente."}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space ha un valore non valido {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet non riuscito."}, + + { ER_SAX_EXCEPTION, + "Eccezione SAX"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "Funzione non supportata."}, + + { ER_XSLT_ERROR, + "Errore XSLT"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "il simbolo della valuta non \u00E8 consentito in una stringa di pattern di formato"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Funzione del documento non supportata nel DOM del foglio di stile."}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Impossibile risolvere il prefisso di un resolver senza prefissi."}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "Estensione di reindirizzamento: impossibile trovare il nome file. L'attributo file o select deve restituire una stringa valida."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Impossibile creare FormatterListener nell'estensione di reindirizzamento."}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Il prefisso in exclude-result-prefixes non \u00E8 valido: {0}"}, + + { ER_MISSING_NS_URI, + "URI dello spazio di nomi mancante per il prefisso specificato"}, + + { ER_MISSING_ARG_FOR_OPTION, + "Argomento mancante per l''opzione: {0}"}, + + { ER_INVALID_OPTION, + "Opzione non valida: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "Stringa con formato errato: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet richiede un attributo 'version'."}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "L''attributo {0} ha un valore non valido {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose richiede xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports non consentito in xsl:for-each"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "Impossibile utilizzare DTMLiaison per un nodo DOM di output... Passare com.sun.org.apache.xpath.internal.DOM2Helper."}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "Impossibile utilizzare DTMLiaison per un nodo DOM di input... Passare com.sun.org.apache.xpath.internal.DOM2Helper."}, + + { ER_CALL_TO_EXT_FAILED, + "Chiamata all''elemento di estensione non riuscita: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "Il prefisso deve essere risolto in uno spazio di nomi: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "Rilevato surrogato UTF-16 non valido: {0}?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} utilizza s\u00E9 stesso, il che pu\u00F2 causare un loop infinito."}, + + { ER_CANNOT_MIX_XERCESDOM, + "Impossibile unire input non Xerces-DOM con output Xerces-DOM."}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "In ElemTemplateElement.readObject: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "Sono stati trovati pi\u00F9 modelli denominati {0}"}, + + { ER_INVALID_KEY_CALL, + "Chiamata di funzione non valida: non sono consentite chiamate recursive key()"}, + + { ER_REFERENCING_ITSELF, + "La variabile {0} fa riferimento a s\u00E9 stessa direttamente o indirettamente."}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "Il nodo di input non pu\u00F2 essere nullo per un DOMSource per newTemplates."}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "File di classe non trovato per l''opzione {0}"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "Elemento richiesto non trovato: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream non pu\u00F2 essere nullo"}, + + { ER_URI_CANNOT_BE_NULL, + "L'URI non pu\u00F2 essere nullo"}, + + { ER_FILE_CANNOT_BE_NULL, + "Il file non pu\u00F2 essere nullo"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource non pu\u00F2 essere nullo"}, + + { ER_CANNOT_INIT_BSFMGR, + "Impossibile inizializzare BSF Manager"}, + + { ER_CANNOT_CMPL_EXTENSN, + "Impossibile compilare l'estensione"}, + + { ER_CANNOT_CREATE_EXTENSN, + "Impossibile creare l''estensione {0}. Motivo: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "La chiamata del metodo di istanza {0} richiede un''istanza di oggetto come primo argomento"}, + + { ER_INVALID_ELEMENT_NAME, + "Specificato nome elemento {0} non valido"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "Il metodo di nome elemento deve essere statico {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "Funzione di estensione {0} : {1} sconosciuta"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "Esistono pi\u00F9 corrispondenze migliori per il costruttore di {0}"}, + + { ER_MORE_MATCH_METHOD, + "Esistono pi\u00F9 corrispondenze migliori per il metodo {0}"}, + + { ER_MORE_MATCH_ELEMENT, + "Esistono pi\u00F9 corrispondenze migliori per il metodo di elemento {0}"}, + + { ER_INVALID_CONTEXT_PASSED, + "Passato contesto non valido per valutare {0}"}, + + { ER_POOL_EXISTS, + "Il pool esiste gi\u00E0"}, + + { ER_NO_DRIVER_NAME, + "Nessun nome driver specificato"}, + + { ER_NO_URL, + "Nessun URL specificato"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "La dimensione del pool \u00E8 minore di uno."}, + + { ER_INVALID_DRIVER, + "Specificato nome driver non valido."}, + + { ER_NO_STYLESHEETROOT, + "Radice del foglio di stile non trovata."}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "Valore non valido per xml:space"}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode non riuscito"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "Impossibile caricare la risorsa [ {0} ]: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Dimensione buffer <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Errore sconosciuto durante la chiamata dell'estensione"}, + + { ER_NO_NAMESPACE_DECL, + "Il prefisso {0} non ha una dichiarazione di spazio di nomi corrispondente"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "Contenuto di elemento non consentito per lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "Il foglio di stile ha causato l'interruzione"}, + + { ER_ONE_OR_TWO, + "1 o 2"}, + + { ER_TWO_OR_THREE, + "2 o 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "Impossibile caricare {0} (verificare CLASSPATH); verranno utilizzati i valori predefiniti"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Impossibile inizializzare i modelli predefiniti"}, + + { ER_RESULT_NULL, + "Il risultato non deve essere nullo"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "Impossibile impostare il risultato"}, + + { ER_NO_OUTPUT_SPECIFIED, + "Nessun output specificato"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Impossibile eseguire la trasformazione in un risultato di tipo {0}"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Impossibile eseguire la trasformazione in un''origine di tipo {0}"}, + + { ER_NULL_CONTENT_HANDLER, + "Handler dei contenuti nullo"}, + + { ER_NULL_ERROR_HANDLER, + "Handler degli errori nullo"}, + + { ER_CANNOT_CALL_PARSE, + "impossibile richiamare parse se non \u00E8 stato impostato ContentHandler"}, + + { ER_NO_PARENT_FOR_FILTER, + "Nessun elemento padre per il filtro"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "Nessun foglio di stile trovato in {0}, media= {1}."}, + + { ER_NO_STYLESHEET_PI, + "Nessun PI xml-stylesheet trovato in {0}"}, + + { ER_NOT_SUPPORTED, + "Non supportato: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "Il valore della propriet\u00E0 {0} deve essere un''istanza booleana"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Impossibile recuperare lo script esterno in {0}"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "Risorsa [ {0} ] non trovata.\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propriet\u00E0 di output non riconosciuta: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "Creazione dell'istanza ElemLiteralResult non riuscita"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "Il valore per {0} deve contenere un numero analizzabile"}, + + { ER_VALUE_SHOULD_EQUAL, + "Il valore per {0} deve corrispondere a yes o no"}, + + { ER_FAILED_CALLING_METHOD, + "Richiamo del metodo {0} non riuscito"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "Creazione dell'istanza ElemTemplateElement non riuscita"}, + + { ER_CHARS_NOT_ALLOWED, + "Non sono consentiti caratteri in questo punto del documento"}, + + { ER_ATTR_NOT_ALLOWED, + "L''attributo \"{0}\" non \u00E8 consentito nell''elemento {1}."}, + + { ER_BAD_VALUE, + "{0} valore non valido {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "{0} valore di attributo non trovato "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} valore di attributo non riconosciuto "}, + + { ER_NULL_URI_NAMESPACE, + "Tentativo di generare un prefisso spazio di nomi con URI nullo"}, + + { ER_NUMBER_TOO_BIG, + "Tentativo di formattare un numero superiore a quello del numero intero di tipo Long pi\u00F9 grande"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "Impossibile trovare la classe di driver SAX1 {0}"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "La classe di driver SAX1 {0} \u00E8 stata trovata, ma non pu\u00F2 essere caricata."}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "La classe di driver SAX1 {0} \u00E8 stata caricata, ma non \u00E8 possibile creare un''istanza."}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "La classe di driver SAX1 {0} non implementa org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Propriet\u00E0 di sistema org.xml.sax.parser non specificata"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "L'argomento del parser non deve essere nullo"}, + + { ER_FEATURE, + "Funzione: {0}"}, + + { ER_PROPERTY, + "Propriet\u00E0: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "Resolver di entit\u00E0 nullo"}, + + { ER_NULL_DTD_HANDLER, + "Handler DTD nullo"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "Nessun nome driver specificato."}, + + { ER_NO_URL_SPECIFIED, + "Nessun URL specificato."}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "La dimensione del pool \u00E8 minore di uno."}, + + { ER_INVALID_DRIVER_NAME, + "Specificato nome driver non valido."}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "Errore del programmatore. L'espressione non ha un elemento padre ElemTemplateElement."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Asserzione del programmatore in RedundentExprEliminator: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0} non consentito in questa posizione nel figlio di stile."}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Testo senza spazi non consentito in questa posizione nel figlio di stile."}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "Valore non valido {1} utilizzato per l''attributo CHAR {0}. Un attributo di tipo CHAR deve avere un solo carattere."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "Valore non valido {1} utilizzato per l''attributo QNAME {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "Valore non valido {1} utilizzato per l''attributo ENUM {0}. Valori validi: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "Valore non valido {1} utilizzato per l''attributo NMTOKEN {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "Valore non valido {1} utilizzato per l''attributo NCNAME {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Valore non valido {1} utilizzato per l''attributo booleano {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Valore non valido {1} utilizzato per l''attributo numerico {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "L''argomento per {0} nel pattern di corrispondenza deve essere un valore."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "Dichiarazione di variabili globali duplicate."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "Dichiarazione di variabili duplicate."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template deve avere un attributo name o match o entrambi"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "Il prefisso in exclude-result-prefixes non \u00E8 valido: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "il set di attributi denominato {0} non esiste"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "La funzione denominata {0} non esiste"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "L''elemento {0} non deve avere entrambi gli attributi content e select."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "Il valore del parametro {0} deve essere un oggetto Java valido"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "L'attributo result-prefix di un elemento xsl:namespace-alias ha il valore '#default', ma non esiste alcuna dichiarazione dello spazio di nomi predefinito nell'ambito per l'elemento."}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "L''attributo result-prefix di un elemento xsl:namespace-alias ha il valore ''{0}'', ma non esiste alcuna dichiarazione dello spazio di nomi per il prefisso ''{0}'' nell''ambito per l''elemento."}, + + { ER_SET_FEATURE_NULL_NAME, + "Il nome funzione non pu\u00F2 essere nullo in TransformerFactory.setFeature (nome stringa, valore booleano)."}, + + { ER_GET_FEATURE_NULL_NAME, + "Il nome funzione non pu\u00F2 essere nullo in TransformerFactory.getFeature (nome stringa)."}, + + { ER_UNSUPPORTED_FEATURE, + "Impossibile impostare la funzione ''{0}'' in questo TransformerFactory."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Non \u00E8 consentito utilizzare l''elemento di estensione ''{0}'' se la funzione di elaborazione sicura \u00E8 impostata su true."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Impossibile recuperare il prefisso per un URI di spazio di nomi nullo."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Impossibile recuperare l'URI di spazio di nomi per un prefisso nullo."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "Il nome funzione non pu\u00F2 essere nullo."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "L'arity non pu\u00F2 essere negativa."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "Trovato '}', ma non esistono modelli di attributo aperti."}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Avvertenza: l''attributo count non corrisponde a un predecessore in xsl:number. Destinazione = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Sintassi obsoleta: il nome dell'attributo 'expr' \u00E8 stato cambiato in 'select'."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan non gestisce ancora il nome di impostazioni nazionali nella funzione format-number."}, + + { WG_LOCALE_NOT_FOUND, + "Avvertenza: impossibile trovare le impostazioni nazionali per xml:lang={0}"}, + + { WG_CANNOT_MAKE_URL_FROM, + "Impossibile creare un URL da {0}"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "Impossibile caricare il documento richiesto: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "Impossibile trovare Collator per >>>>>> Versione Xalan "}, + { "version2", "<<<<<<<"}, + { "yes", "s\u00EC"}, + { "line", "N. riga"}, + { "column","N. colonna"}, + { "xsldone", "XSLProcessor: operazione completata"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Opzioni classe di processo per riga di comando Xalan-J:"}, + { "xslProc_option", "Opzioni classe di processo per riga di comando Xalan-J:"}, + { "xslProc_invalid_xsltc_option", "Opzione {0} non supportata in modalit\u00E0 XSLTC."}, + { "xslProc_invalid_xalan_option", "L''opzione {0} pu\u00F2 essere utilizzata solo con -XSLTC."}, + { "xslProc_no_input", "Errore: non \u00E8 stato specificato alcun foglio di stile o XML di input. Eseguire questo comando senza opzioni per visualizzare le istruzioni sull'uso."}, + { "xslProc_common_options", "-Opzioni comuni-"}, + { "xslProc_xalan_options", "-Opzioni per Xalan-"}, + { "xslProc_xsltc_options", "-Opzioni per XSLTC-"}, + { "xslProc_return_to_continue", "(premere per continuare)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (usa XSLTC per la trasformazione)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER nome classe completamente qualificato per la relazione del parser]"}, + { "optionE", " [-E (non espande i riferimenti alle entit\u00E0)]"}, + { "optionV", " [-E (non espande i riferimenti alle entit\u00E0)]"}, + { "optionQC", " [-QC (avvertenze silenziose per i conflitti di pattern)]"}, + { "optionQ", " [-Q (modalit\u00E0 silenziosa)]"}, + { "optionLF", " [-LF (usa avanzamenti riga solo nell'output {il valore predefinito \u00E8 CR/LF})]"}, + { "optionCR", " [-CR (usa ritorni a capo solo nell'output {il valore predefinito \u00E8 CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (caratteri da sottoporre a escape {il valore predefinito \u00E8 <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (determina il numero di spazi da indentare {il valore predefinito \u00E8 0})]"}, + { "optionTT", " [-TT (tiene traccia dei modelli mentre vengono richiamati.)]"}, + { "optionTG", " [-TG (tiene traccia di ogni evento di generazione.)]"}, + { "optionTS", " [-TS (tiene traccia di ogni evento di selezione.)]"}, + { "optionTTC", " [-TTC (tiene traccia degli elementi secondari di modello mentre vengono elaborati.)]"}, + { "optionTCLASS", " [-TCLASS (classe TraceListener per tenere traccia delle estensioni.)]"}, + { "optionVALIDATE", " [-VALIDATE (imposta se viene eseguita la convalida che, per impostazione predefinita, \u00E8 disattivata.)]"}, + { "optionEDUMP", " [-EDUMP {nome file facoltativo} (esegue stackdump in caso di errore.)]"}, + { "optionXML", " [-XML (usa il formatter XML e aggiunge l'intestazione XML.)]"}, + { "optionTEXT", " [-TEXT (usa il formatter di testo semplice.)]"}, + { "optionHTML", " [-HTML (usa il formatter HTML.)]"}, + { "optionPARAM", " [-PARAM espressione nome (imposta un parametro di foglio di stile)]"}, + { "noParsermsg1", "Processo XSL non riuscito."}, + { "noParsermsg2", "** Impossibile trovare il parser **"}, + { "noParsermsg3", "Controllare il classpath."}, + { "noParsermsg4", "Se non \u00E8 disponibile un parser XML di IBM per Java, \u00E8 possibile scaricarlo da"}, + { "noParsermsg5", "AlphaWorks di IBM: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER nome classe completo (URIResolver da utilizzare per risolvere gli URI)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER nome classe completo (EntityResolver da utilizzare per risolvere le entit\u00E0)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER nome classe completo (ContentHandler da utilizzare per serializzare l'output)]"}, + { "optionLINENUMBERS", " [-L utilizza i numeri di riga per il documento di origine]"}, + { "optionSECUREPROCESSING", " [-SECURE (imposta la funzione di elaborazione sicura su true.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (utilizza l'attributo media per trovare il foglio di stile associato a un documento.)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (utilizza esplicitamente s2s=SAX o d2d=DOM per eseguire la trasformazione.)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (visualizza i millisecondi totali richiesti per la trasformazione.)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (richiede la creazione incrementale di DTM impostando http://xml.apache.org/xalan/features/incremental su true.)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (richiede che non venga elaborata l'ottimizzazione dei fogli di stile impostando http://xml.apache.org/xalan/features/optimize su false.)]"}, + { "optionRL", " [-RL recursionlimit (stabilisce un limite numerico sulla profondit\u00E0 ricorsiva dei fogli di stile.)]"}, + { "optionXO", " [-XO [transletName] (assegna un nome al translet creato)]"}, + { "optionXD", " [-XD destinationDirectory (specifica una directory di destinazione per il translet)]"}, + { "optionXJ", " [-XJ jarfile (crea un package di classi di translet in un file jar denominato )]"}, + { "optionXP", " [-XP package (specifica un prefisso nome package per tutte le classi di translet generate)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (abilita l'inserimento in linea dei modelli)]" }, + { "optionXX", " [-XX (attiva l'output di altri messaggi di debug)]"}, + { "optionXT" , " [-XT (utilizza il translet per eseguire la trasformazione, se possibile.)]"}, + { "diagTiming"," --------- La trasformazione di {0} mediante {1} ha richiesto {2} ms" }, + { "recursionTooDeep","Nidificazione dei modelli troppo profonda. Nidificazione = {0}, modello {1} {2}." }, + { "nameIs", "il nome \u00E8" }, + { "matchPatternIs", "il pattern di corrispondenza \u00E8" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java new file mode 100644 index 000000000..5356ee53c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_ja extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "\u30A8\u30E9\u30FC: \u5F0F\u5185\u306B'{'\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0}\u306B\u4E0D\u6B63\u306A\u5C5E\u6027\u304C\u3042\u308A\u307E\u3059: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode\u306Fxsl:apply-imports\u5185\u3067null\u3067\u3059\u3002"}, + + {ER_CANNOT_ADD, + "{0}\u3092{1}\u306B\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode\u306FhandleApplyTemplatesInstruction\u5185\u3067null\u3067\u3059\u3002"}, + + { ER_NO_NAME_ATTRIB, + "{0}\u306B\u306Fname\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_TEMPLATE_NOT_FOUND, + "\u540D\u524D{0}\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "xsl:call-template\u306E\u540D\u524DAVT\u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_REQUIRES_ATTRIB, + "{0}\u306F\u5C5E\u6027{1}\u304C\u5FC5\u8981\u3067\u3059"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0}\u306F''test''\u5C5E\u6027\u3092\u6301\u3064\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "level\u5C5E\u6027\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction\u540D\u306F'xml'\u306B\u3067\u304D\u307E\u305B\u3093"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction\u540D\u306F\u6709\u52B9\u306ANCName\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "\u30E2\u30FC\u30C9\u304C\u3042\u308B\u5834\u5408\u3001{0}\u306B\u306Fmatch\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0}\u306B\u306Fname\u307E\u305F\u306Fmatch\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u63A5\u982D\u8F9E\u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + { ER_NO_OWNERDOC, + "\u5B50\u30CE\u30FC\u30C9\u306B\u6240\u6709\u8005\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + { ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement\u30A8\u30E9\u30FC: {0}"}, + + { ER_NULL_CHILD, + "null\u306E\u5B50\u3092\u8FFD\u52A0\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F\u3002"}, + + { ER_NEED_SELECT_ATTRIB, + "{0}\u306B\u306Fselect\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when\u306B\u306F'test'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param\u306B\u306F'name'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_NO_CONTEXT_OWNERDOC, + "\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u306B\u6240\u6709\u8005\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "XML TransformerFactory Liaison\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \u30D7\u30ED\u30BB\u30B9\u306F\u6210\u529F\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + { ER_NOT_SUCCESSFUL, + "Xalan: \u306F\u6210\u529F\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + { ER_ENCODING_NOT_SUPPORTED, + "\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "TraceListener\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key\u306B\u306F'name'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key\u306B\u306F'match'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key\u306B\u306F'use'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0}\u306B\u306F''elements''\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0}\u5C5E\u6027''prefix''\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_BAD_STYLESHEET_URL, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8URL\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + { ER_FILE_NOT_FOUND, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + { ER_IOEXCEPTION, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u306B\u5165\u51FA\u529B\u4F8B\u5916\u304C\u3042\u308A\u307E\u3059: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) {0}\u306Ehref\u5C5E\u6027\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0}\u306F\u305D\u308C\u81EA\u4F53\u3092\u76F4\u63A5\u7684\u307E\u305F\u306F\u9593\u63A5\u7684\u306B\u542B\u3093\u3067\u3044\u307E\u3059\u3002"}, + + { ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude\u30A8\u30E9\u30FC\u3001{0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0}\u5C5E\u6027''lang''\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0}\u8981\u7D20\u306E\u914D\u7F6E\u304C\u4E0D\u6B63\u3067\u3059\u3002\u30B3\u30F3\u30C6\u30CA\u8981\u7D20''component''\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Element\u3001DocumentFragment\u3001Document\u307E\u305F\u306FPrintWriter\u306B\u306E\u307F\u51FA\u529B\u3067\u304D\u307E\u3059\u3002"}, + + { ER_PROCESS_ERROR, + "StylesheetRoot.process\u30A8\u30E9\u30FC"}, + + { ER_UNIMPLNODE_ERROR, + "UnImplNode\u30A8\u30E9\u30FC: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "\u30A8\u30E9\u30FC\u3002xpath\u9078\u629E\u5F0F(-select)\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "XSLProcessor\u3092\u30B7\u30EA\u30A2\u30E9\u30A4\u30BA\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_NO_INPUT_STYLESHEET, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u5165\u529B\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + { ER_FAILED_PROCESS_STYLESHEET, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002"}, + + { ER_COULDNT_PARSE_DOC, + "{0}\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u89E3\u6790\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + { ER_COULDNT_FIND_FRAGMENT, + "\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u8B58\u5225\u5B50\u306B\u3088\u3063\u3066\u6307\u793A\u3055\u308C\u305F\u30CE\u30FC\u30C9\u306F\u8981\u7D20\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each\u306Fmatch\u307E\u305F\u306Fname\u5C5E\u6027\u3092\u6301\u3064\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306Fmatch\u307E\u305F\u306Fname\u5C5E\u6027\u3092\u6301\u3064\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u30FB\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u306E\u30AF\u30ED\u30FC\u30F3\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_CANT_CREATE_ITEM, + "\u7D50\u679C\u30C4\u30EA\u30FC\u306B\u9805\u76EE\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "\u30BD\u30FC\u30B9XML\u306Exml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "{0}\u306Exsl:key\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + { ER_CANT_CREATE_URL, + "\u30A8\u30E9\u30FC\u3002{0}\u306EURL\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + { ER_PROCESSOR_ERROR, + "XSLT TransformerFactory\u30A8\u30E9\u30FC"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0}\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306Bxsl:output\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306Bxsl:strip-space\u307E\u305F\u306Fxsl:preserve-space\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306Bxsl:output\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0}\u306B\u306F\u4E0D\u6B63\u306A\u5C5E\u6027\u304C\u3042\u308A\u307E\u3059: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "\u4E0D\u660E\u306AXSL\u8981\u7D20: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort\u306F\u3001xsl:apply-templates\u307E\u305F\u306Fxsl:for-each\u3068\u3068\u3082\u306B\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when\u306E\u914D\u7F6E\u304C\u4E0D\u6B63\u3067\u3059\u3002"}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when\u306E\u89AA\u304Cxsl:choose\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002"}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise\u306E\u914D\u7F6E\u304C\u4E0D\u6B63\u3067\u3059\u3002"}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise\u306E\u89AA\u304Cxsl:choose\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002"}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0}\u306F\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) \u4E0D\u660E\u306A{0}\u62E1\u5F35\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u63A5\u982D\u8F9E{1}\u3067\u3059"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \u30A4\u30F3\u30DD\u30FC\u30C8\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u6700\u521D\u306E\u8981\u7D20\u3068\u3057\u3066\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0}\u306F\u305D\u308C\u81EA\u4F53\u3092\u76F4\u63A5\u307E\u305F\u306F\u9593\u63A5\u7684\u306B\u30A4\u30F3\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u3059\u3002"}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet\u306F\u5931\u6557\u3057\u307E\u3057\u305F\u3002"}, + + { ER_SAX_EXCEPTION, + "SAX\u4F8B\u5916"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "\u95A2\u6570\u304C\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + { ER_XSLT_ERROR, + "XSLT\u30A8\u30E9\u30FC"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "\u901A\u8CA8\u8A18\u53F7\u306F\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u30FB\u30D1\u30BF\u30FC\u30F3\u6587\u5B57\u5217\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u95A2\u6570\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8DOM\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\u975E\u63A5\u982D\u8F9E\u30EA\u30BE\u30EB\u30D0\u306E\u63A5\u982D\u8F9E\u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u62E1\u5F35: \u30D5\u30A1\u30A4\u30EB\u540D\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F - file\u307E\u305F\u306Fselect\u5C5E\u6027\u304C\u6709\u52B9\u306A\u6587\u5B57\u5217\u3092\u8FD4\u3059\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u62E1\u5F35\u3067FormatterListener\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes\u306E\u63A5\u982D\u8F9E\u304C\u7121\u52B9\u3067\u3059: {0}"}, + + { ER_MISSING_NS_URI, + "\u6307\u5B9A\u3057\u305F\u63A5\u982D\u8F9E\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9URI\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_MISSING_ARG_FOR_OPTION, + "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306E\u5F15\u6570\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_INVALID_OPTION, + "\u7121\u52B9\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "\u4E0D\u6B63\u306A\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u306E\u6587\u5B57\u5217\u3067\u3059: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet\u306F'version'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "\u5C5E\u6027{0}\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose\u306Fxsl:when\u304C\u5FC5\u8981\u3067\u3059"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports\u306Fxsl:for-each\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "\u51FA\u529BDOM\u30CE\u30FC\u30C9\u306BDTMLiaison\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093...\u304B\u308F\u308A\u306Bcom.sun.org.apache.xpath.internal.DOM2Helper\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "\u5165\u529BDOM\u30CE\u30FC\u30C9\u306BDTMLiaison\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093...\u304B\u308F\u308A\u306Bcom.sun.org.apache.xpath.internal.DOM2Helper\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + { ER_CALL_TO_EXT_FAILED, + "\u62E1\u5F35\u8981\u7D20\u306E\u547C\u51FA\u3057\u304C\u5931\u6557\u3057\u307E\u3057\u305F: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "\u63A5\u982D\u8F9E\u306F\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306B\u89E3\u6C7A\u3055\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "\u7121\u52B9\u306AUTF-16\u30B5\u30ED\u30B2\u30FC\u30C8\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F: {0}\u3002"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0}\u304C\u305D\u308C\u81EA\u4F53\u3092\u4F7F\u7528\u3057\u3001\u7121\u9650\u30EB\u30FC\u30D7\u304C\u767A\u751F\u3057\u307E\u3059\u3002"}, + + { ER_CANNOT_MIX_XERCESDOM, + "\u975EXerces-DOM\u5165\u529B\u3068Xerces-DOM\u51FA\u529B\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "ElemTemplateElement.readObject\u5185: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "\u540D\u524D{0}\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u8907\u6570\u898B\u3064\u304B\u308A\u307E\u3057\u305F"}, + + { ER_INVALID_KEY_CALL, + "\u7121\u52B9\u306A\u95A2\u6570\u547C\u51FA\u3057: \u518D\u5E30\u7684\u306Akey()\u306E\u547C\u51FA\u3057\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + { ER_REFERENCING_ITSELF, + "\u5909\u6570{0}\u306F\u305D\u308C\u81EA\u4F53\u3092\u76F4\u63A5\u307E\u305F\u306F\u9593\u63A5\u7684\u306B\u53C2\u7167\u3057\u3066\u3044\u307E\u3059\u3002"}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "newTemplates\u306EDOMSource\u306B\u3064\u3044\u3066\u5165\u529B\u30CE\u30FC\u30C9\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306B\u3064\u3044\u3066\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "\u5FC5\u9808\u8981\u7D20\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + { ER_URI_CANNOT_BE_NULL, + "URI\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + { ER_FILE_CANNOT_BE_NULL, + "\u30D5\u30A1\u30A4\u30EB\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + { ER_CANNOT_INIT_BSFMGR, + "BSF\u30DE\u30CD\u30FC\u30B8\u30E3\u3092\u521D\u671F\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + { ER_CANNOT_CMPL_EXTENSN, + "\u62E1\u5F35\u3092\u30B3\u30F3\u30D1\u30A4\u30EB\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + { ER_CANNOT_CREATE_EXTENSN, + "{1}\u304C\u539F\u56E0\u3067\u62E1\u5F35{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "\u30E1\u30BD\u30C3\u30C9{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9\u547C\u51FA\u3057\u3067\u306F\u3001\u6700\u521D\u306E\u5F15\u6570\u3068\u3057\u3066\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u30FB\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5FC5\u8981\u3067\u3059"}, + + { ER_INVALID_ELEMENT_NAME, + "\u7121\u52B9\u306A\u8981\u7D20\u540D\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F{0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "\u8981\u7D20\u540D\u30E1\u30BD\u30C3\u30C9\u306Fstatic {0}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "\u62E1\u5F35\u95A2\u6570{0} : {1}\u304C\u4E0D\u660E\u3067\u3059"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "{0}\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306B\u8907\u6570\u306E\u6700\u9069\u4E00\u81F4\u304C\u3042\u308A\u307E\u3059"}, + + { ER_MORE_MATCH_METHOD, + "\u30E1\u30BD\u30C3\u30C9{0}\u306B\u8907\u6570\u306E\u6700\u9069\u4E00\u81F4\u304C\u3042\u308A\u307E\u3059"}, + + { ER_MORE_MATCH_ELEMENT, + "\u8981\u7D20\u30E1\u30BD\u30C3\u30C9{0}\u306B\u8907\u6570\u306E\u6700\u9069\u4E00\u81F4\u304C\u3042\u308A\u307E\u3059"}, + + { ER_INVALID_CONTEXT_PASSED, + "{0}\u3092\u8A55\u4FA1\u3059\u308B\u305F\u3081\u306B\u7121\u52B9\u306A\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u304C\u6E21\u3055\u308C\u307E\u3057\u305F"}, + + { ER_POOL_EXISTS, + "\u30D7\u30FC\u30EB\u306F\u3059\u3067\u306B\u5B58\u5728\u3057\u307E\u3059"}, + + { ER_NO_DRIVER_NAME, + "\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + { ER_NO_URL, + "URL\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "\u30D7\u30FC\u30EB\u30FB\u30B5\u30A4\u30BA\u304C1\u3088\u308A\u5C0F\u3055\u3044\u3067\u3059\u3002"}, + + { ER_INVALID_DRIVER, + "\u7121\u52B9\u306A\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F\u3002"}, + + { ER_NO_STYLESHEETROOT, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30EB\u30FC\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059"}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode\u304C\u5931\u6557\u3057\u307E\u3057\u305F"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "\u30EA\u30BD\u30FC\u30B9[ {0} ]\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\u30D0\u30C3\u30D5\u30A1\u30FB\u30B5\u30A4\u30BA<=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\u62E1\u5F35\u3092\u547C\u3073\u51FA\u3059\u3068\u304D\u306B\u4E0D\u660E\u306A\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F"}, + + { ER_NO_NAMESPACE_DECL, + "\u63A5\u982D\u8F9E{0}\u306B\u306F\u3001\u5BFE\u5FDC\u3059\u308B\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "\u8981\u7D20\u306E\u5185\u5BB9\u306Flang=javaclass {0}\u306B\u3064\u3044\u3066\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306B\u3088\u308A\u7D42\u4E86\u304C\u6307\u793A\u3055\u308C\u307E\u3057\u305F"}, + + { ER_ONE_OR_TWO, + "1\u307E\u305F\u306F2"}, + + { ER_TWO_OR_THREE, + "2\u307E\u305F\u306F3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "{0}\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F(CLASSPATH\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044)\u3002\u73FE\u5728\u306F\u5358\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u521D\u671F\u5316\u3067\u304D\u307E\u305B\u3093"}, + + { ER_RESULT_NULL, + "\u7D50\u679C\u306Fnull\u306B\u3067\u304D\u307E\u305B\u3093"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "\u7D50\u679C\u3092\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + { ER_NO_OUTPUT_SPECIFIED, + "\u51FA\u529B\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "\u30BF\u30A4\u30D7{0}\u306E\u7D50\u679C\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "\u30BF\u30A4\u30D7{0}\u306E\u30BD\u30FC\u30B9\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093"}, + + { ER_NULL_CONTENT_HANDLER, + "Null\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u30FB\u30CF\u30F3\u30C9\u30E9"}, + + { ER_NULL_ERROR_HANDLER, + "Null\u306E\u30A8\u30E9\u30FC\u30FB\u30CF\u30F3\u30C9\u30E9"}, + + { ER_CANNOT_CALL_PARSE, + "ContentHandler\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u3001\u89E3\u6790\u3092\u547C\u3073\u51FA\u3059\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093"}, + + { ER_NO_PARENT_FOR_FILTER, + "\u30D5\u30A3\u30EB\u30BF\u306E\u89AA\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u304C{0}\u306B\u3042\u308A\u307E\u305B\u3093\u3002\u30E1\u30C7\u30A3\u30A2= {1}"}, + + { ER_NO_STYLESHEET_PI, + "xml-stylesheet PI\u304C{0}\u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}, + + { ER_NOT_SUPPORTED, + "\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "\u30D7\u30ED\u30D1\u30C6\u30A3{0}\u306E\u5024\u306FBoolean\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "{0}\u306E\u5916\u90E8\u30B9\u30AF\u30EA\u30D7\u30C8\u306B\u5230\u9054\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "\u30EA\u30BD\u30FC\u30B9[ {0} ]\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\u51FA\u529B\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A8D\u8B58\u3055\u308C\u307E\u305B\u3093: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "ElemLiteralResult\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "{0}\u306E\u5024\u306B\u306F\u89E3\u6790\u53EF\u80FD\u306A\u6570\u5024\u304C\u542B\u307E\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_VALUE_SHOULD_EQUAL, + "{0}\u306E\u5024\u306Fyes\u307E\u305F\u306Fno\u306B\u7B49\u3057\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_FAILED_CALLING_METHOD, + "{0}\u30E1\u30BD\u30C3\u30C9\u306E\u547C\u51FA\u3057\u306B\u5931\u6557\u3057\u307E\u3057\u305F"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "ElemTemplateElement\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F"}, + + { ER_CHARS_NOT_ALLOWED, + "\u6587\u5B57\u306F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u3053\u306E\u30DD\u30A4\u30F3\u30C8\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + { ER_ATTR_NOT_ALLOWED, + "\"{0}\"\u5C5E\u6027\u306F{1}\u8981\u7D20\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + { ER_BAD_VALUE, + "{0}\u306E\u4E0D\u6B63\u306A\u5024{1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "{0}\u5C5E\u6027\u5024\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0}\u5C5E\u6027\u5024\u304C\u8A8D\u8B58\u3055\u308C\u307E\u305B\u3093 "}, + + { ER_NULL_URI_NAMESPACE, + "null\u306EURI\u3092\u6301\u3064\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u63A5\u982D\u8F9E\u3092\u751F\u6210\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F"}, + + { ER_NUMBER_TOO_BIG, + "\u6700\u5927\u306ELong\u6574\u6570\u3088\u308A\u3082\u5927\u304D\u3044\u6570\u5024\u3092\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u304C\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u304C\u30ED\u30FC\u30C9\u3055\u308C\u307E\u3057\u305F\u304C\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u306Forg.xml.sax.Parser\u3092\u5B9F\u88C5\u3067\u304D\u307E\u305B\u3093"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\u30B7\u30B9\u30C6\u30E0\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3org.xml.sax.parser\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "\u30D1\u30FC\u30B5\u30FC\u5F15\u6570\u306Fnull\u3067\u306A\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_FEATURE, + "\u6A5F\u80FD: {0}"}, + + { ER_PROPERTY, + "\u30D7\u30ED\u30D1\u30C6\u30A3: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "Null\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u30FB\u30EA\u30BE\u30EB\u30D0"}, + + { ER_NULL_DTD_HANDLER, + "Null DTD\u30CF\u30F3\u30C9\u30E9"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + { ER_NO_URL_SPECIFIED, + "URL\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "\u30D7\u30FC\u30EB\u30FB\u30B5\u30A4\u30BA\u304C1\u3088\u308A\u5C0F\u3055\u3044\u3067\u3059\u3002"}, + + { ER_INVALID_DRIVER_NAME, + "\u7121\u52B9\u306A\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F\u3002"}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "\u30D7\u30ED\u30B0\u30E9\u30DE\u306E\u30A8\u30E9\u30FC\u3002\u5F0F\u306BElemTemplateElement\u306E\u89AA\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "RedundentExprEliminator\u3067\u306E\u30D7\u30ED\u30B0\u30E9\u30DE\u306E\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0}\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u3053\u306E\u4F4D\u7F6E\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\u7A7A\u767D\u4EE5\u5916\u306E\u30C6\u30AD\u30B9\u30C8\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u3053\u306E\u4F4D\u7F6E\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CCHAR\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F\u3002CHAR\u578B\u306E\u5C5E\u6027\u306F1\u6587\u5B57\u306E\u307F\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CQNAME\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CENUM\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F\u3002\u6709\u52B9\u306A\u5024\u306F{2}\u3067\u3059\u3002"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CNMTOKEN\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CNCNAME\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "\u4E0D\u6B63\u306A\u5024: {1}\u304Cboolean\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "\u4E0D\u6B63\u306A\u5024: {1}\u304C\u6570\u5024\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "\u4E00\u81F4\u30D1\u30BF\u30FC\u30F3\u306B\u304A\u3051\u308B{0}\u306E\u5F15\u6570\u306F\u30EA\u30C6\u30E9\u30EB\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "\u30B0\u30ED\u30FC\u30D0\u30EB\u5909\u6570\u5BA3\u8A00\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002"}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "\u5909\u6570\u5BA3\u8A00\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002"}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template\u306B\u306Fname\u5C5E\u6027\u307E\u305F\u306Fmatch\u5C5E\u6027(\u3042\u308B\u3044\u306F\u4E21\u65B9)\u304C\u5FC5\u8981\u3067\u3059"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "exclude-result-prefixes\u306E\u63A5\u982D\u8F9E\u304C\u7121\u52B9\u3067\u3059: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "{0}\u3068\u3044\u3046\u540D\u524D\u306Eattribute-set\u306F\u5B58\u5728\u3057\u307E\u305B\u3093"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "{0}\u3068\u3044\u3046\u540D\u524D\u306E\u6A5F\u80FD\u306F\u5B58\u5728\u3057\u307E\u305B\u3093"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0}\u8981\u7D20\u306B\u306F\u30B3\u30F3\u30C6\u30F3\u30C4\u3068select\u5C5E\u6027\u306E\u4E21\u65B9\u3092\u542B\u3081\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002"}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "\u30D1\u30E9\u30E1\u30FC\u30BF{0}\u306F\u6709\u52B9\u306AJava\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias\u8981\u7D20\u306Eresult-prefix\u5C5E\u6027\u306B\u5024'#default'\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u8981\u7D20\u306E\u30B9\u30B3\u30FC\u30D7\u5185\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias\u8981\u7D20\u306Eresult-prefix\u5C5E\u6027\u306B\u5024''{0}''\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u8981\u7D20\u306E\u30B9\u30B3\u30FC\u30D7\u5185\u306B\u63A5\u982D\u8F9E''{0}''\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + { ER_SET_FEATURE_NULL_NAME, + "\u6A5F\u80FD\u540D\u306FTransformerFactory.setFeature(String name, boolean value)\u5185\u3067null\u306B\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_GET_FEATURE_NULL_NAME, + "\u6A5F\u80FD\u540D\u306FTransformerFactory.getFeature(String name)\u5185\u3067null\u306B\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_UNSUPPORTED_FEATURE, + "\u6A5F\u80FD''{0}''\u3092\u3053\u306ETransformerFactory\u306B\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u304Ctrue\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u8981\u7D20''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "null\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9URI\u306B\u3064\u3044\u3066\u63A5\u982D\u8F9E\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "null\u306E\u63A5\u982D\u8F9E\u306B\u3064\u3044\u3066\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9URI\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "\u6A5F\u80FD\u540D\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "arity\u3092\u8CA0\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "'}'\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u304C\u5C5E\u6027\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u958B\u3044\u3066\u3044\u307E\u305B\u3093\u3002"}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\u8B66\u544A: count\u5C5E\u6027\u304Cxsl:number\u5185\u306E\u7956\u5148\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u30BF\u30FC\u30B2\u30C3\u30C8= {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\u53E4\u3044\u69CB\u6587: 'expr'\u5C5E\u6027\u306E\u540D\u524D\u304C'select'\u306B\u5909\u66F4\u3055\u308C\u307E\u3057\u305F\u3002"}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan\u306Fformat-number\u95A2\u6570\u5185\u306E\u30ED\u30B1\u30FC\u30EB\u540D\u3092\u307E\u3060\u51E6\u7406\u3067\u304D\u307E\u305B\u3093\u3002"}, + + { WG_LOCALE_NOT_FOUND, + "\u8B66\u544A: xml:lang={0}\u306E\u30ED\u30B1\u30FC\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F"}, + + { WG_CANNOT_MAKE_URL_FROM, + "{0}\u304B\u3089URL\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "\u30EA\u30AF\u30A8\u30B9\u30C8\u3055\u308C\u305F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8{0}\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093"}, + + { WG_CANNOT_FIND_COLLATOR, + ">>>>>> Xalan\u30D0\u30FC\u30B8\u30E7\u30F3 "}, + { "version2", "<<<<<<<"}, + { "yes", "yes"}, + { "line", "\u884C\u756A\u53F7"}, + { "column","\u5217\u756A\u53F7"}, + { "xsldone", "XSLProcessor: \u5B8C\u4E86\u3057\u307E\u3057\u305F"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Xalan-J\u30B3\u30DE\u30F3\u30C9\u884C\u30D7\u30ED\u30BB\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u30AA\u30D7\u30B7\u30E7\u30F3:"}, + { "xslProc_option", "Xalan-J\u30B3\u30DE\u30F3\u30C9\u884C\u30D7\u30ED\u30BB\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u30AA\u30D7\u30B7\u30E7\u30F3:"}, + { "xslProc_invalid_xsltc_option", "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306FXSLTC\u30E2\u30FC\u30C9\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + { "xslProc_invalid_xalan_option", "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306F-XSLTC\u3068\u3068\u3082\u306B\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"}, + { "xslProc_no_input", "\u30A8\u30E9\u30FC: \u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u307E\u305F\u306F\u5165\u529Bxml\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u4F7F\u7528\u65B9\u6CD5\u306E\u6307\u793A\u306B\u3064\u3044\u3066\u306F\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4ED8\u3051\u305A\u306B\u3053\u306E\u30B3\u30DE\u30F3\u30C9\u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + { "xslProc_common_options", "-\u5171\u901A\u30AA\u30D7\u30B7\u30E7\u30F3-"}, + { "xslProc_xalan_options", "-Xalan\u7528\u30AA\u30D7\u30B7\u30E7\u30F3-"}, + { "xslProc_xsltc_options", "-XSLTC\u7528\u30AA\u30D7\u30B7\u30E7\u30F3-"}, + { "xslProc_return_to_continue", "(\u7D9A\u884C\u3059\u308B\u306B\u306F\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (\u5909\u63DB\u306BXSLTC\u3092\u4F7F\u7528)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER \u30D1\u30FC\u30B5\u30FC\u30FB\u30EA\u30A8\u30BE\u30F3\u306E\u5B8C\u5168\u4FEE\u98FE\u30AF\u30E9\u30B9\u540D]"}, + { "optionE", " [-E (\u5B9F\u4F53\u53C2\u7167\u3092\u62E1\u5F35\u3057\u306A\u3044)]"}, + { "optionV", " [-E (\u5B9F\u4F53\u53C2\u7167\u3092\u62E1\u5F35\u3057\u306A\u3044)]"}, + { "optionQC", " [-QC (\u6291\u5236\u30D1\u30BF\u30FC\u30F3\u7AF6\u5408\u306E\u8B66\u544A)]"}, + { "optionQ", " [-Q (\u6291\u5236\u30E2\u30FC\u30C9)]"}, + { "optionLF", " [-LF (\u51FA\u529B\u3067\u306E\u307F\u6539\u884C\u3092\u4F7F\u7528{\u30C7\u30D5\u30A9\u30EB\u30C8\u306FCR/LF})]"}, + { "optionCR", " [-CR (\u51FA\u529B\u3067\u306E\u307F\u6539\u884C\u3092\u4F7F\u7528{\u30C7\u30D5\u30A9\u30EB\u30C8\u306FCR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (\u30A8\u30B9\u30B1\u30FC\u30D7\u3059\u308B\u6587\u5B57{\u30C7\u30D5\u30A9\u30EB\u30C8\u306F<>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (\u30A4\u30F3\u30C7\u30F3\u30C8\u3059\u308B\u7A7A\u767D\u6587\u5B57\u6570\u3092\u5236\u5FA1{\u30C7\u30D5\u30A9\u30EB\u30C8\u306F0})]"}, + { "optionTT", " [-TT (\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u547C\u3073\u51FA\u3055\u308C\u305F\u3068\u304D\u306B\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + { "optionTG", " [-TG (\u5404\u751F\u6210\u30A4\u30D9\u30F3\u30C8\u3092\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + { "optionTS", " [-TS (\u5404\u9078\u629E\u30A4\u30D9\u30F3\u30C8\u3092\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + { "optionTTC", " [-TTC (\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u5B50\u304C\u51E6\u7406\u3055\u308C\u308B\u3068\u304D\u306B\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + { "optionTCLASS", " [-TCLASS (\u30C8\u30EC\u30FC\u30B9\u62E1\u5F35\u7528\u306ETraceListener\u30AF\u30E9\u30B9\u3002)]"}, + { "optionVALIDATE", " [-VALIDATE (\u691C\u8A3C\u3092\u5B9F\u884C\u3059\u308B\u304B\u3069\u3046\u304B\u3092\u8A2D\u5B9A\u3059\u308B\u3002\u691C\u8A3C\u306F\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u30AA\u30D5\u3002)]"}, + { "optionEDUMP", " [-EDUMP {optional filename} (\u30A8\u30E9\u30FC\u6642\u306Bstackdump\u3092\u5B9F\u884C\u3059\u308B\u3002)]"}, + { "optionXML", " [-XML (XML\u30D5\u30A9\u30FC\u30DE\u30C3\u30BF\u3092\u4F7F\u7528\u3057\u3066XML\u30D8\u30C3\u30C0\u30FC\u3092\u8FFD\u52A0\u3059\u308B\u3002)]"}, + { "optionTEXT", " [-TEXT (\u30B7\u30F3\u30D7\u30EB\u30FB\u30C6\u30AD\u30B9\u30C8\u30FB\u30D5\u30A9\u30FC\u30DE\u30C3\u30BF\u3092\u4F7F\u7528\u3059\u308B\u3002)]"}, + { "optionHTML", " [-HTML (HTML\u30D5\u30A9\u30FC\u30DE\u30C3\u30BF\u3092\u4F7F\u7528\u3059\u308B\u3002)]"}, + { "optionPARAM", " [-PARAM name expression (\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u8A2D\u5B9A\u3059\u308B)]"}, + { "noParsermsg1", "XSL\u30D7\u30ED\u30BB\u30B9\u306F\u6210\u529F\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + { "noParsermsg2", "** \u30D1\u30FC\u30B5\u30FC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F **"}, + { "noParsermsg3", "\u30AF\u30E9\u30B9\u30D1\u30B9\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + { "noParsermsg4", "IBM\u306EJava\u7528XML\u30D1\u30FC\u30B5\u30FC\u304C\u306A\u3044\u5834\u5408\u3001\u6B21\u306E\u30B5\u30A4\u30C8\u304B\u3089\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3067\u304D\u307E\u3059"}, + { "noParsermsg5", "IBM\u306EAlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER full class name (URI\u306E\u89E3\u6C7A\u306B\u4F7F\u7528\u3055\u308C\u308BURIResolver)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER full class name (\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u306E\u89E3\u6C7A\u306B\u4F7F\u7528\u3055\u308C\u308BEntityResolver)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER full class name (\u51FA\u529B\u306E\u30B7\u30EA\u30A2\u30E9\u30A4\u30BA\u306B\u4F7F\u7528\u3055\u308C\u308BContentHandler)]"}, + { "optionLINENUMBERS", " [-L \u30BD\u30FC\u30B9\u30FB\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u884C\u756A\u53F7\u3092\u4F7F\u7528]"}, + { "optionSECUREPROCESSING", " [-SECURE (\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u3092true\u306B\u8A2D\u5B9A\u3059\u308B\u3002)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u95A2\u9023\u4ED8\u3051\u3089\u308C\u305F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u3092\u898B\u3064\u3051\u308B\u305F\u3081\u306B\u30E1\u30C7\u30A3\u30A2\u5C5E\u6027\u3092\u4F7F\u7528\u3059\u308B\u3002)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (\u5909\u63DB\u3092\u884C\u3046\u305F\u3081\u306Bs2s=SAX\u307E\u305F\u306Fd2d=DOM\u3092\u660E\u793A\u7684\u306B\u4F7F\u7528\u3059\u308B\u3002)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (\u5909\u63DB\u306B\u304B\u304B\u3063\u305F\u5408\u8A08\u30DF\u30EA\u79D2\u6570\u3092\u51FA\u529B\u3059\u308B\u3002)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (http://xml.apache.org/xalan/features/incremental\u3092true\u306B\u8A2D\u5B9A\u3059\u308B\u3053\u3068\u306B\u3088\u3063\u3066\u5897\u5206DTM\u69CB\u7BC9\u3092\u30EA\u30AF\u30A8\u30B9\u30C8\u3059\u308B\u3002)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (http://xml.apache.org/xalan/features/optimize\u3092false\u306B\u8A2D\u5B9A\u3059\u308B\u3053\u3068\u306B\u3088\u3063\u3066\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u6700\u9069\u5316\u51E6\u7406\u3092\u30EA\u30AF\u30A8\u30B9\u30C8\u3057\u306A\u3044\u3002)]"}, + { "optionRL", " [-RL recursionlimit (\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u518D\u5E30\u306E\u6DF1\u3055\u306B\u3064\u3044\u3066\u6570\u5024\u4E0A\u306E\u5236\u9650\u3092\u30A2\u30B5\u30FC\u30C8\u3059\u308B\u3002)]"}, + { "optionXO", " [-XO [transletName] (\u751F\u6210\u6E08translet\u306B\u540D\u524D\u3092\u5272\u308A\u5F53\u3066\u308B)]"}, + { "optionXD", " [-XD destinationDirectory (translet\u306E\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u6307\u5B9A\u3059\u308B)]"}, + { "optionXJ", " [-XJ jarfile (translet\u30AF\u30E9\u30B9\u3092\u540D\u524D\u306Ejar\u30D5\u30A1\u30A4\u30EB\u306B\u30D1\u30C3\u30B1\u30FC\u30B8\u3059\u308B)]"}, + { "optionXP", " [-XP package (\u3059\u3079\u3066\u306E\u751F\u6210\u6E08translet\u30AF\u30E9\u30B9\u7528\u306B\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u63A5\u982D\u8F9E\u3092\u6307\u5B9A\u3059\u308B)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u30A4\u30F3\u30E9\u30A4\u30F3\u5316\u3092\u6709\u52B9\u306B\u3059\u308B)]" }, + { "optionXX", " [-XX (\u8FFD\u52A0\u306E\u30C7\u30D0\u30C3\u30B0\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u51FA\u529B\u3092\u30AA\u30F3\u306B\u3059\u308B)]"}, + { "optionXT" , " [-XT (\u53EF\u80FD\u306A\u5834\u5408\u306F\u5909\u63DB\u306E\u305F\u3081\u306Btranslet\u3092\u4F7F\u7528\u3059\u308B)]"}, + { "diagTiming"," --------- {1}\u306B\u3088\u308B{0}\u306E\u5909\u63DB\u306B{2}\u30DF\u30EA\u79D2\u304B\u304B\u308A\u307E\u3057\u305F" }, + { "recursionTooDeep","\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u30CD\u30B9\u30C8\u304C\u6DF1\u3059\u304E\u307E\u3059\u3002\u30CD\u30B9\u30C8= {0}\u3001\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8{1} {2}" }, + { "nameIs", "\u540D\u524D:" }, + { "matchPatternIs", "\u4E00\u81F4\u30D1\u30BF\u30FC\u30F3:" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java new file mode 100644 index 000000000..14ef27e08 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_ko extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "\uC624\uB958: \uD45C\uD604\uC2DD\uC5D0\uB294 '{'\uAC00 \uD3EC\uD568\uB420 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0}\uC5D0 \uC798\uBABB\uB41C \uC18D\uC131\uC774 \uC788\uC74C: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "xsl:apply-imports\uC758 sourceNode\uAC00 \uB110\uC785\uB2C8\uB2E4!"}, + + {ER_CANNOT_ADD, + "{1}\uC5D0 {0}\uC744(\uB97C) \uCD94\uAC00\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "handleApplyTemplatesInstruction\uC758 sourceNode\uAC00 \uB110\uC785\uB2C8\uB2E4!"}, + + { ER_NO_NAME_ATTRIB, + "{0}\uC5D0\uB294 name \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_TEMPLATE_NOT_FOUND, + "\uBA85\uBA85\uB41C \uD15C\uD50C\uB9AC\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "xsl:call-template\uC5D0\uC11C \uC774\uB984 AVT\uB97C \uBD84\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_REQUIRES_ATTRIB, + "{0}\uC5D0 \uC18D\uC131\uC774 \uD544\uC694\uD568: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0}\uC5D0\uB294 ''test'' \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "level \uC18D\uC131\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction \uC774\uB984\uC740 'xml'\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction \uC774\uB984\uC740 \uC801\uD569\uD55C NCName\uC774\uC5B4\uC57C \uD568: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0}\uC5D0 \uBAA8\uB4DC\uAC00 \uC788\uC744 \uACBD\uC6B0 match \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0}\uC5D0\uB294 name \uB610\uB294 match \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC811\uB450\uC5B4\uB97C \uBD84\uC11D\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + { ER_NO_OWNERDOC, + "\uD558\uC704 \uB178\uB4DC\uC5D0 \uC18C\uC720\uC790 \uBB38\uC11C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement \uC624\uB958: {0}"}, + + { ER_NULL_CHILD, + "\uB110 \uD558\uC704\uB97C \uCD94\uAC00\uD558\uB824\uACE0 \uC2DC\uB3C4\uD558\uB294 \uC911\uC785\uB2C8\uB2E4!"}, + + { ER_NEED_SELECT_ATTRIB, + "{0}\uC5D0\uB294 select \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when\uC5D0\uB294 'test' \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param\uC5D0\uB294 'name' \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_NO_CONTEXT_OWNERDOC, + "\uCEE8\uD14D\uC2A4\uD2B8\uC5D0 \uC18C\uC720\uC790 \uBB38\uC11C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "XML TransformerFactory \uC5F0\uACB0\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \uD504\uB85C\uC138\uC2A4\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + { ER_NOT_SUCCESSFUL, + "Xalan: \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + { ER_ENCODING_NOT_SUPPORTED, + "\uC778\uCF54\uB529\uC774 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC74C: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "TraceListener\uB97C \uC0DD\uC131\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key\uC5D0\uB294 'name' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key\uC5D0\uB294 'match' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key\uC5D0\uB294 'use' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0}\uC5D0\uB294 ''elements'' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} \uC18D\uC131 ''prefix''\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + { ER_BAD_STYLESHEET_URL, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 URL\uC774 \uC798\uBABB\uB428: {0}"}, + + { ER_FILE_NOT_FOUND, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + { ER_IOEXCEPTION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uD30C\uC77C\uC5D0 IO \uC608\uC678\uC0AC\uD56D \uBC1C\uC0DD: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) {0}\uC5D0 \uB300\uD55C href \uC18D\uC131\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0}\uC5D0 \uC9C1\uC811 \uB610\uB294 \uAC04\uC811\uC801\uC73C\uB85C \uC790\uC2E0\uC774 \uD3EC\uD568\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4!"}, + + { ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude \uC624\uB958, {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0} \uC18D\uC131 ''lang''\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0} \uC694\uC18C\uC758 \uC704\uCE58\uAC00 \uC798\uBABB\uB41C \uAC83 \uAC19\uC2B5\uB2C8\uB2E4. \uCEE8\uD14C\uC774\uB108 \uC694\uC18C ''component''\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Element, DocumentFragment, Document \uB610\uB294 PrintWriter\uC5D0\uB9CC \uCD9C\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + + { ER_PROCESS_ERROR, + "StylesheetRoot.process \uC624\uB958"}, + + { ER_UNIMPLNODE_ERROR, + "UnImplNode \uC624\uB958: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "\uC624\uB958: xpath select \uD45C\uD604\uC2DD(-select)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "XSLProcessor\uB97C \uC9C1\uB82C\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_NO_INPUT_STYLESHEET, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uC785\uB825\uAC12\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4!"}, + + { ER_FAILED_PROCESS_STYLESHEET, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uCC98\uB9AC\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4!"}, + + { ER_COULDNT_PARSE_DOC, + "{0} \uBB38\uC11C\uC758 \uAD6C\uBB38\uC744 \uBD84\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_COULDNT_FIND_FRAGMENT, + "\uBD80\uBD84\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "\uBD80\uBD84 \uC2DD\uBCC4\uC790\uAC00 \uAC00\uB9AC\uD0A8 \uB178\uB4DC\uB294 \uC694\uC18C\uAC00 \uC544\uB2D8: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each\uC5D0\uB294 match \uB610\uB294 name \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates\uC5D0\uB294 match \uB610\uB294 name \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\uBB38\uC11C \uBD80\uBD84\uC758 \uBCF5\uC81C\uBCF8\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_CANT_CREATE_ITEM, + "\uACB0\uACFC \uD2B8\uB9AC\uC5D0 \uD56D\uBAA9\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "\uC18C\uC2A4 XML\uC758 xml:space\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "{0}\uC5D0 \uB300\uD55C xsl:key \uC120\uC5B8\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_CANT_CREATE_URL, + "\uC624\uB958: {0}\uC5D0 \uB300\uD55C URL\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions\uB294 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + { ER_PROCESSOR_ERROR, + "XSLT TransformerFactory \uC624\uB958"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) \uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC5D0\uC11C\uB294 {0}\uC774(\uAC00) \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns\uB294 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC2E0 xsl:output\uC744 \uC0AC\uC6A9\uD558\uC2ED\uC2DC\uC624."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space\uB294 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC2E0 xsl:strip-space \uB610\uB294 xsl:preserve-space\uB97C \uC0AC\uC6A9\uD558\uC2ED\uC2DC\uC624."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result\uB294 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC2E0 xsl:output\uC744 \uC0AC\uC6A9\uD558\uC2ED\uC2DC\uC624."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0}\uC5D0 \uC798\uBABB\uB41C \uC18D\uC131\uC774 \uC788\uC74C: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "\uC54C \uC218 \uC5C6\uB294 XSL \uC694\uC18C: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort\uB294 xsl:apply-templates \uB610\uB294 xsl:for-each\uC640 \uD568\uAED8\uB9CC \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when\uC758 \uC704\uCE58\uAC00 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when\uC774 xsl:choose\uC5D0 \uC758\uD574 \uC0C1\uC704\uB85C \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4!"}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise\uC758 \uC704\uCE58\uAC00 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise\uAC00 xsl:choose\uC5D0 \uC758\uD574 \uC0C1\uC704\uB85C \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4!"}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) \uD15C\uD50C\uB9AC\uD2B8\uC5D0\uC11C\uB294 {0}\uC774(\uAC00) \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0} \uD655\uC7A5 \uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC811\uB450\uC5B4 {1}\uC744(\uB97C) \uC54C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC758 \uCCAB\uBC88\uC9F8 \uC694\uC18C\uB85C\uB9CC \uC784\uD3EC\uD2B8\uB97C \uC218\uD589\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4!"}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0}\uC774(\uAC00) \uC9C1\uC811 \uB610\uB294 \uAC04\uC811\uC801\uC73C\uB85C \uC790\uC2E0\uC744 \uC784\uD3EC\uD2B8\uD558\uACE0 \uC788\uC2B5\uB2C8\uB2E4!"}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4!"}, + + { ER_SAX_EXCEPTION, + "SAX \uC608\uC678\uC0AC\uD56D"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "\uD568\uC218\uAC00 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + { ER_XSLT_ERROR, + "XSLT \uC624\uB958"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "\uD615\uC2DD \uD328\uD134 \uBB38\uC790\uC5F4\uC5D0\uC11C\uB294 \uD1B5\uD654 \uAE30\uD638\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Document \uD568\uC218\uB294 \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 DOM\uC5D0\uC11C \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\uBE44\uC811\uB450\uC5B4 \uBD84\uC11D\uAE30\uC758 \uC811\uB450\uC5B4\uB97C \uBD84\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "\uC7AC\uC9C0\uC815 \uD655\uC7A5: \uD30C\uC77C \uC774\uB984\uC744 \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. file \uB610\uB294 select \uC18D\uC131\uC740 \uC801\uD569\uD55C \uBB38\uC790\uC5F4\uC744 \uBC18\uD658\uD574\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\uC7AC\uC9C0\uC815 \uD655\uC7A5\uC5D0 FormatterListener\uB97C \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes\uC758 \uC811\uB450\uC5B4\uAC00 \uBD80\uC801\uD569\uD568: {0}"}, + + { ER_MISSING_NS_URI, + "\uC9C0\uC815\uB41C \uC811\uB450\uC5B4\uC5D0 \uB300\uD55C \uB124\uC784\uC2A4\uD398\uC774\uC2A4 URI\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + { ER_MISSING_ARG_FOR_OPTION, + "\uC635\uC158\uC5D0 \uB300\uD55C \uC778\uC218\uAC00 \uB204\uB77D\uB428: {0}"}, + + { ER_INVALID_OPTION, + "\uBD80\uC801\uD569\uD55C \uC635\uC158: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "\uC798\uBABB\uB41C \uD615\uC2DD \uBB38\uC790\uC5F4: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet\uC5D0\uB294 'version' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "{0} \uC18D\uC131\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose\uC5D0\uB294 xsl:when\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:for-each\uC5D0\uC11C\uB294 xsl:apply-imports\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "\uCD9C\uB825 DOM \uB178\uB4DC\uC5D0 DTMLiaison\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uB300\uC2E0 com.sun.org.apache.xpath.internal.DOM2Helper\uB97C \uC804\uB2EC\uD558\uC2ED\uC2DC\uC624!"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "\uC785\uB825 DOM \uB178\uB4DC\uC5D0 DTMLiaison\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uB300\uC2E0 com.sun.org.apache.xpath.internal.DOM2Helper\uB97C \uC804\uB2EC\uD558\uC2ED\uC2DC\uC624!"}, + + { ER_CALL_TO_EXT_FAILED, + "\uD655\uC7A5 \uC694\uC18C\uC5D0 \uB300\uD55C \uD638\uCD9C \uC2E4\uD328: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "\uC811\uB450\uC5B4\uB294 \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uB85C \uBD84\uC11D\uB418\uC5B4\uC57C \uD568: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "\uBD80\uC801\uD569\uD55C UTF-16 \uB300\uB9AC \uC694\uC18C\uAC00 \uAC10\uC9C0\uB428: {0}"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0}\uC774(\uAC00) \uC790\uC2E0\uC744 \uC0AC\uC6A9\uD588\uC2B5\uB2C8\uB2E4. \uC774 \uACBD\uC6B0 \uBB34\uD55C \uB8E8\uD504\uAC00 \uBC1C\uC0DD\uD569\uB2C8\uB2E4."}, + + { ER_CANNOT_MIX_XERCESDOM, + "\uBE44Xerces-DOM \uC785\uB825\uACFC Xerces-DOM \uCD9C\uB825\uC744 \uD568\uAED8 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "ElemTemplateElement.readObject\uC5D0 \uC624\uB958 \uBC1C\uC0DD: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "\uBA85\uBA85\uB41C \uD15C\uD50C\uB9AC\uD2B8\uB97C \uB450 \uAC1C \uC774\uC0C1 \uCC3E\uC74C: {0}"}, + + { ER_INVALID_KEY_CALL, + "\uBD80\uC801\uD569\uD55C \uD568\uC218 \uD638\uCD9C: recursive key() \uD638\uCD9C\uC740 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + { ER_REFERENCING_ITSELF, + "{0} \uBCC0\uC218\uAC00 \uC9C1\uC811 \uB610\uB294 \uAC04\uC811\uC801\uC73C\uB85C \uC790\uC2E0\uC744 \uCC38\uC870\uD558\uACE0 \uC788\uC2B5\uB2C8\uB2E4!"}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "newTemplates\uC758 DOMSource\uC5D0 \uB300\uD55C \uC785\uB825 \uB178\uB4DC\uB294 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "{0} \uC635\uC158\uC5D0 \uB300\uD55C \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "\uD544\uC218 \uC694\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream\uC740 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_URI_CANNOT_BE_NULL, + "URI\uB294 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_FILE_CANNOT_BE_NULL, + "\uD30C\uC77C\uC740 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource\uB294 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_CANNOT_INIT_BSFMGR, + "BSF \uAD00\uB9AC\uC790\uB97C \uCD08\uAE30\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_CANNOT_CMPL_EXTENSN, + "\uD655\uC7A5\uC744 \uCEF4\uD30C\uC77C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_CANNOT_CREATE_EXTENSN, + "{0} \uD655\uC7A5\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uB294 \uC6D0\uC778: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "{0} \uBA54\uC18C\uB4DC\uC5D0 \uB300\uD55C \uC778\uC2A4\uD134\uC2A4 \uBA54\uC18C\uB4DC\uC5D0\uB294 \uAC1D\uCCB4 \uC778\uC2A4\uD134\uC2A4\uAC00 \uCCAB\uBC88\uC9F8 \uC778\uC218\uB85C \uD544\uC694\uD569\uB2C8\uB2E4."}, + + { ER_INVALID_ELEMENT_NAME, + "\uBD80\uC801\uD569\uD55C \uC694\uC18C \uC774\uB984\uC774 \uC9C0\uC815\uB428: {0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "\uC694\uC18C \uC774\uB984 \uBA54\uC18C\uB4DC\uB294 \uC815\uC801 {0}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "\uD655\uC7A5 \uD568\uC218 {0}: {1}\uC744(\uB97C) \uC54C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "{0}\uC5D0 \uB300\uD55C \uC0DD\uC131\uC790\uC640 \uAC00\uC7A5 \uC798 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uB450 \uAC1C \uC774\uC0C1 \uC788\uC2B5\uB2C8\uB2E4."}, + + { ER_MORE_MATCH_METHOD, + "{0} \uBA54\uC18C\uB4DC\uC640 \uAC00\uC7A5 \uC798 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uB450 \uAC1C \uC774\uC0C1 \uC788\uC2B5\uB2C8\uB2E4."}, + + { ER_MORE_MATCH_ELEMENT, + "\uC694\uC18C \uBA54\uC18C\uB4DC {0}\uACFC(\uC640) \uAC00\uC7A5 \uC798 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uB450 \uAC1C \uC774\uC0C1 \uC788\uC2B5\uB2C8\uB2E4."}, + + { ER_INVALID_CONTEXT_PASSED, + "{0} \uD3C9\uAC00\uB97C \uC704\uD574 \uBD80\uC801\uD569\uD55C \uCEE8\uD14D\uC2A4\uD2B8\uAC00 \uC804\uB2EC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + { ER_POOL_EXISTS, + "\uD480\uC774 \uC874\uC7AC\uD569\uB2C8\uB2E4."}, + + { ER_NO_DRIVER_NAME, + "\uC9C0\uC815\uB41C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NO_URL, + "\uC9C0\uC815\uB41C URL\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "\uD480 \uD06C\uAE30\uAC00 1\uBCF4\uB2E4 \uC791\uC2B5\uB2C8\uB2E4!"}, + + { ER_INVALID_DRIVER, + "\uBD80\uC801\uD569\uD55C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + { ER_NO_STYLESHEETROOT, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uB8E8\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space\uC5D0 \uB300\uD55C \uAC12\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "[{0}] \uB9AC\uC18C\uC2A4\uAC00 \uB2E4\uC74C\uC744 \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC74C: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\uBC84\uD37C \uD06C\uAE30 <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\uD655\uC7A5\uC744 \uD638\uCD9C\uD558\uB294 \uC911 \uC54C \uC218 \uC5C6\uB294 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."}, + + { ER_NO_NAMESPACE_DECL, + "{0} \uC811\uB450\uC5B4\uC5D0 \uD574\uB2F9\uD558\uB294 \uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC120\uC5B8\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "lang=javaclass {0}\uC5D0 \uB300\uD574\uC11C\uB294 \uC694\uC18C \uCF58\uD150\uCE20\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uAC00 \uC885\uB8CC\uB97C \uC9C0\uC815\uD588\uC2B5\uB2C8\uB2E4."}, + + { ER_ONE_OR_TWO, + "1 \uB610\uB294 2"}, + + { ER_TWO_OR_THREE, + "2 \uB610\uB294 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "{0}\uC744(\uB97C) \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. CLASSPATH\uB97C \uD655\uC778\uD558\uC2ED\uC2DC\uC624. \uD604\uC7AC \uAE30\uBCF8\uAC12\uB9CC \uC0AC\uC6A9\uD558\uB294 \uC911\uC785\uB2C8\uB2E4."}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\uAE30\uBCF8 \uD15C\uD50C\uB9AC\uD2B8\uB97C \uCD08\uAE30\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_RESULT_NULL, + "\uACB0\uACFC\uB294 \uB110\uC774 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_RESULT_COULD_NOT_BE_SET, + "\uACB0\uACFC\uB97C \uC124\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NO_OUTPUT_SPECIFIED, + "\uC9C0\uC815\uB41C \uCD9C\uB825\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "{0} \uC720\uD615\uC758 \uACB0\uACFC\uB85C \uBCC0\uD658\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "{0} \uC720\uD615\uC758 \uC18C\uC2A4\uB97C \uBCC0\uD658\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NULL_CONTENT_HANDLER, + "\uB110 \uCF58\uD150\uCE20 \uCC98\uB9AC\uAE30"}, + + { ER_NULL_ERROR_HANDLER, + "\uB110 \uC624\uB958 \uCC98\uB9AC\uAE30"}, + + { ER_CANNOT_CALL_PARSE, + "ContentHandler\uAC00 \uC124\uC815\uB418\uC9C0 \uC54A\uC740 \uACBD\uC6B0 parse\uB97C \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NO_PARENT_FOR_FILTER, + "\uD544\uD130\uC5D0 \uB300\uD55C \uC0C1\uC704\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "{0}\uC5D0\uC11C \uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uB9E4\uCCB4 = {1}"}, + + { ER_NO_STYLESHEET_PI, + "{0}\uC5D0\uC11C xml-stylesheet PI\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NOT_SUPPORTED, + "\uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC74C: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "{0} \uC18D\uC131\uC5D0 \uB300\uD55C \uAC12\uC740 \uBD80\uC6B8 \uC778\uC2A4\uD134\uC2A4\uC5EC\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "{0}\uC5D0 \uC788\uB294 \uC678\uBD80 \uC2A4\uD06C\uB9BD\uD2B8\uB85C \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_RESOURCE_COULD_NOT_FIND, + "[{0}] \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\uCD9C\uB825 \uC18D\uC131\uC744 \uC778\uC2DD\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "ElemLiteralResult \uC778\uC2A4\uD134\uC2A4 \uC0DD\uC131\uC744 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "{0}\uC5D0 \uB300\uD55C \uAC12\uC5D0\uB294 \uAD6C\uBB38\uC744 \uBD84\uC11D\uD560 \uC218 \uC788\uB294 \uC22B\uC790\uAC00 \uD3EC\uD568\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_VALUE_SHOULD_EQUAL, + "{0}\uC5D0 \uB300\uD55C \uAC12\uC740 yes \uB610\uB294 no\uC5EC\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_FAILED_CALLING_METHOD, + "{0} \uBA54\uC18C\uB4DC \uD638\uCD9C\uC744 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + { ER_FAILED_CREATING_ELEMTMPL, + "ElemTemplateElement \uC778\uC2A4\uD134\uC2A4 \uC0DD\uC131\uC744 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + { ER_CHARS_NOT_ALLOWED, + "\uBB38\uC11C\uC758 \uC774 \uC9C0\uC810\uC5D0\uC11C\uB294 \uBB38\uC790\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + { ER_ATTR_NOT_ALLOWED, + "{1} \uC694\uC18C\uC5D0\uC11C\uB294 \"{0}\" \uC18D\uC131\uC774 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + { ER_BAD_VALUE, + "{0}: \uC798\uBABB\uB41C \uAC12 {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "{0} \uC18D\uC131\uAC12\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} \uC18D\uC131\uAC12\uC744 \uC778\uC2DD\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. "}, + + { ER_NULL_URI_NAMESPACE, + "\uB110 URI\uB97C \uC0AC\uC6A9\uD558\uC5EC \uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC811\uB450\uC5B4\uB97C \uC0DD\uC131\uD558\uB824\uACE0 \uC2DC\uB3C4\uD558\uB294 \uC911"}, + + { ER_NUMBER_TOO_BIG, + "\uAC00\uC7A5 \uD070 Long \uC815\uC218\uBCF4\uB2E4 \uD070 \uC22B\uC790\uC758 \uD615\uC2DD\uC744 \uC9C0\uC815\uD558\uB824\uACE0 \uC2DC\uB3C4\uD558\uB294 \uC911"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC744(\uB97C) \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC774(\uAC00) \uBC1C\uACAC\uB418\uC5C8\uC9C0\uB9CC \uD574\uB2F9 \uD074\uB798\uC2A4\uB97C \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC774(\uAC00) \uB85C\uB4DC\uB418\uC5C8\uC9C0\uB9CC \uD574\uB2F9 \uD074\uB798\uC2A4\uB97C \uC778\uC2A4\uD134\uC2A4\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC774(\uAC00) org.xml.sax.Parser\uB97C \uAD6C\uD604\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\uC2DC\uC2A4\uD15C \uC18D\uC131 org.xml.sax.parser\uAC00 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "\uAD6C\uBB38 \uBD84\uC11D\uAE30 \uC778\uC218\uB294 \uB110\uC774 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_FEATURE, + "\uAE30\uB2A5: {0}"}, + + { ER_PROPERTY, + "\uC18D\uC131: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "\uB110 \uC5D4\uD2F0\uD2F0 \uBD84\uC11D\uAE30"}, + + { ER_NULL_DTD_HANDLER, + "\uB110 DTD \uCC98\uB9AC\uAE30"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "\uC9C0\uC815\uB41C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_NO_URL_SPECIFIED, + "\uC9C0\uC815\uB41C URL\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "\uD480 \uD06C\uAE30\uAC00 1 \uBBF8\uB9CC\uC785\uB2C8\uB2E4!"}, + + { ER_INVALID_DRIVER_NAME, + "\uBD80\uC801\uD569\uD55C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "\uD504\uB85C\uADF8\uB798\uBA38 \uC624\uB958\uC785\uB2C8\uB2E4! \uD45C\uD604\uC2DD\uC5D0 ElemTemplateElement \uC0C1\uC704\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "RedundentExprEliminator\uC5D0 \uD504\uB85C\uADF8\uB798\uBA38 \uAC80\uC99D\uC774 \uC788\uC74C: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC758 \uC774 \uC704\uCE58\uC5D0\uB294 {0}\uC774(\uAC00) \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC758 \uC774 \uC704\uCE58\uC5D0\uB294 \uACF5\uBC31\uC774 \uC544\uB2CC \uD14D\uC2A4\uD2B8\uB294 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) CHAR \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0}. CHAR \uC720\uD615\uC758 \uC18D\uC131\uC740 1\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) QNAME \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) ENUM \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0}. \uC801\uD569\uD55C \uAC12: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) NMTOKEN \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) NCNAME \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) boolean \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) number \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "\uC77C\uCE58 \uD328\uD134\uC758 {0}\uC5D0 \uB300\uD55C \uC778\uC218\uB294 \uB9AC\uD130\uB7F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "\uC804\uC5ED \uBCC0\uC218 \uC120\uC5B8\uC774 \uC911\uBCF5\uB429\uB2C8\uB2E4."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "\uBCC0\uC218 \uC120\uC5B8\uC774 \uC911\uBCF5\uB429\uB2C8\uB2E4."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template\uC5D0\uB294 name \uB610\uB294 match \uC18D\uC131 \uC911 \uD558\uB098\uAC00 \uC788\uAC70\uB098 \uBAA8\uB450 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "exclude-result-prefixes\uC758 \uC811\uB450\uC5B4\uAC00 \uBD80\uC801\uD569\uD568: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "\uC774\uB984\uC774 {0}\uC778 attribute-set\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "\uC774\uB984\uC774 {0}\uC778 \uD568\uC218\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0} \uC694\uC18C\uC5D0\uB294 content \uC18D\uC131\uACFC select \uC18D\uC131\uC774 \uD568\uAED8 \uD3EC\uD568\uB418\uC9C0 \uC54A\uC544\uC57C \uD569\uB2C8\uB2E4."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "{0} \uB9E4\uAC1C\uBCC0\uC218\uC758 \uAC12\uC740 \uC801\uD569\uD55C Java \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4."}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias \uC694\uC18C\uC758 result-prefix \uC18D\uC131\uC5D0 \uB300\uD55C \uAC12\uC740 '#default'\uC774\uC9C0\uB9CC \uC694\uC18C\uC5D0 \uB300\uD55C \uBC94\uC704\uC5D0\uC11C \uAE30\uBCF8 \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uAC00 \uC120\uC5B8\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias \uC694\uC18C\uC758 result-prefix \uC18D\uC131\uC5D0 \uB300\uD55C \uAC12\uC740 ''{0}''\uC774\uC9C0\uB9CC \uC694\uC18C\uC5D0 \uB300\uD55C \uBC94\uC704\uC5D0\uC11C ''{0}'' \uC811\uB450\uC5B4\uC758 \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uAC00 \uC120\uC5B8\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + { ER_SET_FEATURE_NULL_NAME, + "\uAE30\uB2A5 \uC774\uB984\uC740 TransformerFactory.setFeature(\uBB38\uC790\uC5F4 \uC774\uB984, \uBD80\uC6B8 \uAC12)\uC5D0\uC11C \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_GET_FEATURE_NULL_NAME, + "\uAE30\uB2A5 \uC774\uB984\uC740 TransformerFactory.getFeature(\uBB38\uC790\uC5F4 \uC774\uB984)\uC5D0\uC11C \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_UNSUPPORTED_FEATURE, + "\uC774 TransformerFactory\uC5D0\uC11C ''{0}'' \uAE30\uB2A5\uC744 \uC124\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\uBCF4\uC548 \uCC98\uB9AC \uAE30\uB2A5\uC774 true\uB85C \uC124\uC815\uB41C \uACBD\uC6B0 \uD655\uC7A5 \uC694\uC18C ''{0}''\uC744(\uB97C) \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "\uB110 \uB124\uC784\uC2A4\uD398\uC774\uC2A4 URI\uC5D0 \uB300\uD55C \uC811\uB450\uC5B4\uB97C \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "\uB110 \uC811\uB450\uC5B4\uC5D0 \uB300\uD55C \uB124\uC784\uC2A4\uD398\uC774\uC2A4 URI\uB97C \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "\uD568\uC218 \uC774\uB984\uC740 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "\uC778\uC790 \uC218\uB294 \uC74C\uC218\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "'}'\uB97C \uCC3E\uC558\uC9C0\uB9CC \uC5F4\uB824 \uC788\uB294 \uC18D\uC131 \uD15C\uD50C\uB9AC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\uACBD\uACE0: count \uC18D\uC131\uC774 xsl:number\uC758 \uC870\uC0C1\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC0C1 = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\uC774\uC804 \uAD6C\uBB38: 'expr' \uC18D\uC131\uC758 \uC774\uB984\uC774 'select'\uB85C \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan\uC774 format-number \uD568\uC218\uC5D0\uC11C \uB85C\uCF00\uC77C \uC774\uB984\uC744 \uC544\uC9C1 \uCC98\uB9AC\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + { WG_LOCALE_NOT_FOUND, + "\uACBD\uACE0: xml:lang={0}\uC5D0 \uB300\uD55C \uB85C\uCF00\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { WG_CANNOT_MAKE_URL_FROM, + "{0}\uC5D0\uC11C URL\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "\uC694\uCCAD\uB41C \uBB38\uC11C\uB97C \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + ">>>>>> Xalan \uBC84\uC804 "}, + { "version2", "<<<<<<<"}, + { "yes", "\uC608"}, + { "line", "\uD589 \uBC88\uD638"}, + { "column","\uC5F4 \uBC88\uD638"}, + { "xsldone", "XSLProcessor: \uC644\uB8CC"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Xalan-J \uBA85\uB839\uD589 Process \uD074\uB798\uC2A4 \uC635\uC158:"}, + { "xslProc_option", "Xalan-J \uBA85\uB839\uD589 Process \uD074\uB798\uC2A4 \uC635\uC158:"}, + { "xslProc_invalid_xsltc_option", "XSLTC \uBAA8\uB4DC\uC5D0\uC11C\uB294 {0} \uC635\uC158\uC774 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + { "xslProc_invalid_xalan_option", "{0} \uC635\uC158\uC740 -XSLTC\uC5D0\uB9CC \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + { "xslProc_no_input", "\uC624\uB958: \uC9C0\uC815\uB41C \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uB610\uB294 \uC785\uB825 xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \uC0AC\uC6A9\uBC95 \uC9C0\uCE68\uC5D0 \uB300\uD55C \uC635\uC158 \uC5C6\uC774 \uC774 \uBA85\uB839\uC744 \uC2E4\uD589\uD558\uC2ED\uC2DC\uC624."}, + { "xslProc_common_options", "-\uC77C\uBC18 \uC635\uC158-"}, + { "xslProc_xalan_options", "-Xalan \uC635\uC158-"}, + { "xslProc_xsltc_options", "-XSLTC \uC635\uC158-"}, + { "xslProc_return_to_continue", "(\uACC4\uC18D\uD558\uB824\uBA74 \uD0A4\uB97C \uB204\uB974\uC2ED\uC2DC\uC624.)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC(\uBCC0\uD658\uC5D0 XSLTC \uC0AC\uC6A9)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER \uAD6C\uBB38 \uBD84\uC11D\uAE30 \uC5F0\uACB0\uC758 \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984]"}, + { "optionE", " [-E(\uC5D4\uD2F0\uD2F0 \uCC38\uC870 \uD655\uC7A5 \uC548\uD568)]"}, + { "optionV", " [-E(\uC5D4\uD2F0\uD2F0 \uCC38\uC870 \uD655\uC7A5 \uC548\uD568)]"}, + { "optionQC", " [-QC(\uC790\uB3D9 \uD328\uD134 \uCDA9\uB3CC \uACBD\uACE0)]"}, + { "optionQ", " [-Q(\uC790\uB3D9 \uBAA8\uB4DC)]"}, + { "optionLF", " [-LF(\uCD9C\uB825\uC5D0\uB9CC \uC904 \uBC14\uAFC8 \uC0AC\uC6A9 {\uAE30\uBCF8\uAC12: CR/LF})]"}, + { "optionCR", " [-CR(\uCD9C\uB825\uC5D0\uB9CC \uCE90\uB9AC\uC9C0 \uB9AC\uD134 \uC0AC\uC6A9 {\uAE30\uBCF8\uAC12: CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE(\uC774\uC2A4\uCF00\uC774\uD504 \uBB38\uC790 {\uAE30\uBCF8\uAC12: <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT(\uB4E4\uC5EC \uC4F8 \uACF5\uBC31 \uC218 \uC81C\uC5B4 {\uAE30\uBCF8\uAC12: 0})]"}, + { "optionTT", " [-TT(\uD15C\uD50C\uB9AC\uD2B8 \uD638\uCD9C \uC2DC \uCD94\uC801)]"}, + { "optionTG", " [-TG(\uAC01 \uC0DD\uC131 \uC774\uBCA4\uD2B8 \uCD94\uC801)]"}, + { "optionTS", " [-TS(\uAC01 \uC120\uD0DD \uC774\uBCA4\uD2B8 \uCD94\uC801)]"}, + { "optionTTC", " [-TTC(\uD15C\uD50C\uB9AC\uD2B8 \uD558\uC704 \uD56D\uBAA9 \uCC98\uB9AC \uC2DC \uCD94\uC801)]"}, + { "optionTCLASS", " [-TCLASS(\uCD94\uC801 \uD655\uC7A5\uC5D0 \uB300\uD55C TraceListener \uD074\uB798\uC2A4)]"}, + { "optionVALIDATE", " [-VALIDATE(\uAC80\uC99D \uC5EC\uBD80 \uC124\uC815. \uAE30\uBCF8\uC801\uC73C\uB85C \uAC80\uC99D\uC740 \uD574\uC81C\uB418\uC5B4 \uC788\uC74C)]"}, + { "optionEDUMP", " [-EDUMP {\uC120\uD0DD\uC801 \uD30C\uC77C \uC774\uB984}(\uC624\uB958 \uBC1C\uC0DD \uC2DC \uC2A4\uD0DD \uB364\uD504)]"}, + { "optionXML", " [-XML(XML \uD3EC\uB9F7\uD130 \uC0AC\uC6A9 \uBC0F XML \uD5E4\uB354 \uCD94\uAC00)]"}, + { "optionTEXT", " [-TEXT(\uAC04\uB2E8\uD55C \uD14D\uC2A4\uD2B8 \uD3EC\uB9F7\uD130 \uC0AC\uC6A9)]"}, + { "optionHTML", " [-HTML(HTML \uD3EC\uB9F7\uD130 \uC0AC\uC6A9)]"}, + { "optionPARAM", " [-PARAM \uC774\uB984 \uD45C\uD604\uC2DD(\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uB9E4\uAC1C\uBCC0\uC218 \uC124\uC815)]"}, + { "noParsermsg1", "XSL \uD504\uB85C\uC138\uC2A4\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + { "noParsermsg2", "** \uAD6C\uBB38 \uBD84\uC11D\uAE30\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C **"}, + { "noParsermsg3", "\uD074\uB798\uC2A4 \uACBD\uB85C\uB97C \uD655\uC778\uD558\uC2ED\uC2DC\uC624."}, + { "noParsermsg4", "IBM\uC758 Java\uC6A9 XML \uAD6C\uBB38 \uBD84\uC11D\uAE30\uAC00 \uC5C6\uC744 \uACBD\uC6B0 \uB2E4\uC74C \uC704\uCE58\uC5D0\uC11C \uB2E4\uC6B4\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + { "noParsermsg5", "IBM AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(URI \uBD84\uC11D\uC5D0 \uC0AC\uC6A9\uD560 URIResolver)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(\uC5D4\uD2F0\uD2F0 \uBD84\uC11D\uC5D0 \uC0AC\uC6A9\uD560 EntityResolver)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(\uCD9C\uB825 \uC9C1\uB82C\uD654\uC5D0 \uC0AC\uC6A9\uD560 ContentHandler)]"}, + { "optionLINENUMBERS", " [-L(\uC18C\uC2A4 \uBB38\uC11C\uC5D0 \uD589 \uBC88\uD638 \uC0AC\uC6A9)]"}, + { "optionSECUREPROCESSING", " [-SECURE(\uBCF4\uC548 \uCC98\uB9AC \uAE30\uB2A5\uC744 true\uB85C \uC124\uC815)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType(media \uC18D\uC131\uC744 \uC0AC\uC6A9\uD558\uC5EC \uBB38\uC11C\uC640 \uC5F0\uAD00\uB41C \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uCC3E\uAE30)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName(\uBCC0\uD658\uC5D0 \uBA85\uC2DC\uC801\uC73C\uB85C s2s=SAX \uB610\uB294 d2d=DOM \uC0AC\uC6A9)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG(\uBCC0\uD658\uC5D0 \uAC78\uB9B0 \uCD1D \uC2DC\uAC04(\uBC00\uB9AC\uCD08) \uC778\uC1C4)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL(http://xml.apache.org/xalan/features/incremental\uC744 true\uB85C \uC124\uC815\uD558\uC5EC \uC99D\uBD84\uC801 DTM \uC0DD\uC131 \uC694\uCCAD)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE(http://xml.apache.org/xalan/features/optimize\uB97C false\uB85C \uC124\uC815\uD558\uC5EC \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uCD5C\uC801\uD654 \uCC98\uB9AC \uC548\uD568 \uC694\uCCAD)]"}, + { "optionRL", " [-RL recursionlimit(\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uC21C\uD658 \uAE4A\uC774\uC5D0 \uB300\uD55C \uC22B\uC790 \uC81C\uD55C \uAC80\uC99D)]"}, + { "optionXO", " [-XO [transletName](\uC0DD\uC131\uB41C translet\uC5D0 \uC774\uB984 \uC9C0\uC815)]"}, + { "optionXD", " [-XD destinationDirectory(translet\uC5D0 \uB300\uD55C \uB300\uC0C1 \uB514\uB809\uD1A0\uB9AC \uC9C0\uC815)]"}, + { "optionXJ", " [-XJ jarfile(translet \uD074\uB798\uC2A4\uB97C \uC774\uB984\uC758 jar \uD30C\uC77C\uB85C \uD328\uD0A4\uC9C0\uD654)]"}, + { "optionXP", " [-XP package(\uC0DD\uC131\uB41C \uBAA8\uB4E0 translet \uD074\uB798\uC2A4\uC5D0 \uB300\uD55C \uD328\uD0A4\uC9C0 \uC774\uB984 \uC811\uB450\uC5B4 \uC9C0\uC815)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN(\uD15C\uD50C\uB9AC\uD2B8 \uC778\uB77C\uC778\uC744 \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815)]" }, + { "optionXX", " [-XX(\uCD94\uAC00 \uB514\uBC84\uAE45 \uBA54\uC2DC\uC9C0 \uCD9C\uB825 \uC124\uC815)]"}, + { "optionXT" , " [-XT(\uAC00\uB2A5\uD55C \uACBD\uC6B0 \uBCC0\uD658\uC5D0 translet \uC0AC\uC6A9)]"}, + { "diagTiming"," --------- {1}\uC744(\uB97C) \uD1B5\uD55C {0} \uBCC0\uD658\uC5D0 {2}\uBC00\uB9AC\uCD08\uAC00 \uAC78\uB838\uC2B5\uB2C8\uB2E4." }, + { "recursionTooDeep","\uD15C\uD50C\uB9AC\uD2B8\uAC00 \uB108\uBB34 \uAE4A\uAC8C \uC911\uCCA9\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uC911\uCCA9 = {0}, \uD15C\uD50C\uB9AC\uD2B8: {1} {2}" }, + { "nameIs", "\uC774\uB984:" }, + { "matchPatternIs", "\uC77C\uCE58 \uD328\uD134:" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java new file mode 100644 index 000000000..bc9c35109 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_pt_BR extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "Erro: N\u00E3o \u00E9 poss\u00EDvel utilizar ''{'' na express\u00E3o"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} tem um atributo inv\u00E1lido: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode \u00E9 nulo em xsl:apply-imports!"}, + + {ER_CANNOT_ADD, + "N\u00E3o \u00E9 poss\u00EDvel adicionar {0} a {1}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u00E9 nulo em handleApplyTemplatesInstruction!"}, + + { ER_NO_NAME_ATTRIB, + "{0} deve ter um atributo de nome."}, + + {ER_TEMPLATE_NOT_FOUND, + "N\u00E3o foi poss\u00EDvel localizar o modelo com o nome: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "N\u00E3o foi poss\u00EDvel resolver o nome AVT em xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} requer o atributo: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} deve ter um atributo ''test''."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valor inv\u00E1lido no atributo de n\u00EDvel: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "o nome da instru\u00E7\u00E3o de processamento n\u00E3o pode ser 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "o nome da instru\u00E7\u00E3o de processamento deve ser um NCName v\u00E1lido: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} deve ter um atributo de correspond\u00EAncia se tiver um modo."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} requer um atributo de nome ou de correspond\u00EAncia."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "N\u00E3o \u00E9 poss\u00EDvel resolver o prefixo do namespace: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space tem um valor inv\u00E1lido: {0}"}, + + { ER_NO_OWNERDOC, + "O n\u00F3 filho n\u00E3o tem um documento de propriet\u00E1rio!"}, + + { ER_ELEMTEMPLATEELEM_ERR, + "Erro de ElemTemplateElement: {0}"}, + + { ER_NULL_CHILD, + "Tentativa de adicionar um filho nulo!"}, + + { ER_NEED_SELECT_ATTRIB, + "{0} requer um atributo de sele\u00E7\u00E3o."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when deve ter um atributo 'test'."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param deve ter um atributo 'name'."}, + + { ER_NO_CONTEXT_OWNERDOC, + "o contexto n\u00E3o tem um documento de propriet\u00E1rio!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "N\u00E3o foi poss\u00EDvel criar a Liga\u00E7\u00E3o TransformerFactory XML: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: O processo n\u00E3o foi bem-sucedido."}, + + { ER_NOT_SUCCESSFUL, + "Xalan: N\u00E3o foi bem-sucedido."}, + + { ER_ENCODING_NOT_SUPPORTED, + "Codifica\u00E7\u00E3o n\u00E3o suportada: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "N\u00E3o foi poss\u00EDvel criar TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key requer um atributo 'name'!"}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key requer um atributo 'match'!"}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key requer um atributo 'use'!"}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} requer um atributo ''elements''!"}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) o atributo ''prefix'' de {0} n\u00E3o foi encontrado"}, + + { ER_BAD_STYLESHEET_URL, + "O URL da Folha de Estilos est\u00E1 incorreto: {0}"}, + + { ER_FILE_NOT_FOUND, + "O arquivo da folha de estilos n\u00E3o foi encontrado: {0}"}, + + { ER_IOEXCEPTION, + "Exce\u00E7\u00E3o de E/S com o arquivo de folha de estilos: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) N\u00E3o foi poss\u00EDvel encontrar o atributo href para {0}"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) A folha de estilos {0} est\u00E1 incluindo a si mesma direta ou indiretamente!"}, + + { ER_PROCESSINCLUDE_ERROR, + "Erro de StylesheetHandler.processInclude: {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) O atributo ''lang'' de {0} n\u00E3o foi encontrado"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) elemento {0} incorretamente posicionado?? Elemento ''component'' do container n\u00E3o encontrado"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Sa\u00EDda permitida somente para Element, DocumentFragment, Document ou PrintWriter."}, + + { ER_PROCESS_ERROR, + "Erro de StylesheetRoot.process"}, + + { ER_UNIMPLNODE_ERROR, + "Erro de UnImplNode: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "Erro! N\u00E3o foi poss\u00EDvel localizar a express\u00E3o de sele\u00E7\u00E3o xpath (-select)."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "N\u00E3o \u00E9 poss\u00EDvel serializar um XSLProcessor!"}, + + { ER_NO_INPUT_STYLESHEET, + "A entrada da folha de estilos n\u00E3o foi especificada!"}, + + { ER_FAILED_PROCESS_STYLESHEET, + "Falha ao processar a folha de estilos!"}, + + { ER_COULDNT_PARSE_DOC, + "N\u00E3o foi poss\u00EDvel fazer parsing do documento {0}!"}, + + { ER_COULDNT_FIND_FRAGMENT, + "N\u00E3o foi poss\u00EDvel localizar o fragmento: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "O n\u00F3 indicado pelo identificador de fragmento n\u00E3o era um elemento: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each deve ter um atributo de correspond\u00EAncia ou de nome"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "os modelos devem ter um atributo de correspond\u00EAncia ou de nome"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "N\u00E3o h\u00E1 clone de um fragmento de documento!"}, + + { ER_CANT_CREATE_ITEM, + "N\u00E3o \u00E9 poss\u00EDvel criar um item em uma \u00E1rvore de resultados: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space no XML de origem tem um valor inv\u00E1lido: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "N\u00E3o h\u00E1 uma declara\u00E7\u00E3o de xsl:key para {0}!"}, + + { ER_CANT_CREATE_URL, + "Erro! N\u00E3o \u00E9 poss\u00EDvel criar o url para: {0}"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions n\u00E3o \u00E9 suportado"}, + + { ER_PROCESSOR_ERROR, + "Erro de TransformerFactory XSLT"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} n\u00E3o \u00E9 permitido em uma folha de estilos!"}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns n\u00E3o \u00E9 mais suportado! Em vez disso, use xsl:output."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "padr\u00E3o-space n\u00E3o \u00E9 mais suportado! Em vez disso, use xsl:strip-space ou xsl:preserve-space."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result n\u00E3o \u00E9 mais suportado! Em vez disso, use xsl:output."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} tem um atributo inv\u00E1lido: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "Elemento XSL desconhecido: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort s\u00F3 pode ser usado com xsl:apply-templates ou xsl:for-each."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when posicionado incorretamente!"}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when n\u00E3o relacionado a xsl:choose!"}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise posicionado incorretamente!"}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise n\u00E3o relacionado a xsl:choose!"}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} n\u00E3o \u00E9 permitido em um modelo!"}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) prefixo {1} de namespace da extens\u00E3o de {0} desconhecido"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) As importa\u00E7\u00F5es s\u00F3 podem ocorrer como os primeiros elementos na folha de estilos!"}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) A folha de estilos {0} est\u00E1 importando a si mesmo(a) direta ou indiretamente!"}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space tem um valor inv\u00E1lido: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet malsucedido!"}, + + { ER_SAX_EXCEPTION, + "Exce\u00E7\u00E3o de SAX"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "Fun\u00E7\u00E3o n\u00E3o suportada!"}, + + { ER_XSLT_ERROR, + "Erro de XSLT"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "sinal de moeda n\u00E3o permitido na string de padr\u00E3o de formato"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Fun\u00E7\u00E3o do documento n\u00E3o suportada no DOM da Folha de estilos!"}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "N\u00E3o \u00E9 poss\u00EDvel resolver o prefixo de um resolvedor sem Prefixo!"}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "Redirecionar extens\u00E3o: N\u00E3o foi poss\u00EDvel obter o nome do arquivo - o arquivo ou o atributo de sele\u00E7\u00E3o deve retornar uma string v\u00E1lida."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "N\u00E3o \u00E9 poss\u00EDvel criar FormatterListener na extens\u00E3o de Redirecionamento!"}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "O prefixo em exclude-result-prefixes n\u00E3o \u00E9 v\u00E1lido: {0}"}, + + { ER_MISSING_NS_URI, + "URI do namespace n\u00E3o encontrado para o prefixo especificado"}, + + { ER_MISSING_ARG_FOR_OPTION, + "Argumento n\u00E3o encontrado para a op\u00E7\u00E3o: {0}"}, + + { ER_INVALID_OPTION, + "Op\u00E7\u00E3o inv\u00E1lida: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "String de formato incorreta: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet requer um atributo 'version'!"}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "Atributo: {0} tem um valor inv\u00E1lido: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose requer um xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports n\u00E3o permitido em um xsl:for-each"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "N\u00E3o \u00E9 poss\u00EDvel usar um DTMLiaison para um n\u00F3 DOM de sa\u00EDda... em vez disso, especifique um com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "N\u00E3o \u00E9 poss\u00EDvel usar um DTMLiaison para um n\u00F3 DOM de entrada... em vez disso, especifique um com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + { ER_CALL_TO_EXT_FAILED, + "Falha ao chamar o elemento da extens\u00E3o: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "O prefixo deve ser resolvido para um namespace: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "Foi detectado um substituto de UTF-16 inv\u00E1lido: {0} ?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} usou ele mesmo, o que causar\u00E1 um loop infinito."}, + + { ER_CANNOT_MIX_XERCESDOM, + "N\u00E3o \u00E9 poss\u00EDvel misturar entrada n\u00E3o Xerces-DOM com sa\u00EDda Xerces-DOM!"}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "No ElemTemplateElement.readObject: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "Foi encontrado mais de um modelo com o nome: {0}"}, + + { ER_INVALID_KEY_CALL, + "Chamada de fun\u00E7\u00E3o inv\u00E1lida: chamadas recursivas de key() n\u00E3o s\u00E3o permitidas"}, + + { ER_REFERENCING_ITSELF, + "A vari\u00E1vel {0} est\u00E1 importando ela mesma de forma direta ou indireta!"}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "O n\u00F3 de entrada n\u00E3o pode ser nulo para um DOMSource para newTemplates!"}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "O arquivo de classe n\u00E3o foi encontrado para a op\u00E7\u00E3o {0}"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "Elemento Obrigat\u00F3rio n\u00E3o encontrado: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream n\u00E3o pode ser nulo"}, + + { ER_URI_CANNOT_BE_NULL, + "O URI n\u00E3o pode ser nulo"}, + + { ER_FILE_CANNOT_BE_NULL, + "O arquivo n\u00E3o pode ser nulo"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource n\u00E3o pode ser nulo"}, + + { ER_CANNOT_INIT_BSFMGR, + "N\u00E3o foi poss\u00EDvel inicializar o Gerenciador de BSF"}, + + { ER_CANNOT_CMPL_EXTENSN, + "N\u00E3o foi poss\u00EDvel compilar a extens\u00E3o"}, + + { ER_CANNOT_CREATE_EXTENSN, + "N\u00E3o foi poss\u00EDvel criar a extens\u00E3o: {0} em decorr\u00EAncia de: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "A chamada do m\u00E9todo da inst\u00E2ncia para o m\u00E9todo {0} exige uma inst\u00E2ncia do Objeto como primeiro argumento"}, + + { ER_INVALID_ELEMENT_NAME, + "Nome de elemento inv\u00E1lido especificado {0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "O m\u00E9todo do nome do elemento deve ser est\u00E1tico {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "Fun\u00E7\u00E3o da extens\u00E3o {0} : {1} desconhecido"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "H\u00E1 mais de uma melhor correspond\u00EAncia para o construtor em rela\u00E7\u00E3o a {0}"}, + + { ER_MORE_MATCH_METHOD, + "H\u00E1 mais de uma melhor correspond\u00EAncia para o m\u00E9todo {0}"}, + + { ER_MORE_MATCH_ELEMENT, + "H\u00E1 mais de uma melhor correspond\u00EAncia para o m\u00E9todo do elemento {0}"}, + + { ER_INVALID_CONTEXT_PASSED, + "Contexto inv\u00E1lido especificado para avaliar {0}"}, + + { ER_POOL_EXISTS, + "O pool j\u00E1 existe"}, + + { ER_NO_DRIVER_NAME, + "Nenhum Nome do driver especificado"}, + + { ER_NO_URL, + "Nenhum URL especificado"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "O tamanho do pool \u00E9 menor que um!"}, + + { ER_INVALID_DRIVER, + "Nome do driver inv\u00E1lido especificado!"}, + + { ER_NO_STYLESHEETROOT, + "A raiz da folha de estilos n\u00E3o foi encontrada!"}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "Valor inv\u00E1lido para xml:space"}, + + { ER_PROCESSFROMNODE_FAILED, + "Falha em processFromNode"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "O recurso [ {0} ] n\u00E3o foi carregado: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Tamanho do buffer <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Erro desconhecido ao chamar a extens\u00E3o"}, + + { ER_NO_NAMESPACE_DECL, + "O prefixo {0} n\u00E3o tem uma declara\u00E7\u00E3o de namespace correspondente"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "Conte\u00FAdo do elemento n\u00E3o permitido para lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "T\u00E9rmino direcionado da folha de estilos"}, + + { ER_ONE_OR_TWO, + "1 ou 2"}, + + { ER_TWO_OR_THREE, + "2 ou 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "N\u00E3o foi poss\u00EDvel carregar {0} (verificar CLASSPATH); usando agora apenas os padr\u00F5es"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "N\u00E3o \u00E9 poss\u00EDvel inicializar os modelos padr\u00E3o"}, + + { ER_RESULT_NULL, + "O resultado n\u00E3o deve ser nulo"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "N\u00E3o foi poss\u00EDvel definir o resultado"}, + + { ER_NO_OUTPUT_SPECIFIED, + "Nenhuma sa\u00EDda especificada"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "N\u00E3o \u00E9 poss\u00EDvel transformar um Resultado do tipo {0}"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "N\u00E3o \u00E9 poss\u00EDvel transformar uma Origem do tipo {0}"}, + + { ER_NULL_CONTENT_HANDLER, + "Handler de conte\u00FAdo nulo"}, + + { ER_NULL_ERROR_HANDLER, + "Handler de erro nulo"}, + + { ER_CANNOT_CALL_PARSE, + "o parsing n\u00E3o poder\u00E1 ser chamado se o ContentHandler n\u00E3o tiver sido definido"}, + + { ER_NO_PARENT_FOR_FILTER, + "Nenhum pai para o filtro"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "Nenhuma folha de estilos encontrada em: {0}, m\u00EDdia= {1}"}, + + { ER_NO_STYLESHEET_PI, + "Nenhum PI de xml-stylesheet encontrado em: {0}"}, + + { ER_NOT_SUPPORTED, + "N\u00E3o suportado: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "O valor da propriedade {0} deve ser uma inst\u00E2ncia Booliana"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "N\u00E3o foi poss\u00EDvel obter um script externo em {0}"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "N\u00E3o foi poss\u00EDvel encontrar o recurso [ {0} ].\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propriedade de sa\u00EDda n\u00E3o reconhecida: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "Falha ao criar a inst\u00E2ncia ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "O valor para {0} deve conter um n\u00FAmero pass\u00EDvel de parsing"}, + + { ER_VALUE_SHOULD_EQUAL, + "O valor para {0} deve ser igual a sim ou n\u00E3o"}, + + { ER_FAILED_CALLING_METHOD, + "Falha ao chamar o m\u00E9todo {0}"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "Falha ao criar a inst\u00E2ncia ElemTemplateElement"}, + + { ER_CHARS_NOT_ALLOWED, + "Os caracteres n\u00E3o s\u00E3o permitidos neste ponto do documento"}, + + { ER_ATTR_NOT_ALLOWED, + "O atributo \"{0}\" n\u00E3o \u00E9 permitido no elemento {1}!"}, + + { ER_BAD_VALUE, + "{0} valor incorreto {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "valor do atributo {0} n\u00E3o encontrado "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "Valor do atributo {0} n\u00E3o reconhecido "}, + + { ER_NULL_URI_NAMESPACE, + "Tentativa de gerar um prefixo do namespace com um URI nulo"}, + + { ER_NUMBER_TOO_BIG, + "Tentativa de formatar um n\u00FAmero maior que o n\u00FAmero inteiro Longo maior"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "N\u00E3o \u00E9 poss\u00EDvel localizar a classe do driver SAX1 {0}"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "A classe do driver SAX1 {0} foi encontrada, mas n\u00E3o pode ser carregada"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "A classe do driver SAX1 {0} foi carregada, mas n\u00E3o pode ser instanciada"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "A classe do driver SAX1 {0} n\u00E3o implementa org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "A propriedade do sistema org.xml.sax.parser n\u00E3o foi especificada"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "O argumento de parser n\u00E3o pode ser nulo"}, + + { ER_FEATURE, + "Recurso: {0}"}, + + { ER_PROPERTY, + "Propriedade: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "Resolvedor da entidade nulo"}, + + { ER_NULL_DTD_HANDLER, + "Handler de DTD nulo"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "Nenhum Nome do Driver Especificado!"}, + + { ER_NO_URL_SPECIFIED, + "Nenhum URL Especificado!"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "O tamanho do pool \u00E9 menor que 1!"}, + + { ER_INVALID_DRIVER_NAME, + "Nome do Driver Especificado Inv\u00E1lido!"}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "Erro do programador! A express\u00E3o n\u00E3o tem ElemTemplateElement pai!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Asser\u00E7\u00E3o do Programador no RedundentExprEliminator: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0} n\u00E3o \u00E9 permitido(a) nesta posi\u00E7\u00E3o na folha de estilos!"}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Texto sem espa\u00E7o em branco n\u00E3o permitido nesta posi\u00E7\u00E3o na folha de estilos!"}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "Valor inv\u00E1lido: {1} usado para o atributo CHAR: {0}. Um atributo do tipo CHAR deve ter somente 1 caractere!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "Valor inv\u00E1lido: {1} usado para o atributo QNAME: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "Valor inv\u00E1lido: {1} usado para o atributo ENUM: {0}. Os valores v\u00E1lidos s\u00E3o: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "Valor inv\u00E1lido: {1} usado para o atributo NMTOKEN: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "Valor inv\u00E1lido: {1} usado para o atributo NCNAME: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Valor inv\u00E1lido: {1} usado para o atributo boolean: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Valor inv\u00E1lido: {1} usado para o atributo do n\u00FAmero: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "O argumento para {0} no padr\u00E3o de correspond\u00EAncia deve ser um literal."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "Declara\u00E7\u00E3o de vari\u00E1vel global duplicada."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "Declara\u00E7\u00E3o de vari\u00E1vel duplicada."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template deve ter um atributo name ou match (ou ambos)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "O prefixo em exclude-result-prefixes n\u00E3o \u00E9 v\u00E1lido: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "o conjunto de atributos com o nome {0} n\u00E3o existe"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "A fun\u00E7\u00E3o com o nome {0} n\u00E3o existe"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "O elemento {0} n\u00E3o deve ter um conte\u00FAdo e um atributo select."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "O valor do par\u00E2metro {0} deve ser um Objeto Java v\u00E1lido"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "O atributo result-prefix de um elemento xsl:namespace-alias tem o valor '#padr\u00E3o', mas n\u00E3o h\u00E1 declara\u00E7\u00E3o do namespace padr\u00E3o no escopo do elemento"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "O atributo result-prefix de um elemento xsl:namespace-alias tem o valor ''{0}'', mas n\u00E3o h\u00E1 declara\u00E7\u00E3o de namespace para o prefixo ''{0}'' no escopo do elemento."}, + + { ER_SET_FEATURE_NULL_NAME, + "O nome do recurso n\u00E3o pode ser nulo em TransformerFactory.setFeature(Nome da string, valor booliano)."}, + + { ER_GET_FEATURE_NULL_NAME, + "O nome do recurso n\u00E3o pode ser nulo em TransformerFactory.getFeature(Nome da string)."}, + + { ER_UNSUPPORTED_FEATURE, + "N\u00E3o \u00E9 poss\u00EDvel definir o recurso ''{0}'' nesta TransformerFactory."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "O uso do elemento da extens\u00E3o ''{0}'' n\u00E3o ser\u00E1 permitido quando o recurso de processamento seguro for definido como verdadeiro."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "N\u00E3o \u00E9 poss\u00EDvel obter o prefixo de um uri de namespace nulo."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "N\u00E3o \u00E9 poss\u00EDvel obter o uri do namespace do prefixo nulo."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "O nome da fun\u00E7\u00E3o n\u00E3o pode ser nulo."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "A aridade n\u00E3o pode ser negativa."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "Encontrou '}', mas nenhum modelo do atributo estava aberto!"}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Advert\u00EAncia: o atributo de contagem n\u00E3o corresponde a um ancestral no xsl:number! Alvo = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Sintaxe antiga: O nome do atributo 'expr' foi alterado para 'select'."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "O Xalan ainda n\u00E3o trata o nome das configura\u00E7\u00F5es regionais na fun\u00E7\u00E3o format-number."}, + + { WG_LOCALE_NOT_FOUND, + "Advert\u00EAncia: N\u00E3o foi poss\u00EDvel encontrar o nome das configura\u00E7\u00F5es regionais de xml:lang={0}"}, + + { WG_CANNOT_MAKE_URL_FROM, + "N\u00E3o \u00E9 poss\u00EDvel criar o URL de: {0}"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "N\u00E3o \u00E9 poss\u00EDvel carregar o doc solicitado: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "N\u00E3o foi poss\u00EDvel localizar o Agrupador para >>>>>> Vers\u00E3o do Xalan "}, + { "version2", "<<<<<<<"}, + { "yes", "sim"}, + { "line", "N\u00B0 da Linha"}, + { "column","N\u00B0 da Coluna"}, + { "xsldone", "XSLProcessor: conclu\u00EDdo"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Op\u00E7\u00F5es da classe Process da linha de comandos do Xalan-J:"}, + { "xslProc_option", "Op\u00E7\u00F5es da classe Process da linha de comandos do Xalan-J:"}, + { "xslProc_invalid_xsltc_option", "A op\u00E7\u00E3o {0} n\u00E3o \u00E9 suportada no modo XSLTC."}, + { "xslProc_invalid_xalan_option", "A op\u00E7\u00E3o {0} s\u00F3 pode ser usada com -XSLTC."}, + { "xslProc_no_input", "Erro: N\u00E3o foi especificada uma folha de estilos ou um xml de entrada . Execute este comando sem nenhuma op\u00E7\u00E3o para instru\u00E7\u00F5es de uso."}, + { "xslProc_common_options", "-Op\u00E7\u00F5es Comuns-"}, + { "xslProc_xalan_options", "-Op\u00E7\u00F5es para Xalan-"}, + { "xslProc_xsltc_options", "-Op\u00E7\u00F5es para XSLTC-"}, + { "xslProc_return_to_continue", "(pressione para continuar)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (use XSLTC para transforma\u00E7\u00E3o)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER nome da classe totalmente qualificado de liaison de parser]"}, + { "optionE", " [-E (N\u00E3o expandir refer\u00EAncias da entidade)]"}, + { "optionV", " [-E (N\u00E3o expandir refer\u00EAncias da entidade)]"}, + { "optionQC", " [-QC (Advert\u00EAncias de Conflitos do Padr\u00E3o Silencioso)]"}, + { "optionQ", " [-Q (Modo Silencioso)]"}, + { "optionLF", " [-LF (Usar alimenta\u00E7\u00F5es de linha somente na sa\u00EDda {o padr\u00E3o \u00E9 CR/LF})]"}, + { "optionCR", " [-CR (Use retornos de carro somente na sa\u00EDda {o padr\u00E3o \u00E9 CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (Quais caracteres devem ser identificados como escape {o padr\u00E3o \u00E9 <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (Controla quantos espa\u00E7os devem ser recuados {o padr\u00E3o \u00E9 0})]"}, + { "optionTT", " [-TT (Rastreia os modelos \u00E0 medida que s\u00E3o chamados.)]"}, + { "optionTG", " [-TG (Rastreia cada evento de gera\u00E7\u00E3o.)]"}, + { "optionTS", " [-TS (Rastreia cada evento de sele\u00E7\u00E3o.)]"}, + { "optionTTC", " [-TTC (Rastreia os filhos do modelo \u00E0 medida que s\u00E3o processados.)]"}, + { "optionTCLASS", " [-TCLASS (Classe TraceListener para extens\u00F5es de rastreamento.)]"}, + { "optionVALIDATE", " [-VALIDATE (Define se ocorre valida\u00E7\u00E3o. Por padr\u00E3o, a valida\u00E7\u00E3o fica desativada.)]"}, + { "optionEDUMP", " [-EDUMP {nome do arquivo opcional} (Execute um dump de pilha em caso de erro.)]"}, + { "optionXML", " [-XML (Use o formatador XML e adicione o cabe\u00E7alho XML.)]"}, + { "optionTEXT", " [-TEXT (Use o formatador de Texto simples.)]"}, + { "optionHTML", " [-HTML (Use o formatador HTML.)]"}, + { "optionPARAM", " [-PARAM express\u00E3o do nome (Defina um par\u00E2metro da folha de estilos)]"}, + { "noParsermsg1", "Processo XSL malsucedido."}, + { "noParsermsg2", "** N\u00E3o foi poss\u00EDvel localizar o parser **"}, + { "noParsermsg3", "Verifique seu classpath."}, + { "noParsermsg4", "Se voc\u00EA n\u00E3o tiver um Parser XML da IBM para Java, poder\u00E1 fazer download dele em"}, + { "noParsermsg5", "AlphaWorks da IBM: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER nome completo da classe (URIResolver a ser usado para resolver URIs)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER nome completo da classe (EntityResolver a ser usado para resolver entidades)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER nome completo da classe (ContentHandler a ser usado para serializar a sa\u00EDda)]"}, + { "optionLINENUMBERS", " [-L usa os n\u00FAmeros de linha dos documentos de origem]"}, + { "optionSECUREPROCESSING", " [-SECURE (define o recurso de processamento seguro como verdadeiro.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (use o atributo de m\u00EDdia para localizar a folha de estilos associada a um documento.)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (Use explicitamente s2s=SAX ou d2d=DOM para fazer a transforma\u00E7\u00E3o.)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (Imprimir transforma\u00E7\u00E3o geral de milissegundos detectada.)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (solicitar a constru\u00E7\u00E3o de DTM incremental, definindo http://xml.apache.org/xalan/features/incremental como verdadeiro.)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (solicite o n\u00E3o processamento de otimiza\u00E7\u00E3o da folha de estilos definindo http://xml.apache.org/xalan/features/optimize como falso.)]"}, + { "optionRL", " [-RL recursionlimit (limite num\u00E9rico de asser\u00E7\u00E3o na profundidade de recurs\u00E3o da folha de estilos.)]"}, + { "optionXO", " [-XO [transletName] (atribui o nome ao translet gerado)]"}, + { "optionXD", " [-XD destinationDirectory (especificar um diret\u00F3rio de destino para translet)]"}, + { "optionXJ", " [-XJ jarfile (empacotar classes do translet em um arquivo jar com o nome )]"}, + { "optionXP", " [-XP pacote (especifica um prefixo de nome do pacote para todas as classes translet geradas)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (ativa a inser\u00E7\u00E3o do modelo)]" }, + { "optionXX", " [-XX (ativa a sa\u00EDda da mensagem de depura\u00E7\u00E3o adicional)]"}, + { "optionXT" , " [-XT (usar o translet para transformar, se poss\u00EDvel)]"}, + { "diagTiming"," --------- A transforma\u00E7\u00E3o de {0} por meio de {1} levou {2} ms" }, + { "recursionTooDeep","Aninhamento do modelo muito profundo. aninhamento = {0}, modelo {1} {2}" }, + { "nameIs", "o nome \u00E9" }, + { "matchPatternIs", "o padr\u00E3o de correspond\u00EAncia \u00E9" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java new file mode 100644 index 000000000..556de2d22 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_sv extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "Fel: Uttryck f\u00E5r inte inneh\u00E5lla '{'"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} har ett otill\u00E5tet attribut: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode \u00E4r null i xsl:apply-imports!"}, + + {ER_CANNOT_ADD, + "Kan inte addera {0} till {1}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u00E4r null i handleApplyTemplatesInstruction!"}, + + { ER_NO_NAME_ATTRIB, + "{0} m\u00E5ste ha ett namnattribut."}, + + {ER_TEMPLATE_NOT_FOUND, + "Hittade inte mallen med namnet: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Kunde inte matcha namn-AVT i xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} kr\u00E4ver attribut: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} m\u00E5ste ha ett ''test''-attribut."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Felaktigt v\u00E4rde i niv\u00E5attribut: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "Namn p\u00E5 bearbetningsinstruktion kan inte vara 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "Namn p\u00E5 bearbetningsinstruktion m\u00E5ste vara ett giltigt NCName: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} m\u00E5ste ha ett matchningsattribut n\u00E4r det anger ett l\u00E4ge."}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} kr\u00E4ver antingen ett namn eller ett matchningsattribut."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Kan inte matcha prefix f\u00F6r namnrymd: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space har ett otill\u00E5tet v\u00E4rde: {0}"}, + + { ER_NO_OWNERDOC, + "Underordnad nod har inget \u00E4gardokument!"}, + + { ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement-fel: {0}"}, + + { ER_NULL_CHILD, + "F\u00F6rs\u00F6ker l\u00E4gga till en null-underordnad!"}, + + { ER_NEED_SELECT_ATTRIB, + "{0} kr\u00E4ver ett select-attribut."}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when m\u00E5ste ha ett 'test'-attribut."}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-parametern m\u00E5ste ha ett 'namn'-attribut."}, + + { ER_NO_CONTEXT_OWNERDOC, + "context har inget \u00E4gardokument!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Kunde inte skapa XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: Processen utf\u00F6rdes inte."}, + + { ER_NOT_SUCCESSFUL, + "Xalan: utf\u00F6rdes inte."}, + + { ER_ENCODING_NOT_SUPPORTED, + "Kodningen st\u00F6ds inte: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Kunde inte TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key kr\u00E4ver ett 'namn'-attribut!"}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key kr\u00E4ver ett 'matchning'-attribut!"}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key kr\u00E4ver ett 'anv\u00E4nd'-attribut!"}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} kr\u00E4ver ett ''element''-attribut!"}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) ''prefix'' f\u00F6r {0}-attribut saknas"}, + + { ER_BAD_STYLESHEET_URL, + "Formatmall-URL \u00E4r felaktig: {0}"}, + + { ER_FILE_NOT_FOUND, + "Formatmallfil kunde inte hittas: {0}"}, + + { ER_IOEXCEPTION, + "Fick IO-undantag med formatmallfil: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Hittade inte href-attribut f\u00F6r {0}"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} inkluderar, direkt eller indirekt, sig sj\u00E4lv!"}, + + { ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude-fel, {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) ''lang'' f\u00F6r {0}-attribut saknas"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0}-element?? \u00E4r felplacerat Container-elementet ''component'' saknas"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Kan endast skicka utdata till ett Element, ett DocumentFragment, ett Document eller en PrintWriter."}, + + { ER_PROCESS_ERROR, + "StylesheetRoot.process-fel"}, + + { ER_UNIMPLNODE_ERROR, + "UnImplNode-fel: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "Fel! Hittade inte xpath select-uttryck (-select)."}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Kan inte serialisera en XSLProcessor!"}, + + { ER_NO_INPUT_STYLESHEET, + "Formatmallindata ej angiven!"}, + + { ER_FAILED_PROCESS_STYLESHEET, + "Kunde inte behandla formatmall!"}, + + { ER_COULDNT_PARSE_DOC, + "Kunde inte tolka dokumentet {0}!"}, + + { ER_COULDNT_FIND_FRAGMENT, + "Hittade inte fragment: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "Nod som pekades p\u00E5 av fragment-identifierare var inte ett element: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each kr\u00E4ver antingen en matchning eller ett namnattribut"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates kr\u00E4ver antingen en matchning eller ett namnattribut"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Ingen klon av ett dokumentfragment!"}, + + { ER_CANT_CREATE_ITEM, + "Kan inte skapa element i resultattr\u00E4d: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space i k\u00E4ll-XML har ett otill\u00E5tet v\u00E4rde: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "Det finns ingen xsl:key-deklaration f\u00F6r {0}!"}, + + { ER_CANT_CREATE_URL, + "Fel! Kan inte skapa URL f\u00F6r: {0}"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions st\u00F6ds inte"}, + + { ER_PROCESSOR_ERROR, + "XSLT TransformerFactory-fel"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} \u00E4r inte till\u00E5ten inne i en formatmall!"}, + + { ER_RESULTNS_NOT_SUPPORTED, + "result-ns st\u00F6ds inte l\u00E4ngre! Anv\u00E4nd xsl:output ist\u00E4llet."}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space st\u00F6ds inte l\u00E4ngre! Anv\u00E4nd xsl:strip-space eller xsl:preserve-space ist\u00E4llet."}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result st\u00F6ds inte l\u00E4ngre! Anv\u00E4nd xsl:output ist\u00E4llet."}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} har ett otill\u00E5tet attribut: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "Ok\u00E4nt XSL-element: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort kan endast anv\u00E4ndas med xsl:apply-templates eller xsl:for-each."}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) felplacerade xsl:when!"}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when h\u00E4rstammar inte fr\u00E5n xsl:choose!"}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) felplacerade xsl:otherwise!"}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise h\u00E4rstammar inte fr\u00E5n xsl:choose!"}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} \u00E4r inte till\u00E5ten inne i en mall!"}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) ok\u00E4nt namnrymdsprefix {1} f\u00F6r till\u00E4gg {0}"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Imports kan endast f\u00F6rekomma som de f\u00F6rsta elementen i formatmallen!"}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} importerar, direkt eller indirekt, sig sj\u00E4lv!"}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space har ett otill\u00E5tet v\u00E4rde: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet utf\u00F6rdes inte!"}, + + { ER_SAX_EXCEPTION, + "SAX-undantag"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "Funktionen st\u00F6ds inte!"}, + + { ER_XSLT_ERROR, + "XSLT-fel"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "valutatecken \u00E4r inte till\u00E5tet i formatm\u00F6nsterstr\u00E4ng"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Dokumentfunktion st\u00F6ds inte i Stylesheet DOM!"}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Kan inte matcha prefix med matchning som saknar prefix!"}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "Redirect-till\u00E4gg: Hittade inte filnamn - fil eller valattribut m\u00E5ste returnera giltig str\u00E4ng."}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Kan inte bygga FormatterListener i Redirect-till\u00E4gg!"}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Prefix i exclude-result-prefixes \u00E4r inte giltigt: {0}"}, + + { ER_MISSING_NS_URI, + "Namnrymds-URI saknas f\u00F6r angivna prefix"}, + + { ER_MISSING_ARG_FOR_OPTION, + "Argument saknas f\u00F6r alternativet: {0}"}, + + { ER_INVALID_OPTION, + "Ogiltigt alternativ: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "Felaktigt utformad formatstr\u00E4ng: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet kr\u00E4ver ett 'version'-attribut!"}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "Attribut: {0} har ett otill\u00E5tet v\u00E4rde: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose kr\u00E4ver xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports inte till\u00E5tet i xsl:for-each"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "Kan inte anv\u00E4nda DTMLiaison till en DOM utdatanod... skicka en com.sun.org.apache.xpath.internal.DOM2Helper ist\u00E4llet!"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "Kan inte anv\u00E4nda DTMLiaison till en DOM indatanod... skicka en com.sun.org.apache.xpath.internal.DOM2Helper ist\u00E4llet!"}, + + { ER_CALL_TO_EXT_FAILED, + "Anrop till till\u00E4ggselement utf\u00F6rdes inte: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "Prefix m\u00E5ste matchas till en namnrymd: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "Ogiltigt UTF-16-surrogat uppt\u00E4ckt: {0} ?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} anv\u00E4nde sig sj\u00E4lvt, vilket kommer att orsaka en o\u00E4ndlig slinga."}, + + { ER_CANNOT_MIX_XERCESDOM, + "Kan inte blanda icke-Xerces-DOM-indata med Xerces-DOM-utdata!"}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "I ElemTemplateElement.readObject: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "Hittade fler \u00E4n en mall med namnet: {0}"}, + + { ER_INVALID_KEY_CALL, + "Ogiltigt funktionsanrop: rekursiva key()-anrop \u00E4r inte till\u00E5tna"}, + + { ER_REFERENCING_ITSELF, + "Variabeln {0} refererar, direkt eller indirekt, till sig sj\u00E4lv!"}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "Indatanoden till en DOMSource f\u00F6r newTemplates f\u00E5r inte vara null!"}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "Klassfil f\u00F6r alternativ {0} saknas"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "Obligatoriska element hittades inte: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream kan inte vara null"}, + + { ER_URI_CANNOT_BE_NULL, + "URI kan inte vara null"}, + + { ER_FILE_CANNOT_BE_NULL, + "Fil kan inte vara null"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource kan inte vara null"}, + + { ER_CANNOT_INIT_BSFMGR, + "Kunde inte initiera BSF Manager"}, + + { ER_CANNOT_CMPL_EXTENSN, + "Kunde inte kompilera till\u00E4gg"}, + + { ER_CANNOT_CREATE_EXTENSN, + "Kunde inte skapa till\u00E4gg: {0} p\u00E5 grund av: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "Instansmetodanrop till metod {0} kr\u00E4ver en objektinstans som f\u00F6rsta argument"}, + + { ER_INVALID_ELEMENT_NAME, + "Ogiltigt elementnamn angivet {0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "Elementnamnmetod m\u00E5ste vara statisk {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "Till\u00E4ggsfunktion {0} : {1} \u00E4r ok\u00E4nd"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "Fler \u00E4n en b\u00E4sta matchning f\u00F6r konstruktor f\u00F6r {0}"}, + + { ER_MORE_MATCH_METHOD, + "Fler \u00E4n en b\u00E4sta matchning f\u00F6r metod {0}"}, + + { ER_MORE_MATCH_ELEMENT, + "Fler \u00E4n en b\u00E4sta matchning f\u00F6r elementmetod {0}"}, + + { ER_INVALID_CONTEXT_PASSED, + "Ogiltig kontext skickad f\u00F6r att utv\u00E4rdera {0}"}, + + { ER_POOL_EXISTS, + "Pool finns redan"}, + + { ER_NO_DRIVER_NAME, + "Inget drivrutinsnamn angivet"}, + + { ER_NO_URL, + "Ingen URL angiven"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "Poolstorlek \u00E4r mindre \u00E4n ett!"}, + + { ER_INVALID_DRIVER, + "Ogiltigt drivrutinsnamn angivet!"}, + + { ER_NO_STYLESHEETROOT, + "Hittade inte formatmallen roten!"}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "Otill\u00E5tet v\u00E4rde f\u00F6r xml:space"}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode utf\u00F6rdes inte"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "Resursen [ {0} ] kunde inte laddas: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Buffertstorlek <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Ok\u00E4nt fel vid anrop av till\u00E4gg"}, + + { ER_NO_NAMESPACE_DECL, + "Prefix {0} har ingen motsvarande namnrymdsdeklaration"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "Elementinneh\u00E5ll inte till\u00E5tet f\u00F6r lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "Avslutning via formatmall"}, + + { ER_ONE_OR_TWO, + "1 eller 2"}, + + { ER_TWO_OR_THREE, + "2 eller 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "Kunde inte ladda {0} (kontrollera CLASSPATH), anv\u00E4nder nu enbart standardv\u00E4rden"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Kan inte initiera standardmallar"}, + + { ER_RESULT_NULL, + "Result borde inte vara null"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "Result kunde inte st\u00E4llas in"}, + + { ER_NO_OUTPUT_SPECIFIED, + "Ingen utdata angiven"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Kan inte omvandla till Result av typ {0}"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Kan inte omvandla Source av typ {0}"}, + + { ER_NULL_CONTENT_HANDLER, + "Inneh\u00E5llshanterare med v\u00E4rde null"}, + + { ER_NULL_ERROR_HANDLER, + "Felhanterare med v\u00E4rde null"}, + + { ER_CANNOT_CALL_PARSE, + "parse kan inte anropas om ContentHandler inte har satts"}, + + { ER_NO_PARENT_FOR_FILTER, + "Ingen \u00F6verordnad f\u00F6r filter"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "Formatmall saknas i: {0}, media= {1}"}, + + { ER_NO_STYLESHEET_PI, + "PI f\u00F6r xml-formatmall saknas i: {0}"}, + + { ER_NOT_SUPPORTED, + "Underst\u00F6ds inte: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "V\u00E4rde f\u00F6r egenskap {0} b\u00F6r vara en boolesk instans"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Kunde inte h\u00E4mta externt skript fr\u00E5n {0}"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "Resursen [ {0} ] kunde inte h\u00E4mtas.\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Utdataegenskap kan inte identifieras: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "Kunde inte skapa instans av ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "V\u00E4rdet f\u00F6r {0} b\u00F6r inneh\u00E5lla ett tal som kan tolkas"}, + + { ER_VALUE_SHOULD_EQUAL, + "V\u00E4rdet f\u00F6r {0} b\u00F6r vara ja eller nej"}, + + { ER_FAILED_CALLING_METHOD, + "Kunde inte anropa metoden {0}"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "Kunde inte skapa instans av ElemTemplateElement"}, + + { ER_CHARS_NOT_ALLOWED, + "Tecken \u00E4r inte till\u00E5tna i dokumentet i det h\u00E4r skedet"}, + + { ER_ATTR_NOT_ALLOWED, + "Attributet \"{0}\" \u00E4r inte till\u00E5tet i elementet {1}!"}, + + { ER_BAD_VALUE, + "{0} felaktigt v\u00E4rde {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "Attributet {0} saknas "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "Attributv\u00E4rdet {0} kan inte identifieras "}, + + { ER_NULL_URI_NAMESPACE, + "F\u00F6rs\u00F6ker generera ett namnrymdsprefix med en null-URI"}, + + { ER_NUMBER_TOO_BIG, + "F\u00F6rs\u00F6ker formatera ett tal som \u00E4r st\u00F6rre \u00E4n det st\u00F6rsta l\u00E5nga heltalet"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "Hittar inte SAX1-drivrutinen klass {0}"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "SAX1-drivrutinen klass {0} hittades, men kan inte laddas"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1-drivrutinen klass {0} laddades, men kan inte instansieras"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1-drivrutinen klass {0} implementerar inte org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Systemegenskapen org.xml.sax.parser \u00E4r inte angiven"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "Parserargument m\u00E5ste vara null"}, + + { ER_FEATURE, + "Funktion: {0}"}, + + { ER_PROPERTY, + "Egenskap: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "Enhetsmatchning med v\u00E4rde null"}, + + { ER_NULL_DTD_HANDLER, + "DTD-hanterare med v\u00E4rde null"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "Inget angivet drivrutinsnamn!"}, + + { ER_NO_URL_SPECIFIED, + "Ingen URL angiven!"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "Poolstorlek \u00E4r mindre \u00E4n ett!"}, + + { ER_INVALID_DRIVER_NAME, + "Ogiltigt drivrutinsnamn angivet!"}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "Programmerarfel! Uttrycket har ingen \u00F6verordnad ElemTemplateElement!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Programmerarens utsaga i RedundentExprEliminator: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "{0} \u00E4r inte till\u00E5ten i denna position i formatmallen!"}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Text utan blanktecken \u00E4r inte till\u00E5ten i denna position i formatmallen!"}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r CHAR-attributet: {0}. Ett attribut av CHAR-typ f\u00E5r bara ha 1 tecken!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r QNAME-attributet: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r ENUM-attributet: {0}. Giltiga v\u00E4rden \u00E4r: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r NMTOKEN-attributet: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r NCNAME-attributet: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r boolean-attributet: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r number-attributet: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "Argument f\u00F6r {0} i matchningsm\u00F6nstret m\u00E5ste vara litteral."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "Dubbel deklaration av global variabel."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "Dubbel deklaration av variabel."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template m\u00E5ste ha name- och/eller match-attribut"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "Prefix i exclude-result-prefixes \u00E4r inte giltigt: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "attributserien {0} finns inte"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "Det finns ingen funktion med namnet {0}"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "Elementet {0} kan inte ha b\u00E5de inneh\u00E5ll och select-attribut."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "Parameterv\u00E4rdet f\u00F6r {0} m\u00E5ste vara giltigt Java-objekt"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "result-prefix-attributet i xsl:namespace-alias-element har v\u00E4rdet '#default', men det finns ingen deklaration av standardnamnrymd inom omfattningen av elementet"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "result-prefix-attributet i xsl:namespace-alias-element har v\u00E4rdet ''{0}'', men det finns ingen deklaration av namnrymd f\u00F6r prefixet ''{0}'' inom omfattningen av elementet."}, + + { ER_SET_FEATURE_NULL_NAME, + "Funktionsnamnet kan inte vara null i TransformerFactory.setFeature(namn p\u00E5 str\u00E4ng, booleskt v\u00E4rde)."}, + + { ER_GET_FEATURE_NULL_NAME, + "Funktionsnamnet kan inte vara null i TransformerFactory.getFeature(namn p\u00E5 str\u00E4ng)."}, + + { ER_UNSUPPORTED_FEATURE, + "Kan inte st\u00E4lla in funktionen ''{0}'' i denna TransformerFactory."}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Anv\u00E4ndning av till\u00E4ggselementet ''{0}'' \u00E4r inte till\u00E5tet n\u00E4r s\u00E4ker bearbetning till\u00E4mpas."}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Kan inte h\u00E4mta prefix f\u00F6r namnrymds-uri som \u00E4r null."}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Kan inte h\u00E4mta namnrymds-uri f\u00F6r prefix som \u00E4r null."}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "Funktionsnamn f\u00E5r inte vara null."}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "Ariteten kan inte vara negativ."}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "Hittade '}' men det finns ingen \u00F6ppen attributmall!"}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Varning: r\u00E4knarattribut matchar inte \u00F6verordnad i xsl:number! Target = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Gammal syntax: Namnet p\u00E5 'expr'-attributet har \u00E4ndrats till 'select'."}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan hanterar \u00E4nnu inte spr\u00E5kkonventionen i funktionen format-number."}, + + { WG_LOCALE_NOT_FOUND, + "Varning: Hittade inte spr\u00E5kkonvention f\u00F6r xml:lang={0}"}, + + { WG_CANNOT_MAKE_URL_FROM, + "Kan inte skapa URL fr\u00E5n: {0}"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "Kan inte ladda beg\u00E4rt dokument: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "Hittade inte kollationering f\u00F6r >>>>>> Xalan version "}, + { "version2", "<<<<<<<"}, + { "yes", "ja"}, + { "line", "Rad nr"}, + { "column","Kolumn nr"}, + { "xsldone", "XSLProcessor: utf\u00F6rd"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Process-klassalternativ f\u00F6r Xalan-J-kommandorad:"}, + { "xslProc_option", "Process-klassalternativ f\u00F6r Xalan-J-kommandorad:"}, + { "xslProc_invalid_xsltc_option", "Alternativet {0} underst\u00F6ds inte i XSLTC-l\u00E4ge."}, + { "xslProc_invalid_xalan_option", "Alternativet {0} kan anv\u00E4ndas endast med -XSLTC."}, + { "xslProc_no_input", "Fel: Ingen formatmall eller indata-xml har angetts. K\u00F6r kommandot utan n\u00E5got alternativ f\u00F6r att visa syntax."}, + { "xslProc_common_options", "-Allm\u00E4nna alternativ-"}, + { "xslProc_xalan_options", "-Alternativ f\u00F6r Xalan-"}, + { "xslProc_xsltc_options", "-Alternativ f\u00F6r XSLTC-"}, + { "xslProc_return_to_continue", "(tryck p\u00E5 Enter f\u00F6r att forts\u00E4tta)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (anv\u00E4nd XSLTC f\u00F6r transformering)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER fullt kvalificerat klassnamn p\u00E5 parserf\u00F6rbindelse]"}, + { "optionE", " [-E (Ut\u00F6ka inte enhetsreferenser)]"}, + { "optionV", " [-E (Ut\u00F6ka inte enhetsreferenser)]"}, + { "optionQC", " [-QC (Tysta m\u00F6nsterkonfliktvarningar)]"}, + { "optionQ", " [-Q (Tyst l\u00E4ge)]"}, + { "optionLF", " [-LF (Anv\u00E4nd radmatningar endast f\u00F6r utdata {standard \u00E4r CR/LF})]"}, + { "optionCR", " [-CR (Anv\u00E4nd radmatningar endast f\u00F6r utdata {standard \u00E4r CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (Vilka tecken \u00E4r skiftningstecken {standard \u00E4r <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (Best\u00E4m antal blanksteg f\u00F6r indrag {standard \u00E4r 0})]"}, + { "optionTT", " [-TT (Sp\u00E5ra mallar vid anrop.)]"}, + { "optionTG", " [-TG (Sp\u00E5ra varje generationsh\u00E4ndelse.)]"}, + { "optionTS", " [-TS (Sp\u00E5ra varje urvalsh\u00E4ndelse.)]"}, + { "optionTTC", " [-TTC (Sp\u00E5ra mallunderordnade n\u00E4r de bearbetas.)]"}, + { "optionTCLASS", " [-TCLASS (TraceListener-klass f\u00F6r sp\u00E5rningstill\u00E4gg.)]"}, + { "optionVALIDATE", " [-VALIDATE (St\u00E4ll in om validering utf\u00F6rs. Standard \u00E4r att validering \u00E4r avst\u00E4ngd.)]"}, + { "optionEDUMP", " [-EDUMP {valfritt filnamn} (G\u00F6r stackdump vid fel.)]"}, + { "optionXML", " [-XML (Anv\u00E4nd XML-formaterare och l\u00E4gg till XML-huvud.)]"}, + { "optionTEXT", " [-TEXT (Anv\u00E4nd enkel textformaterare.)]"}, + { "optionHTML", " [-HTML (Anv\u00E4nd HTML-formaterare.)]"}, + { "optionPARAM", " [-PARAM-namnuttryck (St\u00E4ll in parameter f\u00F6r formatmall)]"}, + { "noParsermsg1", "XSL-processen utf\u00F6rdes inte."}, + { "noParsermsg2", "** Hittade inte parser **"}, + { "noParsermsg3", "Kontrollera klass\u00F6kv\u00E4gen."}, + { "noParsermsg4", "Om du inte har IBMs XML Parser f\u00F6r Java kan du ladda ned den fr\u00E5n"}, + { "noParsermsg5", "IBMs AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER fullst\u00E4ndigt klassnamn (URIResolver som anv\u00E4nds vid matchning av URI-er)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER fullst\u00E4ndigt klassnamn (EntityResolver som anv\u00E4nds vid matchning av enheter)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER fullst\u00E4ndigt klassnamn (ContentHandler som anv\u00E4nds vid serialisering av utdata)]"}, + { "optionLINENUMBERS", " [-L anv\u00E4nd radnummer i k\u00E4lldokument]"}, + { "optionSECUREPROCESSING", " [-SECURE (ange att s\u00E4ker bearbetning ska till\u00E4mpas.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (anv\u00E4nd medieattribut f\u00F6r att hitta formatmall som h\u00F6r ihop med dokument.)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (Anv\u00E4nd s2s=SAX eller d2d=DOM vid transformering.)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (Skriv ut tid f\u00F6r transformering i millisekunder.)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (beg\u00E4r inkrementell DTM-konstruktion genom att ange http://xml.apache.org/xalan/features/incremental true.)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (beg\u00E4r att ingen formatmallsoptimering utf\u00F6rs genom att ange http://xml.apache.org/xalan/features/optimize false.)]"}, + { "optionRL", " [-RL rekursionsgr\u00E4ns (verifiera numeriskt gr\u00E4nsv\u00E4rde f\u00F6r formatmallens rekursionsdjup.)]"}, + { "optionXO", " [-XO [transletName] (tilldela namnet till genererad translet)]"}, + { "optionXD", " [-XD destinationDirectory (ange destinationskatalog f\u00F6r translet)]"}, + { "optionXJ", " [-XJ jarfile (paketerar transletklasserna i en jar-fil med namnet )]"}, + { "optionXP", " [-XP package (anger paketnamnsprefix f\u00F6r alla genererade transletklasser)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (aktiverar mallinfogning)]" }, + { "optionXX", " [-XX (aktiverar ytterligare fels\u00F6kningsmeddelanden)]"}, + { "optionXT" , " [-XT (anv\u00E4nder translet vid transformering om m\u00F6jligt)]"}, + { "diagTiming"," --------- Transformering av {0} via {1} tog {2} ms" }, + { "recursionTooDeep","Mallkapslingen \u00E4r f\u00F6r djup. kapsling = {0}, mall {1} {2}" }, + { "nameIs", "namnet \u00E4r" }, + { "matchPatternIs", "matchningsm\u00F6nstret \u00E4r" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java new file mode 100644 index 000000000..07b91a7ae --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_zh_CN extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "\u9519\u8BEF: \u8868\u8FBE\u5F0F\u4E2D\u4E0D\u80FD\u5305\u542B '{'"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0}\u5177\u6709\u975E\u6CD5\u5C5E\u6027: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode \u5728 xsl:apply-imports \u4E2D\u4E3A\u7A7A\u503C!"}, + + {ER_CANNOT_ADD, + "\u65E0\u6CD5\u5411{1}\u6DFB\u52A0{0}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u5728 handleApplyTemplatesInstruction \u4E2D\u4E3A\u7A7A\u503C!"}, + + { ER_NO_NAME_ATTRIB, + "{0}\u5FC5\u987B\u5177\u6709 name \u5C5E\u6027\u3002"}, + + {ER_TEMPLATE_NOT_FOUND, + "\u627E\u4E0D\u5230\u540D\u4E3A{0}\u7684\u6A21\u677F"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "\u65E0\u6CD5\u89E3\u6790 xsl:call-template \u4E2D\u7684\u540D\u79F0 AVT\u3002"}, + + {ER_REQUIRES_ATTRIB, + "{0}\u9700\u8981\u5C5E\u6027: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0}\u5FC5\u987B\u5177\u6709 ''test'' \u5C5E\u6027\u3002"}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "level \u5C5E\u6027\u7684\u503C\u9519\u8BEF: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction \u540D\u79F0\u4E0D\u80FD\u4E3A 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction \u540D\u79F0\u5FC5\u987B\u662F\u6709\u6548\u7684 NCName: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "\u5982\u679C{0}\u5177\u6709\u67D0\u79CD\u6A21\u5F0F, \u5219\u5FC5\u987B\u5177\u6709 match \u5C5E\u6027\u3002"}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0}\u9700\u8981 name \u6216 match \u5C5E\u6027\u3002"}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\u65E0\u6CD5\u89E3\u6790\u540D\u79F0\u7A7A\u95F4\u524D\u7F00: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space \u5177\u6709\u975E\u6CD5\u503C: {0}"}, + + { ER_NO_OWNERDOC, + "\u5B50\u8282\u70B9\u6CA1\u6709\u6240\u6709\u8005\u6587\u6863!"}, + + { ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement \u9519\u8BEF: {0}"}, + + { ER_NULL_CHILD, + "\u6B63\u5728\u5C1D\u8BD5\u6DFB\u52A0\u7A7A\u5B50\u7EA7!"}, + + { ER_NEED_SELECT_ATTRIB, + "{0}\u9700\u8981 select \u5C5E\u6027\u3002"}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when \u5FC5\u987B\u5177\u6709 'test' \u5C5E\u6027\u3002"}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param \u5FC5\u987B\u5177\u6709 'name' \u5C5E\u6027\u3002"}, + + { ER_NO_CONTEXT_OWNERDOC, + "\u4E0A\u4E0B\u6587\u6CA1\u6709\u6240\u6709\u8005\u6587\u6863!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "\u65E0\u6CD5\u521B\u5EFA XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \u8FDB\u7A0B\u672A\u6210\u529F\u3002"}, + + { ER_NOT_SUCCESSFUL, + "Xalan: \u672A\u6210\u529F\u3002"}, + + { ER_ENCODING_NOT_SUPPORTED, + "\u4E0D\u652F\u6301\u7F16\u7801: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "\u65E0\u6CD5\u521B\u5EFA TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key \u9700\u8981 'name' \u5C5E\u6027!"}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key \u9700\u8981 'match' \u5C5E\u6027!"}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key \u9700\u8981 'use' \u5C5E\u6027!"}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0}\u9700\u8981 ''elements'' \u5C5E\u6027!"}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) \u7F3A\u5C11{0}\u5C5E\u6027 ''prefix''"}, + + { ER_BAD_STYLESHEET_URL, + "\u6837\u5F0F\u8868 URL \u9519\u8BEF: {0}"}, + + { ER_FILE_NOT_FOUND, + "\u627E\u4E0D\u5230\u6837\u5F0F\u8868\u6587\u4EF6: {0}"}, + + { ER_IOEXCEPTION, + "\u6837\u5F0F\u8868\u6587\u4EF6\u51FA\u73B0 IO \u5F02\u5E38\u9519\u8BEF: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) \u627E\u4E0D\u5230{0}\u7684 href \u5C5E\u6027"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0}\u76F4\u63A5\u6216\u95F4\u63A5\u5305\u542B\u5176\u81EA\u8EAB!"}, + + { ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude \u9519\u8BEF, {0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) \u7F3A\u5C11{0}\u5C5E\u6027 ''lang''"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0}\u5143\u7D20\u7684\u653E\u7F6E\u4F4D\u7F6E\u662F\u5426\u9519\u8BEF?? \u7F3A\u5C11\u5BB9\u5668\u5143\u7D20 ''component''"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "\u53EA\u80FD\u8F93\u51FA\u5230 Element, DocumentFragment, Document \u6216 PrintWriter\u3002"}, + + { ER_PROCESS_ERROR, + "StylesheetRoot.process \u9519\u8BEF"}, + + { ER_UNIMPLNODE_ERROR, + "UnImplNode \u9519\u8BEF: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "\u9519\u8BEF! \u627E\u4E0D\u5230 xpath \u9009\u62E9\u8868\u8FBE\u5F0F (-select)\u3002"}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "\u65E0\u6CD5\u5E8F\u5217\u5316 XSLProcessor!"}, + + { ER_NO_INPUT_STYLESHEET, + "\u672A\u6307\u5B9A\u6837\u5F0F\u8868\u8F93\u5165!"}, + + { ER_FAILED_PROCESS_STYLESHEET, + "\u65E0\u6CD5\u5904\u7406\u6837\u5F0F\u8868!"}, + + { ER_COULDNT_PARSE_DOC, + "\u65E0\u6CD5\u89E3\u6790{0}\u6587\u6863!"}, + + { ER_COULDNT_FIND_FRAGMENT, + "\u627E\u4E0D\u5230\u7247\u6BB5: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "\u7247\u6BB5\u6807\u8BC6\u7B26\u6307\u5411\u7684\u8282\u70B9\u4E0D\u662F\u5143\u7D20: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each \u5FC5\u987B\u5177\u6709 match \u6216 name \u5C5E\u6027"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates \u5FC5\u987B\u5177\u6709 match \u6216 name \u5C5E\u6027"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\u4E0D\u80FD\u514B\u9686\u6587\u6863\u7247\u6BB5!"}, + + { ER_CANT_CREATE_ITEM, + "\u65E0\u6CD5\u5728\u7ED3\u679C\u6811\u4E2D\u521B\u5EFA\u9879: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "\u6E90 XML \u4E2D\u7684 xml:space \u5177\u6709\u975E\u6CD5\u503C: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "{0}\u6CA1\u6709 xsl:key \u58F0\u660E!"}, + + { ER_CANT_CREATE_URL, + "\u9519\u8BEF! \u65E0\u6CD5\u4E3A{0}\u521B\u5EFA url"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "\u4E0D\u652F\u6301 xsl:functions"}, + + { ER_PROCESSOR_ERROR, + "XSLT TransformerFactory \u9519\u8BEF"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) \u6837\u5F0F\u8868\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528{0}!"}, + + { ER_RESULTNS_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u6301 result-ns! \u8BF7\u6539\u7528 xsl:output\u3002"}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u6301 default-space! \u8BF7\u6539\u7528 xsl:strip-space \u6216 xsl:preserve-space\u3002"}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u6301 indent-result! \u8BF7\u6539\u7528 xsl:output\u3002"}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0}\u5177\u6709\u975E\u6CD5\u5C5E\u6027: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "\u672A\u77E5 XSL \u5143\u7D20: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort \u53EA\u80FD\u4E0E xsl:apply-templates \u6216 xsl:for-each \u4E00\u8D77\u4F7F\u7528\u3002"}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when \u7684\u653E\u7F6E\u4F4D\u7F6E\u9519\u8BEF!"}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when \u7684\u7236\u7EA7\u4E0D\u662F xsl:choose!"}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise \u7684\u653E\u7F6E\u4F4D\u7F6E\u9519\u8BEF!"}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise \u7684\u7236\u7EA7\u4E0D\u662F xsl:choose!"}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) \u6A21\u677F\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528{0}!"}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0}\u6269\u5C55\u540D\u79F0\u7A7A\u95F4\u524D\u7F00 {1} \u672A\u77E5"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \u53EA\u80FD\u4F5C\u4E3A\u6837\u5F0F\u8868\u4E2D\u7684\u7B2C\u4E00\u4E2A\u5143\u7D20\u5BFC\u5165!"}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0}\u76F4\u63A5\u6216\u95F4\u63A5\u5BFC\u5165\u5176\u81EA\u8EAB!"}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space \u5177\u6709\u975E\u6CD5\u503C: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet \u5931\u8D25!"}, + + { ER_SAX_EXCEPTION, + "SAX \u5F02\u5E38\u9519\u8BEF"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "\u4E0D\u652F\u6301\u8BE5\u51FD\u6570!"}, + + { ER_XSLT_ERROR, + "XSLT \u9519\u8BEF"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "\u683C\u5F0F\u6A21\u5F0F\u5B57\u7B26\u4E32\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u8D27\u5E01\u7B26\u53F7"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "\u6837\u5F0F\u8868 DOM \u4E2D\u4E0D\u652F\u6301 Document \u51FD\u6570!"}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\u65E0\u6CD5\u89E3\u6790\u975E\u524D\u7F00\u89E3\u6790\u5668\u7684\u524D\u7F00!"}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "\u91CD\u5B9A\u5411\u6269\u5C55: \u65E0\u6CD5\u83B7\u53D6\u6587\u4EF6\u540D - file \u6216 select \u5C5E\u6027\u5FC5\u987B\u8FD4\u56DE\u6709\u6548\u5B57\u7B26\u4E32\u3002"}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\u65E0\u6CD5\u5728\u91CD\u5B9A\u5411\u6269\u5C55\u4E2D\u6784\u5EFA FormatterListener!"}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F00\u65E0\u6548: {0}"}, + + { ER_MISSING_NS_URI, + "\u6307\u5B9A\u524D\u7F00\u7F3A\u5C11\u540D\u79F0\u7A7A\u95F4 URI"}, + + { ER_MISSING_ARG_FOR_OPTION, + "\u9009\u9879\u7F3A\u5C11\u53C2\u6570: {0}"}, + + { ER_INVALID_OPTION, + "\u9009\u9879\u65E0\u6548: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "\u683C\u5F0F\u5B57\u7B26\u4E32\u7684\u683C\u5F0F\u9519\u8BEF: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet \u9700\u8981 'version' \u5C5E\u6027!"}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "\u5C5E\u6027{0}\u5177\u6709\u975E\u6CD5\u503C: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose \u9700\u8981 xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:for-each \u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528 xsl:apply-imports"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "\u65E0\u6CD5\u5C06 DTMLiaison \u7528\u4E8E\u8F93\u51FA DOM \u8282\u70B9... \u8BF7\u6539\u4E3A\u4F20\u9012 com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "\u65E0\u6CD5\u5C06 DTMLiaison \u7528\u4E8E\u8F93\u5165 DOM \u8282\u70B9... \u8BF7\u6539\u4E3A\u4F20\u9012 com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + { ER_CALL_TO_EXT_FAILED, + "\u672A\u80FD\u8C03\u7528\u6269\u5C55\u5143\u7D20: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "\u524D\u7F00\u5FC5\u987B\u89E3\u6790\u4E3A\u540D\u79F0\u7A7A\u95F4: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "\u68C0\u6D4B\u5230\u65E0\u6548\u7684 UTF-16 \u4EE3\u7406: {0}?"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} \u4F7F\u7528\u5176\u81EA\u8EAB, \u8FD9\u5C06\u5BFC\u81F4\u65E0\u9650\u5FAA\u73AF\u3002"}, + + { ER_CANNOT_MIX_XERCESDOM, + "\u65E0\u6CD5\u6DF7\u5408\u975E Xerces-DOM \u8F93\u5165\u548C Xerces-DOM \u8F93\u51FA!"}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "\u5728 ElemTemplateElement.readObject \u4E2D: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "\u627E\u5230\u591A\u4E2A\u540D\u4E3A{0}\u7684\u6A21\u677F"}, + + { ER_INVALID_KEY_CALL, + "\u51FD\u6570\u8C03\u7528\u65E0\u6548: \u4E0D\u5141\u8BB8\u9012\u5F52 key() \u8C03\u7528"}, + + { ER_REFERENCING_ITSELF, + "\u53D8\u91CF {0} \u76F4\u63A5\u6216\u95F4\u63A5\u5F15\u7528\u5176\u81EA\u8EAB!"}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "\u5BF9\u4E8E newTemplates \u7684 DOMSource, \u8F93\u5165\u8282\u70B9\u4E0D\u80FD\u4E3A\u7A7A\u503C!"}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "\u627E\u4E0D\u5230\u9009\u9879{0}\u7684\u7C7B\u6587\u4EF6"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "\u627E\u4E0D\u5230\u6240\u9700\u5143\u7D20: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + { ER_URI_CANNOT_BE_NULL, + "URI \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + { ER_FILE_CANNOT_BE_NULL, + "File \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + { ER_CANNOT_INIT_BSFMGR, + "\u65E0\u6CD5\u521D\u59CB\u5316 BSF \u7BA1\u7406\u5668"}, + + { ER_CANNOT_CMPL_EXTENSN, + "\u65E0\u6CD5\u7F16\u8BD1\u6269\u5C55"}, + + { ER_CANNOT_CREATE_EXTENSN, + "\u65E0\u6CD5\u521B\u5EFA\u6269\u5C55: {0}, \u539F\u56E0: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "\u5BF9\u65B9\u6CD5{0}\u7684\u5B9E\u4F8B\u65B9\u6CD5\u8C03\u7528\u9700\u8981\u5C06 Object \u5B9E\u4F8B\u4F5C\u4E3A\u7B2C\u4E00\u4E2A\u53C2\u6570"}, + + { ER_INVALID_ELEMENT_NAME, + "\u6307\u5B9A\u7684\u5143\u7D20\u540D\u79F0{0}\u65E0\u6548"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "\u5143\u7D20\u540D\u79F0\u65B9\u6CD5\u5FC5\u987B\u662F static {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "\u6269\u5C55\u51FD\u6570 {0}: {1} \u672A\u77E5"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "{0}\u7684\u6784\u9020\u5668\u5177\u6709\u591A\u4E2A\u6700\u4F73\u5339\u914D"}, + + { ER_MORE_MATCH_METHOD, + "\u65B9\u6CD5{0}\u5177\u6709\u591A\u4E2A\u6700\u4F73\u5339\u914D"}, + + { ER_MORE_MATCH_ELEMENT, + "\u5143\u7D20\u65B9\u6CD5{0}\u5177\u6709\u591A\u4E2A\u6700\u4F73\u5339\u914D"}, + + { ER_INVALID_CONTEXT_PASSED, + "\u4F20\u9012\u7684\u7528\u4E8E\u5BF9{0}\u6C42\u503C\u7684\u4E0A\u4E0B\u6587\u65E0\u6548"}, + + { ER_POOL_EXISTS, + "\u6C60\u5DF2\u5B58\u5728"}, + + { ER_NO_DRIVER_NAME, + "\u672A\u6307\u5B9A\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0"}, + + { ER_NO_URL, + "\u672A\u6307\u5B9A URL"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "\u6C60\u5927\u5C0F\u5C0F\u4E8E 1!"}, + + { ER_INVALID_DRIVER, + "\u6307\u5B9A\u7684\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0\u65E0\u6548!"}, + + { ER_NO_STYLESHEETROOT, + "\u627E\u4E0D\u5230\u6837\u5F0F\u8868\u6839!"}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space \u7684\u503C\u975E\u6CD5"}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode \u5931\u8D25"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "\u8D44\u6E90 [ {0} ] \u65E0\u6CD5\u52A0\u8F7D: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\u7F13\u51B2\u533A\u5927\u5C0F <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\u8C03\u7528\u6269\u5C55\u65F6\u51FA\u73B0\u672A\u77E5\u9519\u8BEF"}, + + { ER_NO_NAMESPACE_DECL, + "\u524D\u7F00 {0} \u6CA1\u6709\u5BF9\u5E94\u7684\u540D\u79F0\u7A7A\u95F4\u58F0\u660E"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "lang=javaclass {0}\u4E0D\u5141\u8BB8\u4F7F\u7528\u5143\u7D20\u5185\u5BB9"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "\u6837\u5F0F\u8868\u6307\u5411\u7EC8\u6B62"}, + + { ER_ONE_OR_TWO, + "1 \u6216 2"}, + + { ER_TWO_OR_THREE, + "2 \u6216 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "\u65E0\u6CD5\u52A0\u8F7D{0} (\u68C0\u67E5 CLASSPATH), \u73B0\u5728\u53EA\u4F7F\u7528\u9ED8\u8BA4\u503C"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\u65E0\u6CD5\u521D\u59CB\u5316\u9ED8\u8BA4\u6A21\u677F"}, + + { ER_RESULT_NULL, + "Result \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "\u65E0\u6CD5\u8BBE\u7F6E Result"}, + + { ER_NO_OUTPUT_SPECIFIED, + "\u672A\u6307\u5B9A\u8F93\u51FA"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "\u65E0\u6CD5\u8F6C\u6362\u4E3A\u7C7B\u578B\u4E3A{0}\u7684 Result"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "\u65E0\u6CD5\u8F6C\u6362\u7C7B\u578B\u4E3A{0}\u7684\u6E90"}, + + { ER_NULL_CONTENT_HANDLER, + "\u7A7A\u5185\u5BB9\u5904\u7406\u7A0B\u5E8F"}, + + { ER_NULL_ERROR_HANDLER, + "\u7A7A\u9519\u8BEF\u5904\u7406\u7A0B\u5E8F"}, + + { ER_CANNOT_CALL_PARSE, + "\u5982\u679C\u5C1A\u672A\u8BBE\u7F6E ContentHandler, \u5219\u65E0\u6CD5\u8C03\u7528 parse"}, + + { ER_NO_PARENT_FOR_FILTER, + "\u7B5B\u9009\u5668\u6CA1\u6709\u7236\u7EA7"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "\u5728{0}\u4E2D\u627E\u4E0D\u5230\u6837\u5F0F\u8868, \u4ECB\u8D28= {1}"}, + + { ER_NO_STYLESHEET_PI, + "\u5728{0}\u4E2D\u627E\u4E0D\u5230 xml-stylesheet PI"}, + + { ER_NOT_SUPPORTED, + "\u4E0D\u652F\u6301: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "\u5C5E\u6027{0}\u7684\u503C\u5E94\u4E3A Boolean \u5B9E\u4F8B"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "\u65E0\u6CD5\u5728{0}\u4E2D\u83B7\u53D6\u5916\u90E8\u811A\u672C"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "\u627E\u4E0D\u5230\u8D44\u6E90 [ {0} ]\u3002\n {1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\u65E0\u6CD5\u8BC6\u522B\u8F93\u51FA\u5C5E\u6027: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "\u672A\u80FD\u521B\u5EFA ElemLiteralResult \u5B9E\u4F8B"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "{0}\u7684\u503C\u5E94\u5305\u542B\u53EF\u89E3\u6790\u7684\u6570\u5B57"}, + + { ER_VALUE_SHOULD_EQUAL, + "{0}\u7684\u503C\u5E94\u7B49\u4E8E\u201C\u662F\u201D\u6216\u201C\u5426\u201D"}, + + { ER_FAILED_CALLING_METHOD, + "\u672A\u80FD\u8C03\u7528{0}\u65B9\u6CD5"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "\u672A\u80FD\u521B\u5EFA ElemTemplateElement \u5B9E\u4F8B"}, + + { ER_CHARS_NOT_ALLOWED, + "\u4E0D\u5141\u8BB8\u5728\u6587\u6863\u4E2D\u7684\u6B64\u4F4D\u7F6E\u5904\u4F7F\u7528\u5B57\u7B26"}, + + { ER_ATTR_NOT_ALLOWED, + "{1}\u5143\u7D20\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528 \"{0}\" \u5C5E\u6027!"}, + + { ER_BAD_VALUE, + "{0}\u9519\u8BEF\u503C{1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "\u627E\u4E0D\u5230{0}\u5C5E\u6027\u503C "}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "\u65E0\u6CD5\u8BC6\u522B{0}\u5C5E\u6027\u503C "}, + + { ER_NULL_URI_NAMESPACE, + "\u5C1D\u8BD5\u4F7F\u7528\u7A7A URI \u751F\u6210\u540D\u79F0\u7A7A\u95F4\u524D\u7F00"}, + + { ER_NUMBER_TOO_BIG, + "\u5C1D\u8BD5\u8BBE\u7F6E\u8D85\u8FC7\u6700\u5927\u957F\u6574\u578B\u7684\u6570\u5B57\u7684\u683C\u5F0F"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "\u627E\u4E0D\u5230 SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B{0}"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "\u5DF2\u627E\u5230 SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B{0}, \u4F46\u65E0\u6CD5\u8FDB\u884C\u52A0\u8F7D"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "\u5DF2\u52A0\u8F7D SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B{0}, \u4F46\u65E0\u6CD5\u8FDB\u884C\u5B9E\u4F8B\u5316"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B {0} \u672A\u5B9E\u73B0 org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\u672A\u6307\u5B9A\u7CFB\u7EDF\u5C5E\u6027 org.xml.sax.parser"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "\u89E3\u6790\u5668\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + { ER_FEATURE, + "\u529F\u80FD: {0}"}, + + { ER_PROPERTY, + "\u5C5E\u6027: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "\u7A7A\u5B9E\u4F53\u89E3\u6790\u5668"}, + + { ER_NULL_DTD_HANDLER, + "\u7A7A DTD \u5904\u7406\u7A0B\u5E8F"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "\u672A\u6307\u5B9A\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0!"}, + + { ER_NO_URL_SPECIFIED, + "\u672A\u6307\u5B9A URL!"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "\u6C60\u5927\u5C0F\u5C0F\u4E8E 1!"}, + + { ER_INVALID_DRIVER_NAME, + "\u6307\u5B9A\u7684\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0\u65E0\u6548!"}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "\u7A0B\u5E8F\u5458\u9519\u8BEF! \u8868\u8FBE\u5F0F\u6CA1\u6709 ElemTemplateElement \u7236\u7EA7!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "RedundentExprEliminator \u4E2D\u7684\u7A0B\u5E8F\u5458\u65AD\u8A00: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "\u4E0D\u5141\u8BB8\u5728\u6837\u5F0F\u8868\u4E2D\u7684\u6B64\u4F4D\u7F6E\u4F7F\u7528{0}!"}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\u4E0D\u5141\u8BB8\u5728\u6837\u5F0F\u8868\u4E2D\u7684\u6B64\u4F4D\u7F6E\u4F7F\u7528\u975E\u7A7A\u767D\u6587\u672C!"}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "CHAR \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1}\u3002CHAR \u7C7B\u578B\u7684\u5C5E\u6027\u53EA\u80FD\u4E3A 1 \u4E2A\u5B57\u7B26!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "QNAME \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "ENUM \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1}\u3002\u6709\u6548\u503C\u4E3A: {2}\u3002"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "NMTOKEN \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "NCNAME \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "Boolean \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "Number \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "\u5339\u914D\u6A21\u5F0F\u4E2D\u7684{0}\u7684\u53C2\u6570\u5FC5\u987B\u4E3A\u6587\u5B57\u3002"}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "\u5168\u5C40\u53D8\u91CF\u58F0\u660E\u91CD\u590D\u3002"}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "\u53D8\u91CF\u58F0\u660E\u91CD\u590D\u3002"}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template \u5FC5\u987B\u5177\u6709 name \u548C/\u6216 match \u5C5E\u6027"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F00\u65E0\u6548: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "\u540D\u4E3A{0}\u7684\u5C5E\u6027\u96C6\u4E0D\u5B58\u5728"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "\u540D\u4E3A{0}\u7684\u51FD\u6570\u4E0D\u5B58\u5728"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0}\u5143\u7D20\u4E0D\u80FD\u540C\u65F6\u5177\u6709\u5185\u5BB9\u548C select \u5C5E\u6027\u3002"}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "\u53C2\u6570 {0} \u7684\u503C\u5FC5\u987B\u662F\u6709\u6548 Java \u5BF9\u8C61"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C5E\u6027\u5177\u6709\u503C '#default', \u4F46\u8BE5\u5143\u7D20\u7684\u4F5C\u7528\u57DF\u4E2D\u6CA1\u6709\u9ED8\u8BA4\u540D\u79F0\u7A7A\u95F4\u7684\u58F0\u660E"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C5E\u6027\u5177\u6709\u503C ''{0}'', \u4F46\u8BE5\u5143\u7D20\u7684\u4F5C\u7528\u57DF\u4E2D\u6CA1\u6709\u524D\u7F00 ''{0}'' \u7684\u540D\u79F0\u7A7A\u95F4\u58F0\u660E\u3002"}, + + { ER_SET_FEATURE_NULL_NAME, + "TransformerFactory.setFeature(String name, boolean value) \u4E2D\u7684\u529F\u80FD\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u503C\u3002"}, + + { ER_GET_FEATURE_NULL_NAME, + "TransformerFactory.getFeature(String name) \u4E2D\u7684\u529F\u80FD\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u503C\u3002"}, + + { ER_UNSUPPORTED_FEATURE, + "\u65E0\u6CD5\u5BF9\u6B64 TransformerFactory \u8BBE\u7F6E\u529F\u80FD ''{0}''\u3002"}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\u5F53\u5B89\u5168\u5904\u7406\u529F\u80FD\u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u65F6, \u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u5143\u7D20 ''{0}''\u3002"}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "\u65E0\u6CD5\u83B7\u53D6\u7A7A\u540D\u79F0\u7A7A\u95F4 uri \u7684\u524D\u7F00\u3002"}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "\u65E0\u6CD5\u83B7\u53D6\u7A7A\u524D\u7F00\u7684\u540D\u79F0\u7A7A\u95F4 uri\u3002"}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "\u51FD\u6570\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u503C\u3002"}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "\u5143\u6570\u4E0D\u80FD\u4E3A\u8D1F\u6570\u3002"}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "\u5DF2\u627E\u5230 '}', \u4F46\u672A\u6253\u5F00\u5C5E\u6027\u6A21\u677F!"}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\u8B66\u544A: count \u5C5E\u6027\u4E0E xsl:number \u4E2D\u7684 ancestor \u4E0D\u5339\u914D! \u76EE\u6807 = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\u65E7\u8BED\u6CD5: 'expr' \u5C5E\u6027\u7684\u540D\u79F0\u5DF2\u66F4\u6539\u4E3A 'select'\u3002"}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan \u5C1A\u672A\u5904\u7406 format-number \u51FD\u6570\u4E2D\u7684\u533A\u57DF\u8BBE\u7F6E\u540D\u79F0\u3002"}, + + { WG_LOCALE_NOT_FOUND, + "\u8B66\u544A: \u627E\u4E0D\u5230 xml:lang={0} \u7684\u533A\u57DF\u8BBE\u7F6E"}, + + { WG_CANNOT_MAKE_URL_FROM, + "\u65E0\u6CD5\u6839\u636E{0}\u751F\u6210 URL"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "\u65E0\u6CD5\u52A0\u8F7D\u8BF7\u6C42\u7684\u6587\u6863: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "\u627E\u4E0D\u5230 >>>>>> Xalan \u7248\u672C "}, + { "version2", "<<<<<<<"}, + { "yes", "\u662F"}, + { "line", "\u884C\u53F7"}, + { "column","\u5217\u53F7"}, + { "xsldone", "XSLProcessor: \u5B8C\u6210"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Xalan-J \u547D\u4EE4\u884C Process \u7C7B\u9009\u9879:"}, + { "xslProc_option", "Xalan-J \u547D\u4EE4\u884C Process \u7C7B\u9009\u9879:"}, + { "xslProc_invalid_xsltc_option", "XSLTC \u6A21\u5F0F\u4E0B\u4E0D\u652F\u6301\u9009\u9879{0}\u3002"}, + { "xslProc_invalid_xalan_option", "\u9009\u9879{0}\u53EA\u80FD\u4E0E -XSLTC \u4E00\u8D77\u4F7F\u7528\u3002"}, + { "xslProc_no_input", "\u9519\u8BEF: \u672A\u6307\u5B9A\u6837\u5F0F\u8868\u6216\u8F93\u5165 xml\u3002\u8FD0\u884C\u6B64\u547D\u4EE4\u65F6, \u7528\u6CD5\u6307\u4EE4\u4E0D\u5E26\u4EFB\u4F55\u9009\u9879\u3002"}, + { "xslProc_common_options", "-\u516C\u7528\u9009\u9879-"}, + { "xslProc_xalan_options", "-Xalan \u7684\u9009\u9879-"}, + { "xslProc_xsltc_options", "-XSLTC \u7684\u9009\u9879-"}, + { "xslProc_return_to_continue", "(\u6309 \u4EE5\u7EE7\u7EED)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (\u4F7F\u7528 XSLTC \u8FDB\u884C\u8F6C\u6362)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER fully qualified class name of parser liaison]"}, + { "optionE", " [-E (\u4E0D\u5C55\u5F00\u5B9E\u4F53\u5F15\u7528)]"}, + { "optionV", " [-E (\u4E0D\u5C55\u5F00\u5B9E\u4F53\u5F15\u7528)]"}, + { "optionQC", " [-QC (\u65E0\u63D0\u793A\u6A21\u5F0F\u51B2\u7A81\u8B66\u544A)]"}, + { "optionQ", " [-Q (\u65E0\u63D0\u793A\u6A21\u5F0F)]"}, + { "optionLF", " [-LF (\u4EC5\u5728\u8F93\u51FA\u65F6\u4F7F\u7528\u6362\u884C\u7B26 {\u9ED8\u8BA4\u503C\u4E3A CR/LF})]"}, + { "optionCR", " [-CR (\u4EC5\u5728\u8F93\u51FA\u65F6\u4F7F\u7528\u56DE\u8F66 {\u9ED8\u8BA4\u503C\u4E3A CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (\u8981\u8F6C\u79FB\u7684\u5B57\u7B26 {\u9ED8\u8BA4\u503C\u4E3A <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (\u63A7\u5236\u8981\u7F29\u8FDB\u7684\u7A7A\u683C\u6570 {\u9ED8\u8BA4\u503C\u4E3A 0})]"}, + { "optionTT", " [-TT (\u5728\u8C03\u7528\u6A21\u677F\u65F6\u8DDF\u8E2A\u6A21\u677F\u3002)]"}, + { "optionTG", " [-TG (\u8DDF\u8E2A\u6BCF\u4E2A\u751F\u6210\u4E8B\u4EF6\u3002)]"}, + { "optionTS", " [-TS (\u8DDF\u8E2A\u6BCF\u4E2A\u9009\u62E9\u4E8B\u4EF6\u3002)]"}, + { "optionTTC", " [-TTC (\u5728\u5904\u7406\u6A21\u677F\u5B50\u7EA7\u65F6\u8DDF\u8E2A\u6A21\u677F\u5B50\u7EA7\u3002)]"}, + { "optionTCLASS", " [-TCLASS (\u7528\u4E8E\u8DDF\u8E2A\u6269\u5C55\u7684 TraceListener \u7C7B\u3002)]"}, + { "optionVALIDATE", " [-VALIDATE (\u8BBE\u7F6E\u662F\u5426\u8FDB\u884C\u9A8C\u8BC1\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u5C06\u7981\u6B62\u9A8C\u8BC1\u3002)]"}, + { "optionEDUMP", " [-EDUMP {optional filename} (\u5728\u51FA\u9519\u65F6\u6267\u884C\u5806\u6808\u8F6C\u50A8\u3002)]"}, + { "optionXML", " [-XML (\u4F7F\u7528 XML \u683C\u5F0F\u8BBE\u7F6E\u5DE5\u5177\u5E76\u6DFB\u52A0 XML \u6807\u5934\u3002)]"}, + { "optionTEXT", " [-TEXT (\u4F7F\u7528\u7B80\u5355\u6587\u672C\u683C\u5F0F\u8BBE\u7F6E\u5DE5\u5177\u3002)]"}, + { "optionHTML", " [-HTML (\u4F7F\u7528 HTML \u683C\u5F0F\u8BBE\u7F6E\u5DE5\u5177\u3002)]"}, + { "optionPARAM", " [-PARAM \u540D\u79F0\u8868\u8FBE\u5F0F (\u8BBE\u7F6E\u6837\u5F0F\u8868\u53C2\u6570)]"}, + { "noParsermsg1", "XSL \u8FDB\u7A0B\u672A\u6210\u529F\u3002"}, + { "noParsermsg2", "** \u627E\u4E0D\u5230\u89E3\u6790\u5668 **"}, + { "noParsermsg3", "\u8BF7\u68C0\u67E5\u60A8\u7684\u7C7B\u8DEF\u5F84\u3002"}, + { "noParsermsg4", "\u5982\u679C\u6CA1\u6709 IBM \u63D0\u4F9B\u7684 XML Parser for Java, \u5219\u53EF\u4EE5\u4ECE"}, + { "noParsermsg5", "IBM AlphaWorks \u8FDB\u884C\u4E0B\u8F7D, \u7F51\u5740\u4E3A: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER \u5B8C\u6574\u7C7B\u540D (\u4F7F\u7528 URIResolver \u89E3\u6790 URI)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER \u5B8C\u6574\u7C7B\u540D (\u4F7F\u7528 EntityResolver \u89E3\u6790\u5B9E\u4F53)]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER \u5B8C\u6574\u7C7B\u540D (\u4F7F\u7528 ContentHandler \u5E8F\u5217\u5316\u8F93\u51FA)]"}, + { "optionLINENUMBERS", " [-L \u4F7F\u7528\u6E90\u6587\u6863\u7684\u884C\u53F7]"}, + { "optionSECUREPROCESSING", " [-SECURE (\u5C06\u5B89\u5168\u5904\u7406\u529F\u80FD\u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u3002)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (\u4F7F\u7528 media \u5C5E\u6027\u67E5\u627E\u4E0E\u6587\u6863\u5173\u8054\u7684\u6837\u5F0F\u8868\u3002)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (\u660E\u786E\u4F7F\u7528 s2s=SAX \u6216 d2d=DOM \u6267\u884C\u8F6C\u6362\u3002)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (\u8F93\u51FA\u5168\u90E8\u8F6C\u6362\u65F6\u95F4 (\u6BEB\u79D2)\u3002)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (\u901A\u8FC7\u5C06 http://xml.apache.org/xalan/features/incremental \u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u6765\u8BF7\u6C42\u589E\u91CF DTM \u6784\u5EFA\u3002)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (\u901A\u8FC7\u5C06 http://xml.apache.org/xalan/features/optimize \u8BBE\u7F6E\u4E3A\u201C\u5047\u201D\u6765\u8BF7\u6C42\u4E0D\u6267\u884C\u6837\u5F0F\u8868\u4F18\u5316\u5904\u7406\u3002)]"}, + { "optionRL", " [-RL recursionlimit (\u58F0\u660E\u6837\u5F0F\u8868\u9012\u5F52\u6DF1\u5EA6\u7684\u6570\u5B57\u9650\u5236\u3002)]"}, + { "optionXO", " [-XO [transletName] (\u4E3A\u751F\u6210\u7684 translet \u5206\u914D\u540D\u79F0)]"}, + { "optionXD", " [-XD destinationDirectory (\u6307\u5B9A translet \u7684\u76EE\u6807\u76EE\u5F55)]"}, + { "optionXJ", " [-XJ jarfile (\u5C06 translet \u7C7B\u6253\u5305\u5230\u540D\u4E3A \u7684 jar \u6587\u4EF6\u4E2D)]"}, + { "optionXP", " [-XP package (\u4E3A\u751F\u6210\u7684\u6240\u6709 translet \u7C7B\u6307\u5B9A\u7A0B\u5E8F\u5305\u540D\u79F0\u524D\u7F00)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (\u542F\u7528\u6A21\u677F\u5185\u5D4C)]" }, + { "optionXX", " [-XX (\u542F\u7528\u9644\u52A0\u8C03\u8BD5\u6D88\u606F\u8F93\u51FA)]"}, + { "optionXT" , " [-XT (\u5982\u679C\u53EF\u80FD, \u4F7F\u7528 translet \u8FDB\u884C\u8F6C\u6362)]"}, + { "diagTiming"," --------- \u901A\u8FC7{1}\u8F6C\u6362{0}\u82B1\u8D39\u4E86 {2} \u6BEB\u79D2\u7684\u65F6\u95F4" }, + { "recursionTooDeep","\u6A21\u677F\u5D4C\u5957\u592A\u6DF1\u3002\u5D4C\u5957 = {0}, \u6A21\u677F{1} {2}" }, + { "nameIs", "\u540D\u79F0\u4E3A" }, + { "matchPatternIs", "\u5339\u914D\u6A21\u5F0F\u4E3A" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java new file mode 100644 index 000000000..e6b4c8f40 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_zh_TW extends ListResourceBundle +{ + +/* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL= + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED" ; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL" ; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY" ; + public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() + { + return new Object[][] { + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000" , "{0}" }, + + { ER_NO_CURLYBRACE, + "\u932F\u8AA4: \u8868\u793A\u5F0F\u4E2D\u4E0D\u53EF\u6709 '{'"}, + + { ER_ILLEGAL_ATTRIBUTE , + "{0} \u5177\u6709\u7121\u6548\u5C6C\u6027: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS , + "sourceNode \u5728 xsl:apply-imports \u4E2D\u662F\u7A7A\u503C\uFF01"}, + + {ER_CANNOT_ADD, + "\u7121\u6CD5\u65B0\u589E {0} \u81F3 {1}"}, + + { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u5728 handleApplyTemplatesInstruction \u4E2D\u662F\u7A7A\u503C\uFF01"}, + + { ER_NO_NAME_ATTRIB, + "{0} \u5FC5\u9808\u6709\u540D\u7A31\u5C6C\u6027\u3002"}, + + {ER_TEMPLATE_NOT_FOUND, + "\u627E\u4E0D\u5230\u4E0B\u5217\u540D\u7A31\u7684\u6A23\u677F: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "\u7121\u6CD5\u89E3\u6790 xsl:call-template \u4E2D\u7684\u540D\u7A31 AVT\u3002"}, + + {ER_REQUIRES_ATTRIB, + "{0} \u9700\u8981\u5C6C\u6027: {1}"}, + + { ER_MUST_HAVE_TEST_ATTRIB, + "{0} \u5FC5\u9808\u6709 ''test'' \u5C6C\u6027\u3002"}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "\u932F\u8AA4\u7684\u503C\u4F4D\u65BC\u5C64\u6B21\u5C6C\u6027: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction \u540D\u7A31\u4E0D\u53EF\u70BA 'xml'"}, + + { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction \u540D\u7A31\u5FC5\u9808\u662F\u6709\u6548\u7684 NCName: {0}"}, + + { ER_NEED_MATCH_ATTRIB, + "{0} \u82E5\u5177\u6709\u6A21\u5F0F\uFF0C\u5247\u5FC5\u9808\u6709\u914D\u5C0D\u5C6C\u6027\u3002"}, + + { ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} \u9700\u8981\u540D\u7A31\u6216\u914D\u5C0D\u5C6C\u6027\u3002"}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\u7121\u6CD5\u89E3\u6790\u547D\u540D\u7A7A\u9593\u524D\u7F6E\u78BC: {0}"}, + + { ER_ILLEGAL_VALUE, + "xml:space \u5177\u6709\u7121\u6548\u503C: {0}"}, + + { ER_NO_OWNERDOC, + "\u5B50\u9805\u7BC0\u9EDE\u4E0D\u5177\u6709\u64C1\u6709\u8005\u6587\u4EF6\uFF01"}, + + { ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement \u932F\u8AA4: {0}"}, + + { ER_NULL_CHILD, + "\u5617\u8A66\u65B0\u589E\u7A7A\u503C\u5B50\u9805\uFF01"}, + + { ER_NEED_SELECT_ATTRIB, + "{0} \u9700\u8981\u9078\u53D6\u5C6C\u6027\u3002"}, + + { ER_NEED_TEST_ATTRIB , + "xsl:when \u5FC5\u9808\u5177\u6709 'test' \u5C6C\u6027\u3002"}, + + { ER_NEED_NAME_ATTRIB, + "xsl:with-param \u5FC5\u9808\u5177\u6709 'name' \u5C6C\u6027\u3002"}, + + { ER_NO_CONTEXT_OWNERDOC, + "\u76F8\u95DC\u8CC7\u8A0A\u74B0\u5883\u4E0D\u5177\u6709\u64C1\u6709\u8005\u6587\u4EF6\uFF01"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "\u7121\u6CD5\u5EFA\u7ACB XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \u8655\u7406\u4F5C\u696D\u5931\u6557\u3002"}, + + { ER_NOT_SUCCESSFUL, + "Xalan: \u5931\u6557\uFF01"}, + + { ER_ENCODING_NOT_SUPPORTED, + "\u4E0D\u652F\u63F4\u7DE8\u78BC: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "\u7121\u6CD5\u5EFA\u7ACB TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key \u9700\u8981 'name' \u5C6C\u6027\uFF01"}, + + { ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key \u9700\u8981 'match' \u5C6C\u6027\uFF01"}, + + { ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key \u9700\u8981 'use' \u5C6C\u6027\uFF01"}, + + { ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} \u9700\u8981 ''elements'' \u5C6C\u6027\uFF01"}, + + { ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) \u907A\u6F0F {0} \u5C6C\u6027 ''prefix''"}, + + { ER_BAD_STYLESHEET_URL, + "\u6A23\u5F0F\u8868 URL \u932F\u8AA4: {0}"}, + + { ER_FILE_NOT_FOUND, + "\u627E\u4E0D\u5230\u6A23\u5F0F\u8868\u6A94\u6848: {0}"}, + + { ER_IOEXCEPTION, + "\u6A23\u5F0F\u8868\u6A94\u6848\u767C\u751F IO \u7570\u5E38\u72C0\u6CC1: {0}"}, + + { ER_NO_HREF_ATTRIB, + "(StylesheetHandler) \u627E\u4E0D\u5230 {0} \u7684 href \u5C6C\u6027"}, + + { ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} \u76F4\u63A5\u6216\u9593\u63A5\u5730\u5305\u542B\u672C\u8EAB\uFF01"}, + + { ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude \u932F\u8AA4\uFF0C{0}"}, + + { ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) \u907A\u6F0F {0} \u5C6C\u6027 ''lang''"}, + + { ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0} \u5143\u7D20\u7684\u4F4D\u7F6E\u932F\u8AA4\uFF1F\u907A\u6F0F\u5BB9\u5668\u5143\u7D20 ''component''"}, + + { ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "\u53EA\u80FD\u8F38\u51FA\u81F3 Element\u3001DocumentFragment\u3001Document \u6216 PrintWriter\u3002"}, + + { ER_PROCESS_ERROR, + "StylesheetRoot.process \u932F\u8AA4"}, + + { ER_UNIMPLNODE_ERROR, + "UnImplNode \u932F\u8AA4: {0}"}, + + { ER_NO_SELECT_EXPRESSION, + "\u932F\u8AA4\uFF01\u627E\u4E0D\u5230 xpath \u9078\u53D6\u8868\u793A\u5F0F (-select)\u3002"}, + + { ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "\u7121\u6CD5\u5E8F\u5217\u5316 XSLProcessor\uFF01"}, + + { ER_NO_INPUT_STYLESHEET, + "\u672A\u6307\u5B9A\u6A23\u5F0F\u8868\u8F38\u5165\uFF01"}, + + { ER_FAILED_PROCESS_STYLESHEET, + "\u7121\u6CD5\u8655\u7406\u6A23\u5F0F\u8868\uFF01"}, + + { ER_COULDNT_PARSE_DOC, + "\u7121\u6CD5\u5256\u6790 {0} \u6587\u4EF6\uFF01"}, + + { ER_COULDNT_FIND_FRAGMENT, + "\u627E\u4E0D\u5230\u7247\u6BB5: {0}"}, + + { ER_NODE_NOT_ELEMENT, + "\u7247\u6BB5 ID \u6307\u5411\u7684\u7BC0\u9EDE\u4E0D\u662F\u5143\u7D20: {0}"}, + + { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each \u5FC5\u9808\u6709\u914D\u5C0D\u6216\u540D\u7A31\u5C6C\u6027"}, + + { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "\u6A23\u677F\u5FC5\u9808\u6709\u914D\u5C0D\u6216\u540D\u7A31\u5C6C\u6027"}, + + { ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\u6C92\u6709\u6587\u4EF6\u7247\u6BB5\u7684\u8907\u88FD\uFF01"}, + + { ER_CANT_CREATE_ITEM, + "\u7121\u6CD5\u5728\u7D50\u679C\u6A39\u72C0\u7D50\u69CB\u4E2D\u5EFA\u7ACB\u9805\u76EE: {0}"}, + + { ER_XMLSPACE_ILLEGAL_VALUE, + "\u4F86\u6E90 XML \u4E2D\u7684 xml:space \u5177\u6709\u7121\u6548\u503C: {0}"}, + + { ER_NO_XSLKEY_DECLARATION, + "{0} \u6C92\u6709 xsl:key \u5BA3\u544A\uFF01"}, + + { ER_CANT_CREATE_URL, + "\u932F\u8AA4\uFF01\u7121\u6CD5\u70BA {0} \u5EFA\u7ACB url"}, + + { ER_XSLFUNCTIONS_UNSUPPORTED, + "\u4E0D\u652F\u63F4 xsl:functions"}, + + { ER_PROCESSOR_ERROR, + "XSLT TransformerFactory \u932F\u8AA4"}, + + { ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) \u6A23\u5F0F\u8868\u5167\u4E0D\u5141\u8A31 {0}\uFF01"}, + + { ER_RESULTNS_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u63F4 result-ns\uFF01\u8ACB\u6539\u7528 xsl:output\u3002"}, + + { ER_DEFAULTSPACE_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u63F4 default-space\uFF01\u8ACB\u6539\u7528 xsl:strip-space \u6216 xsl:preserve-space\u3002"}, + + { ER_INDENTRESULT_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u63F4 indent-result\uFF01\u8ACB\u6539\u7528 xsl:output\u3002"}, + + { ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} \u5177\u6709\u7121\u6548\u5C6C\u6027: {1}"}, + + { ER_UNKNOWN_XSL_ELEM, + "\u4E0D\u660E\u7684 XSL \u5143\u7D20: {0}"}, + + { ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort \u53EA\u80FD\u8207 xsl:apply-templates \u6216 xsl:for-each \u4E00\u8D77\u4F7F\u7528\u3002"}, + + { ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when \u4F4D\u7F6E\u932F\u8AA4\uFF01"}, + + { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when \u7684\u7236\u9805\u4E0D\u662F xsl:choose\uFF01"}, + + { ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise \u4F4D\u7F6E\u932F\u8AA4\uFF01"}, + + { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise \u7684\u7236\u9805\u4E0D\u662F xsl:choose\uFF01"}, + + { ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) \u6A23\u677F\u5167\u4E0D\u5141\u8A31 {0}\uFF01"}, + + { ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) \u4E0D\u660E\u7684 {0} \u64F4\u5145\u5957\u4EF6\u547D\u540D\u7A7A\u9593\u524D\u7F6E\u78BC {1}"}, + + { ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \u532F\u5165\u53EA\u80FD\u767C\u751F\u65BC\u6A23\u5F0F\u8868\u4E2D\u7684\u7B2C\u4E00\u500B\u5143\u7D20\uFF01"}, + + { ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} \u76F4\u63A5\u6216\u9593\u63A5\u5730\u532F\u5165\u672C\u8EAB\uFF01"}, + + { ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space \u5177\u6709\u7121\u6548\u503C: {0}"}, + + { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet \u5931\u6557\uFF01"}, + + { ER_SAX_EXCEPTION, + "SAX \u7570\u5E38\u72C0\u6CC1"}, + +// add this message to fix bug 21478 + { ER_FUNCTION_NOT_SUPPORTED, + "\u4E0D\u652F\u63F4\u51FD\u6578\uFF01"}, + + { ER_XSLT_ERROR, + "XSLT \u932F\u8AA4"}, + + { ER_CURRENCY_SIGN_ILLEGAL, + "\u683C\u5F0F\u6A23\u5F0F\u5B57\u4E32\u4E2D\u4E0D\u5141\u8A31\u8CA8\u5E63\u7B26\u865F"}, + + { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Stylesheet DOM \u4E2D\u4E0D\u652F\u63F4\u6587\u4EF6\u51FD\u6578\uFF01"}, + + { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\u7121\u6CD5\u89E3\u6790\u975E\u524D\u7F6E\u78BC\u89E3\u6790\u5668\u7684\u524D\u7F6E\u78BC\uFF01"}, + + { ER_REDIRECT_COULDNT_GET_FILENAME, + "\u91CD\u5C0E\u64F4\u5145\u5957\u4EF6: \u7121\u6CD5\u53D6\u5F97\u6A94\u6848\u540D\u7A31 - \u6A94\u6848\u6216\u9078\u53D6\u5C6C\u6027\u5FC5\u9808\u50B3\u56DE\u6709\u6548\u5B57\u4E32\u3002"}, + + { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\u7121\u6CD5\u5728\u91CD\u5C0E\u64F4\u5145\u5957\u4EF6\u4E2D\u5EFA\u7ACB FormatterListener\uFF01"}, + + { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F6E\u78BC\u7121\u6548: {0}"}, + + { ER_MISSING_NS_URI, + "\u907A\u6F0F\u6307\u5B9A\u524D\u7F6E\u78BC\u7684\u547D\u540D\u7A7A\u9593 URI"}, + + { ER_MISSING_ARG_FOR_OPTION, + "\u907A\u6F0F\u9078\u9805\u7684\u5F15\u6578: {0}"}, + + { ER_INVALID_OPTION, + "\u7121\u6548\u7684\u9078\u9805: {0}"}, + + { ER_MALFORMED_FORMAT_STRING, + "\u683C\u5F0F\u932F\u8AA4\u7684\u683C\u5F0F\u5B57\u4E32: {0}"}, + + { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet \u9700\u8981 'version' \u5C6C\u6027\uFF01"}, + + { ER_ILLEGAL_ATTRIBUTE_VALUE, + "\u5C6C\u6027: {0} \u5177\u6709\u7121\u6548\u503C: {1}"}, + + { ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose \u9700\u8981 xsl:when"}, + + { ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:for-each \u4E2D\u4E0D\u5141\u8A31 xsl:apply-imports"}, + + { ER_CANT_USE_DTM_FOR_OUTPUT, + "DTMLiaison \u7121\u6CD5\u7528\u65BC\u8F38\u51FA DOM \u7BC0\u9EDE\u3002\u8ACB\u6539\u70BA\u50B3\u9001 com.sun.org.apache.xpath.internal.DOM2Helper\uFF01"}, + + { ER_CANT_USE_DTM_FOR_INPUT, + "DTMLiaison \u7121\u6CD5\u7528\u65BC\u8F38\u5165 DOM \u7BC0\u9EDE\u3002\u8ACB\u6539\u70BA\u50B3\u9001 com.sun.org.apache.xpath.internal.DOM2Helper\uFF01"}, + + { ER_CALL_TO_EXT_FAILED, + "\u547C\u53EB\u64F4\u5145\u5957\u4EF6\u5143\u7D20\u5931\u6557: {0}"}, + + { ER_PREFIX_MUST_RESOLVE, + "\u524D\u7F6E\u78BC\u5FC5\u9808\u89E3\u6790\u70BA\u547D\u540D\u7A7A\u9593: {0}"}, + + { ER_INVALID_UTF16_SURROGATE, + "\u5075\u6E2C\u5230\u7121\u6548\u7684 UTF-16 \u4EE3\u7406: {0}\uFF1F"}, + + { ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} \u4F7F\u7528\u672C\u8EAB\uFF0C\u5982\u6B64\u5C07\u9020\u6210\u7121\u9650\u8FF4\u5708\u3002"}, + + { ER_CANNOT_MIX_XERCESDOM, + "\u7121\u6CD5\u6DF7\u5408\u975E Xerces-DOM \u8F38\u5165\u8207 Xerces-DOM \u8F38\u51FA\uFF01"}, + + { ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + { ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "\u5728 ElemTemplateElement.readObject \u4E2D: {0}"}, + + { ER_DUPLICATE_NAMED_TEMPLATE, + "\u627E\u5230\u8D85\u904E\u4E00\u500B\u4E0B\u5217\u540D\u7A31\u7684\u6A23\u677F: {0}"}, + + { ER_INVALID_KEY_CALL, + "\u7121\u6548\u7684\u51FD\u6578\u547C\u53EB: \u4E0D\u5141\u8A31\u905E\u8FF4 key() \u547C\u53EB"}, + + { ER_REFERENCING_ITSELF, + "\u8B8A\u6578 {0} \u76F4\u63A5\u6216\u9593\u63A5\u5730\u53C3\u7167\u672C\u8EAB\uFF01"}, + + { ER_ILLEGAL_DOMSOURCE_INPUT, + "newTemplates \u4E4B DOMSource \u7684\u8F38\u5165\u7BC0\u9EDE\u4E0D\u53EF\u70BA\u7A7A\u503C\uFF01"}, + + { ER_CLASS_NOT_FOUND_FOR_OPTION, + "\u627E\u4E0D\u5230\u9078\u9805 {0} \u7684\u985E\u5225\u6A94\u6848"}, + + { ER_REQUIRED_ELEM_NOT_FOUND, + "\u627E\u4E0D\u5230\u9700\u8981\u7684\u5143\u7D20: {0}"}, + + { ER_INPUT_CANNOT_BE_NULL, + "InputStream \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + { ER_URI_CANNOT_BE_NULL, + "URI \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + { ER_FILE_CANNOT_BE_NULL, + "File \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + { ER_SOURCE_CANNOT_BE_NULL, + "InputSource \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + { ER_CANNOT_INIT_BSFMGR, + "\u7121\u6CD5\u8D77\u59CB BSF \u7BA1\u7406\u7A0B\u5F0F"}, + + { ER_CANNOT_CMPL_EXTENSN, + "\u7121\u6CD5\u7DE8\u8B6F\u64F4\u5145\u5957\u4EF6"}, + + { ER_CANNOT_CREATE_EXTENSN, + "\u7121\u6CD5\u5EFA\u7ACB\u64F4\u5145\u5957\u4EF6: {0}\uFF0C\u56E0\u70BA: {1}"}, + + { ER_INSTANCE_MTHD_CALL_REQUIRES, + "\u57F7\u884C\u8655\u7406\u65B9\u6CD5\u547C\u53EB\u65B9\u6CD5 {0} \u6642\uFF0C\u9700\u8981 Object \u57F7\u884C\u8655\u7406\u4F5C\u70BA\u7B2C\u4E00\u500B\u5F15\u6578"}, + + { ER_INVALID_ELEMENT_NAME, + "\u6307\u5B9A\u4E86\u7121\u6548\u7684\u5143\u7D20\u540D\u7A31 {0}"}, + + { ER_ELEMENT_NAME_METHOD_STATIC, + "\u5143\u7D20\u540D\u7A31\u65B9\u6CD5\u5FC5\u9808\u662F\u975C\u614B {0}"}, + + { ER_EXTENSION_FUNC_UNKNOWN, + "\u64F4\u5145\u5957\u4EF6\u51FD\u6578 {0} : {1} \u4E0D\u660E"}, + + { ER_MORE_MATCH_CONSTRUCTOR, + "{0} \u7684\u5EFA\u69CB\u5B50\u6709\u8D85\u904E\u4E00\u500B\u4EE5\u4E0A\u7684\u6700\u4F73\u914D\u5C0D"}, + + { ER_MORE_MATCH_METHOD, + "\u65B9\u6CD5 {0} \u6709\u8D85\u904E\u4E00\u500B\u4EE5\u4E0A\u7684\u6700\u4F73\u914D\u5C0D"}, + + { ER_MORE_MATCH_ELEMENT, + "\u5143\u7D20\u65B9\u6CD5 {0} \u6709\u8D85\u904E\u4E00\u500B\u4EE5\u4E0A\u7684\u6700\u4F73\u914D\u5C0D"}, + + { ER_INVALID_CONTEXT_PASSED, + "\u50B3\u9001\u4E86\u7121\u6548\u7684\u76F8\u95DC\u8CC7\u8A0A\u74B0\u5883\u4F86\u8A55\u4F30 {0}"}, + + { ER_POOL_EXISTS, + "\u96C6\u5340\u5DF2\u7D93\u5B58\u5728"}, + + { ER_NO_DRIVER_NAME, + "\u672A\u6307\u5B9A\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31"}, + + { ER_NO_URL, + "\u672A\u6307\u5B9A URL"}, + + { ER_POOL_SIZE_LESSTHAN_ONE, + "\u96C6\u5340\u5927\u5C0F\u5C0F\u65BC\u4E00\uFF01"}, + + { ER_INVALID_DRIVER, + "\u6307\u5B9A\u4E86\u7121\u6548\u7684\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31\uFF01"}, + + { ER_NO_STYLESHEETROOT, + "\u627E\u4E0D\u5230\u6A23\u5F0F\u8868\u6839\uFF01"}, + + { ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space \u7684\u503C\u7121\u6548"}, + + { ER_PROCESSFROMNODE_FAILED, + "processFromNode \u5931\u6557"}, + + { ER_RESOURCE_COULD_NOT_LOAD, + "\u7121\u6CD5\u8F09\u5165\u8CC7\u6E90 [ {0} ]: {1} \n {2} \t {3}"}, + + { ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\u7DE9\u885D\u5340\u5927\u5C0F <=0"}, + + { ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\u547C\u53EB\u64F4\u5145\u5957\u4EF6\u6642\uFF0C\u767C\u751F\u4E0D\u660E\u7684\u932F\u8AA4"}, + + { ER_NO_NAMESPACE_DECL, + "\u524D\u7F6E\u78BC {0} \u6C92\u6709\u5C0D\u61C9\u7684\u547D\u540D\u7A7A\u9593\u5BA3\u544A"}, + + { ER_ELEM_CONTENT_NOT_ALLOWED, + "\u5143\u7D20\u5167\u5BB9\u4E0D\u5141\u8A31 lang=javaclass {0}"}, + + { ER_STYLESHEET_DIRECTED_TERMINATION, + "\u6A23\u5F0F\u8868\u5C0E\u5411\u7684\u7D42\u6B62"}, + + { ER_ONE_OR_TWO, + "1 \u6216 2"}, + + { ER_TWO_OR_THREE, + "2 \u6216 3"}, + + { ER_COULD_NOT_LOAD_RESOURCE, + "\u7121\u6CD5\u8F09\u5165 {0} (\u6AA2\u67E5 CLASSPATH)\uFF0C\u76EE\u524D\u53EA\u4F7F\u7528\u9810\u8A2D\u503C"}, + + { ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\u7121\u6CD5\u8D77\u59CB\u9810\u8A2D\u6A23\u677F"}, + + { ER_RESULT_NULL, + "\u7D50\u679C\u4E0D\u61C9\u70BA\u7A7A\u503C"}, + + { ER_RESULT_COULD_NOT_BE_SET, + "\u7121\u6CD5\u8A2D\u5B9A\u7D50\u679C"}, + + { ER_NO_OUTPUT_SPECIFIED, + "\u672A\u6307\u5B9A\u8F38\u51FA"}, + + { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "\u7121\u6CD5\u8F49\u63DB\u70BA\u985E\u578B {0} \u7684\u7D50\u679C"}, + + { ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "\u7121\u6CD5\u8F49\u63DB\u985E\u578B {0} \u7684\u4F86\u6E90"}, + + { ER_NULL_CONTENT_HANDLER, + "\u7A7A\u503C\u5167\u5BB9\u8655\u7406\u7A0B\u5F0F"}, + + { ER_NULL_ERROR_HANDLER, + "\u7A7A\u503C\u932F\u8AA4\u8655\u7406\u7A0B\u5F0F"}, + + { ER_CANNOT_CALL_PARSE, + "\u82E5\u672A\u8A2D\u5B9A ContentHandler\uFF0C\u5247\u7121\u6CD5\u547C\u53EB\u5256\u6790"}, + + { ER_NO_PARENT_FOR_FILTER, + "\u7BE9\u9078\u6C92\u6709\u7236\u9805"}, + + { ER_NO_STYLESHEET_IN_MEDIA, + "\u5728 {0} \u4E2D\u627E\u4E0D\u5230\u6A23\u5F0F\u8868\uFF0C\u5A92\u9AD4 = {1}"}, + + { ER_NO_STYLESHEET_PI, + "\u5728 {0} \u4E2D\u627E\u4E0D\u5230 xml-stylesheet PI"}, + + { ER_NOT_SUPPORTED, + "\u4E0D\u652F\u63F4: {0}"}, + + { ER_PROPERTY_VALUE_BOOLEAN, + "\u5C6C\u6027 {0} \u7684\u503C\u61C9\u70BA\u5E03\u6797\u57F7\u884C\u8655\u7406"}, + + { ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "\u7121\u6CD5\u5728 {0} \u53D6\u5F97\u5916\u90E8\u547D\u4EE4\u6A94"}, + + { ER_RESOURCE_COULD_NOT_FIND, + "\u627E\u4E0D\u5230\u8CC7\u6E90 [ {0} ]\u3002\n{1}"}, + + { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\u7121\u6CD5\u8FA8\u8B58\u7684\u8F38\u51FA\u5C6C\u6027: {0}"}, + + { ER_FAILED_CREATING_ELEMLITRSLT, + "\u7121\u6CD5\u5EFA\u7ACB ElemLiteralResult \u57F7\u884C\u8655\u7406"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + { ER_VALUE_SHOULD_BE_NUMBER, + "{0} \u7684\u503C\u61C9\u5305\u542B\u53EF\u5256\u6790\u7684\u6578\u5B57"}, + + { ER_VALUE_SHOULD_EQUAL, + "{0} \u7684\u503C\u61C9\u7B49\u65BC yes \u6216 no"}, + + { ER_FAILED_CALLING_METHOD, + "\u7121\u6CD5\u547C\u53EB {0} \u65B9\u6CD5"}, + + { ER_FAILED_CREATING_ELEMTMPL, + "\u7121\u6CD5\u5EFA\u7ACB ElemTemplateElement \u57F7\u884C\u8655\u7406"}, + + { ER_CHARS_NOT_ALLOWED, + "\u6587\u4EF6\u6B64\u8655\u4E0D\u5141\u8A31\u5B57\u5143"}, + + { ER_ATTR_NOT_ALLOWED, + "{1} \u5143\u7D20\u4E0D\u5141\u8A31 \"{0}\" \u5C6C\u6027\uFF01"}, + + { ER_BAD_VALUE, + "{0} \u7121\u6548\u503C {1} "}, + + { ER_ATTRIB_VALUE_NOT_FOUND, + "\u627E\u4E0D\u5230 {0} \u5C6C\u6027\u503C"}, + + { ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} \u5C6C\u6027\u503C\u7121\u6CD5\u8FA8\u8B58 "}, + + { ER_NULL_URI_NAMESPACE, + "\u5617\u8A66\u4EE5\u7A7A\u503C URI \u7522\u751F\u547D\u540D\u7A7A\u9593\u524D\u7F6E\u78BC"}, + + { ER_NUMBER_TOO_BIG, + "\u5617\u8A66\u683C\u5F0F\u5316\u5927\u65BC\u6700\u5927\u9577\u6574\u6578\u7684\u6578\u5B57"}, + + { ER_CANNOT_FIND_SAX1_DRIVER, + "\u627E\u4E0D\u5230 SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0}"}, + + { ER_SAX1_DRIVER_NOT_LOADED, + "\u627E\u5230 SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0}\uFF0C\u4F46\u7121\u6CD5\u8F09\u5165"}, + + { ER_SAX1_DRIVER_NOT_INSTANTIATED, + "\u5DF2\u8F09\u5165 SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0}\uFF0C\u4F46\u7121\u6CD5\u5EFA\u7ACB"}, + + { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0} \u672A\u5BE6\u884C org.xml.sax.Parser"}, + + { ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\u672A\u6307\u5B9A\u7CFB\u7D71\u5C6C\u6027 org.xml.sax.parser"}, + + { ER_PARSER_ARG_CANNOT_BE_NULL, + "\u5256\u6790\u5668\u5F15\u6578\u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + { ER_FEATURE, + "\u529F\u80FD: {0}"}, + + { ER_PROPERTY, + "\u5C6C\u6027: {0}"}, + + { ER_NULL_ENTITY_RESOLVER, + "\u7A7A\u503C\u5BE6\u9AD4\u89E3\u6790\u5668"}, + + { ER_NULL_DTD_HANDLER, + "\u7A7A\u503C DTD \u8655\u7406\u7A0B\u5F0F"}, + + { ER_NO_DRIVER_NAME_SPECIFIED, + "\u672A\u6307\u5B9A\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31\uFF01"}, + + { ER_NO_URL_SPECIFIED, + "\u672A\u6307\u5B9A URL\uFF01"}, + + { ER_POOLSIZE_LESS_THAN_ONE, + "\u96C6\u5340\u5927\u5C0F\u5C0F\u65BC 1\uFF01"}, + + { ER_INVALID_DRIVER_NAME, + "\u6307\u5B9A\u4E86\u7121\u6548\u7684\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31\uFF01"}, + + { ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + { ER_ASSERT_NO_TEMPLATE_PARENT, + "\u7A0B\u5F0F\u8A2D\u8A08\u4EBA\u54E1\u7684\u932F\u8AA4\uFF01\u8868\u793A\u5F0F\u6C92\u6709 ElemTemplateElement \u7236\u9805\uFF01"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "\u7A0B\u5F0F\u8A2D\u8A08\u4EBA\u54E1\u5728 RedundentExprEliminator \u4E2D\u7684\u5BA3\u544A: {0}"}, + + { ER_NOT_ALLOWED_IN_POSITION, + "\u6A23\u5F0F\u8868\u6B64\u4F4D\u7F6E\u4E0D\u5141\u8A31 {0}\uFF01"}, + + { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\u6A23\u5F0F\u8868\u6B64\u4F4D\u7F6E\u4E0D\u5141\u8A31\u975E\u7A7A\u683C\u6587\u5B57\uFF01"}, + + // This code is shared with warning codes. + // SystemId Unknown + { INVALID_TCHAR, + "\u7121\u6548\u503C: {1} \u7528\u65BC CHAR \u5C6C\u6027: {0}\u3002\u985E\u578B CHAR \u7684\u5C6C\u6027\u5FC5\u9808\u50C5\u70BA 1 \u500B\u5B57\u5143\uFF01"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + { INVALID_QNAME, + "\u7121\u6548\u503C: {1} \u7528\u65BC QNAME \u5C6C\u6027: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + { INVALID_ENUM, + "\u7121\u6548\u503C: {1} \u7528\u65BC ENUM \u5C6C\u6027: {0}\u3002\u6709\u6548\u503C\u70BA: {2}\u3002"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NMTOKEN, + "\u7121\u6548\u503C: {1} \u7528\u65BC NMTOKEN \u5C6C\u6027: {0}"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NCNAME, + "\u7121\u6548\u503C: {1} \u7528\u65BC NCNAME \u5C6C\u6027: {0}"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_BOOLEAN, + "\u7121\u6548\u503C: {1} \u7528\u65BC\u5E03\u6797\u5C6C\u6027: {0}"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + { INVALID_NUMBER, + "\u7121\u6548\u503C: {1} \u7528\u65BC\u6578\u5B57\u5C6C\u6027: {0}"}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + { ER_ARG_LITERAL, + "\u914D\u5C0D\u6A23\u5F0F\u4E2D {0} \u7684\u5F15\u6578\u5FC5\u9808\u662F\u6587\u5B57\u3002"}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_GLOBAL_VAR, + "\u91CD\u8907\u7684\u5168\u57DF\u8B8A\u6578\u5BA3\u544A\u3002"}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + { ER_DUPLICATE_VAR, + "\u91CD\u8907\u7684\u8B8A\u6578\u5BA3\u544A\u3002"}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + { ER_TEMPLATE_NAME_MATCH, + "xsl:template \u5FC5\u9808\u6709\u540D\u7A31\u6216\u914D\u5C0D\u5C6C\u6027 (\u6216\u5177\u6709\u5169\u8005)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + { ER_INVALID_PREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F6E\u78BC\u7121\u6548: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + { ER_NO_ATTRIB_SET, + "\u4E0D\u5B58\u5728\u540D\u7A31\u70BA {0} \u7684 attribute-set"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + { ER_FUNCTION_NOT_FOUND, + "\u4E0D\u5B58\u5728\u540D\u7A31\u70BA {0} \u7684\u51FD\u6578"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + { ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0} \u5143\u7D20\u4E0D\u53EF\u540C\u6642\u5177\u6709\u5167\u5BB9\u8207\u9078\u53D6\u5C6C\u6027\u3002"}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + { ER_INVALID_SET_PARAM_VALUE, + "\u53C3\u6578 {0} \u7684\u503C\u5FC5\u9808\u662F\u6709\u6548\u7684 Java \u7269\u4EF6"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C6C\u6027\u5177\u6709\u503C '#default'\uFF0C\u4F46\u662F\u5143\u7D20\u7BC4\u570D\u4E2D\u6C92\u6709\u9810\u8A2D\u547D\u540D\u7A7A\u9593\u7684\u5BA3\u544A"}, + + { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C6C\u6027\u5177\u6709\u503C ''{0}''\uFF0C\u4F46\u662F\u5143\u7D20\u7BC4\u570D\u4E2D\u6C92\u6709\u524D\u7F6E\u78BC ''{0}'' \u7684\u547D\u540D\u7A7A\u9593\u5BA3\u544A\u3002"}, + + { ER_SET_FEATURE_NULL_NAME, + "TransformerFactory.setFeature(\u5B57\u4E32\u540D\u7A31, \u5E03\u6797\u503C) \u4E2D\u7684\u529F\u80FD\u540D\u7A31\u4E0D\u53EF\u70BA\u7A7A\u503C\u3002"}, + + { ER_GET_FEATURE_NULL_NAME, + "TransformerFactory.getFeature(\u5B57\u4E32\u540D\u7A31) \u4E2D\u7684\u529F\u80FD\u540D\u7A31\u4E0D\u53EF\u70BA\u7A7A\u503C\u3002"}, + + { ER_UNSUPPORTED_FEATURE, + "\u7121\u6CD5\u5728\u6B64 TransformerFactory \u4E0A\u8A2D\u5B9A\u529F\u80FD ''{0}''\u3002"}, + + { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\u7576\u5B89\u5168\u8655\u7406\u529F\u80FD\u8A2D\u70BA\u771F\u6642\uFF0C\u4E0D\u5141\u8A31\u4F7F\u7528\u64F4\u5145\u5957\u4EF6\u5143\u7D20 ''{0}''\u3002"}, + + { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "\u7121\u6CD5\u53D6\u5F97\u7A7A\u503C\u547D\u540D\u7A7A\u9593 uri \u7684\u524D\u7F6E\u78BC\u3002"}, + + { ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "\u7121\u6CD5\u53D6\u5F97\u7A7A\u503C\u524D\u7F6E\u78BC\u7684\u547D\u540D\u7A7A\u9593 uri\u3002"}, + + { ER_XPATH_RESOLVER_NULL_QNAME, + "\u51FD\u6578\u540D\u7A31\u4E0D\u53EF\u70BA\u7A7A\u503C\u3002"}, + + { ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "Arity \u4E0D\u53EF\u70BA\u8CA0\u503C\u3002"}, + // Warnings... + + { WG_FOUND_CURLYBRACE, + "\u627E\u5230 '}'\uFF0C\u4F46\u6C92\u6709\u958B\u555F\u7684\u5C6C\u6027\u6A23\u677F\uFF01"}, + + { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\u8B66\u544A: \u8A08\u6578\u5C6C\u6027\u4E0D\u7B26\u5408 xsl:number \u4E2D\u7684\u7956\u7CFB\uFF01\u76EE\u6A19 = {0}"}, + + { WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\u820A\u8A9E\u6CD5: 'expr' \u5C6C\u6027\u7684\u540D\u7A31\u5DF2\u8B8A\u66F4\u70BA 'select'\u3002"}, + + { WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan \u5C1A\u672A\u8655\u7406 format-number \u51FD\u6578\u4E2D\u7684\u5730\u5340\u8A2D\u5B9A\u540D\u7A31\u3002"}, + + { WG_LOCALE_NOT_FOUND, + "\u8B66\u544A: \u627E\u4E0D\u5230 xml:lang={0} \u7684\u5730\u5340\u8A2D\u5B9A"}, + + { WG_CANNOT_MAKE_URL_FROM, + "\u7121\u6CD5\u5F9E {0} \u5EFA\u7ACB URL"}, + + { WG_CANNOT_LOAD_REQUESTED_DOC, + "\u7121\u6CD5\u8F09\u5165\u8981\u6C42\u7684\u6587\u4EF6: {0}"}, + + { WG_CANNOT_FIND_COLLATOR, + "\u627E\u4E0D\u5230 >>>>>> Xalan \u7248\u672C "}, + { "version2", "<<<<<<<"}, + { "yes", "\u662F"}, + { "line", "\u884C\u865F"}, + { "column","\u8CC7\u6599\u6B04\u7DE8\u865F"}, + { "xsldone", "XSLProcessor: \u5B8C\u6210"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + { "xslProc_option", "Xalan-J \u547D\u4EE4\u884C\u8655\u7406\u4F5C\u696D\u985E\u5225\u9078\u9805:"}, + { "xslProc_option", "Xalan-J \u547D\u4EE4\u884C\u8655\u7406\u4F5C\u696D\u985E\u5225\u9078\u9805:"}, + { "xslProc_invalid_xsltc_option", "XSLTC \u6A21\u5F0F\u4E2D\u4E0D\u652F\u63F4\u9078\u9805 {0}\u3002"}, + { "xslProc_invalid_xalan_option", "\u9078\u9805 {0} \u53EA\u80FD\u8207 -XSLTC \u4E00\u8D77\u4F7F\u7528\u3002"}, + { "xslProc_no_input", "\u932F\u8AA4: \u672A\u6307\u5B9A\u6A23\u5F0F\u8868\u6216\u8F38\u5165 xml\u3002\u4E0D\u4F7F\u7528\u4EFB\u4F55\u9078\u9805\u4F86\u57F7\u884C\u6B64\u547D\u4EE4\uFF0C\u53EF\u53D6\u5F97\u7528\u6CD5\u6307\u793A\u3002"}, + { "xslProc_common_options", "-\u4E00\u822C\u9078\u9805-"}, + { "xslProc_xalan_options", "-Xalan \u7684\u9078\u9805-"}, + { "xslProc_xsltc_options", "-XSLTC \u7684\u9078\u9805-"}, + { "xslProc_return_to_continue", "(\u6309 \u4EE5\u7E7C\u7E8C)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + { "optionXSLTC", " [-XSLTC (\u4F7F\u7528 XSLTC \u9032\u884C\u8F49\u63DB)]"}, + { "optionIN", " [-IN inputXMLURL]"}, + { "optionXSL", " [-XSL XSLTransformationURL]"}, + { "optionOUT", " [-OUT outputFileName]"}, + { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + { "optionPARSER", " [-PARSER \u5256\u6790\u5668\u806F\u7D61\u7684\u5B8C\u6574\u985E\u5225\u540D\u7A31]"}, + { "optionE", " [-E (\u52FF\u5C55\u958B\u5BE6\u9AD4\u53C3\u7167)]"}, + { "optionV", " [-E (\u52FF\u5C55\u958B\u5BE6\u9AD4\u53C3\u7167)]"}, + { "optionQC", " [-QC (\u975C\u97F3\u6A23\u5F0F\u885D\u7A81\u8B66\u544A)]"}, + { "optionQ", " [-Q (\u975C\u97F3\u6A21\u5F0F)]"}, + { "optionLF", " [-LF (\u8F38\u51FA\u4E0A\u50C5\u4F7F\u7528\u63DB\u884C\u5B57\u5143 {\u9810\u8A2D\u70BA CR/LF})]"}, + { "optionCR", " [-CR (\u8F38\u51FA\u4E0A\u50C5\u4F7F\u7528\u6B78\u4F4D\u5B57\u5143 {\u9810\u8A2D\u70BA CR/LF})]"}, + { "optionESCAPE", " [-ESCAPE (\u8981\u9041\u96E2\u7684\u5B57\u5143 {\u9810\u8A2D\u70BA <>&\"'\\r\\n}]"}, + { "optionINDENT", " [-INDENT (\u63A7\u5236\u8981\u7E2E\u6392\u7684\u7A7A\u9593 {\u9810\u8A2D\u70BA 0})]"}, + { "optionTT", " [-TT (\u8FFD\u8E64\u547C\u53EB\u7684\u6A23\u677F\u3002)]"}, + { "optionTG", " [-TG (\u8FFD\u8E64\u6BCF\u500B\u7522\u751F\u4E8B\u4EF6\u3002)]"}, + { "optionTS", " [-TS (\u8FFD\u8E64\u6BCF\u500B\u9078\u53D6\u4E8B\u4EF6\u3002)]"}, + { "optionTTC", " [-TTC (\u8FFD\u8E64\u8655\u7406\u7684\u6A23\u677F\u5B50\u9805\u3002)]"}, + { "optionTCLASS", " [-TCLASS (\u8FFD\u8E64\u64F4\u5145\u5957\u4EF6\u7684 TraceListener \u985E\u5225\u3002)]"}, + { "optionVALIDATE", " [-VALIDATE (\u8A2D\u5B9A\u662F\u5426\u57F7\u884C\u9A57\u8B49\u3002\u9810\u8A2D\u4E0D\u6703\u57F7\u884C\u9A57\u8B49\u3002)]"}, + { "optionEDUMP", " [-EDUMP {\u9078\u64C7\u6027\u6A94\u6848\u540D\u7A31} (\u767C\u751F\u932F\u8AA4\u6642\u6703\u57F7\u884C\u5806\u758A\u50BE\u5370\u3002)]"}, + { "optionXML", " [-XML (\u4F7F\u7528 XML \u683C\u5F0F\u5668\u4E26\u65B0\u589E XML \u6A19\u982D\u3002)]"}, + { "optionTEXT", " [-TEXT (\u4F7F\u7528\u7C21\u55AE Text \u683C\u5F0F\u5668\u3002)]"}, + { "optionHTML", " [-HTML (\u4F7F\u7528 HTML \u683C\u5F0F\u5668\u3002)]"}, + { "optionPARAM", " [-PARAM \u540D\u7A31\u8868\u793A\u5F0F (\u8A2D\u5B9A\u6A23\u5F0F\u8868\u53C3\u6578)]"}, + { "noParsermsg1", "XSL \u8655\u7406\u4F5C\u696D\u5931\u6557\u3002"}, + { "noParsermsg2", "** \u627E\u4E0D\u5230\u5256\u6790\u5668 **"}, + { "noParsermsg3", "\u8ACB\u6AA2\u67E5\u985E\u5225\u8DEF\u5F91\u3002"}, + { "noParsermsg4", "\u82E5\u7121 IBM \u7684 XML Parser for Java\uFF0C\u53EF\u4E0B\u8F09\u81EA"}, + { "noParsermsg5", "IBM \u7684 AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + { "optionURIRESOLVER", " [-URIRESOLVER \u5B8C\u6574\u985E\u5225\u540D\u7A31 (\u7528\u4F86\u89E3\u6790 URI \u7684 URIResolver)]"}, + { "optionENTITYRESOLVER", " [-ENTITYRESOLVER \u5B8C\u6574\u985E\u5225\u540D\u7A31 (\u7528\u4F86\u89E3\u6790\u5BE6\u9AD4\u7684 EntityResolver )]"}, + { "optionCONTENTHANDLER", " [-CONTENTHANDLER \u5B8C\u6574\u985E\u5225\u540D\u7A31 (\u7528\u4F86\u5E8F\u5217\u5316\u8F38\u51FA\u7684 ContentHandler)]"}, + { "optionLINENUMBERS", " [-L \u4F7F\u7528\u884C\u865F\u65BC\u4F86\u6E90\u6587\u4EF6]"}, + { "optionSECUREPROCESSING", " [-SECURE (\u5C07\u5B89\u5168\u8655\u7406\u529F\u80FD\u8A2D\u70BA\u771F\u3002)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + { "optionMEDIA", " [-MEDIA mediaType (\u4F7F\u7528\u5A92\u9AD4\u5C6C\u6027\u4F86\u5C0B\u627E\u8207\u6587\u4EF6\u95DC\u806F\u7684\u6A23\u5F0F\u8868\u3002)]"}, + { "optionFLAVOR", " [-FLAVOR flavorName (\u660E\u78BA\u4F7F\u7528 s2s=SAX \u6216 d2d=DOM \u4F86\u57F7\u884C\u8F49\u63DB\u3002)] "}, // Added by sboag/scurcuru; experimental + { "optionDIAG", " [-DIAG (\u5217\u5370\u8F49\u63DB\u6240\u9700\u8981\u7684\u5168\u90E8\u6BEB\u79D2\u3002)]"}, + { "optionINCREMENTAL", " [-INCREMENTAL (\u8A2D\u5B9A http://xml.apache.org/xalan/features/incremental \u70BA\u771F\uFF0C\u4EE5\u8981\u6C42\u6F38\u9032 DTM \u5EFA\u69CB\u3002)]"}, + { "optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (\u8A2D\u5B9A http://xml.apache.org/xalan/features/optimize \u70BA\u507D\uFF0C\u4EE5\u8981\u6C42\u7121\u6A23\u5F0F\u8868\u6700\u4F73\u5316\u8655\u7406\u3002)]"}, + { "optionRL", " [-RL recursionlimit (\u5BA3\u544A\u6A23\u5F0F\u8868\u905E\u8FF4\u6DF1\u5EA6\u7684\u6578\u5B57\u9650\u5236\u3002)]"}, + { "optionXO", " [-XO [transletName] (\u6307\u6D3E\u6240\u7522\u751F translet \u7684\u540D\u7A31)]"}, + { "optionXD", " [-XD destinationDirectory (\u6307\u5B9A translet \u7684\u76EE\u7684\u5730\u76EE\u9304)]"}, + { "optionXJ", " [-XJ jarfile (\u5C01\u88DD translet \u985E\u5225\u6210\u70BA\u540D\u7A31\u70BA \u7684 jar \u6A94\u6848)]"}, + { "optionXP", " [-XP \u5957\u88DD\u7A0B\u5F0F (\u6307\u5B9A\u6240\u6709\u7522\u751F\u7684 translet \u985E\u5225\u7684\u5957\u88DD\u7A0B\u5F0F\u540D\u7A31\u524D\u7F6E\u78BC)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + { "optionXN", " [-XN (\u555F\u7528\u6A23\u677F\u5167\u5D4C)]" }, + { "optionXX", " [-XX (\u958B\u555F\u984D\u5916\u7684\u9664\u932F\u8A0A\u606F\u8F38\u51FA)]"}, + { "optionXT" , " [-XT (\u82E5\u6709\u53EF\u80FD\uFF0C\u4F7F\u7528 translet \u4F86\u8F49\u63DB)]"}, + { "diagTiming"," --------- \u7D93\u7531 {1} \u7684 {0} \u8F49\u63DB\u6B77\u6642 {2} \u6BEB\u79D2" }, + { "recursionTooDeep","\u6A23\u677F\u5DE2\u72C0\u7D50\u69CB\u904E\u6DF1\u3002\u5DE2\u72C0\u7D50\u69CB = {0}\uFF0C\u6A23\u677F {1} {2}" }, + { "nameIs", "\u540D\u7A31\u70BA" }, + { "matchPatternIs", "\u914D\u5C0D\u6A23\u5F0F\u70BA" } + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** String for use when a bad error code was encountered. */ + public static final String BAD_CODE = "BAD_CODE"; + + /** String for use when formatting of the error string failed. */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + + } diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTInfo.properties b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTInfo.properties new file mode 100644 index 000000000..d45d033b3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTInfo.properties @@ -0,0 +1,32 @@ +########################################################################### +# reserved comment block +# DO NOT REMOVE OR ALTER! +########################################################################### +########################################################################### +# Copyright 2000-2004 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## +# +# $Id: XSLTInfo.properties,v 1.1.2.1 2005/08/01 02:10:48 jeffsuttor Exp $ +# +# XSLT Resource File +# + +vendor=Apache Software Foundation +vendor-url=http://xml.apache.org/xalan-j + +# Product Version: Xalan-Java @impl.version@ + +# W3C XSL Transformations (XSLT) Version 1.0 +version=1.0 diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/package.html new file mode 100644 index 000000000..fac82d218 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/package.html @@ -0,0 +1,28 @@ + + + + + Xalan resource Package. + +

    Contains strings that require internationalization.

    + + + + diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/Constants.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/Constants.java new file mode 100644 index 000000000..6fe0f2601 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/Constants.java @@ -0,0 +1,400 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.templates; + + +/** + * Primary constants used in the TransformerImpl classes. + * @xsl.usage advanced + */ +public class Constants extends com.sun.org.apache.xml.internal.utils.Constants +{ + + /** + * IDs for XSL element types. These are associated + * with the string literals in the TransformerImpl class. + * Don't change the numbers. NOTE THAT THESE ARE NOT IN + * ALPHABETICAL ORDER! + * (It's a pity Java doesn't have a real Enumerated Mnemonic + * datatype... or a C-like preprocessor in lieu thereof which + * could be used to generate and maintain synch between these lists.) + */ + public static final int ELEMNAME_UNDEFINED = -1, ELEMNAME_WITHPARAM = 2, + ELEMNAME_ADDATTRIBUTE = 4, ELEMNAME_ANCHOR = 22, + + // ELEMNAME_ANCHOR_PATTERN = 23, + ELEMNAME_APPLY_TEMPLATES = 50, ELEMNAME_USE = 34, ELEMNAME_CHILDREN = 6, + ELEMNAME_CHOOSE = 37, ELEMNAME_COMMENT = 59, // my own + ELEMNAME_CONSTRUCT = 7, // my own + ELEMNAME_CONTENTS = 8, ELEMNAME_COPY = 9, + ELEMNAME_COPY_OF = 74, + ELEMNAME_DECIMALFORMAT = 83, + ELEMNAME_DEFINEATTRIBUTESET = 40, + + // ELEMNAME_DEFINECONSTANT = 29, + // ELEMNAME_DEFINEMACRO = 10, + ELEMNAME_DEFINESCRIPT = 11, ELEMNAME_DISPLAYIF = 12, // my own + ELEMNAME_EMPTY = 14, ELEMNAME_EVAL = 15, + ELEMNAME_EXPECTEDCHILDREN = 16, + ELEMNAME_EXTENSION = 54, + ELEMNAME_EXTENSIONHANDLER = 63, + ELEMNAME_FOREACH = 28, ELEMNAME_KEY = 31, + ELEMNAME_IF = 36, ELEMNAME_IMPORT = 26, + ELEMNAME_INCLUDE = 27, + ELEMNAME_CALLTEMPLATE = 17, + ELEMNAME_PARAMVARIABLE = 41, + ELEMNAME_NUMBER = 35, ELEMNAME_NSALIAS = 84, + ELEMNAME_OTHERWISE = 39, ELEMNAME_PI = 58, + ELEMNAME_PRESERVESPACE = 33, + ELEMNAME_REMOVEATTRIBUTE = 5, + ELEMNAME_TEMPLATE = 19, ELEMNAME_SORT = 64, + ELEMNAME_STRIPSPACE = 32, + ELEMNAME_STYLESHEET = 25, ELEMNAME_TEXT = 42, + ELEMNAME_VALUEOF = 30, ELEMNAME_WHEN = 38, + + // Pattern by example support + ELEMNAME_ROOT = 44, ELEMNAME_ANY = 45, ELEMNAME_ELEMENT = 46, + ELEMNAME_TARGETELEMENT = 47, ELEMNAME_ATTRIBUTE = 48, + ELEMNAME_TARGETATTRIBUTE = 49, ELEMNAME_URL = 52, // my own + ELEMNAME_CALL = 55, // my own + + // ELEMNAME_WITHPARAM = 56, + ELEMNAME_FALLBACK = 57, // my own + ELEMNAME_TARGETPI = 60, // my own + ELEMNAME_TARGETCOMMENT = 61, // my own + ELEMNAME_TARGETTEXT = 62, // my own + ELEMNAME_CSSSTYLECONVERSION = 65, // my own + ELEMNAME_COUNTER = 66, ELEMNAME_COUNTERS = 67, + ELEMNAME_COUNTERINCREMENT = 68, ELEMNAME_COUNTERRESET = 69, + ELEMNAME_COUNTERSCOPE = 71, ELEMNAME_APPLY_IMPORTS = 72, + ELEMNAME_VARIABLE = 73, ELEMNAME_MESSAGE = 75, ELEMNAME_LOCALE = 76, + ELEMNAME_LITERALRESULT = 77, ELEMNAME_TEXTLITERALRESULT = 78, + ELEMNAME_EXTENSIONCALL = 79, ELEMNAME_EXTENSIONDECL = 85, + ELEMNAME_EXTENSIONSCRIPT = 86, ELEMNAME_OUTPUT = 80, + ELEMNAME_COMPONENT = 81, ELEMNAME_SCRIPT = 82; + + // Next free number: 90 (88 and 89 used for EXSLT elements); + + /** + * Literals for XSL element names. Note that there are more + * names than IDs, because some names map to the same ID. + */ + public static final String + ELEMNAME_ANCHOR_STRING = "anchor", + ELEMNAME_ANY_STRING = "any", // pattern-by-example support + ELEMNAME_APPLY_IMPORTS_STRING = "apply-imports", + ELEMNAME_APPLY_TEMPLATES_STRING = "apply-templates", + ELEMNAME_ARG_STRING = "arg", + ELEMNAME_ATTRIBUTESET_STRING = "attribute-set", + ELEMNAME_ATTRIBUTE_STRING = "attribute", // pattern-by-example support + ELEMNAME_CALLTEMPLATEARG_STRING = "invoke-arg", + ELEMNAME_CALLTEMPLATE_STRING = "call-template", + ELEMNAME_CALL_STRING = "call", + ELEMNAME_CHILDREN_STRING = "children", + ELEMNAME_CHOOSE_STRING = "choose", + ELEMNAME_COMMENT_STRING = "comment", + ELEMNAME_COMPONENT_STRING = "component", + ELEMNAME_CONSTRUCT_STRING = "construct", // my own + ELEMNAME_CONTENTS_STRING = "contents", + ELEMNAME_COPY_OF_STRING ="copy-of", + ELEMNAME_COPY_STRING = "copy", + ELEMNAME_COUNTERINCREMENT_STRING = "counter-increment", + ELEMNAME_COUNTERRESET_STRING = "counter-reset", + ELEMNAME_COUNTERSCOPE_STRING = "counter-scope", + ELEMNAME_COUNTERS_STRING = "counters", + ELEMNAME_COUNTER_STRING = "counter", + ELEMNAME_CSSSTYLECONVERSION_STRING = "css-style-conversion", + ELEMNAME_DECIMALFORMAT_STRING = "decimal-format", + ELEMNAME_DISPLAYIF_STRING = "display-if", // my own + ELEMNAME_ELEMENT_STRING = "element", // pattern-by-example support + ELEMNAME_EMPTY_STRING = "empty", + ELEMNAME_EVAL_STRING = "eval", + ELEMNAME_EXPECTEDCHILDREN_STRING = "expectedchildren", + ELEMNAME_EXTENSIONHANDLER_STRING = "code-dispatcher", + ELEMNAME_EXTENSION_STRING = "functions", + ELEMNAME_FALLBACK_STRING = "fallback", + ELEMNAME_FOREACH_STRING = "for-each", + ELEMNAME_IF_STRING = "if", + ELEMNAME_IMPORT_STRING = "import", + ELEMNAME_INCLUDE_STRING = "include", + ELEMNAME_KEY_STRING = "key", + ELEMNAME_LOCALE_STRING = "locale", + ELEMNAME_MESSAGE_STRING = "message", + ELEMNAME_NSALIAS_STRING = "namespace-alias", + ELEMNAME_NUMBER_STRING = "number", + ELEMNAME_OTHERWISE_STRING = "otherwise", + ELEMNAME_OUTPUT_STRING = "output", + ELEMNAME_PARAMVARIABLE_STRING = "param", + ELEMNAME_PI_OLD_STRING = "pi", + ELEMNAME_PI_STRING = "processing-instruction", + ELEMNAME_PRESERVESPACE_STRING = "preserve-space", + ELEMNAME_ROOT_STRING = "root", // pattern-by-example support + ELEMNAME_SCRIPT_STRING = "script", + ELEMNAME_SORT_STRING = "sort", + ELEMNAME_STRIPSPACE_STRING = "strip-space", + ELEMNAME_STYLESHEET_STRING = "stylesheet", + ELEMNAME_TARGETATTRIBUTE_STRING = "target-attribute", // pattern-by-example support + ELEMNAME_TARGETCOMMENT_STRING = "target-comment", + ELEMNAME_TARGETELEMENT_STRING = "target-element", // pattern-by-example support + ELEMNAME_TARGETPI_STRING = "target-pi", + ELEMNAME_TARGETTEXT_STRING = "target-text", + ELEMNAME_TEMPLATE_STRING = "template", + ELEMNAME_TEXT_STRING = "text", + ELEMNAME_TRANSFORM_STRING = "transform", + ELEMNAME_URL_STRING = "uri", // pattern-by-example support + ELEMNAME_USE_STRING = "use", + ELEMNAME_VALUEOF_STRING = "value-of", + ELEMNAME_VARIABLE_STRING = "variable", + ELEMNAME_WHEN_STRING = "when", + ELEMNAME_WITHPARAM_STRING = "with-param"; + + /** + * Literals for EXSLT function elements. + */ + public static final String + EXSLT_ELEMNAME_FUNCTION_STRING = "function", + EXSLT_ELEMNAME_FUNCRESULT_STRING = "result"; + public static final int + EXSLT_ELEMNAME_FUNCTION = 88, + EXSLT_ELEMNAME_FUNCRESULT = 89; + + + /** + * Literals for XSL attribute names. Note that there may be more + * names than IDs, because some names may map to the same ID. + */ + public static final String + ATTRNAME_AMOUNT = "amount", + ATTRNAME_ANCESTOR = "ancestor", + ATTRNAME_ARCHIVE = "archive", + ATTRNAME_ATTRIBUTE = "attribute", + ATTRNAME_ATTRIBUTE_SET = "attribute-set", + ATTRNAME_CASEORDER = "case-order", + ATTRNAME_CLASS = "class", + ATTRNAME_CLASSID = "classid", + ATTRNAME_CODEBASE = "codebase", + ATTRNAME_CODETYPE = "type", + ATTRNAME_CONDITION = "condition", + ATTRNAME_COPYTYPE = "copy-type", + ATTRNAME_COUNT = "count", + ATTRNAME_DATATYPE = "data-type", + ATTRNAME_DECIMALSEPARATOR = "decimal-separator", + ATTRNAME_DEFAULT = "default", + ATTRNAME_DEFAULTSPACE = "default-space", + ATTRNAME_DEPTH = "with-children", + ATTRNAME_DIGIT = "digit", + ATTRNAME_DIGITGROUPSEP = "digit-group-sep", + ATTRNAME_DISABLE_OUTPUT_ESCAPING = "disable-output-escaping", + ATTRNAME_ELEMENT = "element", + ATTRNAME_ELEMENTS = "elements", + ATTRNAME_EXCLUDE_RESULT_PREFIXES ="exclude-result-prefixes", + ATTRNAME_EXPR = "expr", + ATTRNAME_EXTENSIONELEMENTPREFIXES = "extension-element-prefixes", + ATTRNAME_FORMAT = "format", + ATTRNAME_FROM = "from", + ATTRNAME_GROUPINGSEPARATOR = "grouping-separator", + ATTRNAME_GROUPINGSIZE = "grouping-size", + ATTRNAME_HREF = "href", + ATTRNAME_ID = "id", + ATTRNAME_IMPORTANCE = "importance", + ATTRNAME_INDENTRESULT = "indent-result", + ATTRNAME_INFINITY = "infinity", + ATTRNAME_LANG = "lang", + ATTRNAME_LETTERVALUE = "letter-value", + ATTRNAME_LEVEL = "level", + ATTRNAME_MATCH = "match", + ATTRNAME_METHOD = "calls", + ATTRNAME_MINUSSIGN = "minus-sign", + ATTRNAME_MODE = "mode", + ATTRNAME_NAME = "name", + ATTRNAME_NAMESPACE = "namespace", + ATTRNAME_NAN = "NaN", + ATTRNAME_NDIGITSPERGROUP = "n-digits-per-group", + ATTRNAME_NS = "ns", + ATTRNAME_ONLY = "only", + ATTRNAME_ORDER = "order", + ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS = "cdata-section-elements", + ATTRNAME_OUTPUT_DOCTYPE_PUBLIC = "doctype-public", + ATTRNAME_OUTPUT_DOCTYPE_SYSTEM = "doctype-system", + ATTRNAME_OUTPUT_ENCODING = "encoding", + ATTRNAME_OUTPUT_INDENT = "indent", + ATTRNAME_OUTPUT_MEDIATYPE = "media-type", + ATTRNAME_OUTPUT_METHOD = "method", // qname, + ATTRNAME_OUTPUT_OMITXMLDECL = "omit-xml-declaration", + ATTRNAME_OUTPUT_STANDALONE = "standalone", + ATTRNAME_OUTPUT_VERSION = "version", + ATTRNAME_PATTERNSEPARATOR = "pattern-separator", + ATTRNAME_PERCENT = "percent", + ATTRNAME_PERMILLE = "per-mille", + ATTRNAME_PRIORITY = "priority", + ATTRNAME_REFID = "refID", + ATTRNAME_RESULTNS = "result-ns", + ATTRNAME_RESULT_PREFIX = "result-prefix", + ATTRNAME_SELECT = "select", + ATTRNAME_SEQUENCESRC = "sequence-src", + ATTRNAME_STYLE = "style", + ATTRNAME_STYLESHEET_PREFIX = "stylesheet-prefix", + ATTRNAME_TERMINATE = "terminate", + ATTRNAME_TEST = "test", + ATTRNAME_TOSTRING = "to-string", + ATTRNAME_TYPE = "type", + ATTRNAME_USE = "use", + ATTRNAME_USEATTRIBUTESETS = "use-attribute-sets", + ATTRNAME_VALUE = "value", + ATTRNAME_VERSION = "version", + ATTRNAME_XMLNS = "xmlns:", // namespace declaration prefix -- NOT an attribute by itself + ATTRNAME_XMLNSDEF = "xmlns", // default namespace + ATTRNAME_XMLSPACE = "xml:space", + ATTRNAME_ZERODIGIT = "zero-digit"; + + /** IDs for XSL attribute types. These are associated + * with the string literals in the TransformerImpl class. + * Don't change the numbers. NOTE THAT THESE ARE NOT IN + * ALPHABETICAL ORDER! + */ + public static final int TATTRNAME_OUTPUT_METHOD = 1, TATTRNAME_AMOUNT = 2, + TATTRNAME_ANCESTOR = 3, TATTRNAME_ARCHIVE = 4, + TATTRNAME_ATTRIBUTE = 5, + TATTRNAME_ATTRIBUTE_SET = 6, + TATTRNAME_CASEORDER = 7, TATTRNAME_CLASS = 8, + TATTRNAME_CLASSID = 9, TATTRNAME_CODEBASE = 10, + TATTRNAME_CODETYPE = 11, TATTRNAME_CONDITION = 12, + TATTRNAME_COPYTYPE = 13, TATTRNAME_COUNT = 14, + TATTRNAME_DATATYPE = 15, TATTRNAME_DEFAULT = 16, + TATTRNAME_DEFAULTSPACE = 17, TATTRNAME_DEPTH = 18, + TATTRNAME_DIGITGROUPSEP = 19, + TATTRNAME_DISABLE_OUTPUT_ESCAPING = 20, + TATTRNAME_ELEMENT = 21, TATTRNAME_ELEMENTS = 22, + TATTRNAME_EXPR = 23, + TATTRNAME_EXTENSIONELEMENTPREFIXES = 24, + TATTRNAME_FORMAT = 25, TATTRNAME_FROM = 26, + TATTRNAME_GROUPINGSEPARATOR = 27, + TATTRNAME_GROUPINGSIZE = 28, TATTRNAME_HREF = 29, + TATTRNAME_ID = 30, TATTRNAME_IMPORTANCE = 31, + TATTRNAME_INDENTRESULT = 32, TATTRNAME_LANG = 33, + TATTRNAME_LETTERVALUE = 34, TATTRNAME_LEVEL = 35, + TATTRNAME_MATCH = 36, TATTRNAME_METHOD = 37, + TATTRNAME_MODE = 38, TATTRNAME_NAME = 39, + TATTRNAME_NAMESPACE = 40, + TATTRNAME_NDIGITSPERGROUP = 41, TATTRNAME_NS = 42, + TATTRNAME_ONLY = 43, TATTRNAME_ORDER = 44, + TATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS = 45, + TATTRNAME_OUTPUT_DOCTYPE_PUBLIC = 46, + TATTRNAME_OUTPUT_DOCTYPE_SYSTEM = 47, + TATTRNAME_OUTPUT_ENCODING = 48, + TATTRNAME_OUTPUT_INDENT = 49, + TATTRNAME_OUTPUT_MEDIATYPE = 50, + TATTRNAME_OUTPUT_STANDALONE = 51, + TATTRNAME_OUTPUT_VERSION = 52, + TATTRNAME_OUTPUT_OMITXMLDECL = 53, + TATTRNAME_PRIORITY = 54, TATTRNAME_REFID = 55, + TATTRNAME_RESULTNS = 56, TATTRNAME_SELECT = 57, + TATTRNAME_SEQUENCESRC = 58, TATTRNAME_STYLE = 59, + TATTRNAME_TEST = 60, TATTRNAME_TOSTRING = 61, + TATTRNAME_TYPE = 62, TATTRNAME_USE = 63, + TATTRNAME_USEATTRIBUTESETS = 64, + TATTRNAME_VALUE = 65, TATTRNAME_XMLNSDEF = 66, + TATTRNAME_XMLNS = 67, TATTRNAME_XMLSPACE = 68, + TATTRNAME_EXCLUDE_RESULT_PREFIXES = 69; + + /** Mnemonics for the possible values of the xsl:output element's + * method= attribute: + *

      + *
    • ATTRVAL_OUTPUT_METHOD_XML = Use an XML formatter to + * produce the output document (basic XSLT operation).
    • + *
    • ATTRVAL_OUTPUT_METHOD_HTML: Use an HTML formatter to + * produce the output document. When generating HTML documents, + * this may yield better results; it does things like escaping + * characters in href attributes.
    • + * ATTRVAL_OUTPUT_METHOD_TEXT: Use a Text formatter to + * produce the output document. Generally the right choice if your + * stylesheet wants to take over _all_ the details of formatting, + * most often when producing something that isn't an XML or HTML + * document. + *
    + * */ + public static final String ATTRVAL_OUTPUT_METHOD_HTML = "html", + ATTRVAL_OUTPUT_METHOD_XML = "xml", + ATTRVAL_OUTPUT_METHOD_TEXT = "text"; + + + /* For space-att*/ + public static final int ATTRVAL_PRESERVE = 1, ATTRVAL_STRIP = 2; + + + /** For indent-result */ + public static final boolean ATTRVAL_YES = true, ATTRVAL_NO = false; + + + /** For letter-value attribute (part of conversion attributes). */ + public static final String ATTRVAL_ALPHABETIC = "alphabetic", + ATTRVAL_OTHER = "other", + ATTRVAL_TRADITIONAL = "traditional"; + + + /** For level attribute in xsl:number. */ + public static final String ATTRVAL_SINGLE = "single", + ATTRVAL_MULTI = "multiple", ATTRVAL_ANY = "any"; + + + /** For Stylesheet-prefix and result-prefix in xsl:namespace-alias */ + public static final String ATTRVAL_DEFAULT_PREFIX = "#default"; + + /** Integer equivalents for above */ + public static final int NUMBERLETTER_ALPHABETIC = 1, NUMBERLETTER_TRADITIONAL = 2; + + /** Integer equivelents for above */ + public static final int NUMBERLEVEL_SINGLE = 1, NUMBERLEVEL_MULTI = 2, + NUMBERLEVEL_ANY = 3, MAX_MULTI_COUNTING_DEPTH = 32; + + + /** some stuff for my patterns-by-example */ + public static final String ATTRVAL_THIS = ".", ATTRVAL_PARENT = "..", + ATTRVAL_ANCESTOR = "ancestor", ATTRVAL_ID = "id"; + + + /** Stuff for sorting */ + public static final String ATTRVAL_DATATYPE_TEXT = "text", + ATTRVAL_DATATYPE_NUMBER = "number", + ATTRVAL_ORDER_ASCENDING = "ascending", + ATTRVAL_ORDER_DESCENDING = "descending", + ATTRVAL_CASEORDER_UPPER = "upper-first", + ATTRVAL_CASEORDER_LOWER = "lower-first"; + + /** Integer equivelents for DATATYPE attribute */ + public static final int SORTDATATYPE_TEXT = 1, SORTDATATYPE_NUMBER = 2; + + /** Integer equivelents for ORDER attribute */ + public static final int SORTORDER_ASCENDING = 1, SORTORDER_DESCENDING = 2; + + /** Integer equivelents for CASE-ORDER attribute */ + public static final int SORTCASEORDER_UPPERFIRST = 1, SORTCASEORDER_LOWERFIRST = 2; + + /** some stuff for Decimal-format */ + public static final String ATTRVAL_INFINITY = "Infinity", + ATTRVAL_NAN = "NaN", + DEFAULT_DECIMAL_FORMAT = "#default"; + + + /** temp dummy */ + public static final String ATTRNAME_XXXX = "XXXX"; +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/package.html new file mode 100644 index 000000000..d72b9a7af --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/package.html @@ -0,0 +1,15 @@ + + + Xalan Templates Package. + + + +

    This package now only contain the classes used by XSLTC. In J2SE 1.5 only XSLTC is bundled as Transformer for supporting JAXP

    + + + + diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java new file mode 100644 index 000000000..8444d43d2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.utils; + +/** + * A configuration error. This was an internal class in ObjectFactory previously + * + * @LastModified: Oct 2017 + */ +public final class ConfigurationError + extends Error { + private static final long serialVersionUID = 749136645488750664L; + + // + // Data + // + + /** Exception. */ + private Exception exception; + + // + // Constructors + // + + /** + * Construct a new instance with the specified detail string and + * exception. + */ + ConfigurationError(String msg, Exception x) { + super(msg); + this.exception = x; + } // (String,Exception) + + // + // methods + // + + /** Returns the exception associated to this error. */ + public Exception getException() { + return exception; + } // getException():Exception + +} // class ConfigurationError diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java new file mode 100644 index 000000000..61c8b6514 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.org.apache.xalan.internal.utils; + +import jdk.xml.internal.JdkConstants; +import jdk.xml.internal.SecuritySupport; + +/** + * This is the base class for features and properties + * + * @LastModified: May 2021 + */ +public abstract class FeaturePropertyBase { + + /** + * States of the settings of a property, in the order: default value, value + * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system + * properties, and jaxp api properties + */ + public static enum State { + //this order reflects the overriding order + DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY + } + + + /** + * Values of the properties as defined in enum Properties + */ + String[] values = null; + /** + * States of the settings for each property in Properties above + */ + State[] states = {State.DEFAULT, State.DEFAULT}; + + + /** + * Set the value for a specific property. + * + * @param property the property + * @param state the state of the property + * @param value the value of the property + */ + public void setValue(Enum property, State state, String value) { + //only update if it shall override + if (state.compareTo(states[property.ordinal()]) >= 0) { + values[property.ordinal()] = value; + states[property.ordinal()] = state; + } + } + + /** + * Set the value of a property by its index + * @param index the index of the property + * @param state the state of the property + * @param value the value of the property + */ + public void setValue(int index, State state, String value) { + //only update if it shall override + if (state.compareTo(states[index]) >= 0) { + values[index] = value; + states[index] = state; + } + } + + /** + * Set value by property name and state + * @param propertyName property name + * @param state the state of the property + * @param value the value of the property + * @return true if the property is managed by the security property manager; + * false if otherwise. + */ + public boolean setValue(String propertyName, State state, Object value) { + int index = getIndex(propertyName); + if (index > -1) { + setValue(index, state, (String)value); + return true; + } + return false; + } + + /** + * Set value by property name and state + * @param propertyName property name + * @param state the state of the property + * @param value the value of the property + * @return true if the property is managed by the security property manager; + * false if otherwise. + */ + public boolean setValue(String propertyName, State state, boolean value) { + int index = getIndex(propertyName); + if (index > -1) { + if (value) { + setValue(index, state, JdkConstants.FEATURE_TRUE); + } else { + setValue(index, state, JdkConstants.FEATURE_FALSE); + } + return true; + } + return false; + } + + /** + * Return the value of the specified property + * + * @param property the property + * @return the value of the property + */ + public String getValue(Enum property) { + return values[property.ordinal()]; + } + + /** + * Return the value of the specified property + * + * @param property the property + * @return the value of the property + */ + public String getValue(String property) { + int index = getIndex(property); + if (index > -1) { + return getValueByIndex(index); + } + return null; + } + + /** + * Return the value of the specified property. + * + * @param propertyName the property name + * @return the value of the property as a string. If a property is managed + * by this manager, its value shall not be null. + */ + public String getValueAsString(String propertyName) { + int index = getIndex(propertyName); + if (index > -1) { + return getValueByIndex(index); + } + + return null; + } + + /** + * Return the value of a property by its ordinal + * @param index the index of a property + * @return value of a property + */ + public String getValueByIndex(int index) { + return values[index]; + } + + /** + * Get the index by property name + * @param propertyName property name + * @return the index of the property if found; return -1 if not + */ + public abstract int getIndex(String propertyName); + + public > int getIndex(Class property, String propertyName) { + for (Enum enumItem : property.getEnumConstants()) { + if (enumItem.toString().equals(propertyName)) { + //internally, ordinal is used as index + return enumItem.ordinal(); + } + } + return -1; + }; + + + /** + * Read from system properties, or those in jaxp.properties + * + * @param property the property + * @param systemProperty the name of the system property + */ + void getSystemProperty(Enum property, String systemProperty) { + try { + String value = SecuritySupport.getSystemProperty(systemProperty); + if (value != null) { + values[property.ordinal()] = value; + states[property.ordinal()] = State.SYSTEMPROPERTY; + return; + } + + value = SecuritySupport.readJAXPProperty(systemProperty); + if (value != null) { + values[property.ordinal()] = value; + states[property.ordinal()] = State.JAXPDOTPROPERTIES; + } + } catch (NumberFormatException e) { + //invalid setting ignored + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java new file mode 100644 index 000000000..c1d910b06 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.utils; + +import java.util.function.Supplier; +import jdk.xml.internal.SecuritySupport; + +/** + * This class is duplicated for each JAXP subpackage so keep it in sync. + * It is package private and therefore is not exposed as part of the JAXP + * API. + *

    + * This class was moved from the javax.xml.parsers.ObjectFactory + * class and modified to be used as a general utility for creating objects + * dynamically. + * + * @LastModified: Oct 2017 + */ +public class ObjectFactory { + + // + // Constants + // + private static final String JAXP_INTERNAL = "com.sun.org.apache"; + private static final String STAX_INTERNAL = "com.sun.xml.internal"; + + /** Set to true for debugging */ + private static final boolean DEBUG = false; + + + /** Prints a message to standard error if debugging is enabled. */ + private static void debugPrintln(Supplier msgGen) { + if (DEBUG) { + System.err.println("JAXP: " + msgGen.get()); + } + } // debugPrintln(String) + + /** + * Figure out which ClassLoader to use. For JDK 1.2 and later use + * the context ClassLoader. + */ + @SuppressWarnings("removal") + public static ClassLoader findClassLoader() + { + if (System.getSecurityManager()!=null) { + //this will ensure bootclassloader is used + return null; + } + + // Figure out which ClassLoader to use for loading the provider + // class. If there is a Context ClassLoader then use it. + ClassLoader context = SecuritySupport.getContextClassLoader(); + ClassLoader system = SecuritySupport.getSystemClassLoader(); + + ClassLoader chain = system; + while (true) { + if (context == chain) { + // Assert: we are on JDK 1.1 or we have no Context ClassLoader + // or any Context ClassLoader in chain of system classloader + // (including extension ClassLoader) so extend to widest + // ClassLoader (always look in system ClassLoader if Xalan + // is in boot/extension/system classpath and in current + // ClassLoader otherwise); normal classloaders delegate + // back to system ClassLoader first so this widening doesn't + // change the fact that context ClassLoader will be consulted + ClassLoader current = ObjectFactory.class.getClassLoader(); + + chain = system; + while (true) { + if (current == chain) { + // Assert: Current ClassLoader in chain of + // boot/extension/system ClassLoaders + return system; + } + if (chain == null) { + break; + } + chain = SecuritySupport.getParentClassLoader(chain); + } + + // Assert: Current ClassLoader not in chain of + // boot/extension/system ClassLoaders + return current; + } + + if (chain == null) { + // boot ClassLoader reached + break; + } + + // Check for any extension ClassLoaders in chain up to + // boot ClassLoader + chain = SecuritySupport.getParentClassLoader(chain); + } + + // Assert: Context ClassLoader not in chain of + // boot/extension/system ClassLoaders + return context; + } // findClassLoader():ClassLoader + + /** + * Create an instance of a class using the same class loader for the ObjectFactory by default + * or boot class loader when Security Manager is in place + */ + public static Object newInstance(String className, boolean doFallback) + throws ConfigurationError + { + @SuppressWarnings("removal") + ClassLoader cl = System.getSecurityManager()!=null ? null : findClassLoader(); + try{ + Class providerClass = findProviderClass(className, cl, doFallback); + Object instance = providerClass.getConstructor().newInstance(); + debugPrintln(()->"created new instance of " + providerClass + + " using ClassLoader: " + cl); + return instance; + } catch (ClassNotFoundException x) { + throw new ConfigurationError( + "Provider " + className + " not found", x); + } catch (Exception x) { + throw new ConfigurationError( + "Provider " + className + " could not be instantiated: " + x, + x); + } + } + + /** + * Find a Class using the same class loader for the ObjectFactory by default + * or boot class loader when Security Manager is in place + */ + public static Class findProviderClass(String className, boolean doFallback) + throws ClassNotFoundException, ConfigurationError + { + return findProviderClass (className, + findClassLoader (), doFallback); + } + + /** + * Find a Class using the specified ClassLoader + */ + private static Class findProviderClass(String className, ClassLoader cl, + boolean doFallback) + throws ClassNotFoundException, ConfigurationError + { + //throw security exception if the calling thread is not allowed to access the + //class. Restrict the access to the package classes as specified in java.security policy. + @SuppressWarnings("removal") + SecurityManager security = System.getSecurityManager(); + try{ + if (security != null){ + if (className.startsWith(JAXP_INTERNAL) || + className.startsWith(STAX_INTERNAL)) { + cl = null; + } else { + final int lastDot = className.lastIndexOf("."); + String packageName = className; + if (lastDot != -1) packageName = className.substring(0, lastDot); + security.checkPackageAccess(packageName); + } + } + }catch(SecurityException e){ + throw e; + } + + Class providerClass; + if (cl == null) { + providerClass = Class.forName(className, false, ObjectFactory.class.getClassLoader()); + } else { + try { + providerClass = cl.loadClass(className); + } catch (ClassNotFoundException x) { + if (doFallback) { + // Fall back to current classloader + ClassLoader current = ObjectFactory.class.getClassLoader(); + if (current == null) { + providerClass = Class.forName(className); + } else if (cl != current) { + cl = current; + providerClass = cl.loadClass(className); + } else { + throw x; + } + } else { + throw x; + } + } + } + + return providerClass; + } + +} // class ObjectFactory diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java new file mode 100644 index 000000000..0d5cfd17e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.org.apache.xalan.internal.utils; + +import javax.xml.XMLConstants; +import jdk.xml.internal.JdkConstants; + +/** + * This class manages security related properties + * + */ +public final class XMLSecurityPropertyManager extends FeaturePropertyBase { + + /** + * Properties managed by the security property manager + */ + public static enum Property { + ACCESS_EXTERNAL_DTD(XMLConstants.ACCESS_EXTERNAL_DTD, + JdkConstants.EXTERNAL_ACCESS_DEFAULT), + ACCESS_EXTERNAL_STYLESHEET(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, + JdkConstants.EXTERNAL_ACCESS_DEFAULT); + + final String name; + final String defaultValue; + + Property(String name, String value) { + this.name = name; + this.defaultValue = value; + } + + public boolean equalsName(String propertyName) { + return (propertyName == null) ? false : name.equals(propertyName); + } + + String defaultValue() { + return defaultValue; + } + } + + + /** + * Default constructor. Establishes default values + */ + public XMLSecurityPropertyManager() { + values = new String[Property.values().length]; + for (Property property : Property.values()) { + values[property.ordinal()] = property.defaultValue(); + } + //read system properties or jaxp.properties + readSystemProperties(); + } + + /** + * Get the index by property name + * @param propertyName property name + * @return the index of the property if found; return -1 if not + */ + public int getIndex(String propertyName){ + for (Property property : Property.values()) { + if (property.equalsName(propertyName)) { + //internally, ordinal is used as index + return property.ordinal(); + } + } + return -1; + } + + /** + * Read from system properties, or those in jaxp.properties + */ + private void readSystemProperties() { + getSystemProperty(Property.ACCESS_EXTERNAL_DTD, + JdkConstants.SP_ACCESS_EXTERNAL_DTD); + getSystemProperty(Property.ACCESS_EXTERNAL_STYLESHEET, + JdkConstants.SP_ACCESS_EXTERNAL_STYLESHEET); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xslt/package.html b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xslt/package.html new file mode 100644 index 000000000..5915ebed3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xslt/package.html @@ -0,0 +1,28 @@ + + + + + Xalan command-line interface. + +

    Implementation of Xalan command-line interface.

    + + + + diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/CollatorFactory.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/CollatorFactory.java new file mode 100644 index 000000000..318485d42 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/CollatorFactory.java @@ -0,0 +1,35 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import java.text.Collator; +import java.util.Locale; + +/** + * @author W. Eliot Kimber (eliot@isogen.com) + * @author Santiago Pericas-Geertsen + */ +public interface CollatorFactory { + + public Collator getCollator(String lang, String country); + public Collator getCollator(Locale locale); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOM.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOM.java new file mode 100644 index 000000000..47534bc4a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOM.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; +import java.util.Map; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface DOM { + public final static int FIRST_TYPE = 0; + + public final static int NO_TYPE = -1; + + // 0 is reserved for NodeIterator.END + public final static int NULL = 0; + + // used by some node iterators to know which node to return + public final static int RETURN_CURRENT = 0; + public final static int RETURN_PARENT = 1; + + // Constants used by getResultTreeFrag to indicate the types of the RTFs. + public final static int SIMPLE_RTF = 0; + public final static int ADAPTIVE_RTF = 1; + public final static int TREE_RTF = 2; + + /** returns singleton iterator containg the document root */ + public DTMAxisIterator getIterator(); + public String getStringValue(); + + public DTMAxisIterator getChildren(final int node); + public DTMAxisIterator getTypedChildren(final int type); + public DTMAxisIterator getAxisIterator(final int axis); + public DTMAxisIterator getTypedAxisIterator(final int axis, final int type); + public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself); + public DTMAxisIterator getNamespaceAxisIterator(final int axis, final int ns); + public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int returnType, + String value, boolean op); + public DTMAxisIterator orderNodes(DTMAxisIterator source, int node); + public String getNodeName(final int node); + public String getNodeNameX(final int node); + public String getNamespaceName(final int node); + public int getExpandedTypeID(final int node); + public int getNamespaceType(final int node); + public int getParent(final int node); + public int getAttributeNode(final int gType, final int element); + public String getStringValueX(final int node); + public void copy(final int node, SerializationHandler handler) + throws TransletException; + public void copy(DTMAxisIterator nodes, SerializationHandler handler) + throws TransletException; + public String shallowCopy(final int node, SerializationHandler handler) + throws TransletException; + public boolean lessThan(final int node1, final int node2); + public void characters(final int textNode, SerializationHandler handler) + throws TransletException; + public Node makeNode(int index); + public Node makeNode(DTMAxisIterator iter); + public NodeList makeNodeList(int index); + public NodeList makeNodeList(DTMAxisIterator iter); + public String getLanguage(int node); + public int getSize(); + public String getDocumentURI(int node); + public void setFilter(StripFilter filter); + public void setupMapping(String[] names, String[] urisArray, int[] typesArray, String[] namespaces); + public boolean isElement(final int node); + public boolean isAttribute(final int node); + public String lookupNamespace(int node, String prefix) + throws TransletException; + public int getNodeIdent(final int nodehandle); + public int getNodeHandle(final int nodeId); + public DOM getResultTreeFrag(int initialSize, int rtfType); + public DOM getResultTreeFrag(int initialSize, int rtfType, boolean addToDTMManager); + public SerializationHandler getOutputDomBuilder(); + public int getNSType(int node); + public int getDocument(); + public String getUnparsedEntityURI(String name); + public Map getElementsWithIDs(); + public void release(); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMCache.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMCache.java new file mode 100644 index 000000000..6d37efb03 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMCache.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + + +/** + * @author Morten Jorgensen + */ +public interface DOMCache { + + /** + * This method is responsible for: + * + * (1) building the DOMImpl tree + * + * Parser _parser = new Parser(); + * DOMImpl _dom = new DOMImpl(); + * _parser.setDocumentHandler(_dom.getBuilder()); + * _parser.setDTDHandler(_dom.getBuilder()); + * _parser.parse(uri); + * + * (2) giving the translet an early opportunity to extract anything from + * the DOMImpl that it would like + * + * translet.documentPrepass(_dom); + * + * (3) setting the document URI: + * + * _dom.setDocumentURI(uri); + * + * @param baseURI The base URI used by the document call. + * @param href The href argument passed to the document function. + * @param translet A reference to the translet requesting the document + */ + public DOM retrieveDocument(String baseURI, String href, Translet translet); + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMEnhancedForDTM.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMEnhancedForDTM.java new file mode 100644 index 000000000..0194201bb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMEnhancedForDTM.java @@ -0,0 +1,46 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +/** + * Interface for SAXImpl which adds methods used at run-time, over and above + * those provided by the XSLTC DOM interface. An attempt to avoid the current + * "Is the DTM a DOM, if so is it a SAXImpl, . . . + * which was producing some ugly replicated code + * and introducing bugs where that multipathing had not been + * done. This makes it easier to provide other DOM/DOMEnhancedForDTM + * implementations, rather than hard-wiring XSLTC to SAXImpl. + * + * @author Joseph Kesselman + * + */ +public interface DOMEnhancedForDTM extends DOM { + public short[] getMapping(String[] names, String[] uris, int[] types); + public int[] getReverseMapping(String[] names, String[] uris, int[] types); + public short[] getNamespaceMapping(String[] namespaces); + public short[] getReverseNamespaceMapping(String[] namespaces); + public String getDocumentURI(); + public void setDocumentURI(String uri); + public int getExpandedTypeID2(int nodeHandle); + public boolean hasDOMSource(); + public int getElementById(String idString); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/NodeIterator.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/NodeIterator.java new file mode 100644 index 000000000..a8eba9135 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/NodeIterator.java @@ -0,0 +1,84 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import com.sun.org.apache.xml.internal.dtm.DTM; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface NodeIterator extends Cloneable { + public static final int END = DTM.NULL; + + /** + * Callers should not call next() after it returns END. + */ + public int next(); + + /** + * Resets the iterator to the last start node. + */ + public NodeIterator reset(); + + /** + * Returns the number of elements in this iterator. + */ + public int getLast(); + + /** + * Returns the position of the current node in the set. + */ + public int getPosition(); + + /** + * Remembers the current node for the next call to gotoMark(). + */ + public void setMark(); + + /** + * Restores the current node remembered by setMark(). + */ + public void gotoMark(); + + /** + * Set start to END should 'close' the iterator, + * i.e. subsequent call to next() should return END. + */ + public NodeIterator setStartNode(int node); + + /** + * True if this iterator has a reversed axis. + */ + public boolean isReverse(); + + /** + * Returns a deep copy of this iterator. + */ + public NodeIterator cloneIterator(); + + /** + * Prevents or allows iterator restarts. + */ + public void setRestartable(boolean isRestartable); + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/ProcessorVersion.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/ProcessorVersion.java new file mode 100644 index 000000000..dcfab47dc --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/ProcessorVersion.java @@ -0,0 +1,49 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + + +/** + * Admin class that assigns a version number to the XSLTC software. + * The version number is made up from three fields as in: + * MAJOR.MINOR[.DELTA]. Fields are incremented based on the following: + * DELTA field: changes for each bug fix, developer fixing the bug should + * increment this field. + * MINOR field: API changes or a milestone culminating from several + * bug fixes. DELTA field goes to zero and MINOR is + * incremented such as: {1.0,1.0.1,1.0.2,1.0.3,...1.0.18,1.1} + * MAJOR field: milestone culminating in fundamental API changes or + * architectural changes. MINOR field goes to zero + * and MAJOR is incremented such as: {...,1.1.14,1.2,2.0} + * Stability of a release follows: X.0 > X.X > X.X.X + * @author G. Todd Miller + */ +public class ProcessorVersion { + private static int MAJOR = 1; + private static int MINOR = 0; + private static int DELTA = 0; + + public static void main(String[] args) { + System.out.println("XSLTC version " + MAJOR + "." + MINOR + + ((DELTA > 0) ? ("."+DELTA) : (""))); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/StripFilter.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/StripFilter.java new file mode 100644 index 000000000..53393019c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/StripFilter.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface StripFilter { + public boolean stripSpace(DOM dom, int node, int type); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/Translet.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/Translet.java new file mode 100644 index 000000000..5a34a35c5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/Translet.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +public interface Translet { + + public void transform(DOM document, SerializationHandler handler) + throws TransletException; + public void transform(DOM document, SerializationHandler[] handlers) + throws TransletException; + public void transform(DOM document, DTMAxisIterator iterator, + SerializationHandler handler) + throws TransletException; + + public Object addParameter(String name, Object value); + + public void buildKeys(DOM document, DTMAxisIterator iterator, + SerializationHandler handler, int root) + throws TransletException; + public void addAuxiliaryClass(Class auxClass); + public Class getAuxiliaryClass(String className); + public String[] getNamesArray(); + public String[] getUrisArray(); + public int[] getTypesArray(); + public String[] getNamespaceArray(); + public boolean overrideDefaultParser(); + public void setOverrideDefaultParser(boolean flag); + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/TransletException.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/TransletException.java new file mode 100644 index 000000000..d330f6b1c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/TransletException.java @@ -0,0 +1,46 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import org.xml.sax.SAXException; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +public final class TransletException extends SAXException { + static final long serialVersionUID = -878916829521217293L; + + public TransletException() { + super("Translet error"); + } + + public TransletException(Exception e) { + super(e.toString()); + initCause(e); + } + + public TransletException(String message) { + super(message); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsoluteLocationPath.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsoluteLocationPath.java new file mode 100644 index 000000000..ca9ca3e39 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsoluteLocationPath.java @@ -0,0 +1,128 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class AbsoluteLocationPath extends Expression { + private Expression _path; // may be null + + public AbsoluteLocationPath() { + _path = null; + } + + public AbsoluteLocationPath(Expression path) { + _path = path; + if (path != null) { + _path.setParent(this); + } + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_path != null) { + _path.setParser(parser); + } + } + + public Expression getPath() { + return(_path); + } + + public String toString() { + return "AbsoluteLocationPath(" + + (_path != null ? _path.toString() : "null") + ')'; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_path != null) { + final Type ptype = _path.typeCheck(stable); + if (ptype instanceof NodeType) { // promote to node-set + _path = new CastExpr(_path, Type.NodeSet); + } + } + return _type = Type.NodeSet; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + if (_path != null) { + final int initAI = cpg.addMethodref(ABSOLUTE_ITERATOR, + "", + "(" + + NODE_ITERATOR_SIG + + ")V"); + + // Compile relative path iterator(s) + // + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // this argument to its constructor. Instead we calculate the + // value of the argument to the constructor first, store it in + // a temporary variable, create the object and reload the argument + // from the temporary to avoid the problem. + _path.translate(classGen, methodGen); + LocalVariableGen relPathIterator + = methodGen.addLocalVariable("abs_location_path_tmp", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + relPathIterator.setStart( + il.append(new ASTORE(relPathIterator.getIndex()))); + + // Create new AbsoluteIterator + il.append(new NEW(cpg.addClass(ABSOLUTE_ITERATOR))); + il.append(DUP); + relPathIterator.setEnd( + il.append(new ALOAD(relPathIterator.getIndex()))); + + // Initialize AbsoluteIterator with iterator from the stack + il.append(new INVOKESPECIAL(initAI)); + } + else { + final int gitr = cpg.addInterfaceMethodref(DOM_INTF, + "getIterator", + "()"+NODE_ITERATOR_SIG); + il.append(methodGen.loadDOM()); + il.append(new INVOKEINTERFACE(gitr, 1)); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsolutePathPattern.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsolutePathPattern.java new file mode 100644 index 000000000..9de660708 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsolutePathPattern.java @@ -0,0 +1,140 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO_W; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPEQ; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.dtm.DTM; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class AbsolutePathPattern extends LocationPathPattern { + private final RelativePathPattern _left; // may be null + + public AbsolutePathPattern(RelativePathPattern left) { + _left = left; + if (left != null) { + left.setParent(this); + } + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_left != null) + _left.setParser(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return _left == null ? Type.Root : _left.typeCheck(stable); + } + + public boolean isWildcard() { + return false; + } + + public StepPattern getKernelPattern() { + return _left != null ? _left.getKernelPattern() : null; + } + + public void reduceKernelPattern() { + _left.reduceKernelPattern(); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + if (_left != null) { + if (_left instanceof StepPattern) { + final LocalVariableGen local = + // absolute path pattern temporary + methodGen.addLocalVariable2("apptmp", + Util.getJCRefType(NODE_SIG), + null); + il.append(DUP); + local.setStart(il.append(new ISTORE(local.getIndex()))); + _left.translate(classGen, methodGen); + il.append(methodGen.loadDOM()); + local.setEnd(il.append(new ILOAD(local.getIndex()))); + methodGen.removeLocalVariable(local); + } + else { + _left.translate(classGen, methodGen); + } + } + + final int getParent = cpg.addInterfaceMethodref(DOM_INTF, + GET_PARENT, + GET_PARENT_SIG); + final int getType = cpg.addInterfaceMethodref(DOM_INTF, + "getExpandedTypeID", + "(I)I"); + + InstructionHandle begin = il.append(methodGen.loadDOM()); + il.append(SWAP); + il.append(new INVOKEINTERFACE(getParent, 2)); + if (_left instanceof AncestorPattern) { + il.append(methodGen.loadDOM()); + il.append(SWAP); + } + il.append(new INVOKEINTERFACE(getType, 2)); + il.append(new PUSH(cpg, DTM.DOCUMENT_NODE)); + + final BranchHandle skip = il.append(new IF_ICMPEQ(null)); + _falseList.add(il.append(new GOTO_W(null))); + skip.setTarget(il.append(NOP)); + + if (_left != null) { + _left.backPatchTrueList(begin); + + /* + * If _left is an ancestor pattern, backpatch this pattern's false + * list to the loop that searches for more ancestors. + */ + if (_left instanceof AncestorPattern) { + final AncestorPattern ancestor = (AncestorPattern) _left; + _falseList.backPatch(ancestor.getLoopHandle()); // clears list + } + _falseList.append(_left._falseList); + } + } + + public String toString() { + return "absolutePathPattern(" + (_left != null ? _left.toString() : ")"); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AlternativePattern.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AlternativePattern.java new file mode 100644 index 000000000..9a727f960 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AlternativePattern.java @@ -0,0 +1,100 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class AlternativePattern extends Pattern { + private final Pattern _left; + private final Pattern _right; + + /** + * Construct an alternative pattern. The method setParent + * should not be called in this case. + */ + public AlternativePattern(Pattern left, Pattern right) { + _left = left; + _right = right; + } + + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + public Pattern getLeft() { + return _left; + } + + public Pattern getRight() { + return _right; + } + + /** + * The type of an '|' is not really defined, hence null is returned. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _left.typeCheck(stable); + _right.typeCheck(stable); + return null; + } + + public double getPriority() { + double left = _left.getPriority(); + double right = _right.getPriority(); + + if (left < right) + return(left); + else + return(right); + } + + public String toString() { + return "alternative(" + _left + ", " + _right + ')'; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + + _left.translate(classGen, methodGen); + final InstructionHandle gotot = il.append(new GOTO(null)); + il.append(methodGen.loadContextNode()); + _right.translate(classGen, methodGen); + + _left._trueList.backPatch(gotot); + _left._falseList.backPatch(gotot.getNext()); + + _trueList.append(_right._trueList.add(gotot)); + _falseList.append(_right._falseList); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AncestorPattern.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AncestorPattern.java new file mode 100644 index 000000000..bda61123c --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AncestorPattern.java @@ -0,0 +1,182 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFLT; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Erwin Bolwidt + */ +final class AncestorPattern extends RelativePathPattern { + + private final Pattern _left; // may be null + private final RelativePathPattern _right; + private InstructionHandle _loop; + + public AncestorPattern(RelativePathPattern right) { + this(null, right); + } + + public AncestorPattern(Pattern left, RelativePathPattern right) { + _left = left; + (_right = right).setParent(this); + if (left != null) { + left.setParent(this); + } + } + + public InstructionHandle getLoopHandle() { + return _loop; + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_left != null) { + _left.setParser(parser); + } + _right.setParser(parser); + } + + public boolean isWildcard() { + //!!! can be wildcard + return false; + } + + public StepPattern getKernelPattern() { + return _right.getKernelPattern(); + } + + public void reduceKernelPattern() { + _right.reduceKernelPattern(); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_left != null) { + _left.typeCheck(stable); + } + return _right.typeCheck(stable); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + InstructionHandle parent; + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + /* + * The scope of this local var must be the entire method since + * a another pattern may decide to jump back into the loop + */ + final LocalVariableGen local = + methodGen.addLocalVariable2("app", Util.getJCRefType(NODE_SIG), + il.getEnd()); + + final com.sun.org.apache.bcel.internal.generic.Instruction loadLocal = + new ILOAD(local.getIndex()); + final com.sun.org.apache.bcel.internal.generic.Instruction storeLocal = + new ISTORE(local.getIndex()); + + if (_right instanceof StepPattern) { + il.append(DUP); + il.append(storeLocal); + _right.translate(classGen, methodGen); + il.append(methodGen.loadDOM()); + il.append(loadLocal); + } + else { + _right.translate(classGen, methodGen); + + if (_right instanceof AncestorPattern) { + il.append(methodGen.loadDOM()); + il.append(SWAP); + } + } + + if (_left != null) { + final int getParent = cpg.addInterfaceMethodref(DOM_INTF, + GET_PARENT, + GET_PARENT_SIG); + parent = il.append(new INVOKEINTERFACE(getParent, 2)); + + il.append(DUP); + il.append(storeLocal); + _falseList.add(il.append(new IFLT(null))); + il.append(loadLocal); + + _left.translate(classGen, methodGen); + + final SyntaxTreeNode p = getParent(); + if (p == null || p instanceof Instruction || + p instanceof TopLevelElement) + { + // do nothing + } + else { + il.append(loadLocal); + } + + final BranchHandle exit = il.append(new GOTO(null)); + _loop = il.append(methodGen.loadDOM()); + il.append(loadLocal); + local.setEnd(_loop); + il.append(new GOTO(parent)); + exit.setTarget(il.append(NOP)); + _left.backPatchFalseList(_loop); + + _trueList.append(_left._trueList); + } + else { + il.append(POP2); + } + + /* + * If _right is an ancestor pattern, backpatch this pattern's false + * list to the loop that searches for more ancestors. + */ + if (_right instanceof AncestorPattern) { + final AncestorPattern ancestor = (AncestorPattern) _right; + _falseList.backPatch(ancestor.getLoopHandle()); // clears list + } + + _trueList.append(_right._trueList); + _falseList.append(_right._falseList); + } + + public String toString() { + return "AncestorPattern(" + _left + ", " + _right + ')'; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java new file mode 100644 index 000000000..ac19717af --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java @@ -0,0 +1,159 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import java.util.Enumeration; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +final class ApplyImports extends Instruction { + + private QName _modeName; + private int _precedence; + + public void display(int indent) { + indent(indent); + Util.println("ApplyTemplates"); + indent(indent + IndentIncrement); + if (_modeName != null) { + indent(indent + IndentIncrement); + Util.println("mode " + _modeName); + } + } + + /** + * Returns true if this element has parameters + */ + public boolean hasWithParams() { + return hasContents(); + } + + /** + * Determine the lowest import precedence for any stylesheet imported + * or included by the stylesheet in which this + * element occured. The templates that are imported by the stylesheet in + * which this element occured will all have higher import precedence than + * the integer returned by this method. + */ + private int getMinPrecedence(int max) { + // Move to root of include tree + Stylesheet includeRoot = getStylesheet(); + while (includeRoot._includedFrom != null) { + includeRoot = includeRoot._includedFrom; + } + + return includeRoot.getMinimumDescendantPrecedence(); + } + + /** + * Parse the attributes and contents of an element. + */ + public void parseContents(Parser parser) { + // Indicate to the top-level stylesheet that all templates must be + // compiled into separate methods. + Stylesheet stylesheet = getStylesheet(); + stylesheet.setTemplateInlining(false); + + // Get the mode we are currently in (might not be any) + Template template = getTemplate(); + _modeName = template.getModeName(); + _precedence = template.getImportPrecedence(); + + // Get the method name for in this mode + stylesheet = parser.getTopLevelStylesheet(); + + parseChildren(parser); // with-params + } + + /** + * Type-check the attributes/contents of an element. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + typeCheckContents(stable); // with-params + return Type.Void; + } + + /** + * Translate call-template. A parameter frame is pushed only if + * some template in the stylesheet uses parameters. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final Stylesheet stylesheet = classGen.getStylesheet(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int current = methodGen.getLocalIndex("current"); + + // Push the arguments that are passed to applyTemplates() + il.append(classGen.loadTranslet()); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadIterator()); + il.append(methodGen.loadHandler()); + il.append(methodGen.loadCurrentNode()); + + // Push a new parameter frame in case imported template might expect + // parameters. The apply-imports has nothing that it can pass. + if (stylesheet.hasLocalParams()) { + il.append(classGen.loadTranslet()); + final int pushFrame = cpg.addMethodref(TRANSLET_CLASS, + PUSH_PARAM_FRAME, + PUSH_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(pushFrame)); + } + + // Get the [min,max> precedence of all templates imported under the + // current stylesheet + final int maxPrecedence = _precedence; + final int minPrecedence = getMinPrecedence(maxPrecedence); + final Mode mode = stylesheet.getMode(_modeName); + + // Get name of appropriate apply-templates function for this + // xsl:apply-imports instruction + String functionName = mode.functionName(minPrecedence, maxPrecedence); + + // Construct the translet class-name and the signature of the method + final String className = classGen.getStylesheet().getClassName(); + final String signature = classGen.getApplyTemplatesSigForImport(); + final int applyTemplates = cpg.addMethodref(className, + functionName, + signature); + il.append(new INVOKEVIRTUAL(applyTemplates)); + + // Pop any parameter frame that was pushed above. + if (stylesheet.hasLocalParams()) { + il.append(classGen.loadTranslet()); + final int pushFrame = cpg.addMethodref(TRANSLET_CLASS, + POP_PARAM_FRAME, + POP_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(pushFrame)); + } + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java new file mode 100644 index 000000000..228348b44 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.utils.XML11Char; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class ApplyTemplates extends Instruction { + private Expression _select; + private Type _type = null; + private QName _modeName; + private String _functionName; + + public void display(int indent) { + indent(indent); + Util.println("ApplyTemplates"); + indent(indent + IndentIncrement); + Util.println("select " + _select.toString()); + if (_modeName != null) { + indent(indent + IndentIncrement); + Util.println("mode " + _modeName); + } + } + + public boolean hasWithParams() { + return hasContents(); + } + + public void parseContents(Parser parser) { + final String select = getAttribute("select"); + final String mode = getAttribute("mode"); + + if (select.length() > 0) { + _select = parser.parseExpression(this, "select", null); + + } + + if (mode.length() > 0) { + if (!XML11Char.isXML11ValidQName(mode)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this); + parser.reportError(Constants.ERROR, err); + } + _modeName = parser.getQNameIgnoreDefaultNs(mode); + } + + // instantiate Mode if needed, cache (apply temp) function name + _functionName = + parser.getTopLevelStylesheet().getMode(_modeName).functionName(); + parseChildren(parser);// with-params + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_select != null) { + _type = _select.typeCheck(stable); + if (_type instanceof NodeType || _type instanceof ReferenceType) { + _select = new CastExpr(_select, Type.NodeSet); + _type = Type.NodeSet; + } + if (_type instanceof NodeSetType||_type instanceof ResultTreeType) { + typeCheckContents(stable); // with-params + return Type.Void; + } + throw new TypeCheckError(this); + } + else { + typeCheckContents(stable); // with-params + return Type.Void; + } + } + + /** + * Translate call-template. A parameter frame is pushed only if + * some template in the stylesheet uses parameters. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + boolean setStartNodeCalled = false; + final Stylesheet stylesheet = classGen.getStylesheet(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int current = methodGen.getLocalIndex("current"); + + // check if sorting nodes is required + final List sortObjects = new ArrayList<>(); + for (final SyntaxTreeNode child : getContents()) { + if (child instanceof Sort) { + sortObjects.add((Sort)child); + } + } + + // Push a new parameter frame + if (stylesheet.hasLocalParams() || hasContents()) { + il.append(classGen.loadTranslet()); + final int pushFrame = cpg.addMethodref(TRANSLET_CLASS, + PUSH_PARAM_FRAME, + PUSH_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(pushFrame)); + // translate with-params + translateContents(classGen, methodGen); + } + + + il.append(classGen.loadTranslet()); + + // The 'select' expression is a result-tree + if ((_type != null) && (_type instanceof ResultTreeType)) { + // cannot be applied to a result tree - issue warning + if (sortObjects.size() > 0) { + ErrorMsg err = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this); + getParser().reportError(WARNING, err); + } + // Put the result tree (a DOM adapter) on the stack + _select.translate(classGen, methodGen); + // Get back the DOM and iterator (not just iterator!!!) + _type.translateTo(classGen, methodGen, Type.NodeSet); + } + else { + il.append(methodGen.loadDOM()); + + // compute node iterator for applyTemplates + if (sortObjects.size() > 0) { + Sort.translateSortIterator(classGen, methodGen, + _select, sortObjects); + int setStartNode = cpg.addInterfaceMethodref(NODE_ITERATOR, + SET_START_NODE, + "(I)"+ + NODE_ITERATOR_SIG); + il.append(methodGen.loadCurrentNode()); + il.append(new INVOKEINTERFACE(setStartNode,2)); + setStartNodeCalled = true; + } + else { + if (_select == null) + Mode.compileGetChildren(classGen, methodGen, current); + else + _select.translate(classGen, methodGen); + } + } + + if (_select != null && !setStartNodeCalled) { + _select.startIterator(classGen, methodGen); + } + + //!!! need to instantiate all needed modes + final String className = classGen.getStylesheet().getClassName(); + il.append(methodGen.loadHandler()); + final String applyTemplatesSig = classGen.getApplyTemplatesSig(); + final int applyTemplates = cpg.addMethodref(className, + _functionName, + applyTemplatesSig); + il.append(new INVOKEVIRTUAL(applyTemplates)); + + // unmap parameters to release temporary result trees + for (final SyntaxTreeNode child : getContents()) { + if (child instanceof WithParam) { + ((WithParam)child).releaseResultTree(classGen, methodGen); + } + } + + // Pop parameter frame + if (stylesheet.hasLocalParams() || hasContents()) { + il.append(classGen.loadTranslet()); + final int popFrame = cpg.addMethodref(TRANSLET_CLASS, + POP_PARAM_FRAME, + POP_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(popFrame)); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ArgumentList.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ArgumentList.java new file mode 100644 index 000000000..ce654252e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ArgumentList.java @@ -0,0 +1,42 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class ArgumentList { + private final Expression _arg; + private final ArgumentList _rest; + + public ArgumentList(Expression arg, ArgumentList rest) { + _arg = arg; + _rest = rest; + } + + public String toString() { + return _rest == null + ? _arg.toString() + : _arg.toString() + ", " + _rest.toString(); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Attribute.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Attribute.java new file mode 100644 index 000000000..a659d2e5e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Attribute.java @@ -0,0 +1,45 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class Attribute extends Instruction { + private QName _name; + + public void display(int indent) { + indent(indent); + Util.println("Attribute " + _name); + displayContents(indent + IndentIncrement); + } + + public void parseContents(Parser parser) { + _name = parser.getQName(getAttribute("name")); + parseChildren(parser); + //!!! add text nodes + //!!! take care of value templates + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java new file mode 100644 index 000000000..5da16bd3b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: AttributeSet.java,v 1.5 2005/09/28 13:48:04 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.AttributeSetMethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.utils.XML11Char; +import java.util.Iterator; +import java.util.List; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +final class AttributeSet extends TopLevelElement { + + // This prefix is used for the method name of attribute set methods + private static final String AttributeSetPrefix = "$as$"; + + // Element contents + private QName _name; + private UseAttributeSets _useSets; + private AttributeSet _mergeSet; + private String _method; + private boolean _ignore = false; + + /** + * Returns the QName of this attribute set + */ + public QName getName() { + return _name; + } + + /** + * Returns the method name of this attribute set. This method name is + * generated by the compiler (XSLTC) + */ + public String getMethodName() { + return _method; + } + + /** + * Call this method to prevent a method for being compiled for this set. + * This is used in case several elements constitute + * a single set (with one name). The last element will merge itself with + * any previous set(s) with the same name and disable the other set(s). + */ + public void ignore() { + _ignore = true; + } + + /** + * Parse the contents of this attribute set. Recognised attributes are + * "name" (required) and "use-attribute-sets" (optional). + */ + public void parseContents(Parser parser) { + + // Get this attribute set's name + final String name = getAttribute("name"); + + if (!XML11Char.isXML11ValidQName(name)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + _name = parser.getQNameIgnoreDefaultNs(name); + if ((_name == null) || (_name.getStringRep().equals(EMPTYSTRING))) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.UNNAMED_ATTRIBSET_ERR, this); + parser.reportError(Constants.ERROR, msg); + } + + // Get any included attribute sets (similar to inheritance...) + final String useSets = getAttribute("use-attribute-sets"); + if (useSets.length() > 0) { + if (!Util.isValidQNames(useSets)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, useSets, this); + parser.reportError(Constants.ERROR, err); + } + _useSets = new UseAttributeSets(useSets, parser); + } + + // Parse the contents of this node. All child elements must be + // elements. Other elements cause an error. + final List contents = getContents(); + final int count = contents.size(); + for (int i=0; i attributes = elements(); + while (attributes.hasNext()) { + SyntaxTreeNode element = attributes.next(); + if (element instanceof XslAttribute) { + final XslAttribute attribute = (XslAttribute)element; + attribute.translate(classGen, methodGen); + } + } + final InstructionList il = methodGen.getInstructionList(); + il.append(RETURN); + + classGen.addMethod(methodGen); + } + + public String toString() { + StringBuffer buf = new StringBuffer("attribute-set: "); + // Translate all local attributes + final Iterator attributes = elements(); + while (attributes.hasNext()) { + final XslAttribute attribute = + (XslAttribute)attributes.next(); + buf.append(attribute); + } + return(buf.toString()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValue.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValue.java new file mode 100644 index 000000000..3130ee9cb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValue.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +abstract class AttributeValue extends Expression { + + public static final AttributeValue create(SyntaxTreeNode parent, + String text, Parser parser) { + + AttributeValue result; + if (text.indexOf('{') != -1) { + result = new AttributeValueTemplate(text, parser, parent); + } + else if (text.indexOf('}') != -1) { + result = new AttributeValueTemplate(text, parser, parent); + } + else { + result = new SimpleAttributeValue(text); + result.setParser(parser); + result.setParent(parent); + } + return result; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java new file mode 100644 index 000000000..5d57f1320 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: AttributeValueTemplate.java,v 1.2.4.1 2005/09/01 10:26:57 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.StringTokenizer; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class AttributeValueTemplate extends AttributeValue { + + final static int OUT_EXPR = 0; + final static int IN_EXPR = 1; + final static int IN_EXPR_SQUOTES = 2; + final static int IN_EXPR_DQUOTES = 3; + final static String DELIMITER = "\uFFFE"; // A Unicode nonchar + + public AttributeValueTemplate(String value, Parser parser, + SyntaxTreeNode parent) + { + setParent(parent); + setParser(parser); + + try { + parseAVTemplate(value, parser); + } + catch (NoSuchElementException e) { + reportError(parent, parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, value); + } + } + + /** + * Two-pass parsing of ATVs. In the first pass, double curly braces are + * replaced by one, and expressions are delimited using DELIMITER. The + * second pass splits up the resulting buffer into literal and non-literal + * expressions. Errors are reported during the first pass. + */ + private void parseAVTemplate(String text, Parser parser) { + StringTokenizer tokenizer = + new StringTokenizer(text, "{}\"\'", true); + + /* + * First pass: replace double curly braces and delimit expressions + * Simple automaton to parse ATVs, delimit expressions and report + * errors. + */ + String t = null; + String lookahead = null; + StringBuilder buffer = new StringBuilder(); + int state = OUT_EXPR; + + while (tokenizer.hasMoreTokens()) { + // Use lookahead if available + if (lookahead != null) { + t = lookahead; + lookahead = null; + } + else { + t = tokenizer.nextToken(); + } + + if (t.length() == 1) { + switch (t.charAt(0)) { + case '{': + switch (state) { + case OUT_EXPR: + lookahead = tokenizer.nextToken(); + if (lookahead.equals("{")) { + buffer.append(lookahead); // replace {{ by { + lookahead = null; + } + else { + buffer.append(DELIMITER); + state = IN_EXPR; + } + break; + case IN_EXPR: + case IN_EXPR_SQUOTES: + case IN_EXPR_DQUOTES: + reportError(getParent(), parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, text); + break; + } + break; + case '}': + switch (state) { + case OUT_EXPR: + lookahead = tokenizer.nextToken(); + if (lookahead.equals("}")) { + buffer.append(lookahead); // replace }} by } + lookahead = null; + } + else { + reportError(getParent(), parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, text); + } + break; + case IN_EXPR: + buffer.append(DELIMITER); + state = OUT_EXPR; + break; + case IN_EXPR_SQUOTES: + case IN_EXPR_DQUOTES: + buffer.append(t); + break; + } + break; + case '\'': + switch (state) { + case IN_EXPR: + state = IN_EXPR_SQUOTES; + break; + case IN_EXPR_SQUOTES: + state = IN_EXPR; + break; + case OUT_EXPR: + case IN_EXPR_DQUOTES: + break; + } + buffer.append(t); + break; + case '\"': + switch (state) { + case IN_EXPR: + state = IN_EXPR_DQUOTES; + break; + case IN_EXPR_DQUOTES: + state = IN_EXPR; + break; + case OUT_EXPR: + case IN_EXPR_SQUOTES: + break; + } + buffer.append(t); + break; + default: + buffer.append(t); + break; + } + } + else { + buffer.append(t); + } + } + + // Must be in OUT_EXPR at the end of parsing + if (state != OUT_EXPR) { + reportError(getParent(), parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, text); + } + + /* + * Second pass: split up buffer into literal and non-literal expressions. + */ + tokenizer = new StringTokenizer(buffer.toString(), DELIMITER, true); + + while (tokenizer.hasMoreTokens()) { + t = tokenizer.nextToken(); + + if (t.equals(DELIMITER)) { + addElement(parser.parseExpression(this, tokenizer.nextToken())); + tokenizer.nextToken(); // consume other delimiter + } + else { + addElement(new LiteralExpr(t)); + } + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final List contents = getContents(); + final int n = contents.size(); + for (int i = 0; i < n; i++) { + final Expression exp = (Expression)contents.get(i); + if (!exp.typeCheck(stable).identicalTo(Type.String)) { + contents.set(i, new CastExpr(exp, Type.String)); + } + } + return _type = Type.String; + } + + public String toString() { + final StringBuilder buffer = new StringBuilder("AVT:["); + final int count = elementCount(); + for (int i = 0; i < count; i++) { + buffer.append(elementAt(i).toString()); + if (i < count - 1) + buffer.append(' '); + } + return buffer.append(']').toString(); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + if (elementCount() == 1) { + final Expression exp = (Expression)elementAt(0); + exp.translate(classGen, methodGen); + } + else { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int initBuffer = cpg.addMethodref(STRING_BUFFER_CLASS, + "", "()V"); + final Instruction append = + new INVOKEVIRTUAL(cpg.addMethodref(STRING_BUFFER_CLASS, + "append", + "(" + STRING_SIG + ")" + + STRING_BUFFER_SIG)); + + final int toString = cpg.addMethodref(STRING_BUFFER_CLASS, + "toString", + "()"+STRING_SIG); + il.append(new NEW(cpg.addClass(STRING_BUFFER_CLASS))); + il.append(DUP); + il.append(new INVOKESPECIAL(initBuffer)); + // StringBuilder is on the stack + final Iterator elements = elements(); + while (elements.hasNext()) { + final Expression exp = (Expression)elements.next(); + exp.translate(classGen, methodGen); + il.append(append); + } + il.append(new INVOKEVIRTUAL(toString)); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java new file mode 100644 index 000000000..2781f4cfb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Nov 2017 + */ +final class BinOpExpr extends Expression { + public static final int PLUS = 0; + public static final int MINUS = 1; + public static final int TIMES = 2; + public static final int DIV = 3; + public static final int MOD = 4; + + private static final String[] Ops = { + "+", "-", "*", "/", "%" + }; + + private int _op; + private Expression _left, _right; + + public BinOpExpr(int op, Expression left, Expression right) { + _op = op; + (_left = left).setParent(this); + (_right = right).setParent(this); + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + if (_left.hasPositionCall()) return true; + if (_right.hasPositionCall()) return true; + return false; + } + + /** + * Returns true if this expressions contains a call to last() + */ + public boolean hasLastCall() { + return (_left.hasLastCall() || _right.hasLastCall()); + } + + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type tleft = _left.typeCheck(stable); + final Type tright = _right.typeCheck(stable); + final MethodType ptype = lookupPrimop(stable, Ops[_op], + new MethodType(Type.Void, + tleft, tright)); + if (ptype != null) { + final Type arg1 = ptype.argsType().get(0); + if (!arg1.identicalTo(tleft)) { + _left = new CastExpr(_left, arg1); + } + final Type arg2 = ptype.argsType().get(1); + if (!arg2.identicalTo(tright)) { + _right = new CastExpr(_right, arg1); + } + return _type = ptype.resultType(); + } + throw new TypeCheckError(this); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + + switch (_op) { + case PLUS: + il.append(_type.ADD()); + break; + case MINUS: + il.append(_type.SUB()); + break; + case TIMES: + il.append(_type.MUL()); + break; + case DIV: + il.append(_type.DIV()); + break; + case MOD: + il.append(_type.REM()); + break; + default: + ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_BINARY_OP_ERR, this); + getParser().reportError(Constants.ERROR, msg); + } + } + + public String toString() { + return Ops[_op] + '(' + _left + ", " + _right + ')'; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanCall.java new file mode 100644 index 000000000..4eae92e3e --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanCall.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class BooleanCall extends FunctionCall { + + private Expression _arg = null; + + public BooleanCall(QName fname, List arguments) { + super(fname, arguments); + _arg = argument(0); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _arg.typeCheck(stable); + return _type = Type.Boolean; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + _arg.translate(classGen, methodGen); + final Type targ = _arg.getType(); + if (!targ.identicalTo(Type.Boolean)) { + _arg.startIterator(classGen, methodGen); + targ.translateTo(classGen, methodGen, Type.Boolean); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanExpr.java new file mode 100644 index 000000000..5d66ff4d7 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanExpr.java @@ -0,0 +1,79 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * This class implements inlined calls to the XSLT standard functions + * true() and false(). + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class BooleanExpr extends Expression { + private boolean _value; + + public BooleanExpr(boolean value) { + _value = value; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _type = Type.Boolean; + return _type; + } + + public String toString() { + return _value ? "true()" : "false()"; + } + + public boolean getValue() { + return _value; + } + + public boolean contextDependent() { + return false; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + il.append(new PUSH(cpg, _value)); + } + + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + if (_value) { + il.append(NOP); // true list falls through + } + else { + _falseList.add(il.append(new GOTO(null))); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java new file mode 100644 index 000000000..beac36407 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.utils.XML11Char; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Erwin Bolwidt + * @LastModified: Oct 2017 + */ +final class CallTemplate extends Instruction { + + /** + * Name of template to call. + */ + private QName _name; + + /** + * The array of effective parameters in this CallTemplate. An object in + * this array can be either a WithParam or a Param if no WithParam + * exists for a particular parameter. + */ + private SyntaxTreeNode[] _parameters = null; + + /** + * The corresponding template which this CallTemplate calls. + */ + private Template _calleeTemplate = null; + + public void display(int indent) { + indent(indent); + System.out.print("CallTemplate"); + Util.println(" name " + _name); + displayContents(indent + IndentIncrement); + } + + public boolean hasWithParams() { + return elementCount() > 0; + } + + public void parseContents(Parser parser) { + final String name = getAttribute("name"); + if (name.length() > 0) { + if (!XML11Char.isXML11ValidQName(name)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + _name = parser.getQNameIgnoreDefaultNs(name); + } + else { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name"); + } + parseChildren(parser); + } + + /** + * Verify that a template with this name exists. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Template template = stable.lookupTemplate(_name); + if (template != null) { + typeCheckContents(stable); + } + else { + ErrorMsg err = new ErrorMsg(ErrorMsg.TEMPLATE_UNDEF_ERR,_name,this); + throw new TypeCheckError(err); + } + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final Stylesheet stylesheet = classGen.getStylesheet(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // If there are Params in the stylesheet or WithParams in this call? + if (stylesheet.hasLocalParams() || hasContents()) { + _calleeTemplate = getCalleeTemplate(); + + // Build the parameter list if the called template is simple named + if (_calleeTemplate != null) { + buildParameterList(); + } + // This is only needed when the called template is not + // a simple named template. + else { + // Push parameter frame + final int push = cpg.addMethodref(TRANSLET_CLASS, + PUSH_PARAM_FRAME, + PUSH_PARAM_FRAME_SIG); + il.append(classGen.loadTranslet()); + il.append(new INVOKEVIRTUAL(push)); + translateContents(classGen, methodGen); + } + } + + // Generate a valid Java method name + final String className = stylesheet.getClassName(); + String methodName = Util.escape(_name.toString()); + + // Load standard arguments + il.append(classGen.loadTranslet()); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadIterator()); + il.append(methodGen.loadHandler()); + il.append(methodGen.loadCurrentNode()); + + // Initialize prefix of method signature + StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG + + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG); + + // If calling a simply named template, push actual arguments + if (_calleeTemplate != null) { + int numParams = _parameters.length; + + for (int i = 0; i < numParams; i++) { + SyntaxTreeNode node = _parameters[i]; + methodSig.append(OBJECT_SIG); // append Object to signature + + // Push 'null' if Param to indicate no actual parameter specified + if (node instanceof Param) { + il.append(ACONST_NULL); + } + else { // translate WithParam + node.translate(classGen, methodGen); + } + } + } + + // Complete signature and generate invokevirtual call + methodSig.append(")V"); + il.append(new INVOKEVIRTUAL(cpg.addMethodref(className, + methodName, + methodSig.toString()))); + + // release temporary result trees + if (_parameters != null) { + for (int i = 0; i < _parameters.length; i++) { + if (_parameters[i] instanceof WithParam) { + ((WithParam)_parameters[i]).releaseResultTree(classGen, methodGen); + } + } + } + + // Do not need to call Translet.popParamFrame() if we are + // calling a simple named template. + if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) { + // Pop parameter frame + final int pop = cpg.addMethodref(TRANSLET_CLASS, + POP_PARAM_FRAME, + POP_PARAM_FRAME_SIG); + il.append(classGen.loadTranslet()); + il.append(new INVOKEVIRTUAL(pop)); + } + } + + /** + * Return the simple named template which this CallTemplate calls. + * Return false if there is no matched template or the matched + * template is not a simple named template. + */ + public Template getCalleeTemplate() { + Template foundTemplate + = getXSLTC().getParser().getSymbolTable().lookupTemplate(_name); + + return foundTemplate.isSimpleNamedTemplate() ? foundTemplate : null; + } + + /** + * Build the list of effective parameters in this CallTemplate. + * The parameters of the called template are put into the array first. + * Then we visit the WithParam children of this CallTemplate and replace + * the Param with a corresponding WithParam having the same name. + */ + private void buildParameterList() { + // Put the parameters from the called template into the array first. + // This is to ensure the order of the parameters. + List defaultParams = _calleeTemplate.getParameters(); + int numParams = defaultParams.size(); + _parameters = new SyntaxTreeNode[numParams]; + for (int i = 0; i < numParams; i++) { + _parameters[i] = defaultParams.get(i); + } + + // Replace a Param with a WithParam if they have the same name. + int count = elementCount(); + for (int i = 0; i < count; i++) { + Object node = elementAt(i); + + // Ignore if not WithParam + if (node instanceof WithParam) { + WithParam withParam = (WithParam)node; + QName name = withParam.getName(); + + // Search for a Param with the same name + for (int k = 0; k < numParams; k++) { + SyntaxTreeNode parm = _parameters[k]; + if (parm instanceof Param + && ((Param)parm).getName().equals(name)) { + withParam.setDoParameterOptimization(true); + _parameters[k] = withParam; + break; + } + else if (parm instanceof WithParam + && ((WithParam)parm).getName().equals(name)) { + withParam.setDoParameterOptimization(true); + _parameters[k] = withParam; + break; + } + } + } + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastCall.java new file mode 100644 index 000000000..5b85ff093 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastCall.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.CHECKCAST; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class CastCall extends FunctionCall { + + /** + * Name of the class that is the target of the cast. Must be a + * fully-qualified Java class Name. + */ + private String _className; + + /** + * A reference to the expression being casted. + */ + private Expression _right; + + /** + * Constructor. + */ + public CastCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * Type check the two parameters for this function + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Check that the function was passed exactly two arguments + if (argumentCount() != 2) { + throw new TypeCheckError(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, + getName(), this)); + } + + // The first argument must be a literal String + Expression exp = argument(0); + if (exp instanceof LiteralExpr) { + _className = ((LiteralExpr) exp).getValue(); + _type = Type.newObjectType(_className); + } + else { + throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, + getName(), this)); + } + + // Second argument must be of type reference or object + _right = argument(1); + Type tright = _right.typeCheck(stable); + if (tright != Type.Reference && + tright instanceof ObjectType == false) + { + throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, + tright, _type, this)); + } + + return _type; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + _right.translate(classGen, methodGen); + il.append(new CHECKCAST(cpg.addClass(_className))); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java new file mode 100644 index 000000000..e6f0b457b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: CastExpr.java,v 1.2.4.1 2005/09/12 10:06:35 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPNE; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.SIPUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MultiHashtable; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.dtm.Axis; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + */ +final class CastExpr extends Expression { + private final Expression _left; + + /** + * Legal conversions between internal types. + */ + private static final MultiHashtable InternalTypeMap = new MultiHashtable<>(); + + static { + // Possible type conversions between internal types + InternalTypeMap.put(Type.Boolean, Type.Boolean); + InternalTypeMap.put(Type.Boolean, Type.Real); + InternalTypeMap.put(Type.Boolean, Type.String); + InternalTypeMap.put(Type.Boolean, Type.Reference); + InternalTypeMap.put(Type.Boolean, Type.Object); + + InternalTypeMap.put(Type.Real, Type.Real); + InternalTypeMap.put(Type.Real, Type.Int); + InternalTypeMap.put(Type.Real, Type.Boolean); + InternalTypeMap.put(Type.Real, Type.String); + InternalTypeMap.put(Type.Real, Type.Reference); + InternalTypeMap.put(Type.Real, Type.Object); + + InternalTypeMap.put(Type.Int, Type.Int); + InternalTypeMap.put(Type.Int, Type.Real); + InternalTypeMap.put(Type.Int, Type.Boolean); + InternalTypeMap.put(Type.Int, Type.String); + InternalTypeMap.put(Type.Int, Type.Reference); + InternalTypeMap.put(Type.Int, Type.Object); + + InternalTypeMap.put(Type.String, Type.String); + InternalTypeMap.put(Type.String, Type.Boolean); + InternalTypeMap.put(Type.String, Type.Real); + InternalTypeMap.put(Type.String, Type.Reference); + InternalTypeMap.put(Type.String, Type.Object); + + InternalTypeMap.put(Type.NodeSet, Type.NodeSet); + InternalTypeMap.put(Type.NodeSet, Type.Boolean); + InternalTypeMap.put(Type.NodeSet, Type.Real); + InternalTypeMap.put(Type.NodeSet, Type.String); + InternalTypeMap.put(Type.NodeSet, Type.Node); + InternalTypeMap.put(Type.NodeSet, Type.Reference); + InternalTypeMap.put(Type.NodeSet, Type.Object); + + InternalTypeMap.put(Type.Node, Type.Node); + InternalTypeMap.put(Type.Node, Type.Boolean); + InternalTypeMap.put(Type.Node, Type.Real); + InternalTypeMap.put(Type.Node, Type.String); + InternalTypeMap.put(Type.Node, Type.NodeSet); + InternalTypeMap.put(Type.Node, Type.Reference); + InternalTypeMap.put(Type.Node, Type.Object); + + InternalTypeMap.put(Type.ResultTree, Type.ResultTree); + InternalTypeMap.put(Type.ResultTree, Type.Boolean); + InternalTypeMap.put(Type.ResultTree, Type.Real); + InternalTypeMap.put(Type.ResultTree, Type.String); + InternalTypeMap.put(Type.ResultTree, Type.NodeSet); + InternalTypeMap.put(Type.ResultTree, Type.Reference); + InternalTypeMap.put(Type.ResultTree, Type.Object); + + InternalTypeMap.put(Type.Reference, Type.Reference); + InternalTypeMap.put(Type.Reference, Type.Boolean); + InternalTypeMap.put(Type.Reference, Type.Int); + InternalTypeMap.put(Type.Reference, Type.Real); + InternalTypeMap.put(Type.Reference, Type.String); + InternalTypeMap.put(Type.Reference, Type.Node); + InternalTypeMap.put(Type.Reference, Type.NodeSet); + InternalTypeMap.put(Type.Reference, Type.ResultTree); + InternalTypeMap.put(Type.Reference, Type.Object); + + InternalTypeMap.put(Type.Object, Type.String); + + InternalTypeMap.put(Type.Void, Type.String); + + InternalTypeMap.makeUnmodifiable(); + } + + private boolean _typeTest = false; + + /** + * Construct a cast expression and check that the conversion is + * valid by calling typeCheck(). + */ + public CastExpr(Expression left, Type type) throws TypeCheckError { + _left = left; + _type = type; // use inherited field + + if ((_left instanceof Step) && (_type == Type.Boolean)) { + Step step = (Step)_left; + if ((step.getAxis() == Axis.SELF) && (step.getNodeType() != -1)) + _typeTest = true; + } + + // check if conversion is valid + setParser(left.getParser()); + setParent(left.getParent()); + left.setParent(this); + typeCheck(left.getParser().getSymbolTable()); + } + + public Expression getExpr() { + return _left; + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + return(_left.hasPositionCall()); + } + + public boolean hasLastCall() { + return(_left.hasLastCall()); + } + + public String toString() { + return "cast(" + _left + ", " + _type + ")"; + } + + /** + * Type checking a cast expression amounts to verifying that the + * type conversion is legal. Cast expressions are created during + * type checking, but typeCheck() is usually not called on them. + * As a result, this method is called from the constructor. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + Type tleft = _left.getType(); + if (tleft == null) { + tleft = _left.typeCheck(stable); + } + if (tleft instanceof NodeType) { + tleft = Type.Node; // multiple instances + } + else if (tleft instanceof ResultTreeType) { + tleft = Type.ResultTree; // multiple instances + } + if (InternalTypeMap.maps(tleft, _type) != null) { + return _type; + } + // throw new TypeCheckError(this); + throw new TypeCheckError(new ErrorMsg( + ErrorMsg.DATA_CONVERSION_ERR, tleft.toString(), _type.toString())); + } + + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + FlowList fl; + final Type ltype = _left.getType(); + + // This is a special case for the self:: axis. Instead of letting + // the Step object create and iterator that we cast back to a single + // node, we simply ask the DOM for the node type. + if (_typeTest) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final int idx = cpg.addInterfaceMethodref(DOM_INTF, + "getExpandedTypeID", + "(I)I"); + il.append(new SIPUSH((short)((Step)_left).getNodeType())); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadContextNode()); + il.append(new INVOKEINTERFACE(idx, 2)); + _falseList.add(il.append(new IF_ICMPNE(null))); + } + else { + + _left.translate(classGen, methodGen); + if (_type != ltype) { + _left.startIterator(classGen, methodGen); + if (_type instanceof BooleanType) { + fl = ltype.translateToDesynthesized(classGen, methodGen, + _type); + if (fl != null) { + _falseList.append(fl); + } + } + else { + ltype.translateTo(classGen, methodGen, _type); + } + } + } + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final Type ltype = _left.getType(); + _left.translate(classGen, methodGen); + if (_type.identicalTo(ltype) == false) { + _left.startIterator(classGen, methodGen); + ltype.translateTo(classGen, methodGen, _type); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CeilingCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CeilingCall.java new file mode 100644 index 000000000..e0fb68ad3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CeilingCall.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class CeilingCall extends FunctionCall { + public CeilingCall(QName fname, List arguments) { + super(fname, arguments); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + argument(0).translate(classGen, methodGen); + il.append(new INVOKESTATIC(cpg.addMethodref(MATH_CLASS, + "ceil", "(D)D"))); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java new file mode 100644 index 000000000..28831e5be --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Choose.java,v 1.2.4.1 2005/09/01 12:00:14 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class Choose extends Instruction { + + /** + * Display the element contents (a lot of when's and an otherwise) + */ + public void display(int indent) { + indent(indent); + Util.println("Choose"); + indent(indent + IndentIncrement); + displayContents(indent + IndentIncrement); + } + + /** + * Translate this Choose element. Generate a test-chain for the various + * elements and default to the if present. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final List whenElements = new ArrayList<>(); + Otherwise otherwise = null; + Iterator elements = elements(); + + // These two are for reporting errors only + ErrorMsg error = null; + final int line = getLineNumber(); + + // Traverse all child nodes - must be either When or Otherwise + while (elements.hasNext()) { + SyntaxTreeNode element = elements.next(); + // Add a When child element + if (element instanceof When) { + whenElements.add(element); + } + // Add an Otherwise child element + else if (element instanceof Otherwise) { + if (otherwise == null) { + otherwise = (Otherwise)element; + } + else { + error = new ErrorMsg(ErrorMsg.MULTIPLE_OTHERWISE_ERR, this); + getParser().reportError(Constants.ERROR, error); + } + } + else if (element instanceof Text) { + ((Text)element).ignore(); + } + // It is an error if we find some other element here + else { + error = new ErrorMsg(ErrorMsg.WHEN_ELEMENT_ERR, this); + getParser().reportError(Constants.ERROR, error); + } + } + + // Make sure that there is at least one element + if (whenElements.size() == 0) { + error = new ErrorMsg(ErrorMsg.MISSING_WHEN_ERR, this); + getParser().reportError(Constants.ERROR, error); + return; + } + + InstructionList il = methodGen.getInstructionList(); + + // next element will hold a handle to the beginning of next + // When/Otherwise if test on current When fails + BranchHandle nextElement = null; + List exitHandles = new ArrayList<>(); + InstructionHandle exit = null; + + Enumeration whens = Collections.enumeration(whenElements); + while (whens.hasMoreElements()) { + final When when = (When)whens.nextElement(); + final Expression test = when.getTest(); + + InstructionHandle truec = il.getEnd(); + + if (nextElement != null) + nextElement.setTarget(il.append(NOP)); + test.translateDesynthesized(classGen, methodGen); + + if (test instanceof FunctionCall) { + FunctionCall call = (FunctionCall)test; + try { + Type type = call.typeCheck(getParser().getSymbolTable()); + if (type != Type.Boolean) { + test._falseList.add(il.append(new IFEQ(null))); + } + } + catch (TypeCheckError e) { + // handled later! + } + } + // remember end of condition + truec = il.getEnd(); + + // The When object should be ignored completely in case it tests + // for the support of a non-available element + if (!when.ignore()) when.translateContents(classGen, methodGen); + + // goto exit after executing the body of when + exitHandles.add(il.append(new GOTO(null))); + if (whens.hasMoreElements() || otherwise != null) { + nextElement = il.append(new GOTO(null)); + test.backPatchFalseList(nextElement); + } + else + test.backPatchFalseList(exit = il.append(NOP)); + test.backPatchTrueList(truec.getNext()); + } + + // Translate any element + if (otherwise != null) { + nextElement.setTarget(il.append(NOP)); + otherwise.translateContents(classGen, methodGen); + exit = il.append(NOP); + } + + // now that end is known set targets of exit gotos + Enumeration exitGotos = Collections.enumeration(exitHandles); + while (exitGotos.hasMoreElements()) { + BranchHandle gotoExit = (BranchHandle)exitGotos.nextElement(); + gotoExit.setTarget(exit); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Closure.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Closure.java new file mode 100644 index 000000000..b89b9dfbe --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Closure.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Santiago Pericas-Geertsen + */ +public interface Closure { + + /** + * Returns true if this closure is compiled in an inner class (i.e. + * if this is a real closure). + */ + public boolean inInnerClass(); + + /** + * Returns a reference to its parent closure or null if outermost. + */ + public Closure getParentClosure(); + + /** + * Returns the name of the auxiliary class or null if this predicate + * is compiled inside the Translet. + */ + public String getInnerClassName(); + + /** + * Add new variable to the closure. + */ + public void addVariable(VariableRefBase variableRef); +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Comment.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Comment.java new file mode 100644 index 000000000..37ce5a1fd --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Comment.java @@ -0,0 +1,116 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GETFIELD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class Comment extends Instruction { + + public void parseContents(Parser parser) { + parseChildren(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + typeCheckContents(stable); + return Type.String; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Shortcut for literal strings + Text rawText = null; + if (elementCount() == 1) { + Object content = elementAt(0); + if (content instanceof Text) { + rawText = (Text) content; + } + } + + // If the content is literal text, call comment(char[],int,int) or + // comment(String), as appropriate. Otherwise, use a + // StringValueHandler to gather the textual content of the xsl:comment + // and call comment(String) with the result. + if (rawText != null) { + il.append(methodGen.loadHandler()); + + if (rawText.canLoadAsArrayOffsetLength()) { + rawText.loadAsArrayOffsetLength(classGen, methodGen); + final int comment = + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "comment", + "([CII)V"); + il.append(new INVOKEINTERFACE(comment, 4)); + } else { + il.append(new PUSH(cpg, rawText.getText())); + final int comment = + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "comment", + "(" + STRING_SIG + ")V"); + il.append(new INVOKEINTERFACE(comment, 2)); + } + } else { + // Save the current handler base on the stack + il.append(methodGen.loadHandler()); + il.append(DUP); // first arg to "comment" call + + // Get the translet's StringValueHandler + il.append(classGen.loadTranslet()); + il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, + "stringValueHandler", + STRING_VALUE_HANDLER_SIG))); + il.append(DUP); + il.append(methodGen.storeHandler()); + + // translate contents with substituted handler + translateContents(classGen, methodGen); + + // get String out of the handler + il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER, + "getValue", + "()" + STRING_SIG))); + // call "comment" + final int comment = + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "comment", + "(" + STRING_SIG + ")V"); + il.append(new INVOKEINTERFACE(comment, 2)); + // Restore old handler base from stack + il.append(methodGen.storeHandler()); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CompilerException.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CompilerException.java new file mode 100644 index 000000000..76786aa47 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CompilerException.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Morten Jorgensen + */ +public final class CompilerException extends Exception { + static final long serialVersionUID = 1732939618562742663L; + + private String _msg; + + public CompilerException() { + super(); + } + + public CompilerException(Exception e) { + super(e.toString()); + _msg = e.toString(); + } + + public CompilerException(String message) { + super(message); + _msg = message; + } + + public String getMessage() { + final int col = _msg.indexOf(':'); + + if (col > -1) + return(_msg.substring(col)); + else + return(_msg); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ConcatCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ConcatCall.java new file mode 100644 index 000000000..dd1ad68eb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ConcatCall.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class ConcatCall extends FunctionCall { + public ConcatCall(QName fname, List arguments) { + super(fname, arguments); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + for (int i = 0; i < argumentCount(); i++) { + final Expression exp = argument(i); + if (!exp.typeCheck(stable).identicalTo(Type.String)) { + setArgument(i, new CastExpr(exp, Type.String)); + } + } + return _type = Type.String; + } + + /** translate leaves a String on the stack */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int nArgs = argumentCount(); + + switch (nArgs) { + case 0: + il.append(new PUSH(cpg, EMPTYSTRING)); + break; + + case 1: + argument().translate(classGen, methodGen); + break; + + default: + final int initBuffer = cpg.addMethodref(STRING_BUFFER_CLASS, + "", "()V"); + final Instruction append = + new INVOKEVIRTUAL(cpg.addMethodref(STRING_BUFFER_CLASS, + "append", + "("+STRING_SIG+")" + +STRING_BUFFER_SIG)); + + final int toString = cpg.addMethodref(STRING_BUFFER_CLASS, + "toString", + "()"+STRING_SIG); + + il.append(new NEW(cpg.addClass(STRING_BUFFER_CLASS))); + il.append(DUP); + il.append(new INVOKESPECIAL(initBuffer)); + for (int i = 0; i < nArgs; i++) { + argument(i).translate(classGen, methodGen); + il.append(append); + } + il.append(new INVOKEVIRTUAL(toString)); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java new file mode 100644 index 000000000..a1489c2c5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java @@ -0,0 +1,595 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Constants.java,v 1.7 2006/06/19 19:49:04 spericas Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ArithmeticInstruction; +import com.sun.org.apache.bcel.internal.generic.ArrayInstruction; +import com.sun.org.apache.bcel.internal.generic.ConversionInstruction; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionConst; +import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction; +import com.sun.org.apache.bcel.internal.generic.ReturnInstruction; +import com.sun.org.apache.bcel.internal.generic.StackInstruction; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface Constants { + public static final Instruction ACONST_NULL = InstructionConst.ACONST_NULL; + public static final Instruction ATHROW = InstructionConst.ATHROW; + public static final Instruction DCMPG = InstructionConst.DCMPG; + public static final Instruction DCONST_0 = InstructionConst.DCONST_0; + public static final Instruction ICONST_0 = InstructionConst.ICONST_0; + public static final Instruction ICONST_1 = InstructionConst.ICONST_1; + public static final Instruction NOP = InstructionConst.NOP; + + + public static final StackInstruction DUP = InstructionConst.DUP; + public static final StackInstruction DUP2 = InstructionConst.DUP2; + public static final StackInstruction DUP_X1 = InstructionConst.DUP_X1; + public static final StackInstruction DUP_X2 = InstructionConst.DUP_X2; + public static final StackInstruction POP = InstructionConst.POP; + public static final StackInstruction POP2 = InstructionConst.POP2; + public static final StackInstruction SWAP = InstructionConst.SWAP; + + public static final LocalVariableInstruction ALOAD_0 = InstructionConst.ALOAD_0; + public static final LocalVariableInstruction ALOAD_1 = InstructionConst.ALOAD_1; + public static final LocalVariableInstruction ALOAD_2 = InstructionConst.ALOAD_2; + public static final LocalVariableInstruction ILOAD_1 = InstructionConst.ILOAD_1; + public static final LocalVariableInstruction ILOAD_2 = InstructionConst.ILOAD_2; + + public static final ArithmeticInstruction DADD = InstructionConst.DADD; + public static final ArithmeticInstruction IXOR = InstructionConst.IXOR; + + public static final ArrayInstruction AASTORE = InstructionConst.AASTORE; + public static final ArrayInstruction IASTORE = InstructionConst.IASTORE; + + public static final ConversionInstruction D2F = InstructionConst.D2F; + public static final ConversionInstruction D2I = InstructionConst.D2I; + public static final ConversionInstruction D2L = InstructionConst.D2L; + public static final ConversionInstruction F2D = InstructionConst.F2D; + public static final ConversionInstruction I2B = InstructionConst.I2B; + public static final ConversionInstruction I2C = InstructionConst.I2C; + public static final ConversionInstruction I2D = InstructionConst.I2D; + public static final ConversionInstruction I2F = InstructionConst.I2F; + public static final ConversionInstruction I2L = InstructionConst.I2L; + public static final ConversionInstruction I2S = InstructionConst.I2S; + public static final ConversionInstruction L2D = InstructionConst.L2D; + public static final ConversionInstruction L2I = InstructionConst.L2I; + + + public static final ReturnInstruction ARETURN = InstructionConst.ARETURN; + public static final ReturnInstruction IRETURN = InstructionConst.IRETURN; + public static final ReturnInstruction RETURN = InstructionConst.RETURN; + + + + // Error categories used to report errors to Parser.reportError() + + // Unexpected internal errors, such as null-ptr exceptions, etc. + // Immediately terminates compilation, no translet produced + public final int INTERNAL = 0; + // XSLT elements that are not implemented and unsupported ext. + // Immediately terminates compilation, no translet produced + public final int UNSUPPORTED = 1; + // Fatal error in the stylesheet input (parsing or content) + // Immediately terminates compilation, no translet produced + public final int FATAL = 2; + // Other error in the stylesheet input (parsing or content) + // Does not terminate compilation, no translet produced + public final int ERROR = 3; + // Other error in the stylesheet input (content errors only) + // Does not terminate compilation, a translet is produced + public final int WARNING = 4; + + public static final String EMPTYSTRING = ""; + + public static final String NAMESPACE_FEATURE = + "http://xml.org/sax/features/namespaces"; + + public static final String TRANSLET_INTF + = "com.sun.org.apache.xalan.internal.xsltc.Translet"; + public static final String TRANSLET_INTF_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/Translet;"; + + public static final String ATTRIBUTES_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/Attributes;"; + public static final String NODE_ITERATOR_SIG + = "Lcom/sun/org/apache/xml/internal/dtm/DTMAxisIterator;"; + public static final String DOM_INTF_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/DOM;"; + public static final String DOM_IMPL_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/DOM"; // xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl"; + public static final String SAX_IMPL_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/DOM/SAXImpl"; + public static final String DOM_IMPL_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl;"; //xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl;"; + public static final String SAX_IMPL_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl;"; + public static final String DOM_ADAPTER_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter"; + public static final String DOM_ADAPTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter;"; + public static final String MULTI_DOM_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.MultiDOM"; + public static final String MULTI_DOM_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM;"; + + public static final String STRING + = "java.lang.String"; + + public static final int ACC_PUBLIC + = com.sun.org.apache.bcel.internal.Const.ACC_PUBLIC; + public static final int ACC_SUPER + = com.sun.org.apache.bcel.internal.Const.ACC_SUPER; + public static final int ACC_FINAL + = com.sun.org.apache.bcel.internal.Const.ACC_FINAL; + public static final int ACC_PRIVATE + = com.sun.org.apache.bcel.internal.Const.ACC_PRIVATE; + public static final int ACC_PROTECTED + = com.sun.org.apache.bcel.internal.Const.ACC_PROTECTED; + public static final int ACC_STATIC + = com.sun.org.apache.bcel.internal.Const.ACC_STATIC; + + public static final String MODULE_SIG + = "Ljava/lang/Module;"; + public static final String CLASS_SIG + = "Ljava/lang/Class;"; + public static final String STRING_SIG + = "Ljava/lang/String;"; + public static final String STRING_BUFFER_SIG + = "Ljava/lang/StringBuffer;"; + public static final String OBJECT_SIG + = "Ljava/lang/Object;"; + public static final String DOUBLE_SIG + = "Ljava/lang/Double;"; + public static final String INTEGER_SIG + = "Ljava/lang/Integer;"; + public static final String COLLATOR_CLASS + = "java/text/Collator"; + public static final String COLLATOR_SIG + = "Ljava/text/Collator;"; + + public static final String NODE + = "int"; + public static final String NODE_ITERATOR + = "com.sun.org.apache.xml.internal.dtm.DTMAxisIterator"; + public static final String NODE_ITERATOR_BASE + = "com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase"; + public static final String SORT_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.SortingIterator"; + public static final String SORT_ITERATOR_SIG + = "Lcom.sun.org.apache.xalan.internal.xsltc.dom.SortingIterator;"; + public static final String NODE_SORT_RECORD + = "com.sun.org.apache.xalan.internal.xsltc.dom.NodeSortRecord"; + public static final String NODE_SORT_FACTORY + = "com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecordFactory"; + public static final String NODE_SORT_RECORD_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord;"; + public static final String NODE_SORT_FACTORY_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecordFactory;"; + public static final String LOCALE_CLASS + = "java.util.Locale"; + public static final String LOCALE_SIG + = "Ljava/util/Locale;"; + public static final String STRING_VALUE_HANDLER + = "com.sun.org.apache.xalan.internal.xsltc.runtime.StringValueHandler"; + public static final String STRING_VALUE_HANDLER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler;"; + public static final String OUTPUT_HANDLER + = "com/sun/org/apache/xml/internal/serializer/SerializationHandler"; + public static final String OUTPUT_HANDLER_SIG + = "Lcom/sun/org/apache/xml/internal/serializer/SerializationHandler;"; + public static final String FILTER_INTERFACE + = "com.sun.org.apache.xalan.internal.xsltc.dom.Filter"; + public static final String FILTER_INTERFACE_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/Filter;"; + public static final String UNION_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.UnionIterator"; + public static final String STEP_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.StepIterator"; + public static final String CACHED_NODE_LIST_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.CachedNodeListIterator"; + public static final String NTH_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.NthIterator"; + public static final String ABSOLUTE_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.AbsoluteIterator"; + public static final String DUP_FILTERED_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.DupFilterIterator"; + public static final String CURRENT_NODE_LIST_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.CurrentNodeListIterator"; + public static final String CURRENT_NODE_LIST_FILTER + = "com.sun.org.apache.xalan.internal.xsltc.dom.CurrentNodeListFilter"; + public static final String CURRENT_NODE_LIST_ITERATOR_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/CurrentNodeListIterator;"; + public static final String CURRENT_NODE_LIST_FILTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/CurrentNodeListFilter;"; + public static final String FILTER_STEP_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.FilteredStepIterator"; + public static final String FILTER_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.FilterIterator"; + public static final String SINGLETON_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.SingletonIterator"; + public static final String MATCHING_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.MatchingIterator"; + public static final String NODE_SIG + = "I"; + public static final String GET_PARENT + = "getParent"; + public static final String GET_PARENT_SIG + = "(" + NODE_SIG + ")" + NODE_SIG; + public static final String NEXT_SIG + = "()" + NODE_SIG; + public static final String NEXT + = "next"; + public static final String NEXTID + = "nextNodeID"; + public static final String MAKE_NODE + = "makeNode"; + public static final String MAKE_NODE_LIST + = "makeNodeList"; + public static final String GET_UNPARSED_ENTITY_URI + = "getUnparsedEntityURI"; + public static final String STRING_TO_REAL + = "stringToReal"; + public static final String STRING_TO_REAL_SIG + = "(" + STRING_SIG + ")D"; + public static final String STRING_TO_INT + = "stringToInt"; + public static final String STRING_TO_INT_SIG + = "(" + STRING_SIG + ")I"; + + public static final String XSLT_PACKAGE + = "com.sun.org.apache.xalan.internal.xsltc"; + public static final String COMPILER_PACKAGE + = XSLT_PACKAGE + ".compiler"; + public static final String RUNTIME_PACKAGE + = XSLT_PACKAGE + ".runtime"; + public static final String TRANSLET_CLASS + = RUNTIME_PACKAGE + ".AbstractTranslet"; + + public static final String TRANSLET_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet;"; + public static final String UNION_ITERATOR_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/UnionIterator;"; + public static final String TRANSLET_OUTPUT_SIG + = "Lcom/sun/org/apache/xml/internal/serializer/SerializationHandler;"; + public static final String MAKE_NODE_SIG + = "(I)Lorg/w3c/dom/Node;"; + public static final String MAKE_NODE_SIG2 + = "(" + NODE_ITERATOR_SIG + ")Lorg/w3c/dom/Node;"; + public static final String MAKE_NODE_LIST_SIG + = "(I)Lorg/w3c/dom/NodeList;"; + public static final String MAKE_NODE_LIST_SIG2 + = "(" + NODE_ITERATOR_SIG + ")Lorg/w3c/dom/NodeList;"; + + public static final String STREAM_XML_OUTPUT + = "com.sun.org.apache.xml.internal.serializer.ToXMLStream"; + + public static final String OUTPUT_BASE + = "com.sun.org.apache.xml.internal.serializer.SerializerBase"; + + public static final String LOAD_DOCUMENT_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument"; + + public static final String KEY_INDEX_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex"; + public static final String KEY_INDEX_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex;"; + + public static final String KEY_INDEX_ITERATOR_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex$KeyIndexIterator;"; + public static final String DOM_INTF + = "com.sun.org.apache.xalan.internal.xsltc.DOM"; + public static final String DOM_IMPL + = "com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl"; + public static final String SAX_IMPL + = "com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl"; + public static final String CLASS_CLASS + = "java.lang.Class"; + public static final String MODULE_CLASS + = "java.lang.Module"; + public static final String STRING_CLASS + = "java.lang.String"; + public static final String OBJECT_CLASS + = "java.lang.Object"; + public static final String BOOLEAN_CLASS + = "java.lang.Boolean"; + public static final String STRING_BUFFER_CLASS + = "java.lang.StringBuffer"; + public static final String STRING_WRITER + = "java.io.StringWriter"; + public static final String WRITER_SIG + = "Ljava/io/Writer;"; + + public static final String TRANSLET_OUTPUT_BASE + = "com.sun.org.apache.xalan.internal.xsltc.TransletOutputBase"; + // output interface + public static final String TRANSLET_OUTPUT_INTERFACE + = "com.sun.org.apache.xml.internal.serializer.SerializationHandler"; + public static final String BASIS_LIBRARY_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary"; + public static final String ATTRIBUTE_LIST_IMPL_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.runtime.AttributeListImpl"; + public static final String DOUBLE_CLASS + = "java.lang.Double"; + public static final String INTEGER_CLASS + = "java.lang.Integer"; + public static final String RUNTIME_NODE_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.runtime.Node"; + public static final String MATH_CLASS + = "java.lang.Math"; + + public static final String BOOLEAN_VALUE + = "booleanValue"; + public static final String BOOLEAN_VALUE_SIG + = "()Z"; + public static final String INT_VALUE + = "intValue"; + public static final String INT_VALUE_SIG + = "()I"; + public static final String DOUBLE_VALUE + = "doubleValue"; + public static final String DOUBLE_VALUE_SIG + = "()D"; + + public static final String DOM_PNAME + = "dom"; + public static final String NODE_PNAME + = "node"; + public static final String TRANSLET_OUTPUT_PNAME + = "handler"; + public static final String ITERATOR_PNAME + = "iterator"; + public static final String DOCUMENT_PNAME + = "document"; + public static final String TRANSLET_PNAME + = "translet"; + + public static final String INVOKE_METHOD + = "invokeMethod"; + public static final String GET_NODE_NAME + = "getNodeNameX"; + public static final String CHARACTERSW + = "characters"; + public static final String GET_CHILDREN + = "getChildren"; + public static final String GET_TYPED_CHILDREN + = "getTypedChildren"; + public static final String CHARACTERS + = "characters"; + public static final String APPLY_TEMPLATES + = "applyTemplates"; + public static final String GET_NODE_TYPE + = "getNodeType"; + public static final String GET_NODE_VALUE + = "getStringValueX"; + public static final String GET_ELEMENT_VALUE + = "getElementValue"; + public static final String GET_ATTRIBUTE_VALUE + = "getAttributeValue"; + public static final String HAS_ATTRIBUTE + = "hasAttribute"; + public static final String ADD_ITERATOR + = "addIterator"; + public static final String SET_START_NODE + = "setStartNode"; + public static final String RESET + = "reset"; + public static final String GET_MODULE + = "getModule"; + public static final String FOR_NAME + = "forName"; + public static final String ADD_READS + = "addReads"; + + public static final String GET_MODULE_SIG + = "()" + MODULE_SIG; + public static final String FOR_NAME_SIG + = "(" + STRING_SIG + ")" + CLASS_SIG; + public static final String ADD_READS_SIG + = "(" + MODULE_SIG + ")" + MODULE_SIG; + + public static final String ATTR_SET_SIG + = "(" + DOM_INTF_SIG + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + "I)V"; + + public static final String GET_NODE_NAME_SIG + = "(" + NODE_SIG + ")" + STRING_SIG; + public static final String CHARACTERSW_SIG + = "(" + STRING_SIG + TRANSLET_OUTPUT_SIG + ")V"; + public static final String CHARACTERS_SIG + = "(" + NODE_SIG + TRANSLET_OUTPUT_SIG + ")V"; + public static final String GET_CHILDREN_SIG + = "(" + NODE_SIG +")" + NODE_ITERATOR_SIG; + public static final String GET_TYPED_CHILDREN_SIG + = "(I)" + NODE_ITERATOR_SIG; + public static final String GET_NODE_TYPE_SIG + = "()S"; + public static final String GET_NODE_VALUE_SIG + = "(I)" + STRING_SIG; + public static final String GET_ELEMENT_VALUE_SIG + = "(I)" + STRING_SIG; + public static final String GET_ATTRIBUTE_VALUE_SIG + = "(II)" + STRING_SIG; + public static final String HAS_ATTRIBUTE_SIG + = "(II)Z"; + public static final String GET_ITERATOR_SIG + = "()" + NODE_ITERATOR_SIG; + + public static final String NAMES_INDEX + = "namesArray"; + public static final String NAMES_INDEX_SIG + = "[" + STRING_SIG; + public static final String URIS_INDEX + = "urisArray"; + public static final String URIS_INDEX_SIG + = "[" + STRING_SIG; + public static final String TYPES_INDEX + = "typesArray"; + public static final String TYPES_INDEX_SIG + = "[I"; + public static final String NAMESPACE_INDEX + = "namespaceArray"; + public static final String NAMESPACE_INDEX_SIG + = "[" + STRING_SIG; + public static final String HASIDCALL_INDEX + = "_hasIdCall"; + public static final String HASIDCALL_INDEX_SIG + = "Z"; + public static final String TRANSLET_VERSION_INDEX + = "transletVersion"; + public static final String TRANSLET_VERSION_INDEX_SIG + = "I"; + + public static final String DOM_FIELD + = "_dom"; + public static final String STATIC_NAMES_ARRAY_FIELD + = "_sNamesArray"; + public static final String STATIC_URIS_ARRAY_FIELD + = "_sUrisArray"; + public static final String STATIC_TYPES_ARRAY_FIELD + = "_sTypesArray"; + public static final String STATIC_NAMESPACE_ARRAY_FIELD + = "_sNamespaceArray"; + public static final String STATIC_CHAR_DATA_FIELD + = "_scharData"; + public static final String STATIC_CHAR_DATA_FIELD_SIG + = "[C"; + public static final String FORMAT_SYMBOLS_FIELD + = "format_symbols"; + + public static final String ITERATOR_FIELD_SIG + = NODE_ITERATOR_SIG; + public static final String NODE_FIELD + = "node"; + public static final String NODE_FIELD_SIG + = "I"; + + public static final String EMPTYATTR_FIELD + = "EmptyAttributes"; + public static final String ATTRIBUTE_LIST_FIELD + = "attributeList"; + public static final String CLEAR_ATTRIBUTES + = "clear"; + public static final String ADD_ATTRIBUTE + = "addAttribute"; + public static final String ATTRIBUTE_LIST_IMPL_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/AttributeListImpl;"; + public static final String CLEAR_ATTRIBUTES_SIG + = "()" + ATTRIBUTE_LIST_IMPL_SIG; + public static final String ADD_ATTRIBUTE_SIG + = "(" + STRING_SIG + STRING_SIG + ")" + ATTRIBUTE_LIST_IMPL_SIG; + + public static final String ADD_ITERATOR_SIG + = "(" + NODE_ITERATOR_SIG +")" + UNION_ITERATOR_SIG; + + public static final String ORDER_ITERATOR + = "orderNodes"; + public static final String ORDER_ITERATOR_SIG + = "("+NODE_ITERATOR_SIG+"I)"+NODE_ITERATOR_SIG; + + public static final String SET_START_NODE_SIG + = "(" + NODE_SIG + ")" + NODE_ITERATOR_SIG; + + public static final String NODE_COUNTER + = "com.sun.org.apache.xalan.internal.xsltc.dom.NodeCounter"; + public static final String NODE_COUNTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/NodeCounter;"; + public static final String DEFAULT_NODE_COUNTER + = "com.sun.org.apache.xalan.internal.xsltc.dom.DefaultNodeCounter"; + public static final String DEFAULT_NODE_COUNTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/DefaultNodeCounter;"; + public static final String TRANSLET_FIELD + = "translet"; + public static final String TRANSLET_FIELD_SIG + = TRANSLET_SIG; + + public static final String RESET_SIG + = "()" + NODE_ITERATOR_SIG; + public static final String GET_PARAMETER + = "getParameter"; + public static final String ADD_PARAMETER + = "addParameter"; + public static final String PUSH_PARAM_FRAME + = "pushParamFrame"; + public static final String PUSH_PARAM_FRAME_SIG + = "()V"; + public static final String POP_PARAM_FRAME + = "popParamFrame"; + public static final String POP_PARAM_FRAME_SIG + = "()V"; + public static final String GET_PARAMETER_SIG + = "(" + STRING_SIG + ")" + OBJECT_SIG; + public static final String ADD_PARAMETER_SIG + = "(" + STRING_SIG + OBJECT_SIG + "Z)" + OBJECT_SIG; + + public static final String STRIP_SPACE + = "stripSpace"; + public static final String STRIP_SPACE_INTF + = "com/sun/org/apache/xalan/internal/xsltc/StripFilter"; + public static final String STRIP_SPACE_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/StripFilter;"; + public static final String STRIP_SPACE_PARAMS + = "(Lcom/sun/org/apache/xalan/internal/xsltc/DOM;II)Z"; + + public static final String GET_NODE_VALUE_ITERATOR + = "getNodeValueIterator"; + public static final String GET_NODE_VALUE_ITERATOR_SIG + = "("+NODE_ITERATOR_SIG+"I"+STRING_SIG+"Z)"+NODE_ITERATOR_SIG; + + public static final String GET_UNPARSED_ENTITY_URI_SIG + = "("+STRING_SIG+")"+STRING_SIG; + + public static final int POSITION_INDEX = 2; + public static final int LAST_INDEX = 3; + + public static final String XMLNS_PREFIX = "xmlns"; + public static final String XMLNS_STRING = "xmlns:"; + public static final String XMLNS_URI + = "http://www.w3.org/2000/xmlns/"; + public static final String XSLT_URI + = "http://www.w3.org/1999/XSL/Transform"; + public static final String XHTML_URI + = "http://www.w3.org/1999/xhtml"; + public static final String TRANSLET_URI + = "http://xml.apache.org/xalan/xsltc"; + public static final String REDIRECT_URI + = "http://xml.apache.org/xalan/redirect"; + public static final String FALLBACK_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.compiler.Fallback"; + + public static final int RTF_INITIAL_SIZE = 32; + + // the API packages used by generated translet classes + public static String[] PKGS_USED_BY_TRANSLET_CLASSES = { + "com.sun.org.apache.xalan.internal.lib", + "com.sun.org.apache.xalan.internal.xsltc", + "com.sun.org.apache.xalan.internal.xsltc.runtime", + "com.sun.org.apache.xalan.internal.xsltc.dom", + "com.sun.org.apache.xml.internal.serializer", + "com.sun.org.apache.xml.internal.dtm", + "com.sun.org.apache.xml.internal.dtm.ref", + }; +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ContainsCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ContainsCall.java new file mode 100644 index 000000000..90e35c445 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ContainsCall.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IFLT; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class ContainsCall extends FunctionCall { + + private Expression _base = null; + private Expression _token = null; + + /** + * Create a contains() call - two arguments, both strings + */ + public ContainsCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * This XPath function returns true/false values + */ + public boolean isBoolean() { + return true; + } + + /** + * Type check the two parameters for this function + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + + // Check that the function was passed exactly two arguments + if (argumentCount() != 2) { + throw new TypeCheckError(ErrorMsg.ILLEGAL_ARG_ERR, getName(), this); + } + + // The first argument must be a String, or cast to a String + _base = argument(0); + Type baseType = _base.typeCheck(stable); + if (baseType != Type.String) + _base = new CastExpr(_base, Type.String); + + // The second argument must also be a String, or cast to a String + _token = argument(1); + Type tokenType = _token.typeCheck(stable); + if (tokenType != Type.String) + _token = new CastExpr(_token, Type.String); + + return _type = Type.Boolean; + } + + /** + * Compile the expression - leave boolean expression on stack + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + translateDesynthesized(classGen, methodGen); + synthesize(classGen, methodGen); + } + + /** + * Compile expression and update true/false-lists + */ + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + _base.translate(classGen, methodGen); + _token.translate(classGen, methodGen); + il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS, + "indexOf", + "("+STRING_SIG+")I"))); + _falseList.add(il.append(new IFLT(null))); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Copy.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Copy.java new file mode 100644 index 000000000..f48527578 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Copy.java @@ -0,0 +1,157 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.IFNULL; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class Copy extends Instruction { + private UseAttributeSets _useSets; + + public void parseContents(Parser parser) { + final String useSets = getAttribute("use-attribute-sets"); + if (useSets.length() > 0) { + if (!Util.isValidQNames(useSets)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, useSets, this); + parser.reportError(Constants.ERROR, err); + } + _useSets = new UseAttributeSets(useSets, parser); + } + parseChildren(parser); + } + + public void display(int indent) { + indent(indent); + Util.println("Copy"); + indent(indent + IndentIncrement); + displayContents(indent + IndentIncrement); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_useSets != null) { + _useSets.typeCheck(stable); + } + typeCheckContents(stable); + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final LocalVariableGen name = + methodGen.addLocalVariable2("name", + Util.getJCRefType(STRING_SIG), + null); + final LocalVariableGen length = + methodGen.addLocalVariable2("length", + Util.getJCRefType("I"), + null); + + // Get the name of the node to copy and save for later + il.append(methodGen.loadDOM()); + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadHandler()); + final int cpy = cpg.addInterfaceMethodref(DOM_INTF, + "shallowCopy", + "(" + + NODE_SIG + + TRANSLET_OUTPUT_SIG + + ")" + STRING_SIG); + il.append(new INVOKEINTERFACE(cpy, 3)); + il.append(DUP); + name.setStart(il.append(new ASTORE(name.getIndex()))); + final BranchHandle ifBlock1 = il.append(new IFNULL(null)); + + // Get the length of the node name and save for later + il.append(new ALOAD(name.getIndex())); + final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I"); + il.append(new INVOKEVIRTUAL(lengthMethod)); + il.append(DUP); + length.setStart(il.append(new ISTORE(length.getIndex()))); + + // Ignore attribute sets if current node is ROOT. DOM.shallowCopy() + // returns "" for ROOT, so skip attribute sets if length == 0 + final BranchHandle ifBlock4 = il.append(new IFEQ(null)); + + // Copy in attribute sets if specified + if (_useSets != null) { + // If the parent of this element will result in an element being + // output then we know that it is safe to copy out the attributes + final SyntaxTreeNode parent = getParent(); + if ((parent instanceof LiteralElement) || + (parent instanceof LiteralElement)) { + _useSets.translate(classGen, methodGen); + } + // If not we have to check to see if the copy will result in an + // element being output. + else { + // check if element; if not skip to translate body + il.append(new ILOAD(length.getIndex())); + final BranchHandle ifBlock2 = il.append(new IFEQ(null)); + // length != 0 -> element -> do attribute sets + _useSets.translate(classGen, methodGen); + // not an element; root + ifBlock2.setTarget(il.append(NOP)); + } + } + + // Instantiate body of xsl:copy + ifBlock4.setTarget(il.append(NOP)); + translateContents(classGen, methodGen); + + // Call the output handler's endElement() if we copied an element + // (The DOM.shallowCopy() method calls startElement().) + length.setEnd(il.append(new ILOAD(length.getIndex()))); + final BranchHandle ifBlock3 = il.append(new IFEQ(null)); + il.append(methodGen.loadHandler()); + name.setEnd(il.append(new ALOAD(name.getIndex()))); + il.append(methodGen.endElement()); + + final InstructionHandle end = il.append(NOP); + ifBlock1.setTarget(end); + ifBlock3.setTarget(end); + methodGen.removeLocalVariable(name); + methodGen.removeLocalVariable(length); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CopyOf.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CopyOf.java new file mode 100644 index 000000000..5cc06737a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CopyOf.java @@ -0,0 +1,141 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class CopyOf extends Instruction { + private Expression _select; + + public void display(int indent) { + indent(indent); + Util.println("CopyOf"); + indent(indent + IndentIncrement); + Util.println("select " + _select.toString()); + } + + public void parseContents(Parser parser) { + _select = parser.parseExpression(this, "select", null); + // make sure required attribute(s) have been set + if (_select.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select"); + return; + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type tselect = _select.typeCheck(stable); + if (tselect instanceof NodeType || + tselect instanceof NodeSetType || + tselect instanceof ReferenceType || + tselect instanceof ResultTreeType) { + // falls through + } + else { + _select = new CastExpr(_select, Type.String); + } + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final Type tselect = _select.getType(); + + final String CPY1_SIG = "("+NODE_ITERATOR_SIG+TRANSLET_OUTPUT_SIG+")V"; + final int cpy1 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY1_SIG); + + final String CPY2_SIG = "("+NODE_SIG+TRANSLET_OUTPUT_SIG+")V"; + final int cpy2 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY2_SIG); + + final String getDoc_SIG = "()"+NODE_SIG; + final int getDoc = cpg.addInterfaceMethodref(DOM_INTF, "getDocument", getDoc_SIG); + + + if (tselect instanceof NodeSetType) { + il.append(methodGen.loadDOM()); + + // push NodeIterator + _select.translate(classGen, methodGen); + _select.startIterator(classGen, methodGen); + + // call copy from the DOM 'library' + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE(cpy1, 3)); + } + else if (tselect instanceof NodeType) { + il.append(methodGen.loadDOM()); + _select.translate(classGen, methodGen); + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE(cpy2, 3)); + } + else if (tselect instanceof ResultTreeType) { + _select.translate(classGen, methodGen); + // We want the whole tree, so we start with the root node + il.append(DUP); //need a pointer to the DOM ; + il.append(new INVOKEINTERFACE(getDoc,1)); //ICONST_0); + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE(cpy2, 3)); + } + else if (tselect instanceof ReferenceType) { + _select.translate(classGen, methodGen); + il.append(methodGen.loadHandler()); + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadDOM()); + final int copy = cpg.addMethodref(BASIS_LIBRARY_CLASS, "copy", + "(" + + OBJECT_SIG + + TRANSLET_OUTPUT_SIG + + NODE_SIG + + DOM_INTF_SIG + + ")V"); + il.append(new INVOKESTATIC(copy)); + } + else { + il.append(classGen.loadTranslet()); + _select.translate(classGen, methodGen); + il.append(methodGen.loadHandler()); + il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, + CHARACTERSW, + CHARACTERSW_SIG))); + } + + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CurrentCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CurrentCall.java new file mode 100644 index 000000000..9cdae02c6 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CurrentCall.java @@ -0,0 +1,39 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class CurrentCall extends FunctionCall { + public CurrentCall(QName fname) { + super(fname); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + methodGen.getInstructionList().append(methodGen.loadCurrentNode()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DecimalFormatting.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DecimalFormatting.java new file mode 100644 index 000000000..0e82c7f19 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DecimalFormatting.java @@ -0,0 +1,256 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GETSTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.utils.XML11Char; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class DecimalFormatting extends TopLevelElement { + + private static final String DFS_CLASS = "java.text.DecimalFormatSymbols"; + private static final String DFS_SIG = "Ljava/text/DecimalFormatSymbols;"; + + private QName _name = null; + + /** + * No type check needed for the element + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; + } + + /** + * Parse the name of the element + */ + public void parseContents(Parser parser) { + // Get the name of these decimal formatting symbols + final String name = getAttribute("name"); + if (name.length() > 0) { + if (!XML11Char.isXML11ValidQName(name)){ + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + } + _name = parser.getQNameIgnoreDefaultNs(name); + if (_name == null) { + _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING); + } + + // Check if a set of symbols has already been registered under this name + SymbolTable stable = parser.getSymbolTable(); + if (stable.getDecimalFormatting(_name) != null) { + reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR, + _name.toString()); + } + else { + stable.addDecimalFormatting(_name, this); + } + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + + // DecimalFormatSymbols.(Locale); + // xsl:decimal-format - except for the NaN and infinity attributes. + final int init = cpg.addMethodref(DFS_CLASS, "", + "("+LOCALE_SIG+")V"); + + // Push the format name on the stack for call to addDecimalFormat() + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, _name.toString())); + + // Manufacture a DecimalFormatSymbols on the stack + // for call to addDecimalFormat() + // Use the US Locale as the default, as most of its settings + // are equivalent to the default settings required of + il.append(new NEW(cpg.addClass(DFS_CLASS))); + il.append(DUP); + il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", + LOCALE_SIG))); + il.append(new INVOKESPECIAL(init)); + + String tmp = getAttribute("NaN"); + if ((tmp == null) || (tmp.equals(EMPTYSTRING))) { + int nan = cpg.addMethodref(DFS_CLASS, + "setNaN", "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "NaN")); + il.append(new INVOKEVIRTUAL(nan)); + } + + tmp = getAttribute("infinity"); + if ((tmp == null) || (tmp.equals(EMPTYSTRING))) { + int inf = cpg.addMethodref(DFS_CLASS, + "setInfinity", + "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "Infinity")); + il.append(new INVOKEVIRTUAL(inf)); + } + + final int nAttributes = _attributes.getLength(); + for (int i = 0; i < nAttributes; i++) { + final String name = _attributes.getQName(i); + final String value = _attributes.getValue(i); + + boolean valid = true; + int method = 0; + + if (name.equals("decimal-separator")) { + // DecimalFormatSymbols.setDecimalSeparator(); + method = cpg.addMethodref(DFS_CLASS, + "setDecimalSeparator", "(C)V"); + } + else if (name.equals("grouping-separator")) { + method = cpg.addMethodref(DFS_CLASS, + "setGroupingSeparator", "(C)V"); + } + else if (name.equals("minus-sign")) { + method = cpg.addMethodref(DFS_CLASS, + "setMinusSign", "(C)V"); + } + else if (name.equals("percent")) { + method = cpg.addMethodref(DFS_CLASS, + "setPercent", "(C)V"); + } + else if (name.equals("per-mille")) { + method = cpg.addMethodref(DFS_CLASS, + "setPerMill", "(C)V"); + } + else if (name.equals("zero-digit")) { + method = cpg.addMethodref(DFS_CLASS, + "setZeroDigit", "(C)V"); + } + else if (name.equals("digit")) { + method = cpg.addMethodref(DFS_CLASS, + "setDigit", "(C)V"); + } + else if (name.equals("pattern-separator")) { + method = cpg.addMethodref(DFS_CLASS, + "setPatternSeparator", "(C)V"); + } + else if (name.equals("NaN")) { + method = cpg.addMethodref(DFS_CLASS, + "setNaN", "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, value)); + il.append(new INVOKEVIRTUAL(method)); + valid = false; + } + else if (name.equals("infinity")) { + method = cpg.addMethodref(DFS_CLASS, + "setInfinity", + "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, value)); + il.append(new INVOKEVIRTUAL(method)); + valid = false; + } + else { + valid = false; + } + + if (valid) { + il.append(DUP); + il.append(new PUSH(cpg, value.charAt(0))); + il.append(new INVOKEVIRTUAL(method)); + } + + } + + final int put = cpg.addMethodref(TRANSLET_CLASS, + "addDecimalFormat", + "("+STRING_SIG+DFS_SIG+")V"); + il.append(new INVOKEVIRTUAL(put)); + } + + /** + * Creates the default, nameless, DecimalFormat object in + * AbstractTranslet's format_symbols hashtable. + * This should be called for every stylesheet, and the entry + * may be overridden by later nameless xsl:decimal-format instructions. + */ + public static void translateDefaultDFS(ClassGenerator classGen, + MethodGenerator methodGen) { + + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + final int init = cpg.addMethodref(DFS_CLASS, "", + "("+LOCALE_SIG+")V"); + + // Push the format name, which is empty, on the stack + // for call to addDecimalFormat() + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, EMPTYSTRING)); + + // Manufacture a DecimalFormatSymbols on the stack for + // call to addDecimalFormat(). Use the US Locale as the + // default, as most of its settings are equivalent to + // the default settings required of xsl:decimal-format - + // except for the NaN and infinity attributes. + il.append(new NEW(cpg.addClass(DFS_CLASS))); + il.append(DUP); + il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", + LOCALE_SIG))); + il.append(new INVOKESPECIAL(init)); + + int nan = cpg.addMethodref(DFS_CLASS, + "setNaN", "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "NaN")); + il.append(new INVOKEVIRTUAL(nan)); + + int inf = cpg.addMethodref(DFS_CLASS, + "setInfinity", + "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "Infinity")); + il.append(new INVOKEVIRTUAL(inf)); + + final int put = cpg.addMethodref(TRANSLET_CLASS, + "addDecimalFormat", + "("+STRING_SIG+DFS_SIG+")V"); + il.append(new INVOKEVIRTUAL(put)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java new file mode 100644 index 000000000..33e0b472f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GETFIELD; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class DocumentCall extends FunctionCall { + + private Expression _arg1 = null; + private Expression _arg2 = null; + private Type _arg1Type; + + /** + * Default function call constructor + */ + public DocumentCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * Type checks the arguments passed to the document() function. The first + * argument can be any type (we must cast it to a string) and contains the + * URI of the document + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // At least one argument - two at most + final int ac = argumentCount(); + if ((ac < 1) || (ac > 2)) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this); + throw new TypeCheckError(msg); + } + if (getStylesheet() == null) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this); + throw new TypeCheckError(msg); + } + + // Parse the first argument + _arg1 = argument(0); + + if (_arg1 == null) {// should not happened + ErrorMsg msg = new ErrorMsg(ErrorMsg.DOCUMENT_ARG_ERR, this); + throw new TypeCheckError(msg); + } + + _arg1Type = _arg1.typeCheck(stable); + if ((_arg1Type != Type.NodeSet) && (_arg1Type != Type.String)) { + _arg1 = new CastExpr(_arg1, Type.String); + } + + // Parse the second argument + if (ac == 2) { + _arg2 = argument(1); + + if (_arg2 == null) {// should not happened + ErrorMsg msg = new ErrorMsg(ErrorMsg.DOCUMENT_ARG_ERR, this); + throw new TypeCheckError(msg); + } + + final Type arg2Type = _arg2.typeCheck(stable); + + if (arg2Type.identicalTo(Type.Node)) { + _arg2 = new CastExpr(_arg2, Type.NodeSet); + } else if (arg2Type.identicalTo(Type.NodeSet)) { + // falls through + } else { + ErrorMsg msg = new ErrorMsg(ErrorMsg.DOCUMENT_ARG_ERR, this); + throw new TypeCheckError(msg); + } + } + + return _type = Type.NodeSet; + } + + /** + * Translates the document() function call to a call to LoadDocument()'s + * static method document(). + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int ac = argumentCount(); + + final int domField = cpg.addFieldref(classGen.getClassName(), + DOM_FIELD, + DOM_INTF_SIG); + + String docParamList = null; + if (ac == 1) { + // documentF(Object,String,AbstractTranslet,DOM) + docParamList = "("+OBJECT_SIG+STRING_SIG+TRANSLET_SIG+DOM_INTF_SIG + +")"+NODE_ITERATOR_SIG; + } else { //ac == 2; ac < 1 or as >2 was tested in typeChec() + // documentF(Object,DTMAxisIterator,String,AbstractTranslet,DOM) + docParamList = "("+OBJECT_SIG+NODE_ITERATOR_SIG+STRING_SIG + +TRANSLET_SIG+DOM_INTF_SIG+")"+NODE_ITERATOR_SIG; + } + final int docIdx = cpg.addMethodref(LOAD_DOCUMENT_CLASS, "documentF", + docParamList); + + + // The URI can be either a node-set or something else cast to a string + _arg1.translate(classGen, methodGen); + if (_arg1Type == Type.NodeSet) { + _arg1.startIterator(classGen, methodGen); + } + + if (ac == 2) { + //_arg2 == null was tested in typeChec() + _arg2.translate(classGen, methodGen); + _arg2.startIterator(classGen, methodGen); + } + + // Feck the rest of the parameters on the stack + il.append(new PUSH(cpg, getStylesheet().getSystemId())); + il.append(classGen.loadTranslet()); + il.append(DUP); + il.append(new GETFIELD(domField)); + il.append(new INVOKESTATIC(docIdx)); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ElementAvailableCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ElementAvailableCall.java new file mode 100644 index 000000000..126bb0d57 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ElementAvailableCall.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class ElementAvailableCall extends FunctionCall { + + public ElementAvailableCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * Force the argument to this function to be a literal string. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (argument() instanceof LiteralExpr) { + return _type = Type.Boolean; + } + ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, + "element-available", this); + throw new TypeCheckError(err); + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + return getResult() ? Boolean.TRUE : Boolean.FALSE; + } + + /** + * Returns the result that this function will return + */ + public boolean getResult() { + try { + final LiteralExpr arg = (LiteralExpr) argument(); + final String qname = arg.getValue(); + final int index = qname.indexOf(':'); + final String localName = (index > 0) ? + qname.substring(index + 1) : qname; + return getParser().elementSupported(arg.getNamespace(), + localName); + } + catch (ClassCastException e) { + return false; + } + } + + /** + * Calls to 'element-available' are resolved at compile time since + * the namespaces declared in the stylsheet are not available at run + * time. Consequently, arguments to this function must be literals. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final boolean result = getResult(); + methodGen.getInstructionList().append(new PUSH(cpg, result)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/EqualityExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/EqualityExpr.java new file mode 100644 index 000000000..e6fe7ee30 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/EqualityExpr.java @@ -0,0 +1,359 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.BranchInstruction; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.IFNE; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPEQ; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPNE; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.IntType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NumberType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.RealType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.runtime.Operators; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + */ +final class EqualityExpr extends Expression { + + private final int _op; + private Expression _left; + private Expression _right; + + public EqualityExpr(int op, Expression left, Expression right) { + _op = op; + (_left = left).setParent(this); + (_right = right).setParent(this); + } + + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + public String toString() { + return Operators.getOpNames(_op) + '(' + _left + ", " + _right + ')'; + } + + public Expression getLeft() { + return _left; + } + + public Expression getRight() { + return _right; + } + + public boolean getOp() { + return (_op != Operators.NE); + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + if (_left.hasPositionCall()) return true; + if (_right.hasPositionCall()) return true; + return false; + } + + public boolean hasLastCall() { + if (_left.hasLastCall()) return true; + if (_right.hasLastCall()) return true; + return false; + } + + private void swapArguments() { + final Expression temp = _left; + _left = _right; + _right = temp; + } + + /** + * Typing rules: see XSLT Reference by M. Kay page 345. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type tleft = _left.typeCheck(stable); + final Type tright = _right.typeCheck(stable); + + if (tleft.isSimple() && tright.isSimple()) { + if (tleft != tright) { + if (tleft instanceof BooleanType) { + _right = new CastExpr(_right, Type.Boolean); + } + else if (tright instanceof BooleanType) { + _left = new CastExpr(_left, Type.Boolean); + } + else if (tleft instanceof NumberType || + tright instanceof NumberType) { + _left = new CastExpr(_left, Type.Real); + _right = new CastExpr(_right, Type.Real); + } + else { // both compared as strings + _left = new CastExpr(_left, Type.String); + _right = new CastExpr(_right, Type.String); + } + } + } + else if (tleft instanceof ReferenceType) { + _right = new CastExpr(_right, Type.Reference); + } + else if (tright instanceof ReferenceType) { + _left = new CastExpr(_left, Type.Reference); + } + // the following 2 cases optimize @attr|.|.. = 'string' + else if (tleft instanceof NodeType && tright == Type.String) { + _left = new CastExpr(_left, Type.String); + } + else if (tleft == Type.String && tright instanceof NodeType) { + _right = new CastExpr(_right, Type.String); + } + // optimize node/node + else if (tleft instanceof NodeType && tright instanceof NodeType) { + _left = new CastExpr(_left, Type.String); + _right = new CastExpr(_right, Type.String); + } + else if (tleft instanceof NodeType && tright instanceof NodeSetType) { + // compare(Node, NodeSet) will be invoked + } + else if (tleft instanceof NodeSetType && tright instanceof NodeType) { + swapArguments(); // for compare(Node, NodeSet) + } + else { + // At least one argument is of type node, node-set or result-tree + + // Promote an expression of type node to node-set + if (tleft instanceof NodeType) { + _left = new CastExpr(_left, Type.NodeSet); + } + if (tright instanceof NodeType) { + _right = new CastExpr(_right, Type.NodeSet); + } + + // If one arg is a node-set then make it the left one + if (tleft.isSimple() || + tleft instanceof ResultTreeType && + tright instanceof NodeSetType) { + swapArguments(); + } + + // Promote integers to doubles to have fewer compares + if (_right.getType() instanceof IntType) { + _right = new CastExpr(_right, Type.Real); + } + } + return _type = Type.Boolean; + } + + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + final Type tleft = _left.getType(); + final InstructionList il = methodGen.getInstructionList(); + + if (tleft instanceof BooleanType) { + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + _falseList.add(il.append(_op == Operators.EQ ? + (BranchInstruction)new IF_ICMPNE(null) : + (BranchInstruction)new IF_ICMPEQ(null))); + } + else if (tleft instanceof NumberType) { + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + + if (tleft instanceof RealType) { + il.append(DCMPG); + _falseList.add(il.append(_op == Operators.EQ ? + (BranchInstruction)new IFNE(null) : + (BranchInstruction)new IFEQ(null))); + } + else { + _falseList.add(il.append(_op == Operators.EQ ? + (BranchInstruction)new IF_ICMPNE(null) : + (BranchInstruction)new IF_ICMPEQ(null))); + } + } + else { + translate(classGen, methodGen); + desynthesize(classGen, methodGen); + } + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final Type tleft = _left.getType(); + Type tright = _right.getType(); + + if (tleft instanceof BooleanType || tleft instanceof NumberType) { + translateDesynthesized(classGen, methodGen); + synthesize(classGen, methodGen); + return; + } + + if (tleft instanceof StringType) { + final int equals = cpg.addMethodref(STRING_CLASS, + "equals", + "(" + OBJECT_SIG +")Z"); + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + il.append(new INVOKEVIRTUAL(equals)); + + if (_op == Operators.NE) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + BranchHandle truec, falsec; + + if (tleft instanceof ResultTreeType) { + if (tright instanceof BooleanType) { + _right.translate(classGen, methodGen); + if (_op == Operators.NE) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + if (tright instanceof RealType) { + _left.translate(classGen, methodGen); + tleft.translateTo(classGen, methodGen, Type.Real); + _right.translate(classGen, methodGen); + + il.append(DCMPG); + falsec = il.append(_op == Operators.EQ ? + (BranchInstruction) new IFNE(null) : + (BranchInstruction) new IFEQ(null)); + il.append(ICONST_1); + truec = il.append(new GOTO(null)); + falsec.setTarget(il.append(ICONST_0)); + truec.setTarget(il.append(NOP)); + return; + } + + // Next, result-tree/string and result-tree/result-tree comparisons + + _left.translate(classGen, methodGen); + tleft.translateTo(classGen, methodGen, Type.String); + _right.translate(classGen, methodGen); + + if (tright instanceof ResultTreeType) { + tright.translateTo(classGen, methodGen, Type.String); + } + + final int equals = cpg.addMethodref(STRING_CLASS, + "equals", + "(" +OBJECT_SIG+ ")Z"); + il.append(new INVOKEVIRTUAL(equals)); + + if (_op == Operators.NE) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + if (tleft instanceof NodeSetType && tright instanceof BooleanType) { + _left.translate(classGen, methodGen); + _left.startIterator(classGen, methodGen); + Type.NodeSet.translateTo(classGen, methodGen, Type.Boolean); + _right.translate(classGen, methodGen); + + il.append(IXOR); // x != y <-> x xor y + if (_op == Operators.EQ) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + if (tleft instanceof NodeSetType && tright instanceof StringType) { + _left.translate(classGen, methodGen); + _left.startIterator(classGen, methodGen); // needed ? + _right.translate(classGen, methodGen); + il.append(new PUSH(cpg, _op)); + il.append(methodGen.loadDOM()); + final int cmp = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "compare", + "(" + + tleft.toSignature() + + tright.toSignature() + + "I" + + DOM_INTF_SIG + + ")Z"); + il.append(new INVOKESTATIC(cmp)); + return; + } + + // Next, node-set/t for t in {real, string, node-set, result-tree} + _left.translate(classGen, methodGen); + _left.startIterator(classGen, methodGen); + _right.translate(classGen, methodGen); + _right.startIterator(classGen, methodGen); + + // Cast a result tree to a string to use an existing compare + if (tright instanceof ResultTreeType) { + tright.translateTo(classGen, methodGen, Type.String); + tright = Type.String; + } + + // Call the appropriate compare() from the BasisLibrary + il.append(new PUSH(cpg, _op)); + il.append(methodGen.loadDOM()); + + final int compare = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "compare", + "(" + + tleft.toSignature() + + tright.toSignature() + + "I" + + DOM_INTF_SIG + + ")Z"); + il.append(new INVOKESTATIC(compare)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Expression.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Expression.java new file mode 100644 index 000000000..c94a0ae46 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Expression.java @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO_W; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @LastModified: Oct 2017 + */ +abstract class Expression extends SyntaxTreeNode { + /** + * The type of this expression. It is set after calling + * typeCheck(). + */ + protected Type _type; + + /** + * Instruction handles that comprise the true list. + */ + protected FlowList _trueList = new FlowList(); + + /** + * Instruction handles that comprise the false list. + */ + protected FlowList _falseList = new FlowList(); + + public Type getType() { + return _type; + } + + public abstract String toString(); + + public boolean hasPositionCall() { + return false; // default should be 'false' for StepPattern + } + + public boolean hasLastCall() { + return false; + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + return null; + } + + /** + * Type check all the children of this node. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return typeCheckContents(stable); + } + + /** + * Translate this node into JVM bytecodes. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR, + getClass(), this); + getParser().reportError(FATAL, msg); + } + + /** + * Translate this node into a fresh instruction list. + * The original instruction list is saved and restored. + */ + public final InstructionList compile(ClassGenerator classGen, + MethodGenerator methodGen) { + final InstructionList result, save = methodGen.getInstructionList(); + methodGen.setInstructionList(result = new InstructionList()); + translate(classGen, methodGen); + methodGen.setInstructionList(save); + return result; + } + + /** + * Redefined by expressions of type boolean that use flow lists. + */ + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + translate(classGen, methodGen); + if (_type instanceof BooleanType) { + desynthesize(classGen, methodGen); + } + } + + /** + * If this expression is of type node-set and it is not a variable + * reference, then call setStartNode() passing the context node. + */ + public void startIterator(ClassGenerator classGen, + MethodGenerator methodGen) { + // Ignore if type is not node-set + if (_type instanceof NodeSetType == false) { + return; + } + + // setStartNode() should not be called if expr is a variable ref + Expression expr = this; + if (expr instanceof CastExpr) { + expr = ((CastExpr) expr).getExpr(); + } + if (expr instanceof VariableRefBase == false) { + final InstructionList il = methodGen.getInstructionList(); + il.append(methodGen.loadContextNode()); + il.append(methodGen.setStartNode()); + } + } + + /** + * Synthesize a boolean expression, i.e., either push a 0 or 1 onto the + * operand stack for the next statement to succeed. Returns the handle + * of the instruction to be backpatched. + */ + public void synthesize(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + _trueList.backPatch(il.append(ICONST_1)); + final BranchHandle truec = il.append(new GOTO_W(null)); + _falseList.backPatch(il.append(ICONST_0)); + truec.setTarget(il.append(NOP)); + } + + public void desynthesize(ClassGenerator classGen, + MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + _falseList.add(il.append(new IFEQ(null))); + } + + public FlowList getFalseList() { + return _falseList; + } + + public FlowList getTrueList() { + return _trueList; + } + + public void backPatchFalseList(InstructionHandle ih) { + _falseList.backPatch(ih); + } + + public void backPatchTrueList(InstructionHandle ih) { + _trueList.backPatch(ih); + } + + /** + * Search for a primop in the symbol table that matches the method type + * ctype. Two methods match if they have the same arity. + * If a primop is overloaded then the "closest match" is returned. The + * first entry in the vector of primops that has the right arity is + * considered to be the default one. + */ + public MethodType lookupPrimop(SymbolTable stable, String op, + MethodType ctype) { + MethodType result = null; + final List primop = stable.lookupPrimop(op); + if (primop != null) { + final int n = primop.size(); + int minDistance = Integer.MAX_VALUE; + for (int i = 0; i < n; i++) { + final MethodType ptype = primop.get(i); + // Skip if different arity + if (ptype.argsCount() != ctype.argsCount()) { + continue; + } + + // The first method with the right arity is the default + if (result == null) { + result = ptype; // default method + } + + // Check if better than last one found + final int distance = ctype.distanceTo(ptype); + if (distance < minDistance) { + minDistance = distance; + result = ptype; + } + } + } + return result; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Fallback.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Fallback.java new file mode 100644 index 000000000..f509a8bc4 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Fallback.java @@ -0,0 +1,79 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Morten Jorgensen + */ +final class Fallback extends Instruction { + + private boolean _active = false; + + /** + * This element never produces any data on the stack + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_active) { + return(typeCheckContents(stable)); + } + else { + return Type.Void; + } + } + + /** + * Activate this fallback element + */ + public void activate() { + _active = true; + } + + public String toString() { + return("fallback"); + } + + /** + * Parse contents only if this fallback element is put in place of + * some unsupported element or non-XSLTC extension element + */ + public void parseContents(Parser parser) { + if (_active) parseChildren(parser); + } + + /** + * Translate contents only if this fallback element is put in place of + * some unsupported element or non-XSLTC extension element + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + if (_active) translateContents(classGen, methodGen); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java new file mode 100644 index 000000000..de0123c7d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +class FilterExpr extends Expression { + + /** + * Primary expression of this filter. I.e., 'e' in '(e)[p1]...[pn]'. + */ + private Expression _primary; + + /** + * Array of predicates in '(e)[p1]...[pn]'. + */ + private final List _predicates; + + public FilterExpr(Expression primary, List predicates) { + _primary = primary; + _predicates = predicates; + primary.setParent(this); + } + + protected Expression getExpr() { + if (_primary instanceof CastExpr) + return ((CastExpr)_primary).getExpr(); + else + return _primary; + } + + public void setParser(Parser parser) { + super.setParser(parser); + _primary.setParser(parser); + if (_predicates != null) { + final int n = _predicates.size(); + for (int i = 0; i < n; i++) { + final Expression exp = _predicates.get(i); + exp.setParser(parser); + exp.setParent(this); + } + } + } + + public String toString() { + return "filter-expr(" + _primary + ", " + _predicates + ")"; + } + + /** + * Type check a FilterParentPath. If the filter is not a node-set add a + * cast to node-set only if it is of reference type. This type coercion + * is needed for expressions like $x where $x is a parameter reference. + * All optimizations are turned off before type checking underlying + * predicates. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + Type ptype = _primary.typeCheck(stable); + boolean canOptimize = _primary instanceof KeyCall; + + if (ptype instanceof NodeSetType == false) { + if (ptype instanceof ReferenceType) { + _primary = new CastExpr(_primary, Type.NodeSet); + } + else { + throw new TypeCheckError(this); + } + } + + // Type check predicates and turn all optimizations off if appropriate + int n = _predicates.size(); + for (int i = 0; i < n; i++) { + Predicate pred = (Predicate) _predicates.get(i); + + if (!canOptimize) { + pred.dontOptimize(); + } + pred.typeCheck(stable); + } + return _type = Type.NodeSet; + } + + /** + * Translate a filter expression by pushing the appropriate iterator + * onto the stack. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + translateFilterExpr(classGen, methodGen, _predicates == null ? -1 : _predicates.size() - 1); + } + + private void translateFilterExpr(ClassGenerator classGen, + MethodGenerator methodGen, + int predicateIndex) { + if (predicateIndex >= 0) { + translatePredicates(classGen, methodGen, predicateIndex); + } + else { + _primary.translate(classGen, methodGen); + } + } + + /** + * Translate a sequence of predicates. Each predicate is translated + * by constructing an instance of CurrentNodeListIterator + * which is initialized from another iterator (recursive call), a + * filter and a closure (call to translate on the predicate) and "this". + */ + public void translatePredicates(ClassGenerator classGen, + MethodGenerator methodGen, + int predicateIndex) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // If not predicates left, translate primary expression + if (predicateIndex < 0) { + translateFilterExpr(classGen, methodGen, predicateIndex); + } + else { + // Get the next predicate to be translated + Predicate predicate = (Predicate) _predicates.get(predicateIndex--); + + // Translate the rest of the predicates from right to left + translatePredicates(classGen, methodGen, predicateIndex); + + if (predicate.isNthPositionFilter()) { + int nthIteratorIdx = cpg.addMethodref(NTH_ITERATOR_CLASS, + "", + "("+NODE_ITERATOR_SIG+"I)V"); + + // Backwards branches are prohibited if an uninitialized object + // is on the stack by section 4.9.4 of the JVM Specification, + // 2nd Ed. We don't know whether this code might contain + // backwards branches, so we mustn't create the new object unti + + // after we've created the suspect arguments to its constructor + + // Instead we calculate the values of the arguments to the + // constructor first, store them in temporary variables, create + // the object and reload the arguments from the temporaries to + // avoid the problem. + LocalVariableGen iteratorTemp + = methodGen.addLocalVariable("filter_expr_tmp1", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + iteratorTemp.setStart( + il.append(new ASTORE(iteratorTemp.getIndex()))); + + predicate.translate(classGen, methodGen); + LocalVariableGen predicateValueTemp + = methodGen.addLocalVariable("filter_expr_tmp2", + Util.getJCRefType("I"), + null, null); + predicateValueTemp.setStart( + il.append(new ISTORE(predicateValueTemp.getIndex()))); + + il.append(new NEW(cpg.addClass(NTH_ITERATOR_CLASS))); + il.append(DUP); + iteratorTemp.setEnd( + il.append(new ALOAD(iteratorTemp.getIndex()))); + predicateValueTemp.setEnd( + il.append(new ILOAD(predicateValueTemp.getIndex()))); + il.append(new INVOKESPECIAL(nthIteratorIdx)); + } else { + // Translate predicates from right to left + final int initCNLI = cpg.addMethodref(CURRENT_NODE_LIST_ITERATOR, + "", + "("+NODE_ITERATOR_SIG+"Z"+ + CURRENT_NODE_LIST_FILTER_SIG + + NODE_SIG+TRANSLET_SIG+")V"); + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + + LocalVariableGen nodeIteratorTemp = + methodGen.addLocalVariable("filter_expr_tmp1", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + nodeIteratorTemp.setStart( + il.append(new ASTORE(nodeIteratorTemp.getIndex()))); + + predicate.translate(classGen, methodGen); + LocalVariableGen filterTemp = + methodGen.addLocalVariable("filter_expr_tmp2", + Util.getJCRefType(CURRENT_NODE_LIST_FILTER_SIG), + null, null); + filterTemp.setStart(il.append(new ASTORE(filterTemp.getIndex()))); + + // Create a CurrentNodeListIterator + il.append(new NEW(cpg.addClass(CURRENT_NODE_LIST_ITERATOR))); + il.append(DUP); + + // Initialize CurrentNodeListIterator + nodeIteratorTemp.setEnd( + il.append(new ALOAD(nodeIteratorTemp.getIndex()))); + il.append(ICONST_1); + filterTemp.setEnd(il.append(new ALOAD(filterTemp.getIndex()))); + il.append(methodGen.loadCurrentNode()); + il.append(classGen.loadTranslet()); + il.append(new INVOKESPECIAL(initCNLI)); + } + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterParentPath.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterParentPath.java new file mode 100644 index 000000000..f2971ae86 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterParentPath.java @@ -0,0 +1,174 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class FilterParentPath extends Expression { + + private Expression _filterExpr; + private Expression _path; + private boolean _hasDescendantAxis = false; + + public FilterParentPath(Expression filterExpr, Expression path) { + (_path = path).setParent(this); + (_filterExpr = filterExpr).setParent(this); + } + + public void setParser(Parser parser) { + super.setParser(parser); + _filterExpr.setParser(parser); + _path.setParser(parser); + } + + public String toString() { + return "FilterParentPath(" + _filterExpr + ", " + _path + ')'; + } + + public void setDescendantAxis() { + _hasDescendantAxis = true; + } + + /** + * Type check a FilterParentPath. If the filter is not a node-set add a + * cast to node-set only if it is of reference type. This type coercion is + * needed for expressions like $x/LINE where $x is a parameter reference. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type ftype = _filterExpr.typeCheck(stable); + if (ftype instanceof NodeSetType == false) { + if (ftype instanceof ReferenceType) { + _filterExpr = new CastExpr(_filterExpr, Type.NodeSet); + } + /* + else if (ftype instanceof ResultTreeType) { + _filterExpr = new CastExpr(_filterExpr, Type.NodeSet); + } + */ + else if (ftype instanceof NodeType) { + _filterExpr = new CastExpr(_filterExpr, Type.NodeSet); + } + else { + throw new TypeCheckError(this); + } + } + + // Wrap single node path in a node set + final Type ptype = _path.typeCheck(stable); + if (!(ptype instanceof NodeSetType)) { + _path = new CastExpr(_path, Type.NodeSet); + } + + return _type = Type.NodeSet; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + // Create new StepIterator + final int initSI = cpg.addMethodref(STEP_ITERATOR_CLASS, + "", + "(" + +NODE_ITERATOR_SIG + +NODE_ITERATOR_SIG + +")V"); + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + // Recursively compile 2 iterators + _filterExpr.translate(classGen, methodGen); + LocalVariableGen filterTemp = + methodGen.addLocalVariable("filter_parent_path_tmp1", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + filterTemp.setStart(il.append(new ASTORE(filterTemp.getIndex()))); + + _path.translate(classGen, methodGen); + LocalVariableGen pathTemp = + methodGen.addLocalVariable("filter_parent_path_tmp2", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + pathTemp.setStart(il.append(new ASTORE(pathTemp.getIndex()))); + + il.append(new NEW(cpg.addClass(STEP_ITERATOR_CLASS))); + il.append(DUP); + filterTemp.setEnd(il.append(new ALOAD(filterTemp.getIndex()))); + pathTemp.setEnd(il.append(new ALOAD(pathTemp.getIndex()))); + + // Initialize StepIterator with iterators from the stack + il.append(new INVOKESPECIAL(initSI)); + + // This is a special case for the //* path with or without predicates + if (_hasDescendantAxis) { + final int incl = cpg.addMethodref(NODE_ITERATOR_BASE, + "includeSelf", + "()" + NODE_ITERATOR_SIG); + il.append(new INVOKEVIRTUAL(incl)); + } + + SyntaxTreeNode parent = getParent(); + + boolean parentAlreadyOrdered = + (parent instanceof RelativeLocationPath) + || (parent instanceof FilterParentPath) + || (parent instanceof KeyCall) + || (parent instanceof CurrentCall) + || (parent instanceof DocumentCall); + + if (!parentAlreadyOrdered) { + final int order = cpg.addInterfaceMethodref(DOM_INTF, + ORDER_ITERATOR, + ORDER_ITERATOR_SIG); + il.append(methodGen.loadDOM()); + il.append(SWAP); + il.append(methodGen.loadContextNode()); + il.append(new INVOKEINTERFACE(order, 3)); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilteredAbsoluteLocationPath.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilteredAbsoluteLocationPath.java new file mode 100644 index 000000000..6602b9a0d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilteredAbsoluteLocationPath.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author G. Todd Miller + */ +final class FilteredAbsoluteLocationPath extends Expression { + private Expression _path; // may be null + + public FilteredAbsoluteLocationPath() { + _path = null; + } + + public FilteredAbsoluteLocationPath(Expression path) { + _path = path; + if (path != null) { + _path.setParent(this); + } + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_path != null) { + _path.setParser(parser); + } + } + + public Expression getPath() { + return(_path); + } + + public String toString() { + return "FilteredAbsoluteLocationPath(" + + (_path != null ? _path.toString() : "null") + ')'; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_path != null) { + final Type ptype = _path.typeCheck(stable); + if (ptype instanceof NodeType) { // promote to node-set + _path = new CastExpr(_path, Type.NodeSet); + } + } + return _type = Type.NodeSet; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + if (_path != null) { + final int initDFI = cpg.addMethodref(DUP_FILTERED_ITERATOR, + "", + "(" + + NODE_ITERATOR_SIG + + ")V"); + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + // Compile relative path iterator(s) + LocalVariableGen pathTemp = + methodGen.addLocalVariable("filtered_absolute_location_path_tmp", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + _path.translate(classGen, methodGen); + pathTemp.setStart(il.append(new ASTORE(pathTemp.getIndex()))); + + // Create new Dup Filter Iterator + il.append(new NEW(cpg.addClass(DUP_FILTERED_ITERATOR))); + il.append(DUP); + pathTemp.setEnd(il.append(new ALOAD(pathTemp.getIndex()))); + + // Initialize Dup Filter Iterator with iterator from the stack + il.append(new INVOKESPECIAL(initDFI)); + } + else { + final int git = cpg.addInterfaceMethodref(DOM_INTF, + "getIterator", + "()"+NODE_ITERATOR_SIG); + il.append(methodGen.loadDOM()); + il.append(new INVOKEINTERFACE(git, 1)); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FloorCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FloorCall.java new file mode 100644 index 000000000..ff177604d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FloorCall.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class FloorCall extends FunctionCall { + public FloorCall(QName fname, List arguments) { + super(fname, arguments); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + argument().translate(classGen, methodGen); + methodGen.getInstructionList() + .append(new INVOKESTATIC(classGen.getConstantPool() + .addMethodref(MATH_CLASS, + "floor", "(D)D"))); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FlowList.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FlowList.java new file mode 100644 index 000000000..f5a452cd3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FlowList.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +public final class FlowList { + private List _elements; + + public FlowList() { + _elements = null; + } + + public FlowList(InstructionHandle bh) { + _elements = new ArrayList<>(); + _elements.add(bh); + } + + public FlowList(FlowList list) { + _elements = list._elements; + } + + public FlowList add(InstructionHandle bh) { + if (_elements == null) { + _elements = new ArrayList<>(); + } + _elements.add(bh); + return this; + } + + public FlowList append(FlowList right) { + if (_elements == null) { + _elements = right._elements; + } + else { + final List temp = right._elements; + if (temp != null) { + final int n = temp.size(); + for (int i = 0; i < n; i++) { + _elements.add(temp.get(i)); + } + } + } + return this; + } + + /** + * Back patch a flow list. All instruction handles must be branch handles. + */ + public void backPatch(InstructionHandle target) { + if (_elements != null) { + final int n = _elements.size(); + for (int i = 0; i < n; i++) { + BranchHandle bh = (BranchHandle)_elements.get(i); + bh.setTarget(target); + } + _elements.clear(); // avoid backpatching more than once + } + } + + /** + * Redirect the handles from oldList to newList. "This" flow list + * is assumed to be relative to oldList. + */ + public FlowList copyAndRedirect(InstructionList oldList, + InstructionList newList) + { + final FlowList result = new FlowList(); + if (_elements == null) { + return result; + } + + final int n = _elements.size(); + final Iterator oldIter = oldList.iterator(); + final Iterator newIter = newList.iterator(); + + while (oldIter.hasNext()) { + final InstructionHandle oldIh = oldIter.next(); + final InstructionHandle newIh = newIter.next(); + + for (int i = 0; i < n; i++) { + if (_elements.get(i) == oldIh) { + result.add(newIh); + } + } + } + return result; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java new file mode 100644 index 000000000..a35b19481 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: ForEach.java,v 1.2.4.1 2005/09/01 15:23:46 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFGT; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class ForEach extends Instruction { + + private Expression _select; + private Type _type; + + public void display(int indent) { + indent(indent); + Util.println("ForEach"); + indent(indent + IndentIncrement); + Util.println("select " + _select.toString()); + displayContents(indent + IndentIncrement); + } + + public void parseContents(Parser parser) { + _select = parser.parseExpression(this, "select", null); + + parseChildren(parser); + + // make sure required attribute(s) have been set + if (_select.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select"); + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _type = _select.typeCheck(stable); + + if (_type instanceof ReferenceType || _type instanceof NodeType) { + _select = new CastExpr(_select, Type.NodeSet); + typeCheckContents(stable); + return Type.Void; + } + if (_type instanceof NodeSetType||_type instanceof ResultTreeType) { + typeCheckContents(stable); + return Type.Void; + } + throw new TypeCheckError(this); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Save current node and current iterator on the stack + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadIterator()); + + // Collect sort objects associated with this instruction + final List sortObjects = new ArrayList<>(); + Iterator children = elements(); + while (children.hasNext()) { + final SyntaxTreeNode child = children.next(); + if (child instanceof Sort) { + sortObjects.add((Sort)child); + } + } + + if ((_type != null) && (_type instanceof ResultTreeType)) { + // Store existing DOM on stack - must be restored when loop is done + il.append(methodGen.loadDOM()); + + // cannot be applied to a result tree - issue warning + if (sortObjects.size() > 0) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this); + getParser().reportError(WARNING, msg); + } + + // Put the result tree on the stack (DOM) + _select.translate(classGen, methodGen); + // Get an iterator for the whole DOM - excluding the root node + _type.translateTo(classGen, methodGen, Type.NodeSet); + // Store the result tree as the default DOM + il.append(SWAP); + il.append(methodGen.storeDOM()); + } + else { + // Compile node iterator + if (sortObjects.size() > 0) { + Sort.translateSortIterator(classGen, methodGen, + _select, sortObjects); + } + else { + _select.translate(classGen, methodGen); + } + + if (_type instanceof ReferenceType == false) { + il.append(methodGen.loadContextNode()); + il.append(methodGen.setStartNode()); + } + } + + + // Overwrite current iterator + il.append(methodGen.storeIterator()); + + // Give local variables (if any) default values before starting loop + initializeVariables(classGen, methodGen); + + final BranchHandle nextNode = il.append(new GOTO(null)); + final InstructionHandle loop = il.append(NOP); + + translateContents(classGen, methodGen); + + nextNode.setTarget(il.append(methodGen.loadIterator())); + il.append(methodGen.nextNode()); + il.append(DUP); + il.append(methodGen.storeCurrentNode()); + il.append(new IFGT(loop)); + + // Restore current DOM (if result tree was used instead for this loop) + if ((_type != null) && (_type instanceof ResultTreeType)) { + il.append(methodGen.storeDOM()); + } + + // Restore current node and current iterator from the stack + il.append(methodGen.storeIterator()); + il.append(methodGen.storeCurrentNode()); + } + + /** + * The code that is generated by nested for-each loops can appear to some + * JVMs as if it is accessing un-initialized variables. We must add some + * code that pushes the default variable value on the stack and pops it + * into the variable slot. This is done by the Variable.initialize() + * method. The code that we compile for this loop looks like this: + * + * initialize iterator + * initialize variables <-- HERE!!! + * goto Iterate + * Loop: : + * : (code for contents) + * : + * Iterate: node = iterator.next(); + * if (node != END) goto Loop + */ + public void initializeVariables(ClassGenerator classGen, + MethodGenerator methodGen) { + final int n = elementCount(); + for (int i = 0; i < n; i++) { + final Object child = getContents().get(i); + if (child instanceof Variable) { + Variable var = (Variable)child; + var.initialize(classGen, methodGen); + } + } + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FormatNumberCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FormatNumberCall.java new file mode 100644 index 000000000..f63c425eb --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FormatNumberCall.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.RealType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class FormatNumberCall extends FunctionCall { + private Expression _value; + private Expression _format; + private Expression _name; + private QName _resolvedQName = null; + + public FormatNumberCall(QName fname, List arguments) { + super(fname, arguments); + _value = argument(0); + _format = argument(1); + _name = argumentCount() == 3 ? argument(2) : null; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + + // Inform stylesheet to instantiate a DecimalFormat object + getStylesheet().numberFormattingUsed(); + + final Type tvalue = _value.typeCheck(stable); + if (tvalue instanceof RealType == false) { + _value = new CastExpr(_value, Type.Real); + } + final Type tformat = _format.typeCheck(stable); + if (tformat instanceof StringType == false) { + _format = new CastExpr(_format, Type.String); + } + if (argumentCount() == 3) { + final Type tname = _name.typeCheck(stable); + + if (_name instanceof LiteralExpr) { + final LiteralExpr literal = (LiteralExpr) _name; + _resolvedQName = + getParser().getQNameIgnoreDefaultNs(literal.getValue()); + } + else if (tname instanceof StringType == false) { + _name = new CastExpr(_name, Type.String); + } + } + return _type = Type.String; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + _value.translate(classGen, methodGen); + _format.translate(classGen, methodGen); + + final int fn3arg = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "formatNumber", + "(DLjava/lang/String;"+ + "Ljava/text/DecimalFormat;)"+ + "Ljava/lang/String;"); + final int get = cpg.addMethodref(TRANSLET_CLASS, + "getDecimalFormat", + "(Ljava/lang/String;)"+ + "Ljava/text/DecimalFormat;"); + + il.append(classGen.loadTranslet()); + if (_name == null) { + il.append(new PUSH(cpg, EMPTYSTRING)); + } + else if (_resolvedQName != null) { + il.append(new PUSH(cpg, _resolvedQName.toString())); + } + else { + _name.translate(classGen, methodGen); + } + il.append(new INVOKEVIRTUAL(get)); + il.append(new INVOKESTATIC(fn3arg)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java new file mode 100644 index 000000000..8a836537f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.utils.ObjectFactory; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.List; + +/** + * @author G. Todd Miller + * @author Santiago Pericas-Geertsen + * @LastModified: Nov 2017 + */ +final class FunctionAvailableCall extends FunctionCall { + + private Expression _arg; + private String _nameOfFunct = null; + private String _namespaceOfFunct = null; + private boolean _isFunctionAvailable = false; + + /** + * Constructs a FunctionAvailableCall FunctionCall. Takes the + * function name qname, for example, 'function-available', and + * a list of arguments where the arguments must be instances of + * LiteralExpression. + */ + public FunctionAvailableCall(QName fname, List arguments) { + super(fname, arguments); + _arg = arguments.get(0); + _type = null; + + if (_arg instanceof LiteralExpr) { + LiteralExpr arg = (LiteralExpr) _arg; + _namespaceOfFunct = arg.getNamespace(); + _nameOfFunct = arg.getValue(); + + if (!isInternalNamespace()) { + _isFunctionAvailable = hasMethods(); + } + } + } + + /** + * Argument of function-available call must be literal, typecheck + * returns the type of function-available to be boolean. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_type != null) { + return _type; + } + if (_arg instanceof LiteralExpr) { + return _type = Type.Boolean; + } + ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, + "function-available", this); + throw new TypeCheckError(err); + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + return getResult() ? Boolean.TRUE : Boolean.FALSE; + } + + /** + * for external java functions only: reports on whether or not + * the specified method is found in the specifed class. + */ + private boolean hasMethods() { + + // Get the class name from the namespace uri + String className = getClassNameFromUri(_namespaceOfFunct); + + // Get the method name from the argument to function-available + String methodName = null; + int colonIndex = _nameOfFunct.indexOf(":"); + if (colonIndex > 0) { + String functionName = _nameOfFunct.substring(colonIndex+1); + int lastDotIndex = functionName.lastIndexOf('.'); + if (lastDotIndex > 0) { + methodName = functionName.substring(lastDotIndex+1); + if (className != null && className.length() != 0) + className = className + "." + functionName.substring(0, lastDotIndex); + else + className = functionName.substring(0, lastDotIndex); + } + else + methodName = functionName; + } + else + methodName = _nameOfFunct; + + if (className == null || methodName == null) { + return false; + } + + // Replace the '-' characters in the method name + if (methodName.indexOf('-') > 0) + methodName = replaceDash(methodName); + + try { + final Class clazz = ObjectFactory.findProviderClass(className, true); + + if (clazz == null) { + return false; + } + + final Method[] methods = clazz.getMethods(); + + for (int i = 0; i < methods.length; i++) { + final int mods = methods[i].getModifiers(); + + if (Modifier.isPublic(mods) && Modifier.isStatic(mods) + && methods[i].getName().equals(methodName)) + { + return true; + } + } + } + catch (ClassNotFoundException e) { + return false; + } + return false; + } + + /** + * Reports on whether the function specified in the argument to + * xslt function 'function-available' was found. + */ + public boolean getResult() { + if (_nameOfFunct == null) { + return false; + } + + if (isInternalNamespace()) { + final Parser parser = getParser(); + _isFunctionAvailable = + parser.functionSupported(Util.getLocalName(_nameOfFunct)); + } + return _isFunctionAvailable; + } + + /** + * Return true if the namespace uri is null or it is the XSLTC translet uri. + */ + private boolean isInternalNamespace() { + return (_namespaceOfFunct == null || + _namespaceOfFunct.equals(EMPTYSTRING) || + _namespaceOfFunct.equals(TRANSLET_URI)); + } + + /** + * Calls to 'function-available' are resolved at compile time since + * the namespaces declared in the stylsheet are not available at run + * time. Consequently, arguments to this function must be literals. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + methodGen.getInstructionList().append(new PUSH(cpg, getResult())); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java new file mode 100644 index 000000000..cd7c9e498 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java @@ -0,0 +1,1186 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionConst; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.InvokeInstruction; +import com.sun.org.apache.bcel.internal.generic.LDC; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.utils.ObjectFactory; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.IntType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MultiHashtable; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import jdk.xml.internal.JdkXmlFeatures; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author Todd Miller + * @LastModified: Nov 2017 + */ +class FunctionCall extends Expression { + + // Name of this function call + private QName _fname; + // Arguments to this function call (might not be any) + private final List _arguments; + // Empty argument list, used for certain functions + private final static List EMPTY_ARG_LIST = new ArrayList<>(0); + + // Valid namespaces for Java function-call extension + protected final static String EXT_XSLTC = + TRANSLET_URI; + + protected final static String JAVA_EXT_XSLTC = + EXT_XSLTC + "/java"; + + protected final static String EXT_XALAN = + "http://xml.apache.org/xalan"; + + protected final static String JAVA_EXT_XALAN = + "http://xml.apache.org/xalan/java"; + + protected final static String JAVA_EXT_XALAN_OLD = + "http://xml.apache.org/xslt/java"; + + protected final static String EXSLT_COMMON = + "http://exslt.org/common"; + + protected final static String EXSLT_MATH = + "http://exslt.org/math"; + + protected final static String EXSLT_SETS = + "http://exslt.org/sets"; + + protected final static String EXSLT_DATETIME = + "http://exslt.org/dates-and-times"; + + protected final static String EXSLT_STRINGS = + "http://exslt.org/strings"; + + protected final static String XALAN_CLASSPACKAGE_NAMESPACE = + "xalan://"; + + // Namespace format constants + protected final static int NAMESPACE_FORMAT_JAVA = 0; + protected final static int NAMESPACE_FORMAT_CLASS = 1; + protected final static int NAMESPACE_FORMAT_PACKAGE = 2; + protected final static int NAMESPACE_FORMAT_CLASS_OR_PACKAGE = 3; + + // Namespace format + private int _namespace_format = NAMESPACE_FORMAT_JAVA; + + /** + * Stores reference to object for non-static Java calls + */ + Expression _thisArgument = null; + + // External Java function's class/method/signature + private String _className; + private Class _clazz; + private Method _chosenMethod; + private Constructor _chosenConstructor; + private MethodType _chosenMethodType; + + // Encapsulates all unsupported external function calls + private boolean unresolvedExternal; + + // If FunctionCall is a external java constructor + private boolean _isExtConstructor = false; + + // If the java method is static + private boolean _isStatic = false; + + // Legal conversions between internal and Java types. + private static final MultiHashtable _internal2Java = new MultiHashtable<>(); + + // Legal conversions between Java and internal types. + private static final Map, Type> JAVA2INTERNAL; + + // The mappings between EXSLT extension namespaces and implementation classes + private static final Map EXTENSIONNAMESPACE; + + // Extension functions that are implemented in BasisLibrary + private static final Map EXTENSIONFUNCTION; + /** + * inner class to used in internal2Java mappings, contains + * the Java type and the distance between the internal type and + * the Java type. + */ + static class JavaType { + public Class type; + public int distance; + + public JavaType(Class type, int distance){ + this.type = type; + this.distance = distance; + } + + @Override + public int hashCode() { + return Objects.hashCode(this.type); + } + + @Override + public boolean equals(Object query) { + if (query == null) { + return false; + } + if (query.getClass().isAssignableFrom(JavaType.class)) { + return ((JavaType)query).type.equals(type); + } else { + return query.equals(type); + } + } + } + + /** + * Defines 2 conversion tables: + * 1. From internal types to Java types and + * 2. From Java types to internal types. + * These two tables are used when calling external (Java) functions. + */ + static { + final Class nodeClass, nodeListClass; + try { + nodeClass = Class.forName("org.w3c.dom.Node"); + nodeListClass = Class.forName("org.w3c.dom.NodeList"); + } + catch (ClassNotFoundException e) { + ErrorMsg err = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR,"org.w3c.dom.Node or NodeList"); + throw new Error(err.toString()); + } + + // -- Internal to Java -------------------------------------------- + + // Type.Boolean -> { boolean(0), Boolean(1), Object(2) } + _internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE, 0)); + _internal2Java.put(Type.Boolean, new JavaType(Boolean.class, 1)); + _internal2Java.put(Type.Boolean, new JavaType(Object.class, 2)); + + // Type.Real -> { double(0), Double(1), float(2), long(3), int(4), + // short(5), byte(6), char(7), Object(8) } + _internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0)); + _internal2Java.put(Type.Real, new JavaType(Double.class, 1)); + _internal2Java.put(Type.Real, new JavaType(Float.TYPE, 2)); + _internal2Java.put(Type.Real, new JavaType(Long.TYPE, 3)); + _internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 4)); + _internal2Java.put(Type.Real, new JavaType(Short.TYPE, 5)); + _internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 6)); + _internal2Java.put(Type.Real, new JavaType(Character.TYPE, 7)); + _internal2Java.put(Type.Real, new JavaType(Object.class, 8)); + + // Type.Int must be the same as Type.Real + _internal2Java.put(Type.Int, new JavaType(Double.TYPE, 0)); + _internal2Java.put(Type.Int, new JavaType(Double.class, 1)); + _internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2)); + _internal2Java.put(Type.Int, new JavaType(Long.TYPE, 3)); + _internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 4)); + _internal2Java.put(Type.Int, new JavaType(Short.TYPE, 5)); + _internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 6)); + _internal2Java.put(Type.Int, new JavaType(Character.TYPE, 7)); + _internal2Java.put(Type.Int, new JavaType(Object.class, 8)); + + // Type.String -> { String(0), Object(1) } + _internal2Java.put(Type.String, new JavaType(String.class, 0)); + _internal2Java.put(Type.String, new JavaType(Object.class, 1)); + + // Type.NodeSet -> { NodeList(0), Node(1), Object(2), String(3) } + _internal2Java.put(Type.NodeSet, new JavaType(nodeListClass, 0)); + _internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1)); + _internal2Java.put(Type.NodeSet, new JavaType(Object.class, 2)); + _internal2Java.put(Type.NodeSet, new JavaType(String.class, 3)); + + // Type.Node -> { Node(0), NodeList(1), Object(2), String(3) } + _internal2Java.put(Type.Node, new JavaType(nodeListClass, 0)); + _internal2Java.put(Type.Node, new JavaType(nodeClass, 1)); + _internal2Java.put(Type.Node, new JavaType(Object.class, 2)); + _internal2Java.put(Type.Node, new JavaType(String.class, 3)); + + // Type.ResultTree -> { NodeList(0), Node(1), Object(2), String(3) } + _internal2Java.put(Type.ResultTree, new JavaType(nodeListClass, 0)); + _internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1)); + _internal2Java.put(Type.ResultTree, new JavaType(Object.class, 2)); + _internal2Java.put(Type.ResultTree, new JavaType(String.class, 3)); + + _internal2Java.put(Type.Reference, new JavaType(Object.class, 0)); + + _internal2Java.makeUnmodifiable(); + + Map, Type> java2Internal = new HashMap<>(); + Map extensionNamespaceTable = new HashMap<>(); + Map extensionFunctionTable = new HashMap<>(); + + // Possible conversions between Java and internal types + java2Internal.put(Boolean.TYPE, Type.Boolean); + java2Internal.put(Void.TYPE, Type.Void); + java2Internal.put(Character.TYPE, Type.Real); + java2Internal.put(Byte.TYPE, Type.Real); + java2Internal.put(Short.TYPE, Type.Real); + java2Internal.put(Integer.TYPE, Type.Real); + java2Internal.put(Long.TYPE, Type.Real); + java2Internal.put(Float.TYPE, Type.Real); + java2Internal.put(Double.TYPE, Type.Real); + + java2Internal.put(String.class, Type.String); + + java2Internal.put(Object.class, Type.Reference); + + // Conversions from org.w3c.dom.Node/NodeList to internal NodeSet + java2Internal.put(nodeListClass, Type.NodeSet); + java2Internal.put(nodeClass, Type.NodeSet); + + // Initialize the extension namespace table + extensionNamespaceTable.put(EXT_XALAN, "com.sun.org.apache.xalan.internal.lib.Extensions"); + extensionNamespaceTable.put(EXSLT_COMMON, "com.sun.org.apache.xalan.internal.lib.ExsltCommon"); + extensionNamespaceTable.put(EXSLT_MATH, "com.sun.org.apache.xalan.internal.lib.ExsltMath"); + extensionNamespaceTable.put(EXSLT_SETS, "com.sun.org.apache.xalan.internal.lib.ExsltSets"); + extensionNamespaceTable.put(EXSLT_DATETIME, "com.sun.org.apache.xalan.internal.lib.ExsltDatetime"); + extensionNamespaceTable.put(EXSLT_STRINGS, "com.sun.org.apache.xalan.internal.lib.ExsltStrings"); + + // Initialize the extension function table + extensionFunctionTable.put(EXSLT_COMMON + ":nodeSet", "nodeset"); + extensionFunctionTable.put(EXSLT_COMMON + ":objectType", "objectType"); + extensionFunctionTable.put(EXT_XALAN + ":nodeset", "nodeset"); + + JAVA2INTERNAL = Collections.unmodifiableMap(java2Internal); + EXTENSIONNAMESPACE = Collections.unmodifiableMap(extensionNamespaceTable); + EXTENSIONFUNCTION = Collections.unmodifiableMap(extensionFunctionTable); + + } + + public FunctionCall(QName fname, List arguments) { + _fname = fname; + _arguments = arguments; + _type = null; + } + + public FunctionCall(QName fname) { + this(fname, EMPTY_ARG_LIST); + } + + public String getName() { + return(_fname.toString()); + } + + @Override + public void setParser(Parser parser) { + super.setParser(parser); + if (_arguments != null) { + final int n = _arguments.size(); + for (int i = 0; i < n; i++) { + final Expression exp = _arguments.get(i); + exp.setParser(parser); + exp.setParent(this); + } + } + } + + public String getClassNameFromUri(String uri) + { + String className = EXTENSIONNAMESPACE.get(uri); + + if (className != null) + return className; + else { + if (uri.startsWith(JAVA_EXT_XSLTC)) { + int length = JAVA_EXT_XSLTC.length() + 1; + return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING; + } + else if (uri.startsWith(JAVA_EXT_XALAN)) { + int length = JAVA_EXT_XALAN.length() + 1; + return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING; + } + else if (uri.startsWith(JAVA_EXT_XALAN_OLD)) { + int length = JAVA_EXT_XALAN_OLD.length() + 1; + return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING; + } + else { + int index = uri.lastIndexOf('/'); + return (index > 0) ? uri.substring(index+1) : uri; + } + } + } + + /** + * Type check a function call. Since different type conversions apply, + * type checking is different for standard and external (Java) functions. + */ + @Override + public Type typeCheck(SymbolTable stable) + throws TypeCheckError + { + if (_type != null) return _type; + + final String namespace = _fname.getNamespace(); + String local = _fname.getLocalPart(); + + if (isExtension()) { + _fname = new QName(null, null, local); + return typeCheckStandard(stable); + } + else if (isStandard()) { + return typeCheckStandard(stable); + } + // Handle extension functions (they all have a namespace) + else { + try { + _className = getClassNameFromUri(namespace); + + final int pos = local.lastIndexOf('.'); + if (pos > 0) { + _isStatic = true; + if (_className != null && _className.length() > 0) { + _namespace_format = NAMESPACE_FORMAT_PACKAGE; + _className = _className + "." + local.substring(0, pos); + } + else { + _namespace_format = NAMESPACE_FORMAT_JAVA; + _className = local.substring(0, pos); + } + + _fname = new QName(namespace, null, local.substring(pos + 1)); + } + else { + if (_className != null && _className.length() > 0) { + try { + _clazz = ObjectFactory.findProviderClass(_className, true); + _namespace_format = NAMESPACE_FORMAT_CLASS; + } + catch (ClassNotFoundException e) { + _namespace_format = NAMESPACE_FORMAT_PACKAGE; + } + } + else + _namespace_format = NAMESPACE_FORMAT_JAVA; + + if (local.indexOf('-') > 0) { + local = replaceDash(local); + } + + String extFunction = EXTENSIONFUNCTION.get(namespace + ":" + local); + if (extFunction != null) { + _fname = new QName(null, null, extFunction); + return typeCheckStandard(stable); + } + else + _fname = new QName(namespace, null, local); + } + + return typeCheckExternal(stable); + } + catch (TypeCheckError e) { + ErrorMsg errorMsg = e.getErrorMsg(); + if (errorMsg == null) { + final String name = _fname.getLocalPart(); + errorMsg = new ErrorMsg(ErrorMsg.METHOD_NOT_FOUND_ERR, name); + } + getParser().reportError(ERROR, errorMsg); + return _type = Type.Void; + } + } + } + + /** + * Type check a call to a standard function. Insert CastExprs when needed. + * If as a result of the insertion of a CastExpr a type check error is + * thrown, then catch it and re-throw it with a new "this". + */ + public Type typeCheckStandard(SymbolTable stable) throws TypeCheckError { + _fname.clearNamespace(); // HACK!!! + + final int n = _arguments.size(); + final List argsType = typeCheckArgs(stable); + final MethodType args = new MethodType(Type.Void, argsType); + final MethodType ptype = + lookupPrimop(stable, _fname.getLocalPart(), args); + + if (ptype != null) { + for (int i = 0; i < n; i++) { + final Type argType = ptype.argsType().get(i); + final Expression exp = _arguments.get(i); + if (!argType.identicalTo(exp.getType())) { + try { + _arguments.set(i, new CastExpr(exp, argType)); + } + catch (TypeCheckError e) { + throw new TypeCheckError(this); // invalid conversion + } + } + } + _chosenMethodType = ptype; + return _type = ptype.resultType(); + } + throw new TypeCheckError(this); + } + + + + public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{ + final List> constructors = findConstructors(); + if (constructors == null) { + // Constructor not found in this class + throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND, + _className); + + } + + final int nConstructors = constructors.size(); + final int nArgs = _arguments.size(); + final List argsType = typeCheckArgs(stable); + + // Try all constructors + int bestConstrDistance = Integer.MAX_VALUE; + _type = null; // reset + for (int j, i = 0; i < nConstructors; i++) { + // Check if all parameters to this constructor can be converted + final Constructor constructor = constructors.get(i); + final Class[] paramTypes = constructor.getParameterTypes(); + + Class extType; + int currConstrDistance = 0; + for (j = 0; j < nArgs; j++) { + // Convert from internal (translet) type to external (Java) type + extType = paramTypes[j]; + final Type intType = argsType.get(j); + JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0)); + if (match != null) { + currConstrDistance += match.distance; + } + else if (intType instanceof ObjectType) { + ObjectType objectType = (ObjectType)intType; + if (objectType.getJavaClass() == extType) + continue; + else if (extType.isAssignableFrom(objectType.getJavaClass())) + currConstrDistance += 1; + else { + currConstrDistance = Integer.MAX_VALUE; + break; + } + } + else { + // no mapping available + currConstrDistance = Integer.MAX_VALUE; + break; + } + } + + if (j == nArgs && currConstrDistance < bestConstrDistance ) { + _chosenConstructor = constructor; + _isExtConstructor = true; + bestConstrDistance = currConstrDistance; + + _type = (_clazz != null) ? Type.newObjectType(_clazz) + : Type.newObjectType(_className); + } + } + + if (_type != null) { + return _type; + } + + throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType)); + } + + + /** + * Type check a call to an external (Java) method. + * The method must be static an public, and a legal type conversion + * must exist for all its arguments and its return type. + * Every method of name _fname is inspected + * as a possible candidate. + */ + public Type typeCheckExternal(SymbolTable stable) throws TypeCheckError { + int nArgs = _arguments.size(); + final String name = _fname.getLocalPart(); + + // check if function is a contructor 'new' + if (_fname.getLocalPart().equals("new")) { + return typeCheckConstructor(stable); + } + // check if we are calling an instance method + else { + boolean hasThisArgument = false; + + if (nArgs == 0) + _isStatic = true; + + if (!_isStatic) { + if (_namespace_format == NAMESPACE_FORMAT_JAVA + || _namespace_format == NAMESPACE_FORMAT_PACKAGE) + hasThisArgument = true; + + Expression firstArg = _arguments.get(0); + Type firstArgType = firstArg.typeCheck(stable); + + if (_namespace_format == NAMESPACE_FORMAT_CLASS + && firstArgType instanceof ObjectType + && _clazz != null + && _clazz.isAssignableFrom(((ObjectType)firstArgType).getJavaClass())) + hasThisArgument = true; + + if (hasThisArgument) { + _thisArgument = _arguments.get(0); + _arguments.remove(0); nArgs--; + if (firstArgType instanceof ObjectType) { + _className = ((ObjectType) firstArgType).getJavaClassName(); + } + else + throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, name); + } + } + else if (_className.length() == 0) { + /* + * Warn user if external function could not be resolved. + * Warning will _NOT_ be issued is the call is properly + * wrapped in an or element. For details + * see If.parserContents() and When.parserContents() + */ + final Parser parser = getParser(); + if (parser != null) { + reportWarning(this, parser, ErrorMsg.FUNCTION_RESOLVE_ERR, + _fname.toString()); + } + unresolvedExternal = true; + return _type = Type.Int; // use "Int" as "unknown" + } + } + + final List methods = findMethods(); + + if (methods == null) { + // Method not found in this class + throw new TypeCheckError(ErrorMsg.METHOD_NOT_FOUND_ERR, _className + "." + name); + } + + Class extType = null; + final int nMethods = methods.size(); + final List argsType = typeCheckArgs(stable); + + // Try all methods to identify the best fit + int bestMethodDistance = Integer.MAX_VALUE; + _type = null; // reset internal type + for (int j, i = 0; i < nMethods; i++) { + // Check if all paramteters to this method can be converted + final Method method = methods.get(i); + final Class[] paramTypes = method.getParameterTypes(); + + int currMethodDistance = 0; + for (j = 0; j < nArgs; j++) { + // Convert from internal (translet) type to external (Java) type + extType = paramTypes[j]; + final Type intType = argsType.get(j); + JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0)); + if (match != null) { + currMethodDistance += match.distance; + } + else { + // no mapping available + // + // Allow a Reference type to match any external (Java) type at + // the moment. The real type checking is performed at runtime. + if (intType instanceof ReferenceType) { + currMethodDistance += 1; + } + else if (intType instanceof ObjectType) { + ObjectType object = (ObjectType)intType; + if (extType.getName().equals(object.getJavaClassName())) + currMethodDistance += 0; + else if (extType.isAssignableFrom(object.getJavaClass())) + currMethodDistance += 1; + else { + currMethodDistance = Integer.MAX_VALUE; + break; + } + } + else { + currMethodDistance = Integer.MAX_VALUE; + break; + } + } + } + + if (j == nArgs) { + // Check if the return type can be converted + extType = method.getReturnType(); + + _type = JAVA2INTERNAL.get(extType); + if (_type == null) { + _type = Type.newObjectType(extType); + } + + // Use this method if all parameters & return type match + if (_type != null && currMethodDistance < bestMethodDistance) { + _chosenMethod = method; + bestMethodDistance = currMethodDistance; + } + } + } + + // It is an error if the chosen method is an instance menthod but we don't + // have a this argument. + if (_chosenMethod != null && _thisArgument == null && + !Modifier.isStatic(_chosenMethod.getModifiers())) { + throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, getMethodSignature(argsType)); + } + + if (_type != null) { + if (_type == Type.NodeSet) { + getXSLTC().setMultiDocument(true); + } + return _type; + } + + throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType)); + } + + /** + * Type check the actual arguments of this function call. + */ + public List typeCheckArgs(SymbolTable stable) throws TypeCheckError { + final List result = new ArrayList<>(); + for (Expression exp : _arguments) { + result.add(exp.typeCheck(stable)); + } + return result; + } + + protected final Expression argument(int i) { + return _arguments.get(i); + } + + protected final Expression argument() { + return argument(0); + } + + protected final int argumentCount() { + return _arguments.size(); + } + + protected final void setArgument(int i, Expression exp) { + _arguments.set(i, exp); + } + + /** + * Compile the function call and treat as an expression + * Update true/false-lists. + */ + @Override + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) + { + Type type = Type.Boolean; + if (_chosenMethodType != null) + type = _chosenMethodType.resultType(); + + final InstructionList il = methodGen.getInstructionList(); + translate(classGen, methodGen); + + if ((type instanceof BooleanType) || (type instanceof IntType)) { + _falseList.add(il.append(new IFEQ(null))); + } + } + + + /** + * Translate a function call. The compiled code will leave the function's + * return value on the JVM's stack. + */ + @Override + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final int n = argumentCount(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final boolean isSecureProcessing = classGen.getParser().getXSLTC().isSecureProcessing(); + final boolean isExtensionFunctionEnabled = classGen.getParser().getXSLTC() + .getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION); + int index; + + // Translate calls to methods in the BasisLibrary + if (isStandard() || isExtension()) { + for (int i = 0; i < n; i++) { + final Expression exp = argument(i); + exp.translate(classGen, methodGen); + exp.startIterator(classGen, methodGen); + } + + // append "F" to the function's name + final String name = _fname.toString().replace('-', '_') + "F"; + String args = Constants.EMPTYSTRING; + + // Special precautions for some method calls + if (name.equals("sumF")) { + args = DOM_INTF_SIG; + il.append(methodGen.loadDOM()); + } + else if (name.equals("normalize_spaceF")) { + if (_chosenMethodType.toSignature(args). + equals("()Ljava/lang/String;")) { + args = "I"+DOM_INTF_SIG; + il.append(methodGen.loadContextNode()); + il.append(methodGen.loadDOM()); + } + } + + // Invoke the method in the basis library + index = cpg.addMethodref(BASIS_LIBRARY_CLASS, name, + _chosenMethodType.toSignature(args)); + il.append(new INVOKESTATIC(index)); + } + // Add call to BasisLibrary.unresolved_externalF() to generate + // run-time error message for unsupported external functions + else if (unresolvedExternal) { + index = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "unresolved_externalF", + "(Ljava/lang/String;)V"); + il.append(new PUSH(cpg, _fname.toString())); + il.append(new INVOKESTATIC(index)); + } + else if (_isExtConstructor) { + if (isSecureProcessing && !isExtensionFunctionEnabled) + translateUnallowedExtension(cpg, il); + + final String clazz = + _chosenConstructor.getDeclaringClass().getName(); + + // Generate call to Module.addReads: + // .class.getModule().addReads( + generateAddReads(classGen, methodGen, clazz); + + Class[] paramTypes = _chosenConstructor.getParameterTypes(); + LocalVariableGen[] paramTemp = new LocalVariableGen[n]; + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + for (int i = 0; i < n; i++) { + final Expression exp = argument(i); + Type expType = exp.getType(); + exp.translate(classGen, methodGen); + // Convert the argument to its Java type + exp.startIterator(classGen, methodGen); + expType.translateTo(classGen, methodGen, paramTypes[i]); + paramTemp[i] = + methodGen.addLocalVariable("function_call_tmp"+i, + expType.toJCType(), + null, null); + paramTemp[i].setStart( + il.append(expType.STORE(paramTemp[i].getIndex()))); + + } + + il.append(new NEW(cpg.addClass(_className))); + il.append(InstructionConst.DUP); + + for (int i = 0; i < n; i++) { + final Expression arg = argument(i); + paramTemp[i].setEnd( + il.append(arg.getType().LOAD(paramTemp[i].getIndex()))); + } + + final StringBuffer buffer = new StringBuffer(); + buffer.append('('); + for (int i = 0; i < paramTypes.length; i++) { + buffer.append(getSignature(paramTypes[i])); + } + buffer.append(')'); + buffer.append("V"); + + index = cpg.addMethodref(clazz, + "", + buffer.toString()); + il.append(new INVOKESPECIAL(index)); + + // Convert the return type back to our internal type + (Type.Object).translateFrom(classGen, methodGen, + _chosenConstructor.getDeclaringClass()); + + } + // Invoke function calls that are handled in separate classes + else { + if (isSecureProcessing && !isExtensionFunctionEnabled) + translateUnallowedExtension(cpg, il); + + final String clazz = _chosenMethod.getDeclaringClass().getName(); + Class[] paramTypes = _chosenMethod.getParameterTypes(); + + + // Generate call to Module.addReads: + // .class.getModule().addReads( + // Class.forName().getModule()); + generateAddReads(classGen, methodGen, clazz); + + // Push "this" if it is an instance method + if (_thisArgument != null) { + _thisArgument.translate(classGen, methodGen); + } + + for (int i = 0; i < n; i++) { + final Expression exp = argument(i); + exp.translate(classGen, methodGen); + // Convert the argument to its Java type + exp.startIterator(classGen, methodGen); + exp.getType().translateTo(classGen, methodGen, paramTypes[i]); + } + + final StringBuffer buffer = new StringBuffer(); + buffer.append('('); + for (int i = 0; i < paramTypes.length; i++) { + buffer.append(getSignature(paramTypes[i])); + } + buffer.append(')'); + buffer.append(getSignature(_chosenMethod.getReturnType())); + + if (_thisArgument != null && _clazz.isInterface()) { + index = cpg.addInterfaceMethodref(clazz, + _fname.getLocalPart(), + buffer.toString()); + il.append(new INVOKEINTERFACE(index, n+1)); + } + else { + index = cpg.addMethodref(clazz, + _fname.getLocalPart(), + buffer.toString()); + il.append(_thisArgument != null ? (InvokeInstruction) new INVOKEVIRTUAL(index) : + (InvokeInstruction) new INVOKESTATIC(index)); + } + + // Convert the return type back to our internal type + _type.translateFrom(classGen, methodGen, + _chosenMethod.getReturnType()); + } + } + + private void generateAddReads(ClassGenerator classGen, MethodGenerator methodGen, + String clazz) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Generate call to Module.addReads: + // .class.getModule().addReads( + // Class.forName().getModule()); + // Class.forName may throw ClassNotFoundException. + // This is OK as it will caught higher up the stack in + // TransformerImpl.transform() and wrapped into a + // TransformerException. + methodGen.markChunkStart(); + + int index = cpg.addMethodref(CLASS_CLASS, + GET_MODULE, + GET_MODULE_SIG); + int index2 = cpg.addMethodref(CLASS_CLASS, + FOR_NAME, + FOR_NAME_SIG); + il.append(new LDC(cpg.addString(classGen.getClassName()))); + il.append(new INVOKESTATIC(index2)); + il.append(new INVOKEVIRTUAL(index)); + il.append(new LDC(cpg.addString(clazz))); + il.append(new INVOKESTATIC(index2)); + il.append(new INVOKEVIRTUAL(index)); + index = cpg.addMethodref(MODULE_CLASS, + ADD_READS, + ADD_READS_SIG); + il.append(new INVOKEVIRTUAL(index)); + il.append(InstructionConst.POP); + + methodGen.markChunkEnd(); + } + + @Override + public String toString() { + return "funcall(" + _fname + ", " + _arguments + ')'; + } + + public boolean isStandard() { + final String namespace = _fname.getNamespace(); + return (namespace == null) || (namespace.equals(Constants.EMPTYSTRING)); + } + + public boolean isExtension() { + final String namespace = _fname.getNamespace(); + return (namespace != null) && (namespace.equals(EXT_XSLTC)); + } + + /** + * Returns a vector with all methods named _fname + * after stripping its namespace or null + * if no such methods exist. + */ + private List findMethods() { + + List result = null; + final String namespace = _fname.getNamespace(); + + if (_className != null && _className.length() > 0) { + final int nArgs = _arguments.size(); + try { + if (_clazz == null) { + final boolean isSecureProcessing = getXSLTC().isSecureProcessing(); + final boolean isExtensionFunctionEnabled = getXSLTC() + .getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION); + + //Check if FSP and SM - only then process with loading + if (namespace != null && isSecureProcessing + && isExtensionFunctionEnabled + && (namespace.startsWith(JAVA_EXT_XALAN) + || namespace.startsWith(JAVA_EXT_XSLTC) + || namespace.startsWith(JAVA_EXT_XALAN_OLD) + || namespace.startsWith(XALAN_CLASSPACKAGE_NAMESPACE))) { + _clazz = getXSLTC().loadExternalFunction(_className); + } else { + _clazz = ObjectFactory.findProviderClass(_className, true); + } + + if (_clazz == null) { + final ErrorMsg msg = + new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + } + + final String methodName = _fname.getLocalPart(); + final Method[] methods = _clazz.getMethods(); + + for (int i = 0; i < methods.length; i++) { + final int mods = methods[i].getModifiers(); + // Is it public and same number of args ? + if (Modifier.isPublic(mods) + && methods[i].getName().equals(methodName) + && methods[i].getParameterTypes().length == nArgs) + { + if (result == null) { + result = new ArrayList<>(); + } + result.add(methods[i]); + } + } + } + catch (ClassNotFoundException e) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + } + return result; + } + + /** + * Returns a vector with all constructors named _fname + * after stripping its namespace or null + * if no such methods exist. + */ + private List> findConstructors() { + List> result = null; + + final int nArgs = _arguments.size(); + try { + if (_clazz == null) { + _clazz = ObjectFactory.findProviderClass(_className, true); + + if (_clazz == null) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + } + + final Constructor[] constructors = _clazz.getConstructors(); + + for (Constructor constructor : constructors) { + final int mods = constructor.getModifiers(); + // Is it public, static and same number of args ? + if (Modifier.isPublic(mods) && constructor.getParameterTypes().length == nArgs) { + if (result == null) { + result = new ArrayList<>(); + } result.add(constructor); + } + } + } + catch (ClassNotFoundException e) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + + return result; + } + + + /** + * Compute the JVM signature for the class. + */ + static final String getSignature(Class clazz) { + if (clazz.isArray()) { + final StringBuffer sb = new StringBuffer(); + Class cl = clazz; + while (cl.isArray()) { + sb.append("["); + cl = cl.getComponentType(); + } + sb.append(getSignature(cl)); + return sb.toString(); + } + else if (clazz.isPrimitive()) { + if (clazz == Integer.TYPE) { + return "I"; + } + else if (clazz == Byte.TYPE) { + return "B"; + } + else if (clazz == Long.TYPE) { + return "J"; + } + else if (clazz == Float.TYPE) { + return "F"; + } + else if (clazz == Double.TYPE) { + return "D"; + } + else if (clazz == Short.TYPE) { + return "S"; + } + else if (clazz == Character.TYPE) { + return "C"; + } + else if (clazz == Boolean.TYPE) { + return "Z"; + } + else if (clazz == Void.TYPE) { + return "V"; + } + else { + final String name = clazz.toString(); + ErrorMsg err = new ErrorMsg(ErrorMsg.UNKNOWN_SIG_TYPE_ERR,name); + throw new Error(err.toString()); + } + } + else { + return "L" + clazz.getName().replace('.', '/') + ';'; + } + } + + /** + * Compute the JVM method descriptor for the method. + */ + static final String getSignature(Method meth) { + final StringBuffer sb = new StringBuffer(); + sb.append('('); + final Class[] params = meth.getParameterTypes(); // avoid clone + for (int j = 0; j < params.length; j++) { + sb.append(getSignature(params[j])); + } + return sb.append(')').append(getSignature(meth.getReturnType())) + .toString(); + } + + /** + * Compute the JVM constructor descriptor for the constructor. + */ + static final String getSignature(Constructor cons) { + final StringBuffer sb = new StringBuffer(); + sb.append('('); + final Class[] params = cons.getParameterTypes(); // avoid clone + for (int j = 0; j < params.length; j++) { + sb.append(getSignature(params[j])); + } + return sb.append(")V").toString(); + } + + /** + * Return the signature of the current method + */ + private String getMethodSignature(List argsType) { + final StringBuffer buf = new StringBuffer(_className); + buf.append('.').append(_fname.getLocalPart()).append('('); + + int nArgs = argsType.size(); + for (int i = 0; i < nArgs; i++) { + final Type intType = argsType.get(i); + buf.append(intType.toString()); + if (i < nArgs - 1) buf.append(", "); + } + + buf.append(')'); + return buf.toString(); + } + + /** + * To support EXSLT extensions, convert names with dash to allowable Java names: + * e.g., convert abc-xyz to abcXyz. + * Note: dashes only appear in middle of an EXSLT function or element name. + */ + protected static String replaceDash(String name) + { + char dash = '-'; + final StringBuilder buff = new StringBuilder(""); + for (int i = 0; i < name.length(); i++) { + if (i > 0 && name.charAt(i-1) == dash) + buff.append(Character.toUpperCase(name.charAt(i))); + else if (name.charAt(i) != dash) + buff.append(name.charAt(i)); + } + return buff.toString(); + } + + /** + * Translate code to call the BasisLibrary.unallowed_extensionF(String) + * method. + */ + private void translateUnallowedExtension(ConstantPoolGen cpg, + InstructionList il) { + int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "unallowed_extension_functionF", + "(Ljava/lang/String;)V"); + il.append(new PUSH(cpg, _fname.toString())); + il.append(new INVOKESTATIC(index)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/GenerateIdCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/GenerateIdCall.java new file mode 100644 index 000000000..00c0a28cc --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/GenerateIdCall.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class GenerateIdCall extends FunctionCall { + public GenerateIdCall(QName fname, List arguments) { + super(fname, arguments); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + if (argumentCount() == 0) { + il.append(methodGen.loadContextNode()); + } + else { // one argument + argument().translate(classGen, methodGen); + } + final ConstantPoolGen cpg = classGen.getConstantPool(); + il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS, + "generate_idF", + // reuse signature + GET_NODE_NAME_SIG))); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdKeyPattern.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdKeyPattern.java new file mode 100644 index 000000000..cf32ae168 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdKeyPattern.java @@ -0,0 +1,127 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFNE; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +abstract class IdKeyPattern extends LocationPathPattern { + + protected RelativePathPattern _left = null;; + private String _index = null; + private String _value = null;; + + public IdKeyPattern(String index, String value) { + _index = index; + _value = value; + } + + public String getIndexName() { + return(_index); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.NodeSet; + } + + public boolean isWildcard() { + return false; + } + + public void setLeft(RelativePathPattern left) { + _left = left; + } + + public StepPattern getKernelPattern() { + return(null); + } + + public void reduceKernelPattern() { } + + public String toString() { + return "id/keyPattern(" + _index + ", " + _value + ')'; + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Returns the KeyIndex object of a given name + final int getKeyIndex = cpg.addMethodref(TRANSLET_CLASS, + "getKeyIndex", + "(Ljava/lang/String;)"+ + KEY_INDEX_SIG); + + // Initialises a KeyIndex to return nodes with specific values + final int lookupId = cpg.addMethodref(KEY_INDEX_CLASS, + "containsID", + "(ILjava/lang/Object;)I"); + final int lookupKey = cpg.addMethodref(KEY_INDEX_CLASS, + "containsKey", + "(ILjava/lang/Object;)I"); + final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeIdent", + "(I)"+NODE_SIG); + + // Call getKeyIndex in AbstractTranslet with the name of the key + // to get the index for this key (which is also a node iterator). + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg,_index)); + il.append(new INVOKEVIRTUAL(getKeyIndex)); + + // Now use the value in the second argument to determine what nodes + // the iterator should return. + il.append(SWAP); + il.append(new PUSH(cpg,_value)); + if (this instanceof IdPattern) + { + il.append(new INVOKEVIRTUAL(lookupId)); + } + else + { + il.append(new INVOKEVIRTUAL(lookupKey)); + } + + _trueList.add(il.append(new IFNE(null))); + _falseList.add(il.append(new GOTO(null))); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdPattern.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdPattern.java new file mode 100644 index 000000000..c9e984781 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdPattern.java @@ -0,0 +1,35 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class IdPattern extends IdKeyPattern { + + public IdPattern(String id) { + super("##id",id); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/If.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/If.java new file mode 100644 index 000000000..dd8f82752 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/If.java @@ -0,0 +1,110 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class If extends Instruction { + + private Expression _test; + private boolean _ignore = false; + + /** + * Display the contents of this element + */ + public void display(int indent) { + indent(indent); + Util.println("If"); + indent(indent + IndentIncrement); + System.out.print("test "); + Util.println(_test.toString()); + displayContents(indent + IndentIncrement); + } + + /** + * Parse the "test" expression and contents of this element. + */ + public void parseContents(Parser parser) { + // Parse the "test" expression + _test = parser.parseExpression(this, "test", null); + + // Make sure required attribute(s) have been set + if (_test.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test"); + return; + } + + // Ignore xsl:if when test is false (function-available() and + // element-available()) + Object result = _test.evaluateAtCompileTime(); + if (result != null && result instanceof Boolean) { + _ignore = !((Boolean) result).booleanValue(); + } + + parseChildren(parser); + } + + /** + * Type-check the "test" expression and contents of this element. + * The contents will be ignored if we know the test will always fail. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Type-check the "test" expression + if (_test.typeCheck(stable) instanceof BooleanType == false) { + _test = new CastExpr(_test, Type.Boolean); + } + // Type check the element contents + if (!_ignore) { + typeCheckContents(stable); + } + return Type.Void; + } + + /** + * Translate the "test" expression and contents of this element. + * The contents will be ignored if we know the test will always fail. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + _test.translateDesynthesized(classGen, methodGen); + // remember end of condition + final InstructionHandle truec = il.getEnd(); + if (!_ignore) { + translateContents(classGen, methodGen); + } + _test.backPatchFalseList(il.append(NOP)); + _test.backPatchTrueList(truec.getNext()); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IllegalCharException.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IllegalCharException.java new file mode 100644 index 000000000..353dd3b4d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IllegalCharException.java @@ -0,0 +1,33 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +class IllegalCharException extends Exception { + static final long serialVersionUID = -667236676706226266L; + public IllegalCharException(String s) { + super(s); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java new file mode 100644 index 000000000..098d3c8a2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Import.java,v 1.8 2007/04/09 21:30:40 joehw Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.utils.SystemIDResolver; +import java.util.Iterator; +import javax.xml.XMLConstants; +import jdk.xml.internal.JdkConstants; +import jdk.xml.internal.SecuritySupport; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +/** + * @author Jacek Ambroziak + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author Gunnlaugur Briem + * @LastModified: May 2021 + */ +final class Import extends TopLevelElement { + + private Stylesheet _imported = null; + + public Stylesheet getImportedStylesheet() { + return _imported; + } + + public void parseContents(final Parser parser) { + final XSLTC xsltc = parser.getXSLTC(); + final Stylesheet context = parser.getCurrentStylesheet(); + + try { + String docToLoad = getAttribute("href"); + if (context.checkForLoop(docToLoad)) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CIRCULAR_INCLUDE_ERR, + docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + InputSource input = null; + XMLReader reader = null; + String currLoadedDoc = context.getSystemId(); + SourceLoader loader = context.getSourceLoader(); + + // Use SourceLoader if available + if (loader != null) { + input = loader.loadSource(docToLoad, currLoadedDoc, xsltc); + if (input != null) { + docToLoad = input.getSystemId(); + reader = xsltc.getXMLReader(); + } else if (parser.errorsFound()) { + return; + } + } + + // No SourceLoader or not resolved by SourceLoader + if (input == null) { + docToLoad = SystemIDResolver.getAbsoluteURI(docToLoad, currLoadedDoc); + String accessError = SecuritySupport.checkAccess(docToLoad, + (String)xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET), + JdkConstants.ACCESS_EXTERNAL_ALL); + + if (accessError != null) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.ACCESSING_XSLT_TARGET_ERR, + SecuritySupport.sanitizePath(docToLoad), accessError, + this); + parser.reportError(Constants.FATAL, msg); + return; + } + input = new InputSource(docToLoad); + } + + // Return if we could not resolve the URL + if (input == null) { + final ErrorMsg msg = + new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + final SyntaxTreeNode root; + if (reader != null) { + root = parser.parse(reader,input); + } + else { + root = parser.parse(input); + } + + if (root == null) return; + _imported = parser.makeStylesheet(root); + if (_imported == null) return; + + _imported.setSourceLoader(loader); + _imported.setSystemId(docToLoad); + _imported.setParentStylesheet(context); + _imported.setImportingStylesheet(context); + _imported.setTemplateInlining(context.getTemplateInlining()); + + // precedence for the including stylesheet + final int currPrecedence = parser.getCurrentImportPrecedence(); + final int nextPrecedence = parser.getNextImportPrecedence(); + _imported.setImportPrecedence(currPrecedence); + context.setImportPrecedence(nextPrecedence); + parser.setCurrentStylesheet(_imported); + _imported.parseContents(parser); + + final Iterator elements = _imported.elements(); + final Stylesheet topStylesheet = parser.getTopLevelStylesheet(); + while (elements.hasNext()) { + final Object element = elements.next(); + if (element instanceof TopLevelElement) { + if (element instanceof Variable) { + topStylesheet.addVariable((Variable) element); + } + else if (element instanceof Param) { + topStylesheet.addParam((Param) element); + } + else { + topStylesheet.addElement((TopLevelElement) element); + } + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + parser.setCurrentStylesheet(context); + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + // do nothing + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java new file mode 100644 index 000000000..ecb03df9f --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Include.java,v 1.8 2007/04/09 21:30:41 joehw Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.utils.SystemIDResolver; +import java.util.Iterator; +import javax.xml.XMLConstants; +import jdk.xml.internal.JdkConstants; +import jdk.xml.internal.SecuritySupport; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +/** + * @author Jacek Ambroziak + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author Gunnlaugur Briem + * @LastModified: May 2021 + */ +final class Include extends TopLevelElement { + + private Stylesheet _included = null; + + public Stylesheet getIncludedStylesheet() { + return _included; + } + + public void parseContents(final Parser parser) { + XSLTC xsltc = parser.getXSLTC(); + Stylesheet context = parser.getCurrentStylesheet(); + + String docToLoad = getAttribute("href"); + try { + if (context.checkForLoop(docToLoad)) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CIRCULAR_INCLUDE_ERR, + docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + InputSource input = null; + XMLReader reader = null; + String currLoadedDoc = context.getSystemId(); + SourceLoader loader = context.getSourceLoader(); + + // Use SourceLoader if available + if (loader != null) { + input = loader.loadSource(docToLoad, currLoadedDoc, xsltc); + if (input != null) { + docToLoad = input.getSystemId(); + reader = xsltc.getXMLReader(); + } else if (parser.errorsFound()) { + return; + } + } + + // No SourceLoader or not resolved by SourceLoader + if (input == null) { + docToLoad = SystemIDResolver.getAbsoluteURI(docToLoad, currLoadedDoc); + String accessError = SecuritySupport.checkAccess(docToLoad, + (String)xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET), + JdkConstants.ACCESS_EXTERNAL_ALL); + + if (accessError != null) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.ACCESSING_XSLT_TARGET_ERR, + SecuritySupport.sanitizePath(docToLoad), accessError, + this); + parser.reportError(Constants.FATAL, msg); + return; + } + input = new InputSource(docToLoad); + } + + // Return if we could not resolve the URL + if (input == null) { + final ErrorMsg msg = + new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + final SyntaxTreeNode root; + if (reader != null) { + root = parser.parse(reader,input); + } + else { + root = parser.parse(input); + } + + if (root == null) return; + _included = parser.makeStylesheet(root); + if (_included == null) return; + + _included.setSourceLoader(loader); + _included.setSystemId(docToLoad); + _included.setParentStylesheet(context); + _included.setIncludingStylesheet(context); + _included.setTemplateInlining(context.getTemplateInlining()); + + // An included stylesheet gets the same import precedence + // as the stylesheet that included it. + final int precedence = context.getImportPrecedence(); + _included.setImportPrecedence(precedence); + parser.setCurrentStylesheet(_included); + _included.parseContents(parser); + + final Iterator elements = _included.elements(); + final Stylesheet topStylesheet = parser.getTopLevelStylesheet(); + while (elements.hasNext()) { + final Object element = elements.next(); + if (element instanceof TopLevelElement) { + if (element instanceof Variable) { + topStylesheet.addVariable((Variable) element); + } + else if (element instanceof Param) { + topStylesheet.addParam((Param) element); + } + else { + topStylesheet.addElement((TopLevelElement) element); + } + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + parser.setCurrentStylesheet(context); + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + // do nothing + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Instruction.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Instruction.java new file mode 100644 index 000000000..1275fcd46 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Instruction.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +abstract class Instruction extends SyntaxTreeNode { + /** + * Type check all the children of this node. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return typeCheckContents(stable); + } + + /** + * Translate this node into JVM bytecodes. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR, + getClass(), this); + getParser().reportError(FATAL, msg); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IntExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IntExpr.java new file mode 100644 index 000000000..658d306f5 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IntExpr.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class IntExpr extends Expression { + private final int _value; + + public IntExpr(int value) { + _value = value; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return _type = Type.Int; + } + + public String toString() { + return "int-expr(" + _value + ')'; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + il.append(new PUSH(cpg, _value)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java new file mode 100644 index 000000000..0b880f2c2 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Key.java,v 1.6 2006/04/25 02:25:08 jeffsuttor Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.IFGE; +import com.sun.org.apache.bcel.internal.generic.IFGT; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.dtm.Axis; +import com.sun.org.apache.xml.internal.utils.XML11Char; + +/** + * @author Morten Jorgensen + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class Key extends TopLevelElement { + + /** + * The name of this key as defined in xsl:key. + */ + private QName _name; + + /** + * The pattern to match starting at the root node. + */ + private Pattern _match; + + /** + * The expression that generates the values for this key. + */ + private Expression _use; + + /** + * The type of the _use expression. + */ + private Type _useType; + + /** + * Parse the element and attributes + * @param parser A reference to the stylesheet parser + */ + public void parseContents(Parser parser) { + + // Get the required attributes and parser XPath expressions + final String name = getAttribute("name"); + if (!XML11Char.isXML11ValidQName(name)){ + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + + // Parse key name and add to symbol table + _name = parser.getQNameIgnoreDefaultNs(name); + getSymbolTable().addKey(_name, this); + + _match = parser.parsePattern(this, "match", null); + _use = parser.parseExpression(this, "use", null); + + // Make sure required attribute(s) have been set + if (_name == null) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name"); + return; + } + if (_match.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "match"); + return; + } + if (_use.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "use"); + return; + } + } + + /** + * Returns a String-representation of this key's name + * @return The key's name (from the elements 'name' attribute). + */ + public String getName() { + return _name.toString(); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Type check match pattern + _match.typeCheck(stable); + + // Cast node values to string values (except for nodesets) + _useType = _use.typeCheck(stable); + if (_useType instanceof StringType == false && + _useType instanceof NodeSetType == false) + { + _use = new CastExpr(_use, Type.String); + } + + return Type.Void; + } + + /** + * This method is called if the "use" attribute of the key contains a + * node set. In this case we must traverse all nodes in the set and + * create one entry in this key's index for each node in the set. + */ + public void traverseNodeSet(ClassGenerator classGen, + MethodGenerator methodGen, + int buildKeyIndex) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // DOM.getStringValueX(nodeIndex) => String + final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF, + GET_NODE_VALUE, + "(I)"+STRING_SIG); + + final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeIdent", + "(I)"+NODE_SIG); + + // AbstractTranslet.SetKeyIndexDom(name, Dom) => void + final int keyDom = cpg.addMethodref(TRANSLET_CLASS, + "setKeyIndexDom", + "("+STRING_SIG+DOM_INTF_SIG+")V"); + + + // This variable holds the id of the node we found with the "match" + // attribute of xsl:key. This is the id we store, with the value we + // get from the nodes we find here, in the index for this key. + final LocalVariableGen parentNode = + methodGen.addLocalVariable("parentNode", + Util.getJCRefType("I"), + null, null); + + // Get the 'parameter' from the stack and store it in a local var. + parentNode.setStart(il.append(new ISTORE(parentNode.getIndex()))); + + // Save current node and current iterator on the stack + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadIterator()); + + // Overwrite current iterator with one that gives us only what we want + _use.translate(classGen, methodGen); + _use.startIterator(classGen, methodGen); + il.append(methodGen.storeIterator()); + + final BranchHandle nextNode = il.append(new GOTO(null)); + final InstructionHandle loop = il.append(NOP); + + // Prepare to call buildKeyIndex(String name, int node, String value); + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, _name.toString())); + parentNode.setEnd(il.append(new ILOAD(parentNode.getIndex()))); + + // Now get the node value and push it on the parameter stack + il.append(methodGen.loadDOM()); + il.append(methodGen.loadCurrentNode()); + il.append(new INVOKEINTERFACE(getNodeValue, 2)); + + // Finally do the call to add an entry in the index for this key. + il.append(new INVOKEVIRTUAL(buildKeyIndex)); + + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, getName())); + il.append(methodGen.loadDOM()); + il.append(new INVOKEVIRTUAL(keyDom)); + + nextNode.setTarget(il.append(methodGen.loadIterator())); + il.append(methodGen.nextNode()); + + il.append(DUP); + il.append(methodGen.storeCurrentNode()); + il.append(new IFGE(loop)); // Go on to next matching node.... + + // Restore current node and current iterator from the stack + il.append(methodGen.storeIterator()); + il.append(methodGen.storeCurrentNode()); + } + + /** + * Gather all nodes that match the expression in the attribute "match" + * and add one (or more) entries in this key's index. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int current = methodGen.getLocalIndex("current"); + + // AbstractTranslet.buildKeyIndex(name,node_id,value) => void + final int key = cpg.addMethodref(TRANSLET_CLASS, + "buildKeyIndex", + "("+STRING_SIG+"I"+STRING_SIG+")V"); + + // AbstractTranslet.SetKeyIndexDom(name, Dom) => void + final int keyDom = cpg.addMethodref(TRANSLET_CLASS, + "setKeyIndexDom", + "("+STRING_SIG+DOM_INTF_SIG+")V"); + + final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeIdent", + "(I)"+NODE_SIG); + + // DOM.getAxisIterator(root) => NodeIterator + final int git = cpg.addInterfaceMethodref(DOM_INTF, + "getAxisIterator", + "(I)"+NODE_ITERATOR_SIG); + + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadIterator()); + + // Get an iterator for all nodes in the DOM + il.append(methodGen.loadDOM()); + il.append(new PUSH(cpg,Axis.DESCENDANT)); + il.append(new INVOKEINTERFACE(git, 2)); + + // Reset the iterator to start with the root node + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.setStartNode()); + il.append(methodGen.storeIterator()); + + // Loop for traversing all nodes in the DOM + final BranchHandle nextNode = il.append(new GOTO(null)); + final InstructionHandle loop = il.append(NOP); + + // Check if the current node matches the pattern in "match" + il.append(methodGen.loadCurrentNode()); + _match.translate(classGen, methodGen); + _match.synthesize(classGen, methodGen); // Leaves 0 or 1 on stack + final BranchHandle skipNode = il.append(new IFEQ(null)); + + // If this is a node-set we must go through each node in the set + if (_useType instanceof NodeSetType) { + // Pass current node as parameter (we're indexing on that node) + il.append(methodGen.loadCurrentNode()); + traverseNodeSet(classGen, methodGen, key); + } + else { + il.append(classGen.loadTranslet()); + il.append(DUP); + il.append(new PUSH(cpg, _name.toString())); + il.append(DUP_X1); + il.append(methodGen.loadCurrentNode()); + _use.translate(classGen, methodGen); + il.append(new INVOKEVIRTUAL(key)); + + il.append(methodGen.loadDOM()); + il.append(new INVOKEVIRTUAL(keyDom)); + } + + // Get the next node from the iterator and do loop again... + final InstructionHandle skip = il.append(NOP); + + il.append(methodGen.loadIterator()); + il.append(methodGen.nextNode()); + il.append(DUP); + il.append(methodGen.storeCurrentNode()); + il.append(new IFGT(loop)); + + // Restore current node and current iterator from the stack + il.append(methodGen.storeIterator()); + il.append(methodGen.storeCurrentNode()); + + nextNode.setTarget(skip); + skipNode.setTarget(skip); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyCall.java new file mode 100644 index 000000000..8a649f247 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyCall.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Morten Jorgensen + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class KeyCall extends FunctionCall { + + /** + * The name of the key. + */ + private Expression _name; + + /** + * The value to look up in the key/index. + */ + private Expression _value; + + /** + * The value's data type. + */ + private Type _valueType; // The value's data type + + /** + * Expanded qname when name is literal. + */ + private QName _resolvedQName = null; + + /** + * Get the parameters passed to function: + * key(String name, String value) + * key(String name, NodeSet value) + * The 'arguments' vector should contain two parameters for key() calls, + * one holding the key name and one holding the value(s) to look up. The + * vector has only one parameter for id() calls (the key name is always + * "##id" for id() calls). + * + * @param fname The function name (should be 'key' or 'id') + * @param arguments A vector containing the arguments the the function + */ + public KeyCall(QName fname, List arguments) { + super(fname, arguments); + switch(argumentCount()) { + case 1: + _name = null; + _value = argument(0); + break; + case 2: + _name = argument(0); + _value = argument(1); + break; + default: + _name = _value = null; + break; + } + } + + /** + * If this call to key() is in a top-level element like another variable + * or param, add a dependency between that top-level element and the + * referenced key. For example, + * + * + * + * + * and assuming this class represents "key('x', 1)", add a reference + * between variable y and key x. Note that if 'x' is unknown statically + * in key('x', 1), there's nothing we can do at this point. + */ + public void addParentDependency() { + // If name unknown statically, there's nothing we can do + if (_resolvedQName == null) return; + + SyntaxTreeNode node = this; + while (node != null && node instanceof TopLevelElement == false) { + node = node.getParent(); + } + + TopLevelElement parent = (TopLevelElement) node; + if (parent != null) { + parent.addDependency(getSymbolTable().getKey(_resolvedQName)); + } + } + + /** + * Type check the parameters for the id() or key() function. + * The index name (for key() call only) must be a string or convertable + * to a string, and the lookup-value must be a string or a node-set. + * @param stable The parser's symbol table + * @throws TypeCheckError When the parameters have illegal type + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type returnType = super.typeCheck(stable); + + // Run type check on the key name (first argument) - must be a string, + // and if it is not it must be converted to one using string() rules. + if (_name != null) { + final Type nameType = _name.typeCheck(stable); + + if (_name instanceof LiteralExpr) { + final LiteralExpr literal = (LiteralExpr) _name; + _resolvedQName = + getParser().getQNameIgnoreDefaultNs(literal.getValue()); + } + else if (nameType instanceof StringType == false) { + _name = new CastExpr(_name, Type.String); + } + } + + // Run type check on the value for this key. This value can be of + // any data type, so this should never cause any type-check errors. + // If the value is a reference, then we have to defer the decision + // of how to process it until run-time. + // If the value is known not to be a node-set, then it should be + // converted to a string before the lookup is done. If the value is + // known to be a node-set then this process (convert to string, then + // do lookup) should be applied to every node in the set, and the + // result from all lookups should be added to the resulting node-set. + _valueType = _value.typeCheck(stable); + + if (_valueType != Type.NodeSet + && _valueType != Type.Reference + && _valueType != Type.String) { + _value = new CastExpr(_value, Type.String); + _valueType = _value.typeCheck(stable); + } + + // If in a top-level element, create dependency to the referenced key + addParentDependency(); + + return returnType; + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + *

    This method will generate byte code that produces an iterator + * for the nodes in the node set for the key or id function call. + * @param classGen The Java class generator + * @param methodGen The method generator + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Returns the KeyIndex object of a given name + final int getKeyIndex = cpg.addMethodref(TRANSLET_CLASS, + "getKeyIndex", + "(Ljava/lang/String;)"+ + KEY_INDEX_SIG); + + // KeyIndex.setDom(Dom, node) => void + final int keyDom = cpg.addMethodref(KEY_INDEX_CLASS, + "setDom", + "(" + DOM_INTF_SIG + "I)V"); + + // Initialises a KeyIndex to return nodes with specific values + final int getKeyIterator = + cpg.addMethodref(KEY_INDEX_CLASS, + "getKeyIndexIterator", + "(" + _valueType.toSignature() + "Z)" + + KEY_INDEX_ITERATOR_SIG); + + // Initialise the index specified in the first parameter of key() + il.append(classGen.loadTranslet()); + if (_name == null) { + il.append(new PUSH(cpg,"##id")); + } else if (_resolvedQName != null) { + il.append(new PUSH(cpg, _resolvedQName.toString())); + } else { + _name.translate(classGen, methodGen); + } + + // Generate following byte code: + // + // KeyIndex ki = translet.getKeyIndex(_name) + // ki.setDom(translet.dom); + // ki.getKeyIndexIterator(_value, true) - for key() + // OR + // ki.getKeyIndexIterator(_value, false) - for id() + il.append(new INVOKEVIRTUAL(getKeyIndex)); + il.append(DUP); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadCurrentNode()); + il.append(new INVOKEVIRTUAL(keyDom)); + + _value.translate(classGen, methodGen); + il.append((_name != null) ? ICONST_1: ICONST_0); + il.append(new INVOKEVIRTUAL(getKeyIterator)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyPattern.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyPattern.java new file mode 100644 index 000000000..77ead97ef --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyPattern.java @@ -0,0 +1,34 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class KeyPattern extends IdKeyPattern { + + public KeyPattern(String index, String value) { + super(index,value); + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LangCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LangCall.java new file mode 100644 index 000000000..edce2ca68 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LangCall.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.FilterGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import java.util.List; + +/** + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class LangCall extends FunctionCall { + private Expression _lang; + private Type _langType; + + /** + * Get the parameters passed to function: + * lang(string) + */ + public LangCall(QName fname, List arguments) { + super(fname, arguments); + _lang = argument(0); + } + + /** + * + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _langType = _lang.typeCheck(stable); + if (!(_langType instanceof StringType)) { + _lang = new CastExpr(_lang, Type.String); + } + return Type.Boolean; + } + + /** + * + */ + public Type getType() { + return(Type.Boolean); + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final int tst = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "testLanguage", + "("+STRING_SIG+DOM_INTF_SIG+"I)Z"); + _lang.translate(classGen,methodGen); + il.append(methodGen.loadDOM()); + if (classGen instanceof FilterGenerator) + il.append(new ILOAD(1)); + else + il.append(methodGen.loadContextNode()); + il.append(new INVOKESTATIC(tst)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LastCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LastCall.java new file mode 100644 index 000000000..84614a442 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LastCall.java @@ -0,0 +1,69 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.CompareGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TestGenerator; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class LastCall extends FunctionCall { + + public LastCall(QName fname) { + super(fname); + } + + public boolean hasPositionCall() { + return true; + } + + public boolean hasLastCall() { + return true; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + + if (methodGen instanceof CompareGenerator) { + il.append(((CompareGenerator)methodGen).loadLastNode()); + } + else if (methodGen instanceof TestGenerator) { + il.append(new ILOAD(LAST_INDEX)); + } + else { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR, + "getLast", + "()I"); + il.append(methodGen.loadIterator()); + il.append(new INVOKEINTERFACE(getLast, 1)); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralAttribute.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralAttribute.java new file mode 100644 index 000000000..67ee1a88d --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralAttribute.java @@ -0,0 +1,157 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +import com.sun.org.apache.xml.internal.serializer.ElemDesc; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class LiteralAttribute extends Instruction { + + private final String _name; // Attribute name (incl. prefix) + private final AttributeValue _value; // Attribute value + + /** + * Creates a new literal attribute (but does not insert it into the AST). + * @param name the attribute name (incl. prefix) as a String. + * @param value the attribute value. + * @param parser the XSLT parser (wraps XPath parser). + */ + public LiteralAttribute(String name, String value, Parser parser, + SyntaxTreeNode parent) + { + _name = name; + setParent(parent); + _value = AttributeValue.create(this, value, parser); + } + + public void display(int indent) { + indent(indent); + Util.println("LiteralAttribute name=" + _name + " value=" + _value); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _value.typeCheck(stable); + typeCheckContents(stable); + return Type.Void; + } + + protected boolean contextDependent() { + return _value.contextDependent(); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // push handler + il.append(methodGen.loadHandler()); + // push attribute name - namespace prefix set by parent node + il.append(new PUSH(cpg, _name)); + // push attribute value + _value.translate(classGen, methodGen); + + // Generate code that calls SerializationHandler.addUniqueAttribute() + // if all attributes are unique. + SyntaxTreeNode parent = getParent(); + if (parent instanceof LiteralElement + && ((LiteralElement)parent).allAttributesUnique()) { + + int flags = 0; + boolean isHTMLAttrEmpty = false; + ElemDesc elemDesc = ((LiteralElement)parent).getElemDesc(); + + // Set the HTML flags + if (elemDesc != null) { + if (elemDesc.isAttrFlagSet(_name, ElemDesc.ATTREMPTY)) { + flags = flags | SerializationHandler.HTML_ATTREMPTY; + isHTMLAttrEmpty = true; + } + else if (elemDesc.isAttrFlagSet(_name, ElemDesc.ATTRURL)) { + flags = flags | SerializationHandler.HTML_ATTRURL; + } + } + + if (_value instanceof SimpleAttributeValue) { + String attrValue = ((SimpleAttributeValue)_value).toString(); + + if (!hasBadChars(attrValue) && !isHTMLAttrEmpty) { + flags = flags | SerializationHandler.NO_BAD_CHARS; + } + } + + il.append(new PUSH(cpg, flags)); + il.append(methodGen.uniqueAttribute()); + } + else { + // call attribute + il.append(methodGen.attribute()); + } + } + + /** + * Return true if at least one character in the String is considered to + * be a "bad" character. A bad character is one whose code is: + * less than 32 (a space), + * or greater than 126, + * or it is one of '<', '>', '&' or '\"'. + * This helps the serializer to decide whether the String needs to be escaped. + */ + private boolean hasBadChars(String value) { + char[] chars = value.toCharArray(); + int size = chars.length; + for (int i = 0; i < size; i++) { + char ch = chars[i]; + if (ch < 32 || 126 < ch || ch == '<' || ch == '>' || ch == '&' || ch == '\"') + return true; + } + return false; + } + + /** + * Return the name of the attribute + */ + public String getName() { + return _name; + } + + /** + * Return the value of the attribute + */ + public AttributeValue getValue() { + return _value; + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java new file mode 100644 index 000000000..c7c2b9072 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.serializer.ElemDesc; +import com.sun.org.apache.xml.internal.serializer.ToHTMLStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Sep 2021 + */ +final class LiteralElement extends Instruction { + + private String _name; + private LiteralElement _literalElemParent = null; + private List _attributeElements = null; + private Map _accessedPrefixes = null; + + // True if all attributes of this LRE are unique, i.e. they all have + // different names. This flag is set to false if some attribute + // names are not known at compile time. + private boolean _allAttributesUnique = false; + + /** + * Returns the QName for this literal element + */ + public QName getName() { + return _qname; + } + + /** + * Displays the contents of this literal element + */ + public void display(int indent) { + indent(indent); + Util.println("LiteralElement name = " + _name); + displayContents(indent + IndentIncrement); + } + + /** + * Returns the namespace URI for which a prefix is pointing to + */ + private String accessedNamespace(String prefix) { + if (_literalElemParent != null) { + String result = _literalElemParent.accessedNamespace(prefix); + if (result != null) { + return result; + } + } + return _accessedPrefixes != null ? _accessedPrefixes.get(prefix) : null; + } + + /** + * Method used to keep track of what namespaces that are references by + * this literal element and its attributes. The output must contain a + * definition for each namespace, so we stuff them in a map. + */ + public void registerNamespace(String prefix, String uri, + SymbolTable stable, boolean declared) { + + // Check if the parent has a declaration for this namespace + if (_literalElemParent != null) { + final String parentUri = _literalElemParent.accessedNamespace(prefix); + if (parentUri != null && parentUri.equals(uri)) { + return; + } + } + + // Check if we have any declared namespaces + if (_accessedPrefixes == null) { + // use Hashtable for behavior compatibility + _accessedPrefixes = new Hashtable<>(); + } + else { + if (!declared) { + // Check if this node has a declaration for this namespace + final String old = _accessedPrefixes.get(prefix); + if (old != null) { + if (old.equals(uri)) + return; + else + prefix = stable.generateNamespacePrefix(); + } + } + } + + if (!prefix.equals("xml")) { + _accessedPrefixes.put(prefix,uri); + } + } + + /** + * Translates the prefix of a QName according to the rules set in + * the attributes of xsl:stylesheet. Also registers a QName to assure + * that the output element contains the necessary namespace declarations. + */ + private String translateQName(QName qname, SymbolTable stable) { + // Break up the QName and get prefix:localname strings + String localname = qname.getLocalPart(); + String prefix = qname.getPrefix(); + + // Treat default namespace as "" and not null + if (prefix == null) + prefix = Constants.EMPTYSTRING; + else if (prefix.equals(XMLNS_PREFIX)) + return(XMLNS_PREFIX); + + // Check if we must translate the prefix + final String alternative = stable.lookupPrefixAlias(prefix); + if (alternative != null) { + stable.excludeNamespaces(prefix); + prefix = alternative; + } + + // Get the namespace this prefix refers to + String uri = lookupNamespace(prefix); + if (uri == null) return(localname); + + // Register the namespace as accessed + registerNamespace(prefix, uri, stable, false); + + // Construct the new name for the element (may be unchanged) + if (prefix != Constants.EMPTYSTRING) + return(prefix+":"+localname); + else + return(localname); + } + + /** + * Add an attribute to this element + */ + public void addAttribute(SyntaxTreeNode attribute) { + if (_attributeElements == null) { + _attributeElements = new ArrayList<>(2); + } + _attributeElements.add(attribute); + } + + /** + * Set the first attribute of this element + */ + public void setFirstAttribute(SyntaxTreeNode attribute) { + if (_attributeElements == null) { + _attributeElements = new ArrayList<>(2); + } + _attributeElements.add(0, attribute); + } + + /** + * Type-check the contents of this element. The element itself does not + * need any type checking as it leaves nothign on the JVM's stack. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Type-check all attributes + if (_attributeElements != null) { + for (SyntaxTreeNode node : _attributeElements) { + node.typeCheck(stable); + } + } + typeCheckContents(stable); + return Type.Void; + } + + /** + * This method starts at a given node, traverses all namespace mappings, + * and assembles a list of all prefixes that (for the given node) maps + * to _ANY_ namespace URI. Used by literal result elements to determine + */ + public Set> getNamespaceScope(SyntaxTreeNode node) { + Map all = new LinkedHashMap<>(); + + while (node != null) { + Map mapping = node.getPrefixMapping(); + if (mapping != null) { + mapping.entrySet().stream().forEach((entry) -> { + all.putIfAbsent(entry.getKey(), entry.getValue()); + }); + } + node = node.getParent(); + } + return all.entrySet(); + } + + /** + * Determines the final QName for the element and its attributes. + * Registers all namespaces that are used by the element/attributes + */ + public void parseContents(Parser parser) { + final SymbolTable stable = parser.getSymbolTable(); + stable.setCurrentNode(this); + + // Check if in a literal element context + SyntaxTreeNode parent = getParent(); + if (parent != null && parent instanceof LiteralElement) { + _literalElemParent = (LiteralElement) parent; + } + + _name = translateQName(_qname, stable); + + // Process all attributes and register all namespaces they use + final int count = _attributes.getLength(); + for (int i = 0; i < count; i++) { + final QName qname = parser.getQName(_attributes.getQName(i)); + final String uri = qname.getNamespace(); + final String val = _attributes.getValue(i); + + // Handle xsl:use-attribute-sets. Attribute sets are placed first + // in the vector or attributes to make sure that later local + // attributes can override an attributes in the set. + if (qname.equals(parser.getUseAttributeSets())) { + if (!Util.isValidQNames(val)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, val, this); + parser.reportError(Constants.ERROR, err); + } + setFirstAttribute(new UseAttributeSets(val, parser)); + } + // Handle xsl:extension-element-prefixes + else if (qname.equals(parser.getExtensionElementPrefixes())) { + stable.excludeNamespaces(val); + } + // Handle xsl:exclude-result-prefixes + else if (qname.equals(parser.getExcludeResultPrefixes())) { + stable.excludeNamespaces(val); + } + else { + // Ignore special attributes (e.g. xmlns:prefix and xmlns) + final String prefix = qname.getPrefix(); + if (prefix != null && prefix.equals(XMLNS_PREFIX) || + prefix == null && qname.getLocalPart().equals(XMLNS_PREFIX) || + uri != null && uri.equals(XSLT_URI)) + { + continue; + } + + // Handle all other literal attributes + final String name = translateQName(qname, stable); + LiteralAttribute attr = new LiteralAttribute(name, val, parser, this); + addAttribute(attr); + attr.setParent(this); + attr.parseContents(parser); + } + } + + // Register all namespaces that are in scope, except for those that + // are listed in the xsl:stylesheet element's *-prefixes attributes + Set> include = getNamespaceScope(this); + for (Map.Entry entry : include) { + final String prefix = entry.getKey(); + if (!prefix.equals("xml")) { + final String uri = lookupNamespace(prefix); + if (uri != null && !stable.isExcludedNamespace(uri)) { + registerNamespace(prefix, uri, stable, true); + } + } + } + + parseChildren(parser); + + // Process all attributes and register all namespaces they use + for (int i = 0; i < count; i++) { + final QName qname = parser.getQName(_attributes.getQName(i)); + final String val = _attributes.getValue(i); + + // Handle xsl:extension-element-prefixes + if (qname.equals(parser.getExtensionElementPrefixes())) { + stable.unExcludeNamespaces(val); + } + // Handle xsl:exclude-result-prefixes + else if (qname.equals(parser.getExcludeResultPrefixes())) { + stable.unExcludeNamespaces(val); + } + } + } + + protected boolean contextDependent() { + return dependentContents(); + } + + /** + * Compiles code that emits the literal element to the output handler, + * first the start tag, then namespace declaration, then attributes, + * then the element contents, and then the element end tag. Since the + * value of an attribute may depend on a variable, variables must be + * compiled first. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Check whether all attributes are unique. + _allAttributesUnique = checkAttributesUnique(); + + // Compile code to emit element start tag + il.append(methodGen.loadHandler()); + + il.append(new PUSH(cpg, _name)); + il.append(DUP2); // duplicate these 2 args for endElement + il.append(methodGen.startElement()); + + // The value of an attribute may depend on a (sibling) variable + int j = 0; + while (j < elementCount()) { + final SyntaxTreeNode item = elementAt(j); + if (item instanceof Variable) { + item.translate(classGen, methodGen); + } + j++; + } + + // Compile code to emit namespace attributes + if (_accessedPrefixes != null) { + for (Map.Entry entry : _accessedPrefixes.entrySet()) { + final String prefix = entry.getKey(); + final String uri = entry.getValue(); + il.append(methodGen.loadHandler()); + il.append(new PUSH(cpg, prefix)); + il.append(new PUSH(cpg, uri)); + il.append(methodGen.namespace()); + } + } + + // Output all attributes + if (_attributeElements != null) { + for (SyntaxTreeNode node : _attributeElements) { + if (!(node instanceof XslAttribute)) { + node.translate(classGen, methodGen); + } + } + } + + // Compile code to emit attributes and child elements + translateContents(classGen, methodGen); + + // Compile code to emit element end tag + il.append(methodGen.endElement()); + } + + /** + * Return true if the output method is html. + */ + private boolean isHTMLOutput() { + return getStylesheet().getOutputMethod() == Stylesheet.HTML_OUTPUT; + } + + /** + * Return the ElemDesc object for an HTML element. + * Return null if the output method is not HTML or this is not a + * valid HTML element. + */ + public ElemDesc getElemDesc() { + if (isHTMLOutput()) { + return ToHTMLStream.getElemDesc(_name); + } + else + return null; + } + + /** + * Return true if all attributes of this LRE have unique names. + */ + public boolean allAttributesUnique() { + return _allAttributesUnique; + } + + /** + * Check whether all attributes are unique. + */ + private boolean checkAttributesUnique() { + boolean hasHiddenXslAttribute = canProduceAttributeNodes(this, true); + if (hasHiddenXslAttribute) + return false; + + if (_attributeElements != null) { + int numAttrs = _attributeElements.size(); + Map attrsTable = null; + for (int i = 0; i < numAttrs; i++) { + SyntaxTreeNode node = _attributeElements.get(i); + + if (node instanceof UseAttributeSets) { + return false; + } + else if (node instanceof XslAttribute) { + if (attrsTable == null) { + attrsTable = new HashMap<>(); + for (int k = 0; k < i; k++) { + SyntaxTreeNode n = _attributeElements.get(k); + if (n instanceof LiteralAttribute) { + LiteralAttribute literalAttr = (LiteralAttribute)n; + attrsTable.put(literalAttr.getName(), literalAttr); + } + } + } + + XslAttribute xslAttr = (XslAttribute)node; + AttributeValue attrName = xslAttr.getName(); + if (attrName instanceof AttributeValueTemplate) { + return false; + } + else if (attrName instanceof SimpleAttributeValue) { + SimpleAttributeValue simpleAttr = (SimpleAttributeValue)attrName; + String name = simpleAttr.toString(); + if (name != null && attrsTable.get(name) != null) + return false; + else if (name != null) { + attrsTable.put(name, xslAttr); + } + } + } + } + } + return true; + } + + /** + * Return true if the instructions under the given SyntaxTreeNode can produce attribute nodes + * to an element. Only return false when we are sure that no attribute node is produced. + * Return true if we are not sure. If the flag ignoreXslAttribute is true, the direct + * children of the current node are not included in the check. + */ + private boolean canProduceAttributeNodes(SyntaxTreeNode node, boolean ignoreXslAttribute) { + List contents = node.getContents(); + for (SyntaxTreeNode child : contents) { + if (child instanceof Text) { + Text text = (Text)child; + if (text.isIgnore()) + continue; + else + return false; + } + // Cannot add an attribute to an element after children have been added to it. + // We can safely return false when the instruction can produce an output node. + else if (child instanceof LiteralElement + || child instanceof ValueOf + || child instanceof XslElement + || child instanceof Comment + || child instanceof Number + || child instanceof ProcessingInstruction) + return false; + else if (child instanceof XslAttribute) { + if (ignoreXslAttribute) + continue; + else + return true; + } + // In general, there is no way to check whether or + // can produce attribute nodes. and + // can also copy attribute nodes to an element. Return + // true in those cases to be safe. + else if (child instanceof CallTemplate + || child instanceof ApplyTemplates + || child instanceof Copy + || child instanceof CopyOf) + return true; + else if ((child instanceof If + || child instanceof ForEach) + && canProduceAttributeNodes(child, false)) { + return true; + } + else if (child instanceof Choose) { + List chooseContents = child.getContents(); + for (SyntaxTreeNode chooseChild : chooseContents) { + if (chooseChild instanceof When || chooseChild instanceof Otherwise) { + if (canProduceAttributeNodes(chooseChild, false)) + return true; + } + } + } + } + return false; + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralExpr.java new file mode 100644 index 000000000..da84c2e1b --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralExpr.java @@ -0,0 +1,85 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class LiteralExpr extends Expression { + private final String _value; + private final String _namespace; + + /** + * Creates a new literal expression node. + * @param value the literal expression content/value. + */ + public LiteralExpr(String value) { + _value = value; + _namespace = null; + } + + /** + * Creates a new literal expression node. + * @param value the literal expression content/value. + * @param namespace the namespace in which the expression exists. + */ + public LiteralExpr(String value, String namespace) { + _value = value; + _namespace = namespace.equals(Constants.EMPTYSTRING) ? null : namespace; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return _type = Type.String; + } + + public String toString() { + return "literal-expr(" + _value + ')'; + } + + protected boolean contextDependent() { + return false; + } + + protected String getValue() { + return _value; + } + + protected String getNamespace() { + return _namespace; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + il.append(new PUSH(cpg, _value)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocalNameCall.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocalNameCall.java new file mode 100644 index 000000000..09faa0d29 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocalNameCall.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import java.util.List; + +/** + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class LocalNameCall extends NameBase { + + /** + * Handles calls with no parameter (current node is implicit parameter). + */ + public LocalNameCall(QName fname) { + super(fname); + } + + /** + * Handles calls with one parameter (either node or node-set). + */ + public LocalNameCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Returns the name of a node in the DOM + final int getNodeName = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeName", + "(I)"+STRING_SIG); + + final int getLocalName = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "getLocalName", + "(Ljava/lang/String;)"+ + "Ljava/lang/String;"); + super.translate(classGen, methodGen); + il.append(new INVOKEINTERFACE(getNodeName, 2)); + il.append(new INVOKESTATIC(getLocalName)); + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocationPathPattern.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocationPathPattern.java new file mode 100644 index 000000000..d3f68348a --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocationPathPattern.java @@ -0,0 +1,107 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.dtm.Axis; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +public abstract class LocationPathPattern extends Pattern { + private Template _template; + private int _importPrecedence; + private double _priority = Double.NaN; + private int _position = 0; + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; // TODO + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + // TODO: What does it mean to translate a Pattern ? + } + + public void setTemplate(final Template template) { + _template = template; + _priority = template.getPriority(); + _importPrecedence = template.getImportPrecedence(); + _position = template.getPosition(); + } + + public Template getTemplate() { + return _template; + } + + public final double getPriority() { + return Double.isNaN(_priority) ? getDefaultPriority() : _priority; + } + + public double getDefaultPriority() { + return 0.5; + } + + /** + * This method is used by the Mode class to prioritise patterns and + * template. This method is called for templates that are in the same + * mode and that match on the same core pattern. The rules used are: + * o) first check precedence - highest precedence wins + * o) then check priority - highest priority wins + * o) then check the position - the template that occured last wins + */ + public boolean noSmallerThan(LocationPathPattern other) { + if (_importPrecedence > other._importPrecedence) { + return true; + } + else if (_importPrecedence == other._importPrecedence) { + if (_priority > other._priority) { + return true; + } + else if (_priority == other._priority) { + if (_position > other._position) { + return true; + } + } + } + return false; + } + + public abstract StepPattern getKernelPattern(); + + public abstract void reduceKernelPattern(); + + public abstract boolean isWildcard(); + + public int getAxis() { + final StepPattern sp = getKernelPattern(); + return (sp != null) ? sp.getAxis() : Axis.CHILD; + } + + public String toString() { + return "root()"; + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java new file mode 100644 index 000000000..43c3332ae --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +final class LogicalExpr extends Expression { + + public static final int OR = 0; + public static final int AND = 1; + + private final int _op; // operator + private Expression _left; // first operand + private Expression _right; // second operand + + private static final String[] Ops = { "or", "and" }; + + /** + * Creates a new logical expression - either OR or AND. Note that the + * left- and right-hand side expressions can also be logical expressions, + * thus creating logical trees representing structures such as + * (a and (b or c) and d), etc... + */ + public LogicalExpr(int op, Expression left, Expression right) { + _op = op; + (_left = left).setParent(this); + (_right = right).setParent(this); + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + return (_left.hasPositionCall() || _right.hasPositionCall()); + } + + /** + * Returns true if this expressions contains a call to last() + */ + public boolean hasLastCall() { + return (_left.hasLastCall() || _right.hasLastCall()); + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + final Object leftb = _left.evaluateAtCompileTime(); + final Object rightb = _right.evaluateAtCompileTime(); + + // Return null if we can't evaluate at compile time + if (leftb == null || rightb == null) { + return null; + } + + if (_op == AND) { + return (leftb == Boolean.TRUE && rightb == Boolean.TRUE) ? + Boolean.TRUE : Boolean.FALSE; + } + else { + return (leftb == Boolean.TRUE || rightb == Boolean.TRUE) ? + Boolean.TRUE : Boolean.FALSE; + } + } + + /** + * Returns this logical expression's operator - OR or AND represented + * by 0 and 1 respectively. + */ + public int getOp() { + return(_op); + } + + /** + * Override the SyntaxTreeNode.setParser() method to make sure that the + * parser is set for sub-expressions + */ + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + /** + * Returns a string describing this expression + */ + public String toString() { + return Ops[_op] + '(' + _left + ", " + _right + ')'; + } + + /** + * Type-check this expression, and possibly child expressions. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Get the left and right operand types + Type tleft = _left.typeCheck(stable); + Type tright = _right.typeCheck(stable); + + // Check if the operator supports the two operand types + MethodType wantType = new MethodType(Type.Void, tleft, tright); + MethodType haveType = lookupPrimop(stable, Ops[_op], wantType); + + // Yes, the operation is supported + if (haveType != null) { + // Check if left-hand side operand must be type casted + Type arg1 = haveType.argsType().get(0); + if (!arg1.identicalTo(tleft)) + _left = new CastExpr(_left, arg1); + // Check if right-hand side operand must be type casted + Type arg2 = haveType.argsType().get(1); + if (!arg2.identicalTo(tright)) + _right = new CastExpr(_right, arg1); + // Return the result type for the operator we will use + return _type = haveType.resultType(); + } + throw new TypeCheckError(this); + } + + /** + * Compile the expression - leave boolean expression on stack + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + translateDesynthesized(classGen, methodGen); + synthesize(classGen, methodGen); + } + + /** + * Compile expression and update true/false-lists + */ + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + + final InstructionList il = methodGen.getInstructionList(); + final SyntaxTreeNode parent = getParent(); + + // Compile AND-expression + if (_op == AND) { + + // Translate left hand side - must be true + _left.translateDesynthesized(classGen, methodGen); + + // Need this for chaining any OR-expression children + InstructionHandle middle = il.append(NOP); + + // Translate left right side - must be true + _right.translateDesynthesized(classGen, methodGen); + + // Need this for chaining any OR-expression children + InstructionHandle after = il.append(NOP); + + // Append child expression false-lists to our false-list + _falseList.append(_right._falseList.append(_left._falseList)); + + // Special case for OR-expression as a left child of AND. + // The true-list of OR must point to second clause of AND. + if ((_left instanceof LogicalExpr) && + (((LogicalExpr)_left).getOp() == OR)) { + _left.backPatchTrueList(middle); + } + else if (_left instanceof NotCall) { + _left.backPatchTrueList(middle); + } + else { + _trueList.append(_left._trueList); + } + + // Special case for OR-expression as a right child of AND + // The true-list of OR must point to true-list of AND. + if ((_right instanceof LogicalExpr) && + (((LogicalExpr)_right).getOp() == OR)) { + _right.backPatchTrueList(after); + } + else if (_right instanceof NotCall) { + _right.backPatchTrueList(after); + } + else { + _trueList.append(_right._trueList); + } + } + // Compile OR-expression + else { + // Translate left-hand side expression and produce true/false list + _left.translateDesynthesized(classGen, methodGen); + + // This GOTO is used to skip over the code for the last test + // in the case where the the first test succeeds + InstructionHandle ih = il.append(new GOTO(null)); + + // Translate right-hand side expression and produce true/false list + _right.translateDesynthesized(classGen, methodGen); + + _left._trueList.backPatch(ih); + _left._falseList.backPatch(ih.getNext()); + + _falseList.append(_right._falseList); + _trueList.add(ih).append(_right._trueList); + } + } +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java new file mode 100644 index 000000000..fb1e54fe3 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +final class Message extends Instruction { + private boolean _terminate = false; + + public void parseContents(Parser parser) { + String termstr = getAttribute("terminate"); + if (termstr != null) { + _terminate = termstr.equals("yes"); + } + parseChildren(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + typeCheckContents(stable); + return Type.Void; + } + + @SuppressWarnings("fallthrough") // at default + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Load the translet (for call to displayMessage() function) + il.append(classGen.loadTranslet()); + + switch (elementCount()) { + case 0: + il.append(new PUSH(cpg, "")); + break; + case 1: + SyntaxTreeNode child = elementAt(0); + if (child instanceof Text) { + il.append(new PUSH(cpg, ((Text) child).getText())); + break; + } + // falls through + default: + // Push current output handler onto the stack + il.append(methodGen.loadHandler()); + + // Replace the current output handler by a ToXMLStream + il.append(new NEW(cpg.addClass(STREAM_XML_OUTPUT))); + il.append(methodGen.storeHandler()); + + // Push a reference to a StringWriter + il.append(new NEW(cpg.addClass(STRING_WRITER))); + il.append(DUP); + il.append(DUP); + il.append(new INVOKESPECIAL( + cpg.addMethodref(STRING_WRITER, "", "()V"))); + + // Load ToXMLStream + il.append(methodGen.loadHandler()); + il.append(new INVOKESPECIAL( + cpg.addMethodref(STREAM_XML_OUTPUT, "", + "()V"))); + + // Invoke output.setWriter(STRING_WRITER) + il.append(methodGen.loadHandler()); + il.append(SWAP); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "setWriter", + "("+WRITER_SIG+")V"), 2)); + + // Invoke output.setEncoding("UTF-8") + il.append(methodGen.loadHandler()); + il.append(new PUSH(cpg, "UTF-8")); // other encodings? + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "setEncoding", + "("+STRING_SIG+")V"), 2)); + + // Invoke output.setOmitXMLDeclaration(true) + il.append(methodGen.loadHandler()); + il.append(ICONST_1); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "setOmitXMLDeclaration", + "(Z)V"), 2)); + + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "startDocument", + "()V"), 1)); + + // Inline translation of contents + translateContents(classGen, methodGen); + + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "endDocument", + "()V"), 1)); + + // Call toString() on StringWriter + il.append(new INVOKEVIRTUAL( + cpg.addMethodref(STRING_WRITER, "toString", + "()" + STRING_SIG))); + + // Restore old output handler + il.append(SWAP); + il.append(methodGen.storeHandler()); + break; + } + + // Send the resulting string to the message handling method + il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, + "displayMessage", + "("+STRING_SIG+")V"))); + + // If 'terminate' attribute is set to 'yes': Instanciate a + // RunTimeException, but it on the stack and throw an exception + if (_terminate == true) { + // Create a new instance of RunTimeException + final int einit = cpg.addMethodref("java.lang.RuntimeException", + "", + "(Ljava/lang/String;)V"); + il.append(new NEW(cpg.addClass("java.lang.RuntimeException"))); + il.append(DUP); + il.append(new PUSH(cpg,"Termination forced by an " + + "xsl:message instruction")); + il.append(new INVOKESPECIAL(einit)); + il.append(ATHROW); + } + } + +} diff --git a/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java new file mode 100644 index 000000000..2c1f7e645 --- /dev/null +++ b/feature/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java @@ -0,0 +1,1498 @@ +/* + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Mode.java,v 1.2.4.1 2005/09/19 05:18:11 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.DUP; +import com.sun.org.apache.bcel.internal.generic.GOTO_W; +import com.sun.org.apache.bcel.internal.generic.IFLT; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.SWITCH; +import com.sun.org.apache.bcel.internal.generic.TargetLostException; +import com.sun.org.apache.bcel.internal.util.InstructionFinder; +import com.sun.org.apache.xalan.internal.xsltc.DOM; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NamedMethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.dtm.Axis; +import com.sun.org.apache.xml.internal.dtm.DTM; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Mode gathers all the templates belonging to a given mode; + * it is responsible for generating an appropriate + * applyTemplates + (mode name) method in the translet. + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author G. Todd Miller + * @LastModified: Sep 2021 + */ +final class Mode implements Constants { + + /** + * The name of this mode as defined in the stylesheet. + */ + private final QName _name; + + /** + * A reference to the stylesheet object that owns this mode. + */ + private final Stylesheet _stylesheet; + + /** + * The name of the method in which this mode is compiled. + */ + private final String _methodName; + + /** + * A vector of all the templates in this mode. + */ + private List