summaryrefslogtreecommitdiff
path: root/libjava/classpath/tools
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/tools')
-rw-r--r--libjava/classpath/tools/.cvsignore19
-rwxr-xr-xlibjava/classpath/tools/Makefile.am415
-rw-r--r--libjava/classpath/tools/Makefile.in1402
-rw-r--r--libjava/classpath/tools/README58
-rw-r--r--libjava/classpath/tools/appletviewer.in46
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/AnnotationVisitor.classbin0 -> 481 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/AnnotationWriter.classbin0 -> 5344 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/Attribute.classbin0 -> 2624 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/ByteVector.classbin0 -> 3259 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/ClassAdapter.classbin0 -> 2432 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/ClassReader.classbin0 -> 22143 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/ClassVisitor.classbin0 -> 894 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/ClassWriter.classbin0 -> 14071 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/Edge.classbin0 -> 360 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/FieldVisitor.classbin0 -> 295 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/FieldWriter.classbin0 -> 3658 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/Handler.classbin0 -> 428 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/Item.classbin0 -> 2190 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/Label.classbin0 -> 2561 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/MethodAdapter.classbin0 -> 4363 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/MethodVisitor.classbin0 -> 1464 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/MethodWriter.classbin0 -> 20587 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/Opcodes.classbin0 -> 5782 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/Type.classbin0 -> 7900 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapAttribute.classbin0 -> 6499 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapFrame.classbin0 -> 1113 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapTableAttribute.classbin0 -> 9987 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapType.classbin0 -> 2422 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/AdviceAdapter.classbin0 -> 7758 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/EmptyVisitor.classbin0 -> 5591 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/GeneratorAdapter.classbin0 -> 18394 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/LocalVariablesSorter.classbin0 -> 2561 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/Method.classbin0 -> 3964 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder$Item.classbin0 -> 946 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.classbin0 -> 5030 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/StaticInitMerger.classbin0 -> 2143 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/commons/TableSwitchGenerator.classbin0 -> 234 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.classbin0 -> 3362 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.classbin0 -> 4492 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassOptimizer.classbin0 -> 4264 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Constant.classbin0 -> 3227 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ConstantPool.classbin0 -> 4508 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.classbin0 -> 1555 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/JarOptimizer.classbin0 -> 2470 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.classbin0 -> 4251 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodOptimizer.classbin0 -> 2637 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/NameMapping.classbin0 -> 2504 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker$ConstantComparator.classbin0 -> 2004 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker.classbin0 -> 4058 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureReader.classbin0 -> 2803 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureVisitor.classbin0 -> 808 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureWriter.classbin0 -> 2981 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/AbstractInsnNode.classbin0 -> 994 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/AnnotationNode.classbin0 -> 2730 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/ClassNode.classbin0 -> 4545 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldInsnNode.classbin0 -> 996 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldNode.classbin0 -> 1958 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/IincInsnNode.classbin0 -> 749 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/InnerClassNode.classbin0 -> 836 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/InsnNode.classbin0 -> 994 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/IntInsnNode.classbin0 -> 819 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/JumpInsnNode.classbin0 -> 874 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/LabelNode.classbin0 -> 736 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/LdcInsnNode.classbin0 -> 729 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/LineNumberNode.classbin0 -> 709 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/LocalVariableNode.classbin0 -> 1021 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.classbin0 -> 1626 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/MemberNode.classbin0 -> 1241 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodInsnNode.classbin0 -> 1000 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode$1.classbin0 -> 803 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode.classbin0 -> 8654 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.classbin0 -> 828 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/TableSwitchInsnNode.classbin0 -> 1372 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/TryCatchBlockNode.classbin0 -> 904 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/TypeInsnNode.classbin0 -> 858 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/VarInsnNode.classbin0 -> 815 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Analyzer.classbin0 -> 8867 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/AnalyzerException.classbin0 -> 1243 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.classbin0 -> 5974 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicValue.classbin0 -> 1962 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicVerifier.classbin0 -> 7836 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.classbin0 -> 4302 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowValue.classbin0 -> 1356 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Frame.classbin0 -> 10023 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/IntMap.classbin0 -> 1230 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Interpreter.classbin0 -> 1312 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.classbin0 -> 4833 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SmallSet.classbin0 -> 1641 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Subroutine.classbin0 -> 1836 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Value.classbin0 -> 147 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.classbin0 -> 4875 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.classbin0 -> 2587 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierClassVisitor.classbin0 -> 9817 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierFieldVisitor.classbin0 -> 437 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierMethodVisitor.classbin0 -> 7739 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/AbstractVisitor.classbin0 -> 3823 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/CheckAnnotationAdapter.classbin0 -> 2766 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/CheckClassAdapter.classbin0 -> 9732 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/CheckFieldAdapter.classbin0 -> 1588 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/CheckMethodAdapter.classbin0 -> 13225 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAbstractVisitor.classbin0 -> 2593 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAnnotationVisitor.classbin0 -> 5991 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/TraceClassVisitor.classbin0 -> 9174 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/TraceFieldVisitor.classbin0 -> 1141 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/TraceMethodVisitor.classbin0 -> 10058 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/TraceSignatureVisitor.classbin0 -> 4781 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.classbin0 -> 5535 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.classbin0 -> 5483 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMifiable.classbin0 -> 210 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/Traceable.classbin0 -> 189 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationDefaultRule.classbin0 -> 1414 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationParameterRule.classbin0 -> 1864 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationRule.classbin0 -> 1905 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueAnnotationRule.classbin0 -> 1591 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueArrayRule.classbin0 -> 1512 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueEnumRule.classbin0 -> 1373 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueRule.classbin0 -> 1408 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ClassRule.classbin0 -> 1854 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionRule.classbin0 -> 1279 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionsRule.classbin0 -> 1814 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$FieldRule.classbin0 -> 1866 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InnerClassRule.classbin0 -> 1448 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfaceRule.classbin0 -> 1279 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfacesRule.classbin0 -> 1879 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LabelRule.classbin0 -> 1283 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LineNumberRule.classbin0 -> 1472 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LocalVarRule.classbin0 -> 1724 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchLabelRule.classbin0 -> 1469 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchRule.classbin0 -> 2483 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MaxRule.classbin0 -> 1327 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MethodRule.classbin0 -> 1719 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Opcode.classbin0 -> 525 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodeGroup.classbin0 -> 594 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodesRule.classbin0 -> 3114 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OuterClassRule.classbin0 -> 1346 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Rule.classbin0 -> 4970 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$RuleSet.classbin0 -> 2077 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$SourceRule.classbin0 -> 1269 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchLabelRule.classbin0 -> 1376 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchRule.classbin0 -> 2406 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TryCatchRule.classbin0 -> 1541 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler.classbin0 -> 16825 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ASMContentHandlerFactory.classbin0 -> 871 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ContentHandlerFactory.classbin0 -> 299 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$EntryElement.classbin0 -> 367 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$InputSlicingHandler.classbin0 -> 2395 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$OutputSlicingHandler.classbin0 -> 3132 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ProtectedInputStream.classbin0 -> 1130 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriter.classbin0 -> 4521 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriterFactory.classbin0 -> 867 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SingleDocElement.classbin0 -> 930 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SubdocumentHandlerFactory.classbin0 -> 781 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$TransformerHandlerFactory.classbin0 -> 1756 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ZipEntryElement.classbin0 -> 1163 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor.classbin0 -> 11122 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAdapter.classbin0 -> 1848 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.classbin0 -> 4628 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXClassAdapter.classbin0 -> 6837 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXCodeAdapter.classbin0 -> 7552 bytes
-rw-r--r--libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXFieldAdapter.classbin0 -> 1719 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/ClassDoc.classbin0 -> 1087 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/ConstructorDoc.classbin0 -> 215 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/Doc.classbin0 -> 741 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/DocErrorReporter.classbin0 -> 219 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/Doclet.classbin0 -> 750 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/ExecutableMemberDoc.classbin0 -> 504 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/FieldDoc.classbin0 -> 405 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/MemberDoc.classbin0 -> 184 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/MethodDoc.classbin0 -> 290 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/PackageDoc.classbin0 -> 351 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/ParamTag.classbin0 -> 214 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/Parameter.classbin0 -> 261 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/ProgramElementDoc.classbin0 -> 508 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/RootDoc.classbin0 -> 504 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/SeeTag.classbin0 -> 413 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/SerialFieldTag.classbin0 -> 363 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/SourcePosition.classbin0 -> 239 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/Tag.classbin0 -> 294 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/ThrowsTag.classbin0 -> 267 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/Type.classbin0 -> 382 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/javadoc/TypeVariable.classbin0 -> 250 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/tools/doclets/Taglet.classbin0 -> 419 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/tools/javac/Main.classbin0 -> 3764 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/tools/javac/Messages.classbin0 -> 1130 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/tools/javadoc/Main.classbin0 -> 453 bytes
-rw-r--r--libjava/classpath/tools/classes/com/sun/tools/javah/Main.classbin0 -> 692 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$FileStreamInfo.classbin0 -> 1086 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$JarStreamInfo.classbin0 -> 1741 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$StreamInfo.classbin0 -> 446 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader.classbin0 -> 6253 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/IOToolkit.classbin0 -> 3753 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputEvent.classbin0 -> 1267 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputListener.classbin0 -> 228 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/NotifyingInputStreamReader.classbin0 -> 5878 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/StringToolkit.classbin0 -> 1124 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletClassLoader.classbin0 -> 935 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletSecurityManager.classbin0 -> 1193 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletTag.classbin0 -> 8668 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletContext.classbin0 -> 2750 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletStub.classbin0 -> 1891 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/ErrorApplet.classbin0 -> 648 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$1.classbin0 -> 828 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$10.classbin0 -> 801 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$2.classbin0 -> 828 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$3.classbin0 -> 828 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$4.classbin0 -> 973 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$5.classbin0 -> 974 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$6.classbin0 -> 915 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$7.classbin0 -> 1067 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$8.classbin0 -> 831 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$9.classbin0 -> 799 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main.classbin0 -> 8053 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Messages.classbin0 -> 1169 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletContext.classbin0 -> 1320 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletViewer.classbin0 -> 3918 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletWindow.classbin0 -> 8194 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletContext.classbin0 -> 1397 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.classbin0 -> 4309 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow$1.classbin0 -> 1119 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.classbin0 -> 11928 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/TagParser.classbin0 -> 6630 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/CallbackUtil.classbin0 -> 2816 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$1.classbin0 -> 1028 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$2.classbin0 -> 983 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$AtFileArgumentCallback.classbin0 -> 1727 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser.classbin0 -> 4028 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/Messages.classbin0 -> 1151 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent$ExitTask.classbin0 -> 532 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent.classbin0 -> 570 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$1.classbin0 -> 891 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$2.classbin0 -> 705 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil.classbin0 -> 2879 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/common/SecurityProviderInfo.classbin0 -> 1215 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionGroup.classbin0 -> 2075 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTag.classbin0 -> 3296 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTaglet.classbin0 -> 4359 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTagletPath.classbin0 -> 955 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$IndexKey.classbin0 -> 1129 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$InterfaceRelation.classbin0 -> 663 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$UsageType.classbin0 -> 1848 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet.classbin0 -> 27182 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletConfigurationException.classbin0 -> 432 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOption.classbin0 -> 575 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionColonSeparated.classbin0 -> 1139 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFile.classbin0 -> 962 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFlag.classbin0 -> 755 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.classbin0 -> 2108 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionString.classbin0 -> 776 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InlineTagRenderer.classbin0 -> 258 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InvalidPackageWildcardException.classbin0 -> 437 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageGroup.classbin0 -> 698 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageMatcher.classbin0 -> 2907 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/StandardTaglet.classbin0 -> 1341 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/TagletPrinter.classbin0 -> 187 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.classbin0 -> 4081 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/CssClass.classbin0 -> 14612 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.classbin0 -> 3836 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$1.classbin0 -> 1205 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$2.classbin0 -> 1207 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$3.classbin0 -> 1401 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$TreeNode.classbin0 -> 1088 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.classbin0 -> 79930 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.classbin0 -> 12297 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.classbin0 -> 876 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$1.classbin0 -> 935 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$NullErrorReporter.classbin0 -> 793 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$UsageType.classbin0 -> 1537 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver.classbin0 -> 52598 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.classbin0 -> 955 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer$TagInfo.classbin0 -> 1043 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.classbin0 -> 10463 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/TargetContext.classbin0 -> 1172 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet$DocErrorReporterOutputStream.classbin0 -> 1093 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.classbin0 -> 14435 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.classbin0 -> 774 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.classbin0 -> 1218 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.classbin0 -> 865 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.classbin0 -> 2127 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.classbin0 -> 1467 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/FileArgumentCallback.classbin0 -> 459 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Messages.classbin0 -> 1151 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Option.classbin0 -> 2640 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionException.classbin0 -> 565 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionGroup.classbin0 -> 3894 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$1.classbin0 -> 1061 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$2.classbin0 -> 1119 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$3.classbin0 -> 904 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser.classbin0 -> 8255 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/AbstractTagImpl.classbin0 -> 2825 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.classbin0 -> 1762 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BlockSourceComponent.classbin0 -> 629 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BracketClose.classbin0 -> 862 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassComponent.classbin0 -> 2610 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocImpl.classbin0 -> 25782 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocProxy.classbin0 -> 7577 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.classbin0 -> 8685 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/CommentComponent.classbin0 -> 1517 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ConstructorDocImpl.classbin0 -> 757 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Debug.classbin0 -> 1447 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree$FileNode.classbin0 -> 943 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree.classbin0 -> 1226 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DocImpl.classbin0 -> 19116 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/EmptyStatementComponent.classbin0 -> 612 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ErrorReporter.classbin0 -> 1660 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.classbin0 -> 9289 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldComponent.classbin0 -> 3110 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldDocImpl.classbin0 -> 8266 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FunctionComponent.classbin0 -> 2992 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocPackageDoc.classbin0 -> 217 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocRootDoc.classbin0 -> 184 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/IgnoredFileParseException.classbin0 -> 357 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ImportComponent.classbin0 -> 1226 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/InheritDocTagImpl.classbin0 -> 1838 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/JavadocWrapper.classbin0 -> 960 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/LinkTagImpl.classbin0 -> 918 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$1.classbin0 -> 825 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$10.classbin0 -> 1221 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$11.classbin0 -> 1728 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$12.classbin0 -> 1799 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$13.classbin0 -> 1800 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$14.classbin0 -> 1002 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$15.classbin0 -> 924 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$16.classbin0 -> 1715 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$17.classbin0 -> 828 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$18.classbin0 -> 809 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$19.classbin0 -> 809 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$2.classbin0 -> 767 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$20.classbin0 -> 1382 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$21.classbin0 -> 1401 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$22.classbin0 -> 809 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$23.classbin0 -> 809 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$24.classbin0 -> 809 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$25.classbin0 -> 809 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$3.classbin0 -> 767 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$4.classbin0 -> 767 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$5.classbin0 -> 767 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$6.classbin0 -> 806 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$7.classbin0 -> 825 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$8.classbin0 -> 825 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$9.classbin0 -> 806 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$OptionProcessor.classbin0 -> 727 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main.classbin0 -> 29338 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MemberDocImpl.classbin0 -> 5337 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MethodDocImpl.classbin0 -> 1247 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageComponent.classbin0 -> 1142 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageDocImpl.classbin0 -> 5798 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParamTagImpl.classbin0 -> 1368 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParameterImpl.classbin0 -> 1682 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParseException.classbin0 -> 463 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$1.classbin0 -> 1669 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$Context.classbin0 -> 1209 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser.classbin0 -> 13190 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.classbin0 -> 3566 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImport.classbin0 -> 403 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportClassFile.classbin0 -> 3100 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportNotFound.classbin0 -> 1664 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportPackageFile.classbin0 -> 3932 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionClass.classbin0 -> 1980 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionPackage.classbin0 -> 2039 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ScheduledClass.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl.classbin0 -> 20655 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SeeTagImpl.classbin0 -> 4114 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.classbin0 -> 2862 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SlashSlashCommentComponent.classbin0 -> 556 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourceComponent.classbin0 -> 787 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourcePositionImpl.classbin0 -> 1095 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/StaticBlockComponent.classbin0 -> 1030 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagContainer.classbin0 -> 247 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagImpl.classbin0 -> 1350 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TemporaryStore.classbin0 -> 548 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TextTagImpl.classbin0 -> 1026 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ThrowsTagImpl.classbin0 -> 2479 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Timer.classbin0 -> 2568 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet$1.classbin0 -> 900 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet.classbin0 -> 2637 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeImpl.classbin0 -> 2694 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeVariableImpl.classbin0 -> 1292 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ValueTagImpl.classbin0 -> 1032 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Whitespace.classbin0 -> 591 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/WritableType.classbin0 -> 309 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AdditionExpression.classbin0 -> 2306 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AndExpression.classbin0 -> 756 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.classbin0 -> 1711 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.classbin0 -> 2769 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.classbin0 -> 2071 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryExpression.classbin0 -> 615 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.classbin0 -> 1593 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.classbin0 -> 1928 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.classbin0 -> 1691 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.classbin0 -> 784 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.classbin0 -> 618 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.classbin0 -> 1670 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.classbin0 -> 1371 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantByte.classbin0 -> 1082 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantChar.classbin0 -> 1634 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantDouble.classbin0 -> 1288 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantExpression.classbin0 -> 787 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantFloat.classbin0 -> 1448 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantInteger.classbin0 -> 1378 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantLong.classbin0 -> 1599 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantNull.classbin0 -> 829 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantShort.classbin0 -> 1088 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantString.classbin0 -> 1025 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Context.classbin0 -> 818 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/DivisionExpression.classbin0 -> 959 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EqualExpression.classbin0 -> 1067 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Evaluator.classbin0 -> 3343 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.classbin0 -> 378 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.classbin0 -> 780 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Expression.classbin0 -> 333 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.classbin0 -> 988 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.classbin0 -> 1009 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.classbin0 -> 2874 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.classbin0 -> 577 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.classbin0 -> 773 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaLexer.classbin0 -> 27040 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.classbin0 -> 22390 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.classbin0 -> 3902 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanExpression.classbin0 -> 979 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.classbin0 -> 1000 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.classbin0 -> 693 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.classbin0 -> 1557 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.classbin0 -> 683 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ModuloExpression.classbin0 -> 953 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.classbin0 -> 977 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NegateExpression.classbin0 -> 1696 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.classbin0 -> 1071 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotExpression.classbin0 -> 1467 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.classbin0 -> 772 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.classbin0 -> 775 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.classbin0 -> 968 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Type.classbin0 -> 1204 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.classbin0 -> 2687 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnaryExpression.classbin0 -> 524 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.classbin0 -> 473 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Action.classbin0 -> 393 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.classbin0 -> 7270 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Entry.classbin0 -> 873 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Extractor.classbin0 -> 2938 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Indexer.classbin0 -> 4278 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Lister.classbin0 -> 2941 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$1.classbin0 -> 977 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$2.classbin0 -> 916 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$3.classbin0 -> 912 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$4.classbin0 -> 917 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$5.classbin0 -> 1027 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$6.classbin0 -> 979 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$7.classbin0 -> 923 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$HandleFile.classbin0 -> 1151 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$JarParser.classbin0 -> 1469 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$ModeOption.classbin0 -> 1413 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main.classbin0 -> 5683 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Messages.classbin0 -> 1142 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/Updater.classbin0 -> 2785 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jar/WorkSet.classbin0 -> 1708 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/HashUtils.classbin0 -> 2530 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarSigner.classbin0 -> 5541 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarVerifier.classbin0 -> 9461 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$1.classbin0 -> 1187 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$10.classbin0 -> 1136 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$11.classbin0 -> 1138 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$12.classbin0 -> 1201 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$2.classbin0 -> 1188 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$3.classbin0 -> 1192 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$4.classbin0 -> 1190 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$5.classbin0 -> 1193 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$6.classbin0 -> 1199 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$7.classbin0 -> 1130 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$8.classbin0 -> 1129 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$9.classbin0 -> 1131 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParser.classbin0 -> 3938 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParserCallback.classbin0 -> 1000 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main.classbin0 -> 12108 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Messages.classbin0 -> 2707 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/SFHelper.classbin0 -> 11445 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml$State.classbin0 -> 900 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml.classbin0 -> 26673 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.classbin0 -> 9260 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.classbin0 -> 1929 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.classbin0 -> 5411 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.classbin0 -> 4087 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.classbin0 -> 2118 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$1.classbin0 -> 1195 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$2.classbin0 -> 1195 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$3.classbin0 -> 1195 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$4.classbin0 -> 1195 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$5.classbin0 -> 990 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$6.classbin0 -> 928 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$7.classbin0 -> 928 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$8.classbin0 -> 928 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$9.classbin0 -> 928 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain.classbin0 -> 3098 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniHelper.classbin0 -> 2909 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.classbin0 -> 4600 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniPrintStream.classbin0 -> 3289 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.classbin0 -> 3599 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.classbin0 -> 3638 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.classbin0 -> 1002 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.classbin0 -> 941 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.classbin0 -> 1119 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.classbin0 -> 1124 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.classbin0 -> 1007 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.classbin0 -> 1069 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.classbin0 -> 939 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.classbin0 -> 1064 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.classbin0 -> 1064 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.classbin0 -> 973 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.classbin0 -> 11933 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.classbin0 -> 2993 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PackageWrapper.classbin0 -> 500 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$1.classbin0 -> 939 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$2.classbin0 -> 1104 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$3.classbin0 -> 1104 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$4.classbin0 -> 1103 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$5.classbin0 -> 1108 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$6.classbin0 -> 1107 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup.classbin0 -> 3678 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.classbin0 -> 2159 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/javah/Text.classbin0 -> 565 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$1.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$2.classbin0 -> 1030 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$3.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$4.classbin0 -> 1034 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$5.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$6.classbin0 -> 972 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd.classbin0 -> 6606 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$1.classbin0 -> 1035 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$10.classbin0 -> 987 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$2.classbin0 -> 1042 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$3.classbin0 -> 1045 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$4.classbin0 -> 1038 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$5.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$6.classbin0 -> 1035 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$7.classbin0 -> 1040 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$8.classbin0 -> 1047 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$9.classbin0 -> 978 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd.classbin0 -> 10372 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command$ShutdownHook.classbin0 -> 780 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command.classbin0 -> 19742 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$1.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$2.classbin0 -> 1030 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$3.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$4.classbin0 -> 1034 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$5.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$6.classbin0 -> 972 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd.classbin0 -> 5720 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$1.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$2.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$3.classbin0 -> 1030 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$4.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$5.classbin0 -> 1034 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$6.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$7.classbin0 -> 968 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$8.classbin0 -> 972 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd.classbin0 -> 6735 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$1.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$10.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$11.classbin0 -> 1043 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$12.classbin0 -> 974 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$2.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$3.classbin0 -> 1034 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$4.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$5.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$6.classbin0 -> 1032 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$7.classbin0 -> 1035 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$8.classbin0 -> 1030 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$9.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd.classbin0 -> 12086 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$1.classbin0 -> 1059 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$2.classbin0 -> 1054 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$3.classbin0 -> 1053 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$4.classbin0 -> 1058 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$5.classbin0 -> 1065 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$6.classbin0 -> 996 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd.classbin0 -> 4563 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$1.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$10.classbin0 -> 974 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$2.classbin0 -> 1036 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$3.classbin0 -> 1032 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$4.classbin0 -> 973 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$5.classbin0 -> 977 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$6.classbin0 -> 1030 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$7.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$8.classbin0 -> 1034 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$9.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd.classbin0 -> 17528 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$1.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$2.classbin0 -> 1045 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$3.classbin0 -> 1044 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$4.classbin0 -> 1047 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$5.classbin0 -> 1042 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$6.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$7.classbin0 -> 1046 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$8.classbin0 -> 1053 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$9.classbin0 -> 984 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd.classbin0 -> 8733 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$1.classbin0 -> 1047 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$2.classbin0 -> 1050 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$3.classbin0 -> 1053 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$4.classbin0 -> 1048 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$5.classbin0 -> 1047 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$6.classbin0 -> 1052 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$7.classbin0 -> 1059 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$8.classbin0 -> 990 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd.classbin0 -> 8305 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$1.classbin0 -> 1017 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$2.classbin0 -> 1018 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$3.classbin0 -> 1017 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$4.classbin0 -> 1022 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$5.classbin0 -> 1029 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$6.classbin0 -> 960 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$7.classbin0 -> 956 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd.classbin0 -> 8706 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$NoParseOption.classbin0 -> 1130 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$ShutdownHook.classbin0 -> 756 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main.classbin0 -> 8838 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Messages.classbin0 -> 2614 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$1.classbin0 -> 1054 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$2.classbin0 -> 990 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd.classbin0 -> 3871 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$1.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$10.classbin0 -> 986 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$2.classbin0 -> 1048 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$3.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$4.classbin0 -> 1044 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$5.classbin0 -> 1047 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$6.classbin0 -> 1042 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$7.classbin0 -> 1041 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$8.classbin0 -> 1046 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$9.classbin0 -> 1053 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd.classbin0 -> 8750 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$1.classbin0 -> 1065 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$2.classbin0 -> 1060 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$3.classbin0 -> 1059 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$4.classbin0 -> 1064 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$5.classbin0 -> 1071 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$6.classbin0 -> 1002 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd.classbin0 -> 7050 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Messages.classbin0 -> 1169 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$1.classbin0 -> 1264 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$2.classbin0 -> 1019 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$3.classbin0 -> 1019 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$HandleFile.classbin0 -> 1088 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII.classbin0 -> 4205 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$1.classbin0 -> 1106 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$2.classbin0 -> 1052 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$3.classbin0 -> 1048 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$4.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$5.classbin0 -> 721 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main.classbin0 -> 5476 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Messages.classbin0 -> 1145 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContext.classbin0 -> 3047 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContextMap.classbin0 -> 1138 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap$Entry.classbin0 -> 2457 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap.classbin0 -> 5547 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/AbstractMethodGenerator.classbin0 -> 232 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler$MethodRef.classbin0 -> 2719 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler.classbin0 -> 30526 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/CompilationError.classbin0 -> 624 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Generator.classbin0 -> 2901 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/GiopIo.classbin0 -> 2777 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/HashFinder.classbin0 -> 1064 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$1.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$10.classbin0 -> 971 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$11.classbin0 -> 900 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$12.classbin0 -> 971 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$13.classbin0 -> 971 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$14.classbin0 -> 971 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$15.classbin0 -> 1039 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$16.classbin0 -> 972 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$17.classbin0 -> 1039 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$18.classbin0 -> 900 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$2.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$3.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$4.classbin0 -> 1048 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$5.classbin0 -> 1048 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$6.classbin0 -> 960 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$7.classbin0 -> 960 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$8.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$9.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main.classbin0 -> 6058 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Messages.classbin0 -> 1145 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/MethodGenerator.classbin0 -> 5280 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RMICException.classbin0 -> 555 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmiMethodGenerator.classbin0 -> 5116 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmicBackend.classbin0 -> 271 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.classbin0 -> 12269 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceRmicCompiler.classbin0 -> 3894 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Variables.classbin0 -> 3290 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmic/WrapUnWrapper.classbin0 -> 1244 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl.classbin0 -> 5285 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.classbin0 -> 8775 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$1.classbin0 -> 1084 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$2.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$3.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$4.classbin0 -> 969 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$5.classbin0 -> 1048 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$6.classbin0 -> 983 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main.classbin0 -> 5921 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Messages.classbin0 -> 1145 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$AdaptedReader.classbin0 -> 1111 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$WriteToDiskTask.classbin0 -> 755 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable.classbin0 -> 4185 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$1.classbin0 -> 1011 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$2.classbin0 -> 1011 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$3.classbin0 -> 1011 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$4.classbin0 -> 1090 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$5.classbin0 -> 965 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$6.classbin0 -> 883 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main.classbin0 -> 5715 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Messages.classbin0 -> 1166 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable$WriteToDiskTask.classbin0 -> 766 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable.classbin0 -> 4109 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl.classbin0 -> 2955 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.classbin0 -> 4191 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.classbin0 -> 3829 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/serialver/Messages.classbin0 -> 1160 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$1.classbin0 -> 1171 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$2.classbin0 -> 1197 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$3.classbin0 -> 950 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer.classbin0 -> 4636 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet$EmailReplacement.classbin0 -> 714 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet.classbin0 -> 4878 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CodeTaglet.classbin0 -> 1529 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CopyrightTaglet.classbin0 -> 2366 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/DeprecatedTaglet.classbin0 -> 2371 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GenericTaglet.classbin0 -> 2708 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GnuExtendedTaglet.classbin0 -> 381 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/SinceTaglet.classbin0 -> 2962 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/TagletContext.classbin0 -> 858 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/ValueTaglet.classbin0 -> 2695 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/taglets/VersionTaglet.classbin0 -> 2580 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$1.classbin0 -> 1136 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$2.classbin0 -> 1082 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main.classbin0 -> 2391 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Messages.classbin0 -> 1160 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$PtrMarks.classbin0 -> 612 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$SizeKind.classbin0 -> 1004 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap.classbin0 -> 5443 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BytePtr.classbin0 -> 2466 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ItemList.classbin0 -> 3477 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1$Info.classbin0 -> 510 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1.classbin0 -> 1109 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$2.classbin0 -> 1109 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$3.classbin0 -> 1073 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$4.classbin0 -> 1086 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$OptionParser.classbin0 -> 2636 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$SubstringComparator.classbin0 -> 1269 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze.classbin0 -> 10680 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$Range.classbin0 -> 714 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$RangeComparator.classbin0 -> 1080 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap.classbin0 -> 7398 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap$ObjectItem.classbin0 -> 894 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap.classbin0 -> 4140 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolLookup.classbin0 -> 2485 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolTable.classbin0 -> 5783 bytes
-rw-r--r--libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ToolPrefix.classbin0 -> 1051 bytes
-rw-r--r--libjava/classpath/tools/classes/sun/rmi/rmic/Main.classbin0 -> 985 bytes
-rw-r--r--libjava/classpath/tools/classes/sun/rmi/rmic/Messages.classbin0 -> 1109 bytes
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/ClassDoc.java321
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/ConstructorDoc.java56
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/Doc.java264
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/DocErrorReporter.java76
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/Doclet.java98
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/ExecutableMemberDoc.java137
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/FieldDoc.java112
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/MemberDoc.java59
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/MethodDoc.java79
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/PackageDoc.java108
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/ParamTag.java65
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/Parameter.java87
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/ProgramElementDoc.java169
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/RootDoc.java111
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/SeeTag.java108
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/SerialFieldTag.java101
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/SourcePosition.java68
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/Tag.java106
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/ThrowsTag.java75
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/Type.java119
-rw-r--r--libjava/classpath/tools/com/sun/javadoc/TypeVariable.java73
-rw-r--r--libjava/classpath/tools/com/sun/tools/doclets/Taglet.java63
-rw-r--r--libjava/classpath/tools/com/sun/tools/javac/Main.java158
-rw-r--r--libjava/classpath/tools/com/sun/tools/javac/Messages.java67
-rw-r--r--libjava/classpath/tools/com/sun/tools/javadoc/Main.java46
-rw-r--r--libjava/classpath/tools/com/sun/tools/javah/Main.java58
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationVisitor.java88
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationWriter.java311
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/Attribute.java254
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/ByteVector.java293
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/ClassAdapter.java121
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/ClassReader.java1606
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/ClassVisitor.java195
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/ClassWriter.java1162
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/Edge.java57
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/FieldVisitor.java63
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/FieldWriter.java276
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/Handler.java70
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/Item.java252
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/Label.java299
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/MethodAdapter.java185
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/MethodVisitor.java334
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/MethodWriter.java2022
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/Opcodes.java295
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/Type.java760
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapAttribute.java378
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapFrame.java82
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapTableAttribute.java927
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapType.java114
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/AdviceAdapter.java642
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/EmptyVisitor.java211
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/GeneratorAdapter.java1454
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/LocalVariablesSorter.java136
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/Method.java220
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.java490
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/StaticInitMerger.java99
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/commons/TableSwitchGenerator.java55
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.java150
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.java212
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassOptimizer.java182
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Constant.java265
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ConstantPool.java198
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.java76
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/JarOptimizer.java87
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.java168
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodOptimizer.java108
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/NameMapping.java101
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Shrinker.java168
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/shrink.properties225
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureReader.java233
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureVisitor.java185
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureWriter.java207
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AbstractInsnNode.java143
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AnnotationNode.java187
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/ClassNode.java283
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldInsnNode.java97
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldNode.java123
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IincInsnNode.java71
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InnerClassNode.java101
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InsnNode.java96
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IntInsnNode.java75
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/JumpInsnNode.java84
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LabelNode.java54
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LdcInsnNode.java68
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LineNumberNode.java73
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LocalVariableNode.java111
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.java103
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MemberNode.java120
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodInsnNode.java98
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodNode.java439
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.java71
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TableSwitchInsnNode.java102
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TryCatchBlockNode.java93
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TypeInsnNode.java78
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/VarInsnNode.java81
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Analyzer.java416
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/AnalyzerException.java56
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.java335
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicValue.java105
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicVerifier.java428
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.java174
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowValue.java92
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Frame.java670
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/IntMap.java73
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Interpreter.java178
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.java266
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SmallSet.java126
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Subroutine.java96
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Value.java45
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.java226
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.java127
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierClassVisitor.java607
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierFieldVisitor.java50
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierMethodVisitor.java347
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/AbstractVisitor.java201
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckAnnotationAdapter.java125
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckClassAdapter.java416
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckFieldAdapter.java75
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckMethodAdapter.java942
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAbstractVisitor.java180
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAnnotationVisitor.java272
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceClassVisitor.java534
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceFieldVisitor.java78
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceMethodVisitor.java486
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceSignatureVisitor.java300
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.java223
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.java214
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMifiable.java53
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/Traceable.java52
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java1215
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/xml/Processor.java1048
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java91
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java191
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java351
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java310
-rw-r--r--libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java77
-rw-r--r--libjava/classpath/tools/gappletviewer.in47
-rw-r--r--libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.java1962
-rw-r--r--libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.smap1280
-rw-r--r--libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.java1406
-rw-r--r--libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.smap987
-rw-r--r--libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.java122
-rw-r--r--libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.txt116
-rw-r--r--libjava/classpath/tools/gjar.in48
-rw-r--r--libjava/classpath/tools/gjarsigner.in48
-rw-r--r--libjava/classpath/tools/gjavah.in48
-rw-r--r--libjava/classpath/tools/gjdoc.in49
-rw-r--r--libjava/classpath/tools/gkeytool.in48
-rw-r--r--libjava/classpath/tools/gnative2ascii.in48
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/FileSystemClassLoader.java312
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/IOToolkit.java216
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/MalformedInputEvent.java110
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/MalformedInputListener.java56
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/NotifyingInputStreamReader.java423
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/StringToolkit.java84
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java81
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java95
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java489
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java133
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java139
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java53
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java323
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java72
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java178
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java448
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java76
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java148
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java560
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java356
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java145
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/common/ClasspathToolParser.java239
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/common/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/common/Persistent.java87
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java163
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java99
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/AbstractDoclet.java1386
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/DocletConfigurationException.java54
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOption.java56
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionColonSeparated.java76
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFile.java77
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFlag.java69
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.java124
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionString.java68
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/InlineTagRenderer.java46
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/InvalidPackageWildcardException.java51
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/PackageGroup.java58
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/PackageMatcher.java152
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/StandardTaglet.java100
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/TagletPrinter.java46
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.java174
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/CssClass.java300
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.java187
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.java3887
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.java535
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.java65
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java2451
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java84
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java690
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java103
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.java460
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.java53
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.java63
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.java62
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.java91
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java66
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java62
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java266
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java58
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java268
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java495
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/AbstractTagImpl.java107
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.java121
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocImpl.java1260
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocProxy.java169
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.java219
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ConstructorDocImpl.java59
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/Debug.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/DirectoryTree.java74
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/DocImpl.java1090
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java121
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.java427
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/FieldDocImpl.java409
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocPackageDoc.java56
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocRootDoc.java56
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/InheritDocTagImpl.java103
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/JavadocWrapper.java53
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/LinkTagImpl.java63
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/Main.java1854
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/MemberDocImpl.java235
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/MethodDocImpl.java64
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/PackageDocImpl.java223
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParamTagImpl.java81
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParameterImpl.java69
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParseException.java51
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/Parser.java1064
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.java177
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/RootDocImpl.java1334
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/SeeTagImpl.java215
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.java128
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/SourcePositionImpl.java77
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagContainer.java52
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagImpl.java60
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java132
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/TextTagImpl.java56
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ThrowsTagImpl.java105
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/Timer.java88
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/TimerDoclet.java104
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeImpl.java109
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeVariableImpl.java108
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/ValueTagImpl.java65
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/WritableType.java44
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AdditionExpression.java86
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AndExpression.java57
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.java68
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.java92
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.java89
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryExpression.java51
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.java64
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.java82
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.java66
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.java57
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.java52
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.java74
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.java84
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantByte.java74
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantChar.java98
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantDouble.java79
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantExpression.java52
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantFloat.java79
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantInteger.java79
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantLong.java84
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantNull.java66
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantShort.java74
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantString.java74
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Context.java62
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/DivisionExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EqualExpression.java72
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Evaluator.java148
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.java46
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.java57
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Expression.java44
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.java89
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.java52
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.java57
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.java52
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.java60
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.java52
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ModuloExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NegateExpression.java66
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.java72
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotExpression.java60
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.java57
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.java57
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Type.java60
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.java87
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnaryExpression.java49
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.java47
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/java-expression.g471
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Action.java51
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java251
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java70
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java127
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java142
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java112
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Main.java293
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java98
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java83
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java124
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java173
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java343
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java689
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java119
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java491
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/java2xhtml/Java2xhtml.java1354
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java376
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java80
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java274
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java129
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java99
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/GcjhMain.java153
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/JniHelper.java120
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java169
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/JniPrintStream.java115
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java109
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java172
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/Main.java468
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java122
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/PackageWrapper.java54
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/PathOptionGroup.java147
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java139
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/javah/Text.java60
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java313
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java475
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java1228
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java280
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java328
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java602
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java232
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java930
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java407
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java395
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java432
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java329
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java118
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java143
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java440
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java318
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java194
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/orbd/Main.java226
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/orbd/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContext.java152
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContextMap.java87
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentMap.java454
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java53
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java1834
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/CompilationError.java69
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/Generator.java145
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/GiopIo.java129
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/HashFinder.java100
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java293
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/MethodGenerator.java302
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/RMICException.java70
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java297
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/RmicBackend.java48
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java694
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java189
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java154
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java99
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java243
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java556
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmid/Main.java258
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmid/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java269
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Main.java232
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Messages.java67
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java262
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java138
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java278
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java263
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java68
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java179
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/AuthorTaglet.java293
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/CodeTaglet.java101
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java123
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java132
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/GenericTaglet.java157
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/GnuExtendedTaglet.java48
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/SinceTaglet.java161
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/TagletContext.java60
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/ValueTaglet.java130
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/taglets/VersionTaglet.java153
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/tnameserv/Main.java115
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/tnameserv/Messages.java67
-rw-r--r--libjava/classpath/tools/gorbd.in48
-rw-r--r--libjava/classpath/tools/grmic.in48
-rw-r--r--libjava/classpath/tools/grmid.in48
-rw-r--r--libjava/classpath/tools/grmiregistry.in48
-rw-r--r--libjava/classpath/tools/gserialver.in48
-rw-r--r--libjava/classpath/tools/gtnameserv.in48
-rw-r--r--libjava/classpath/tools/jarsigner.in47
-rw-r--r--libjava/classpath/tools/keytool.in47
-rw-r--r--libjava/classpath/tools/resource/com/sun/tools/javac/messages.properties42
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/appletviewer/messages.properties102
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/common/Messages.properties40
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/getopt/Messages.properties46
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/gjdoc_common.xsl54
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/about.xsl83
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allclasses.xsl63
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allpackages.xsl78
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex.xsl107
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex_chunked.xsl112
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-source.xsl61
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-uses.xsl169
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc.xsl1070
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/deprecated.xsl261
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/descriptor.xsl58
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/doctranslet.xsl115
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/fulltree.xsl201
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/gjdoc.xsl240
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/help.xsl93
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/html_common.xsl584
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index.xsl66
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index_noframes.xsl146
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packageclasses.xsl90
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packagedoc.xsl153
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/default_help_en.html7
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdoc.js108
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-clean.css382
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-fixed.css286
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-sclara.css266
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml.css29
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/dbcentx.mod204
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsa.ent98
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsb.ent84
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsc.ent52
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsn.ent101
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amso.ent68
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsr.ent126
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-box.ent82
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr1.ent109
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr2.ent68
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-dia.ent56
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk1.ent91
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk2.ent62
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk3.ent85
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk4.ent85
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat1.ent104
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat2.ent163
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-num.ent118
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-pub.ent127
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-tech.ent104
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc-alphaindex.dtd35
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc.dtd35
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/HtmlDoclet.properties32
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdoc.js115
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-color1.css80
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-layout.css460
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-vanilla.css21
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/help.xhtml25
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/inherit.pngbin0 -> 199 bytes
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/xhtml11-target10.dtd54
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.2.txt78
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.3.txt79
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.4.txt82
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.5.txt90
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-classdoc.rng649
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-common.rng264
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-index.rng176
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/jar/messages.properties72
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/jarsigner/messages.properties126
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/keytool/messages.properties570
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/native2ascii/messages.properties44
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/orbd/messages.properties46
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/messages.properties61
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/ImplTie.jav152
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub.jav47
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethod.jav33
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav32
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12.jav62
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12Method.jav26
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav25
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Tie.jav184
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethod.jav11
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav9
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmid/messages.properties50
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/rmiregistry/messages.properties48
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/serialver/messages.properties44
-rw-r--r--libjava/classpath/tools/resource/gnu/classpath/tools/tnameserv/messages.properties43
-rw-r--r--libjava/classpath/tools/resource/sun/rmi/rmic/messages.properties38
-rw-r--r--libjava/classpath/tools/sun/rmi/rmic/Main.java60
-rw-r--r--libjava/classpath/tools/sun/rmi/rmic/Messages.java67
-rw-r--r--libjava/classpath/tools/toolwrapper.c264
1262 files changed, 111026 insertions, 0 deletions
diff --git a/libjava/classpath/tools/.cvsignore b/libjava/classpath/tools/.cvsignore
new file mode 100644
index 000000000..a013e8d16
--- /dev/null
+++ b/libjava/classpath/tools/.cvsignore
@@ -0,0 +1,19 @@
+jarsigner
+keytool
+Makefile.in
+Makefile
+tools.zip
+appletviewer
+.deps
+gappletviewer
+gjarsigner
+gkeytool
+gjar
+gnative2ascii
+gserialver
+gjavah
+gorbd
+grmic
+grmid
+grmiregistry
+gtnameserv
diff --git a/libjava/classpath/tools/Makefile.am b/libjava/classpath/tools/Makefile.am
new file mode 100755
index 000000000..44489c89a
--- /dev/null
+++ b/libjava/classpath/tools/Makefile.am
@@ -0,0 +1,415 @@
+## Input file for automake to generate the Makefile.in used by configure
+
+if CREATE_GJDOC
+## GCJ LOCAL: always put source files in srcdir
+## if CREATE_GJDOC_PARSER
+## gjdoc_gendir = ${top_builddir}/tools/generated
+## else
+gjdoc_gendir = ${top_srcdir}/tools/generated
+## endif
+## END GCJ LOCAL
+ANTLR_CLASSPATH = $(ANTLR_JAR):$(gjdoc_gendir)
+endif
+
+## GCJ LOCAL: use srcdir to find core classes.
+GLIBJ_BOOTCLASSPATH='$(top_srcdir)/lib'
+GLIBJ_CLASSPATH=.:$(srcdir)/asm:$(ANTLR_CLASSPATH)
+## END GCJ LOCAL
+
+# Setup the compiler to use the GNU Classpath library we just built.
+if GCJ_JAVAC
+JCOMPILER = $(JAVAC) $(JAVACFLAGS) -fsource=1.5 -ftarget=1.5 --encoding=UTF-8 --bootclasspath=$(GLIBJ_BOOTCLASSPATH) --classpath=$(GLIBJ_CLASSPATH)
+else
+JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_BOOTCLASSPATH) -classpath $(GLIBJ_CLASSPATH)
+endif
+
+if CREATE_WRAPPERS
+bin_SCRIPTS =
+bin_programs = gappletviewer gjarsigner gkeytool \
+ gjar gnative2ascii gserialver gjavah grmiregistry \
+ gtnameserv gorbd grmid grmic
+if CREATE_GJDOC
+bin_programs += gjdoc
+endif
+if INSTALL_BINARIES
+bin_PROGRAMS = $(bin_programs)
+else
+noinst_PROGRAMS = $(bin_programs)
+endif
+
+AM_CPPFLAGS = -Wall \
+ -I$(top_srcdir)/include \
+ -DLIBJVM="\"$(libdir)/libjvm\"" \
+ -DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\""
+
+gappletviewer_SOURCES = toolwrapper.c
+gappletviewer_CFLAGS = \
+ -DTOOLPACKAGE="\"appletviewer\"" \
+ -DTOOLNAME="\"gappletviewer\""
+
+gjarsigner_SOURCES = toolwrapper.c
+gjarsigner_CFLAGS = \
+ -DTOOLPACKAGE="\"jarsigner\"" \
+ -DTOOLNAME="\"gjarsigner\""
+
+gkeytool_SOURCES = toolwrapper.c
+gkeytool_CFLAGS = \
+ -DTOOLPACKAGE="\"keytool\"" \
+ -DTOOLNAME="\"gkeytool\""
+
+gjar_SOURCES = toolwrapper.c
+gjar_CFLAGS = \
+ -DTOOLPACKAGE="\"jar\"" \
+ -DTOOLNAME="\"gjar\""
+
+gnative2ascii_SOURCES = toolwrapper.c
+gnative2ascii_CFLAGS = \
+ -DTOOLPACKAGE="\"native2ascii\"" \
+ -DTOOLNAME="\"gnative2ascii\"" \
+ -DMAINCLASS="\"Native2ASCII\""
+
+gserialver_SOURCES = toolwrapper.c
+gserialver_CFLAGS = \
+ -DTOOLPACKAGE="\"serialver\"" \
+ -DTOOLNAME="\"gserialver\"" \
+ -DMAINCLASS="\"SerialVer\""
+
+grmiregistry_SOURCES = toolwrapper.c
+grmiregistry_CFLAGS = \
+ -DTOOLPACKAGE="\"rmiregistry\"" \
+ -DTOOLNAME="\"grmiregistry\""
+
+gtnameserv_SOURCES = toolwrapper.c
+gtnameserv_CFLAGS = \
+ -DTOOLPACKAGE="\"tnameserv\"" \
+ -DTOOLNAME="\"gtnameserv\""
+
+gorbd_SOURCES = toolwrapper.c
+gorbd_CFLAGS = \
+ -DTOOLPACKAGE="\"orbd\"" \
+ -DTOOLNAME="\"gorbd\""
+
+grmid_SOURCES = toolwrapper.c
+grmid_CFLAGS = \
+ -DTOOLPACKAGE="\"rmid\"" \
+ -DTOOLNAME="\"grmid\""
+
+gjavah_SOURCES = toolwrapper.c
+gjavah_CFLAGS = \
+ -DTOOLPACKAGE="\"javah\"" \
+ -DTOOLNAME="\"gjavah\""
+
+grmic_SOURCES = toolwrapper.c
+grmic_CFLAGS = \
+ -DTOOLPACKAGE="\"rmic\"" \
+ -DTOOLNAME="\"grmic\""
+
+gjdoc_SOURCES = toolwrapper.c
+gjdoc_CFLAGS = \
+ -DTOOLPACKAGE="\"gjdoc\"" \
+ -DTOOLNAME="\"gjdoc\""
+
+else
+## GCJ LOCAL: do not install these.
+noinst_SCRIPTS = gappletviewer gjarsigner gkeytool \
+ gjar gnative2ascii gserialver gjavah grmiregistry \
+ gtnameserv gorbd grmid grmic
+if CREATE_GJDOC
+noinst_SCRIPTS += gjdoc
+endif
+bin_PROGRAMS =
+## FIXME: remove these unneeded dependency lines once we can
+## require Automake 1.11.
+gappletviewer: gappletviewer.in
+gjarsigner: gjarsigner.in
+gkeytool: gkeytool.in
+gjar: gjar.in
+gnative2ascii: gnative2ascii.in
+gserialver: gserialver.in
+gjavah: gjavah.in
+grmiregistry: grmiregistry.in
+gtnameserv: gtnameserv.in
+gorbd: gorbd.in
+grmid: grmid.in
+grmic: grmic.in
+if CREATE_GJDOC
+gjdoc: gjdoc.in
+endif
+endif
+EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
+ gjar.in gnative2ascii.in gserialver.in gjavah.in grmiregistry.in \
+ gtnameserv.in gorbd.in grmid.in grmic.in gjdoc.in
+
+# All our example java source files
+TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*/*.java \
+ $(srcdir)/gnu/classpath/tools/*.java \
+ $(srcdir)/gnu/classpath/tools/*/*.java \
+ $(srcdir)/gnu/classpath/tools/*/*/*.java \
+ $(srcdir)/gnu/classpath/tools/*/*/*/*.java \
+ $(srcdir)/com/sun/javadoc/*.java \
+ $(srcdir)/com/sun/tools/doclets/*.java \
+ $(srcdir)/com/sun/tools/javac/*.java \
+ $(srcdir)/com/sun/tools/javah/*.java \
+ $(srcdir)/com/sun/tools/javadoc/*.java \
+ $(srcdir)/sun/rmi/rmic/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/attrs/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/commons/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/optimizer/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/signature/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/tree/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/tree/analysis/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/util/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/util/attrs/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/xml/*.java
+
+# Properties files that must be included in the generated zip file.
+PROPERTY_FILES = $(srcdir)/external/asm/org/objectweb/asm/optimizer/shrink.properties \
+ $(srcdir)/resource/com/sun/tools/javac/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/jar/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/orbd/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/rmic/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/rmid/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/serialver/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/keytool/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/native2ascii/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/appletviewer/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/common/Messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/getopt/Messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/tnameserv/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/jarsigner/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/rmiregistry/messages.properties \
+ $(srcdir)/resource/sun/rmi/rmic/messages.properties
+
+# RMIC templates that must be included in the generated zip file.
+RMIC_TEMPLATES = $(srcdir)/resource/gnu/classpath/tools/rmic/templates/*.jav
+
+# gjdoc resource files.
+gnu_classpath_tools_gjdoc_jar_CSS = \
+ doctranslets/html/res/gjdochtml-clean.css \
+ doctranslets/html/res/gjdochtml-fixed.css \
+ doctranslets/html/res/gjdochtml-sclara.css \
+ doctranslets/html/res/gjdochtml.css \
+ htmldoclet/gjdochtml-vanilla.css \
+ htmldoclet/gjdochtml-clean-layout.css \
+ htmldoclet/gjdochtml-clean-color1.css
+
+gnu_classpath_tools_gjdoc_jar_DTDS = \
+ htmldoclet/xhtml11-target10.dtd \
+ dtd/gjdoc-alphaindex.dtd \
+ dtd/gjdoc.dtd
+
+gnu_classpath_tools_gjdoc_jar_ENTS = \
+ dtd/ent/iso-amsa.ent \
+ dtd/ent/iso-amsb.ent \
+ dtd/ent/iso-amsc.ent \
+ dtd/ent/iso-amsn.ent \
+ dtd/ent/iso-amso.ent \
+ dtd/ent/iso-amsr.ent \
+ dtd/ent/iso-box.ent \
+ dtd/ent/iso-cyr1.ent \
+ dtd/ent/iso-cyr2.ent \
+ dtd/ent/iso-dia.ent \
+ dtd/ent/iso-grk1.ent \
+ dtd/ent/iso-grk2.ent \
+ dtd/ent/iso-grk3.ent \
+ dtd/ent/iso-grk4.ent \
+ dtd/ent/iso-lat1.ent \
+ dtd/ent/iso-lat2.ent \
+ dtd/ent/iso-num.ent \
+ dtd/ent/iso-pub.ent \
+ dtd/ent/iso-tech.ent
+
+gnu_classpath_tools_gjdoc_jar_HTML = doctranslets/html/res/default_help_en.html
+
+gnu_classpath_tools_gjdoc_jar_JS = \
+ doctranslets/html/res/gjdoc.js \
+ htmldoclet/gjdoc.js
+
+gnu_classpath_tools_gjdoc_jar_PNG = \
+ htmldoclet/inherit.png
+
+gnu_classpath_tools_gjdoc_jar_MODS = dtd/dbcentx.mod
+
+gnu_classpath_tools_gjdoc_jar_PROPERTIES = htmldoclet/HtmlDoclet.properties
+
+gnu_classpath_tools_gjdoc_jar_RNGS = \
+ rng/gjdoc-classdoc.rng \
+ rng/gjdoc-common.rng \
+ rng/gjdoc-index.rng
+
+gnu_classpath_tools_gjdoc_jar_TXTS = \
+ java.lang-classes-1.2.txt \
+ java.lang-classes-1.3.txt \
+ java.lang-classes-1.4.txt \
+ java.lang-classes-1.5.txt
+
+gnu_classpath_tools_gjdoc_jar_XHTML = htmldoclet/help.xhtml
+
+gnu_classpath_tools_gjdoc_jar_XSLS = \
+ doctranslets/gjdoc_common.xsl \
+ doctranslets/html/about.xsl \
+ doctranslets/html/allclasses.xsl \
+ doctranslets/html/allpackages.xsl \
+ doctranslets/html/alphaindex.xsl \
+ doctranslets/html/alphaindex_chunked.xsl \
+ doctranslets/html/classdoc-source.xsl \
+ doctranslets/html/classdoc-uses.xsl \
+ doctranslets/html/classdoc.xsl \
+ doctranslets/html/deprecated.xsl \
+ doctranslets/html/descriptor.xsl \
+ doctranslets/html/doctranslet.xsl \
+ doctranslets/html/fulltree.xsl \
+ doctranslets/html/gjdoc.xsl \
+ doctranslets/html/help.xsl \
+ doctranslets/html/html_common.xsl \
+ doctranslets/html/index_noframes.xsl \
+ doctranslets/html/index.xsl \
+ doctranslets/html/packageclasses.xsl \
+ doctranslets/html/packagedoc.xsl
+
+# All our resources.
+gjdoc_resources = $(gnu_classpath_tools_gjdoc_jar_CSS) $(gnu_classpath_tools_gjdoc_jar_DTDS) \
+ $(gnu_classpath_tools_gjdoc_jar_ENTS) $(gnu_classpath_tools_gjdoc_jar_HTML) \
+ $(gnu_classpath_tools_gjdoc_jar_JS) $(gnu_classpath_tools_gjdoc_jar_MODS) \
+ $(gnu_classpath_tools_gjdoc_jar_PNG) $(gnu_classpath_tools_gjdoc_jar_PROPERTIES) \
+ $(gnu_classpath_tools_gjdoc_jar_RNGS) $(gnu_classpath_tools_gjdoc_jar_TXTS) \
+ $(gnu_classpath_tools_gjdoc_jar_XHTML) $(gnu_classpath_tools_gjdoc_jar_XSLS)
+
+if !CREATE_GJDOC
+GJDOC_EX = -name gjdoc -prune -o \
+ -name doclets -prune -o \
+ -name taglets -prune -o \
+ -name javadoc -prune -o
+endif
+
+# The zip files with classes we want to produce.
+TOOLS_ZIP = tools.zip
+
+# Extra objects that will not exist until configure-time
+BUILT_SOURCES = $(TOOLS_ZIP)
+
+# All the files we find "interesting"
+ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(RMIC_TEMPLATES) $(PROPERTY_FILES) \
+ $(addprefix $(srcdir)/resource/gnu/classpath/tools/gjdoc/,$(gjdoc_resources))\
+ $(srcdir)/gnu/classpath/tools/gjdoc/expr/java-expression.g
+
+# Some architecture independent data to be installed.
+# GCJ LOCAL: do not install this.
+noinst_DATA = $(TOOLS_ZIP)
+
+# Where we want these data files installed.
+TOOLSdir = $(pkgdatadir)
+
+# Make sure everything is included in the distribution.
+dist-hook:
+ srcdir_cnt=`echo $(srcdir) | wc -c`; \
+ for file in $(ALL_TOOLS_FILES); do \
+ f=`echo $$file | cut -c$$srcdir_cnt-`; \
+ fdir=`dirname $$f`; \
+ if test ! -d $(distdir)/$$fdir; then \
+ echo "$(makeinstalldirs) $(distdir)/$$fdir"; \
+ $(mkinstalldirs) $(distdir)/$$fdir; \
+ fi; \
+ echo "cp -p $$file $(distdir)/$$f"; \
+ cp -p $$file $(distdir)/$$f; \
+ done
+
+# To generate the example zip just depend on the sources and ignore
+# the class files. Always regenerate all .class files and remove them
+# immediately. And copy the template files we use to the classes dir
+# so they get also included.
+$(TOOLS_ZIP): $(ALL_TOOLS_FILES)
+## GCJ LOCAL: put classes in srcdir
+## @rm -rf classes asm
+## @mkdir_p@ classes asm
+if JAVA_MAINTAINER_MODE
+if CREATE_GJDOC
+if CREATE_GJDOC_PARSER
+## Generate antlr sources.
+ @mkdir_p@ $(gjdoc_gendir)/gnu/classpath/tools/gjdoc/expr
+ $(ANTLR) -o $(gjdoc_gendir)/gnu/classpath/tools/gjdoc/expr/ \
+ $(srcdir)/gnu/classpath/tools/gjdoc/expr/java-expression.g
+endif
+endif
+endif
+ find $(srcdir)/external/asm -name '*.java' -print > asm.lst
+ find $(srcdir)/gnu/classpath/tools \
+ $(srcdir)/com/sun/javadoc \
+ $(srcdir)/com/sun/tools/doclets \
+ $(srcdir)/com/sun/tools/javadoc \
+ $(srcdir)/com/sun/tools/javac \
+ $(srcdir)/com/sun/tools/javah \
+ $(srcdir)/sun/rmi/rmic \
+ $(GJDOC_EX) \
+ -name '*.java' -print > classes.lst
+ if [ -f $(top_builddir)/../vm-tools-packages ]; then \
+ : > vm-tools.lst; \
+ for pkg in `cat $(top_builddir)/../vm-tools-packages`; do \
+ $(FIND) $(top_srcdir)/../$$pkg -follow -name '*.java' -print >> vm-tools.lst; \
+ done \
+ else \
+ echo -n > vm-tools.lst; \
+ fi
+ cat classes.lst asm.lst vm-tools.lst > all-classes.lst
+if JAVA_MAINTAINER_MODE
+## Compile ASM separately as it is latin-1 encoded.
+ AC=`echo $(JCOMPILER) | sed -e 's/UTF-8/ISO-8859-1/g'`; \
+ $$AC -g -w -d $(srcdir)/asm @asm.lst
+ $(JCOMPILER) $(USE_JAVAC_FLAGS) -g -d $(srcdir)/classes @classes.lst @vm-tools.lst
+endif
+## END GCJ LOCAL
+## Copy over tools resource files.
+ @list=`cd $(srcdir)/resource && find gnu/classpath/tools com/sun/tools/javac \
+ sun/rmi/rmic $(GJDOC_EX) -name \*.properties -print -o -name \*.jav -print`; \
+ for p in $$list; do \
+ dirname=classes/`dirname $$p`; \
+ if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+ echo " cp $(srcdir)/resource/$$p classes/$$p"; \
+ cp $(srcdir)/resource/$$p classes/$$p; \
+ done
+## BEGIN GCJ LOCAL
+ cp -pR $(srcdir)/asm .
+ cp -pR $(srcdir)/classes .
+ if [ -d asm/.svn ]; then \
+ find asm classes -depth -type d -name .svn -exec rm -rf \{\} \;; \
+ fi
+## END GCJ LOCAL
+if CREATE_GJDOC
+## Copy over gjdoc resource files.
+ for res in $(gjdoc_resources); do \
+ dir=classes/`dirname $$res`; \
+ if ! test -d "$$dir"; then @mkdir_p@ "$$dir"; fi; \
+ echo " cp $(srcdir)/resource/gnu/classpath/tools/gjdoc/$$res classes/$$res"; \
+ cp $(srcdir)/resource/gnu/classpath/tools/gjdoc/$$res classes/$$res; \
+ done
+endif
+
+if WITH_JAR
+CREATE_TOOLS_ZIP=$(JAR) cf ../$(TOOLS_ZIP) .
+UPDATE_TOOLS_ZIP=$(JAR) uf ../$(TOOLS_ZIP) .
+else
+CREATE_TOOLS_ZIP=$(ZIP) -r ../$(TOOLS_ZIP) .
+UPDATE_TOOLS_ZIP=$(ZIP) -u -r ../$(TOOLS_ZIP) .
+endif
+
+## First add classpath tools stuff.
+ (cd classes; \
+ $(CREATE_TOOLS_ZIP); \
+ cd ..)
+## Now add ASM classes.
+ (cd asm; \
+ $(UPDATE_TOOLS_ZIP); \
+ cd ..)
+ rm -rf asm classes classes.lst asm.lst
+
+# Zip file be gone! (and make sure the classes are gone too)
+clean-local:
+ rm -rf $(TOOLS_ZIP) classes classes.lst asm asm.lst all-classes.lst
+if CREATE_GJDOC_PARSER
+ rm -rf $(gjdoc_gendir)
+endif
+
+# FIXME: remove this when GNU Classpath includes a bootstrap VM.
+installcheck-binSCRIPTS:
+ :
diff --git a/libjava/classpath/tools/Makefile.in b/libjava/classpath/tools/Makefile.in
new file mode 100644
index 000000000..c8b0a6320
--- /dev/null
+++ b/libjava/classpath/tools/Makefile.in
@@ -0,0 +1,1402 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@CREATE_GJDOC_TRUE@@CREATE_WRAPPERS_TRUE@am__append_1 = gjdoc
+@CREATE_WRAPPERS_TRUE@@INSTALL_BINARIES_TRUE@bin_PROGRAMS = \
+@CREATE_WRAPPERS_TRUE@@INSTALL_BINARIES_TRUE@ $(am__EXEEXT_2)
+@CREATE_WRAPPERS_TRUE@@INSTALL_BINARIES_FALSE@noinst_PROGRAMS = \
+@CREATE_WRAPPERS_TRUE@@INSTALL_BINARIES_FALSE@ $(am__EXEEXT_2)
+@CREATE_GJDOC_TRUE@@CREATE_WRAPPERS_FALSE@am__append_2 = gjdoc
+subdir = tools
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(srcdir)/gappletviewer.in $(srcdir)/gjarsigner.in \
+ $(srcdir)/gkeytool.in $(srcdir)/gjar.in \
+ $(srcdir)/gnative2ascii.in $(srcdir)/gserialver.in \
+ $(srcdir)/grmiregistry.in $(srcdir)/gtnameserv.in \
+ $(srcdir)/gorbd.in $(srcdir)/grmid.in $(srcdir)/grmic.in \
+ $(srcdir)/gjavah.in $(srcdir)/gjdoc.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \
+ $(top_srcdir)/../../config/lead-dot.m4 \
+ $(top_srcdir)/../../config/lib-ld.m4 \
+ $(top_srcdir)/../../config/lib-link.m4 \
+ $(top_srcdir)/../../config/lib-prefix.m4 \
+ $(top_srcdir)/../../config/multi.m4 \
+ $(top_srcdir)/../../config/no-executables.m4 \
+ $(top_srcdir)/../../config/override.m4 \
+ $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/../../ltoptions.m4 \
+ $(top_srcdir)/../../ltsugar.m4 \
+ $(top_srcdir)/../../ltversion.m4 \
+ $(top_srcdir)/../../lt~obsolete.m4 \
+ $(top_srcdir)/m4/ac_prog_antlr.m4 \
+ $(top_srcdir)/m4/ac_prog_java.m4 \
+ $(top_srcdir)/m4/ac_prog_java_works.m4 \
+ $(top_srcdir)/m4/ac_prog_javac.m4 \
+ $(top_srcdir)/m4/ac_prog_javac_works.m4 \
+ $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
+ $(top_srcdir)/m4/acinclude.m4 \
+ $(top_srcdir)/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/m4/ax_func_which_gethostbyname_r.m4 \
+ $(top_srcdir)/m4/gcc_attribute.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES = gappletviewer gjarsigner gkeytool gjar \
+ gnative2ascii gserialver grmiregistry gtnameserv gorbd grmid \
+ grmic gjavah gjdoc
+CONFIG_CLEAN_VPATH_FILES =
+@CREATE_GJDOC_TRUE@@CREATE_WRAPPERS_TRUE@am__EXEEXT_1 = \
+@CREATE_GJDOC_TRUE@@CREATE_WRAPPERS_TRUE@ gjdoc$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@am__EXEEXT_2 = gappletviewer$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@ gjarsigner$(EXEEXT) gkeytool$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@ gjar$(EXEEXT) gnative2ascii$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@ gserialver$(EXEEXT) gjavah$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@ grmiregistry$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@ gtnameserv$(EXEEXT) gorbd$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@ grmid$(EXEEXT) grmic$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@ $(am__EXEEXT_1)
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+@CREATE_WRAPPERS_TRUE@am_gappletviewer_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ gappletviewer-toolwrapper.$(OBJEXT)
+gappletviewer_OBJECTS = $(am_gappletviewer_OBJECTS)
+gappletviewer_LDADD = $(LDADD)
+gappletviewer_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(gappletviewer_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gjar_OBJECTS = gjar-toolwrapper.$(OBJEXT)
+gjar_OBJECTS = $(am_gjar_OBJECTS)
+gjar_LDADD = $(LDADD)
+gjar_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(gjar_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gjarsigner_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ gjarsigner-toolwrapper.$(OBJEXT)
+gjarsigner_OBJECTS = $(am_gjarsigner_OBJECTS)
+gjarsigner_LDADD = $(LDADD)
+gjarsigner_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(gjarsigner_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gjavah_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ gjavah-toolwrapper.$(OBJEXT)
+gjavah_OBJECTS = $(am_gjavah_OBJECTS)
+gjavah_LDADD = $(LDADD)
+gjavah_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(gjavah_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gjdoc_OBJECTS = gjdoc-toolwrapper.$(OBJEXT)
+gjdoc_OBJECTS = $(am_gjdoc_OBJECTS)
+gjdoc_LDADD = $(LDADD)
+gjdoc_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(gjdoc_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gkeytool_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ gkeytool-toolwrapper.$(OBJEXT)
+gkeytool_OBJECTS = $(am_gkeytool_OBJECTS)
+gkeytool_LDADD = $(LDADD)
+gkeytool_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(gkeytool_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gnative2ascii_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ gnative2ascii-toolwrapper.$(OBJEXT)
+gnative2ascii_OBJECTS = $(am_gnative2ascii_OBJECTS)
+gnative2ascii_LDADD = $(LDADD)
+gnative2ascii_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(gnative2ascii_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gorbd_OBJECTS = gorbd-toolwrapper.$(OBJEXT)
+gorbd_OBJECTS = $(am_gorbd_OBJECTS)
+gorbd_LDADD = $(LDADD)
+gorbd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(gorbd_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_grmic_OBJECTS = grmic-toolwrapper.$(OBJEXT)
+grmic_OBJECTS = $(am_grmic_OBJECTS)
+grmic_LDADD = $(LDADD)
+grmic_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(grmic_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_grmid_OBJECTS = grmid-toolwrapper.$(OBJEXT)
+grmid_OBJECTS = $(am_grmid_OBJECTS)
+grmid_LDADD = $(LDADD)
+grmid_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(grmid_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_grmiregistry_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ grmiregistry-toolwrapper.$(OBJEXT)
+grmiregistry_OBJECTS = $(am_grmiregistry_OBJECTS)
+grmiregistry_LDADD = $(LDADD)
+grmiregistry_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(grmiregistry_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gserialver_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ gserialver-toolwrapper.$(OBJEXT)
+gserialver_OBJECTS = $(am_gserialver_OBJECTS)
+gserialver_LDADD = $(LDADD)
+gserialver_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(gserialver_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+@CREATE_WRAPPERS_TRUE@am_gtnameserv_OBJECTS = \
+@CREATE_WRAPPERS_TRUE@ gtnameserv-toolwrapper.$(OBJEXT)
+gtnameserv_OBJECTS = $(am_gtnameserv_OBJECTS)
+gtnameserv_LDADD = $(LDADD)
+gtnameserv_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(gtnameserv_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/../../depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(gappletviewer_SOURCES) $(gjar_SOURCES) \
+ $(gjarsigner_SOURCES) $(gjavah_SOURCES) $(gjdoc_SOURCES) \
+ $(gkeytool_SOURCES) $(gnative2ascii_SOURCES) $(gorbd_SOURCES) \
+ $(grmic_SOURCES) $(grmid_SOURCES) $(grmiregistry_SOURCES) \
+ $(gserialver_SOURCES) $(gtnameserv_SOURCES)
+DATA = $(noinst_DATA)
+ETAGS = etags
+CTAGS = ctags
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+ANTLR = @ANTLR@
+ANTLR_JAR = @ANTLR_JAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLASSPATH_CONVENIENCE = @CLASSPATH_CONVENIENCE@
+CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
+CLASSPATH_MODULE = @CLASSPATH_MODULE@
+COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
+CP = @CP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ_JAR = @ECJ_JAR@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+EXTRA_CFLAGS = @EXTRA_CFLAGS@
+FGREP = @FGREP@
+FIND = @FIND@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
+GJDOC = @GJDOC@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GMP_CFLAGS = @GMP_CFLAGS@
+GMP_LIBS = @GMP_LIBS@
+GREP = @GREP@
+GSTREAMER_BASE_CFLAGS = @GSTREAMER_BASE_CFLAGS@
+GSTREAMER_BASE_LIBS = @GSTREAMER_BASE_LIBS@
+GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@
+GSTREAMER_FILE_READER = @GSTREAMER_FILE_READER@
+GSTREAMER_LIBS = @GSTREAMER_LIBS@
+GSTREAMER_MIXER_PROVIDER = @GSTREAMER_MIXER_PROVIDER@
+GSTREAMER_PLUGINS_BASE_CFLAGS = @GSTREAMER_PLUGINS_BASE_CFLAGS@
+GSTREAMER_PLUGINS_BASE_LIBS = @GSTREAMER_PLUGINS_BASE_LIBS@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAR = @JAR@
+JAVA = @JAVA@
+JAVAC = @JAVAC@
+JAVAC_IS_GCJ = @JAVAC_IS_GCJ@
+JAVAC_MEM_OPT = @JAVAC_MEM_OPT@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
+PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
+QT_CFLAGS = @QT_CFLAGS@
+QT_LIBS = @QT_LIBS@
+RANLIB = @RANLIB@
+REMOVE = @REMOVE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+TOOLSDIR = @TOOLSDIR@
+USER_JAVAH = @USER_JAVAH@
+VERSION = @VERSION@
+WANT_NATIVE_BIG_INTEGER = @WANT_NATIVE_BIG_INTEGER@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+XMKMF = @XMKMF@
+XML_CFLAGS = @XML_CFLAGS@
+XML_LIBS = @XML_LIBS@
+XSLT_CFLAGS = @XSLT_CFLAGS@
+XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZIP = @ZIP@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_ANTLR = @ac_ct_ANTLR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+default_toolkit = @default_toolkit@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+multi_basedir = @multi_basedir@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+uudecode = @uudecode@
+vm_classes = @vm_classes@
+@CREATE_GJDOC_TRUE@gjdoc_gendir = ${top_srcdir}/tools/generated
+@CREATE_GJDOC_TRUE@ANTLR_CLASSPATH = $(ANTLR_JAR):$(gjdoc_gendir)
+GLIBJ_BOOTCLASSPATH = '$(top_srcdir)/lib'
+GLIBJ_CLASSPATH = .:$(srcdir)/asm:$(ANTLR_CLASSPATH)
+@GCJ_JAVAC_FALSE@JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_BOOTCLASSPATH) -classpath $(GLIBJ_CLASSPATH)
+
+# Setup the compiler to use the GNU Classpath library we just built.
+@GCJ_JAVAC_TRUE@JCOMPILER = $(JAVAC) $(JAVACFLAGS) -fsource=1.5 -ftarget=1.5 --encoding=UTF-8 --bootclasspath=$(GLIBJ_BOOTCLASSPATH) --classpath=$(GLIBJ_CLASSPATH)
+@CREATE_WRAPPERS_TRUE@bin_SCRIPTS =
+@CREATE_WRAPPERS_TRUE@bin_programs = gappletviewer gjarsigner gkeytool \
+@CREATE_WRAPPERS_TRUE@ gjar gnative2ascii gserialver gjavah \
+@CREATE_WRAPPERS_TRUE@ grmiregistry gtnameserv gorbd grmid \
+@CREATE_WRAPPERS_TRUE@ grmic $(am__append_1)
+@CREATE_WRAPPERS_TRUE@AM_CPPFLAGS = -Wall \
+@CREATE_WRAPPERS_TRUE@ -I$(top_srcdir)/include \
+@CREATE_WRAPPERS_TRUE@ -DLIBJVM="\"$(libdir)/libjvm\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\""
+
+@CREATE_WRAPPERS_TRUE@gappletviewer_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gappletviewer_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"appletviewer\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gappletviewer\""
+
+@CREATE_WRAPPERS_TRUE@gjarsigner_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gjarsigner_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"jarsigner\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gjarsigner\""
+
+@CREATE_WRAPPERS_TRUE@gkeytool_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gkeytool_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"keytool\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gkeytool\""
+
+@CREATE_WRAPPERS_TRUE@gjar_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gjar_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"jar\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gjar\""
+
+@CREATE_WRAPPERS_TRUE@gnative2ascii_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gnative2ascii_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"native2ascii\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gnative2ascii\"" \
+@CREATE_WRAPPERS_TRUE@ -DMAINCLASS="\"Native2ASCII\""
+
+@CREATE_WRAPPERS_TRUE@gserialver_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gserialver_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"serialver\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gserialver\"" \
+@CREATE_WRAPPERS_TRUE@ -DMAINCLASS="\"SerialVer\""
+
+@CREATE_WRAPPERS_TRUE@grmiregistry_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@grmiregistry_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"rmiregistry\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"grmiregistry\""
+
+@CREATE_WRAPPERS_TRUE@gtnameserv_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gtnameserv_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"tnameserv\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gtnameserv\""
+
+@CREATE_WRAPPERS_TRUE@gorbd_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gorbd_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"orbd\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gorbd\""
+
+@CREATE_WRAPPERS_TRUE@grmid_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@grmid_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"rmid\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"grmid\""
+
+@CREATE_WRAPPERS_TRUE@gjavah_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gjavah_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"javah\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gjavah\""
+
+@CREATE_WRAPPERS_TRUE@grmic_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@grmic_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"rmic\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"grmic\""
+
+@CREATE_WRAPPERS_TRUE@gjdoc_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@gjdoc_CFLAGS = \
+@CREATE_WRAPPERS_TRUE@ -DTOOLPACKAGE="\"gjdoc\"" \
+@CREATE_WRAPPERS_TRUE@ -DTOOLNAME="\"gjdoc\""
+
+@CREATE_WRAPPERS_FALSE@noinst_SCRIPTS = gappletviewer gjarsigner \
+@CREATE_WRAPPERS_FALSE@ gkeytool gjar gnative2ascii gserialver \
+@CREATE_WRAPPERS_FALSE@ gjavah grmiregistry gtnameserv gorbd \
+@CREATE_WRAPPERS_FALSE@ grmid grmic $(am__append_2)
+EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
+ gjar.in gnative2ascii.in gserialver.in gjavah.in grmiregistry.in \
+ gtnameserv.in gorbd.in grmid.in grmic.in gjdoc.in
+
+
+# All our example java source files
+TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*/*.java \
+ $(srcdir)/gnu/classpath/tools/*.java \
+ $(srcdir)/gnu/classpath/tools/*/*.java \
+ $(srcdir)/gnu/classpath/tools/*/*/*.java \
+ $(srcdir)/gnu/classpath/tools/*/*/*/*.java \
+ $(srcdir)/com/sun/javadoc/*.java \
+ $(srcdir)/com/sun/tools/doclets/*.java \
+ $(srcdir)/com/sun/tools/javac/*.java \
+ $(srcdir)/com/sun/tools/javah/*.java \
+ $(srcdir)/com/sun/tools/javadoc/*.java \
+ $(srcdir)/sun/rmi/rmic/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/attrs/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/commons/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/optimizer/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/signature/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/tree/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/tree/analysis/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/util/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/util/attrs/*.java \
+ $(srcdir)/external/asm/org/objectweb/asm/xml/*.java
+
+
+# Properties files that must be included in the generated zip file.
+PROPERTY_FILES = $(srcdir)/external/asm/org/objectweb/asm/optimizer/shrink.properties \
+ $(srcdir)/resource/com/sun/tools/javac/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/jar/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/orbd/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/rmic/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/rmid/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/serialver/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/keytool/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/native2ascii/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/appletviewer/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/common/Messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/getopt/Messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/tnameserv/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/jarsigner/messages.properties \
+ $(srcdir)/resource/gnu/classpath/tools/rmiregistry/messages.properties \
+ $(srcdir)/resource/sun/rmi/rmic/messages.properties
+
+
+# RMIC templates that must be included in the generated zip file.
+RMIC_TEMPLATES = $(srcdir)/resource/gnu/classpath/tools/rmic/templates/*.jav
+
+# gjdoc resource files.
+gnu_classpath_tools_gjdoc_jar_CSS = \
+ doctranslets/html/res/gjdochtml-clean.css \
+ doctranslets/html/res/gjdochtml-fixed.css \
+ doctranslets/html/res/gjdochtml-sclara.css \
+ doctranslets/html/res/gjdochtml.css \
+ htmldoclet/gjdochtml-vanilla.css \
+ htmldoclet/gjdochtml-clean-layout.css \
+ htmldoclet/gjdochtml-clean-color1.css
+
+gnu_classpath_tools_gjdoc_jar_DTDS = \
+ htmldoclet/xhtml11-target10.dtd \
+ dtd/gjdoc-alphaindex.dtd \
+ dtd/gjdoc.dtd
+
+gnu_classpath_tools_gjdoc_jar_ENTS = \
+ dtd/ent/iso-amsa.ent \
+ dtd/ent/iso-amsb.ent \
+ dtd/ent/iso-amsc.ent \
+ dtd/ent/iso-amsn.ent \
+ dtd/ent/iso-amso.ent \
+ dtd/ent/iso-amsr.ent \
+ dtd/ent/iso-box.ent \
+ dtd/ent/iso-cyr1.ent \
+ dtd/ent/iso-cyr2.ent \
+ dtd/ent/iso-dia.ent \
+ dtd/ent/iso-grk1.ent \
+ dtd/ent/iso-grk2.ent \
+ dtd/ent/iso-grk3.ent \
+ dtd/ent/iso-grk4.ent \
+ dtd/ent/iso-lat1.ent \
+ dtd/ent/iso-lat2.ent \
+ dtd/ent/iso-num.ent \
+ dtd/ent/iso-pub.ent \
+ dtd/ent/iso-tech.ent
+
+gnu_classpath_tools_gjdoc_jar_HTML = doctranslets/html/res/default_help_en.html
+gnu_classpath_tools_gjdoc_jar_JS = \
+ doctranslets/html/res/gjdoc.js \
+ htmldoclet/gjdoc.js
+
+gnu_classpath_tools_gjdoc_jar_PNG = \
+ htmldoclet/inherit.png
+
+gnu_classpath_tools_gjdoc_jar_MODS = dtd/dbcentx.mod
+gnu_classpath_tools_gjdoc_jar_PROPERTIES = htmldoclet/HtmlDoclet.properties
+gnu_classpath_tools_gjdoc_jar_RNGS = \
+ rng/gjdoc-classdoc.rng \
+ rng/gjdoc-common.rng \
+ rng/gjdoc-index.rng
+
+gnu_classpath_tools_gjdoc_jar_TXTS = \
+ java.lang-classes-1.2.txt \
+ java.lang-classes-1.3.txt \
+ java.lang-classes-1.4.txt \
+ java.lang-classes-1.5.txt
+
+gnu_classpath_tools_gjdoc_jar_XHTML = htmldoclet/help.xhtml
+gnu_classpath_tools_gjdoc_jar_XSLS = \
+ doctranslets/gjdoc_common.xsl \
+ doctranslets/html/about.xsl \
+ doctranslets/html/allclasses.xsl \
+ doctranslets/html/allpackages.xsl \
+ doctranslets/html/alphaindex.xsl \
+ doctranslets/html/alphaindex_chunked.xsl \
+ doctranslets/html/classdoc-source.xsl \
+ doctranslets/html/classdoc-uses.xsl \
+ doctranslets/html/classdoc.xsl \
+ doctranslets/html/deprecated.xsl \
+ doctranslets/html/descriptor.xsl \
+ doctranslets/html/doctranslet.xsl \
+ doctranslets/html/fulltree.xsl \
+ doctranslets/html/gjdoc.xsl \
+ doctranslets/html/help.xsl \
+ doctranslets/html/html_common.xsl \
+ doctranslets/html/index_noframes.xsl \
+ doctranslets/html/index.xsl \
+ doctranslets/html/packageclasses.xsl \
+ doctranslets/html/packagedoc.xsl
+
+
+# All our resources.
+gjdoc_resources = $(gnu_classpath_tools_gjdoc_jar_CSS) $(gnu_classpath_tools_gjdoc_jar_DTDS) \
+ $(gnu_classpath_tools_gjdoc_jar_ENTS) $(gnu_classpath_tools_gjdoc_jar_HTML) \
+ $(gnu_classpath_tools_gjdoc_jar_JS) $(gnu_classpath_tools_gjdoc_jar_MODS) \
+ $(gnu_classpath_tools_gjdoc_jar_PNG) $(gnu_classpath_tools_gjdoc_jar_PROPERTIES) \
+ $(gnu_classpath_tools_gjdoc_jar_RNGS) $(gnu_classpath_tools_gjdoc_jar_TXTS) \
+ $(gnu_classpath_tools_gjdoc_jar_XHTML) $(gnu_classpath_tools_gjdoc_jar_XSLS)
+
+@CREATE_GJDOC_FALSE@GJDOC_EX = -name gjdoc -prune -o \
+@CREATE_GJDOC_FALSE@ -name doclets -prune -o \
+@CREATE_GJDOC_FALSE@ -name taglets -prune -o \
+@CREATE_GJDOC_FALSE@ -name javadoc -prune -o
+
+
+# The zip files with classes we want to produce.
+TOOLS_ZIP = tools.zip
+
+# Extra objects that will not exist until configure-time
+BUILT_SOURCES = $(TOOLS_ZIP)
+
+# All the files we find "interesting"
+ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(RMIC_TEMPLATES) $(PROPERTY_FILES) \
+ $(addprefix $(srcdir)/resource/gnu/classpath/tools/gjdoc/,$(gjdoc_resources))\
+ $(srcdir)/gnu/classpath/tools/gjdoc/expr/java-expression.g
+
+
+# Some architecture independent data to be installed.
+# GCJ LOCAL: do not install this.
+noinst_DATA = $(TOOLS_ZIP)
+
+# Where we want these data files installed.
+TOOLSdir = $(pkgdatadir)
+@WITH_JAR_FALSE@CREATE_TOOLS_ZIP = $(ZIP) -r ../$(TOOLS_ZIP) .
+@WITH_JAR_TRUE@CREATE_TOOLS_ZIP = $(JAR) cf ../$(TOOLS_ZIP) .
+@WITH_JAR_FALSE@UPDATE_TOOLS_ZIP = $(ZIP) -u -r ../$(TOOLS_ZIP) .
+@WITH_JAR_TRUE@UPDATE_TOOLS_ZIP = $(JAR) uf ../$(TOOLS_ZIP) .
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tools/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+@CREATE_WRAPPERS_FALSE@gappletviewer: $(top_builddir)/config.status $(srcdir)/gappletviewer.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gjarsigner: $(top_builddir)/config.status $(srcdir)/gjarsigner.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gkeytool: $(top_builddir)/config.status $(srcdir)/gkeytool.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gjar: $(top_builddir)/config.status $(srcdir)/gjar.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gnative2ascii: $(top_builddir)/config.status $(srcdir)/gnative2ascii.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gserialver: $(top_builddir)/config.status $(srcdir)/gserialver.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@grmiregistry: $(top_builddir)/config.status $(srcdir)/grmiregistry.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gtnameserv: $(top_builddir)/config.status $(srcdir)/gtnameserv.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gorbd: $(top_builddir)/config.status $(srcdir)/gorbd.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@grmid: $(top_builddir)/config.status $(srcdir)/grmid.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@grmic: $(top_builddir)/config.status $(srcdir)/grmic.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+@CREATE_WRAPPERS_FALSE@gjavah: $(top_builddir)/config.status $(srcdir)/gjavah.in
+@CREATE_WRAPPERS_FALSE@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gjdoc: $(top_builddir)/config.status $(srcdir)/gjdoc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p || test -f $$p1; \
+ then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+installcheck-binPROGRAMS: $(bin_PROGRAMS)
+ bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
+ case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
+ *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
+ esac; \
+ f=`echo "$$p" | \
+ sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ for opt in --help --version; do \
+ if "$(DESTDIR)$(bindir)/$$f" $$opt >c$${pid}_.out \
+ 2>c$${pid}_.err </dev/null \
+ && test -n "`cat c$${pid}_.out`" \
+ && test -z "`cat c$${pid}_.err`"; then :; \
+ else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
+ done; \
+ done; rm -f c$${pid}_.???; exit $$bad
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+@CREATE_WRAPPERS_TRUE@gappletviewer$(EXEEXT): $(gappletviewer_OBJECTS) $(gappletviewer_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gappletviewer$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gappletviewer_LINK) $(gappletviewer_OBJECTS) $(gappletviewer_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gjar$(EXEEXT): $(gjar_OBJECTS) $(gjar_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gjar$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gjar_LINK) $(gjar_OBJECTS) $(gjar_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gjarsigner$(EXEEXT): $(gjarsigner_OBJECTS) $(gjarsigner_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gjarsigner$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gjarsigner_LINK) $(gjarsigner_OBJECTS) $(gjarsigner_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gjavah$(EXEEXT): $(gjavah_OBJECTS) $(gjavah_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gjavah$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gjavah_LINK) $(gjavah_OBJECTS) $(gjavah_LDADD) $(LIBS)
+@CREATE_GJDOC_FALSE@gjdoc$(EXEEXT): $(gjdoc_OBJECTS) $(gjdoc_DEPENDENCIES)
+@CREATE_GJDOC_FALSE@ @rm -f gjdoc$(EXEEXT)
+@CREATE_GJDOC_FALSE@ $(gjdoc_LINK) $(gjdoc_OBJECTS) $(gjdoc_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gjdoc$(EXEEXT): $(gjdoc_OBJECTS) $(gjdoc_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gjdoc$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gjdoc_LINK) $(gjdoc_OBJECTS) $(gjdoc_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gkeytool$(EXEEXT): $(gkeytool_OBJECTS) $(gkeytool_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gkeytool$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gkeytool_LINK) $(gkeytool_OBJECTS) $(gkeytool_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gnative2ascii$(EXEEXT): $(gnative2ascii_OBJECTS) $(gnative2ascii_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gnative2ascii$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gnative2ascii_LINK) $(gnative2ascii_OBJECTS) $(gnative2ascii_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gorbd$(EXEEXT): $(gorbd_OBJECTS) $(gorbd_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gorbd$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gorbd_LINK) $(gorbd_OBJECTS) $(gorbd_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@grmic$(EXEEXT): $(grmic_OBJECTS) $(grmic_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f grmic$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(grmic_LINK) $(grmic_OBJECTS) $(grmic_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@grmid$(EXEEXT): $(grmid_OBJECTS) $(grmid_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f grmid$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(grmid_LINK) $(grmid_OBJECTS) $(grmid_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@grmiregistry$(EXEEXT): $(grmiregistry_OBJECTS) $(grmiregistry_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f grmiregistry$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(grmiregistry_LINK) $(grmiregistry_OBJECTS) $(grmiregistry_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gserialver$(EXEEXT): $(gserialver_OBJECTS) $(gserialver_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gserialver$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gserialver_LINK) $(gserialver_OBJECTS) $(gserialver_LDADD) $(LIBS)
+@CREATE_WRAPPERS_TRUE@gtnameserv$(EXEEXT): $(gtnameserv_OBJECTS) $(gtnameserv_DEPENDENCIES)
+@CREATE_WRAPPERS_TRUE@ @rm -f gtnameserv$(EXEEXT)
+@CREATE_WRAPPERS_TRUE@ $(gtnameserv_LINK) $(gtnameserv_OBJECTS) $(gtnameserv_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gappletviewer-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gjar-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gjarsigner-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gjavah-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gjdoc-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gkeytool-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnative2ascii-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gorbd-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grmic-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grmid-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grmiregistry-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gserialver-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtnameserv-toolwrapper.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+gappletviewer-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gappletviewer_CFLAGS) $(CFLAGS) -MT gappletviewer-toolwrapper.o -MD -MP -MF $(DEPDIR)/gappletviewer-toolwrapper.Tpo -c -o gappletviewer-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gappletviewer-toolwrapper.Tpo $(DEPDIR)/gappletviewer-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gappletviewer-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gappletviewer_CFLAGS) $(CFLAGS) -c -o gappletviewer-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gappletviewer-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gappletviewer_CFLAGS) $(CFLAGS) -MT gappletviewer-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gappletviewer-toolwrapper.Tpo -c -o gappletviewer-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gappletviewer-toolwrapper.Tpo $(DEPDIR)/gappletviewer-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gappletviewer-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gappletviewer_CFLAGS) $(CFLAGS) -c -o gappletviewer-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gjar-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjar_CFLAGS) $(CFLAGS) -MT gjar-toolwrapper.o -MD -MP -MF $(DEPDIR)/gjar-toolwrapper.Tpo -c -o gjar-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjar-toolwrapper.Tpo $(DEPDIR)/gjar-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjar-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjar_CFLAGS) $(CFLAGS) -c -o gjar-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gjar-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjar_CFLAGS) $(CFLAGS) -MT gjar-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gjar-toolwrapper.Tpo -c -o gjar-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjar-toolwrapper.Tpo $(DEPDIR)/gjar-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjar-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjar_CFLAGS) $(CFLAGS) -c -o gjar-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gjarsigner-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjarsigner_CFLAGS) $(CFLAGS) -MT gjarsigner-toolwrapper.o -MD -MP -MF $(DEPDIR)/gjarsigner-toolwrapper.Tpo -c -o gjarsigner-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjarsigner-toolwrapper.Tpo $(DEPDIR)/gjarsigner-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjarsigner-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjarsigner_CFLAGS) $(CFLAGS) -c -o gjarsigner-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gjarsigner-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjarsigner_CFLAGS) $(CFLAGS) -MT gjarsigner-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gjarsigner-toolwrapper.Tpo -c -o gjarsigner-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjarsigner-toolwrapper.Tpo $(DEPDIR)/gjarsigner-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjarsigner-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjarsigner_CFLAGS) $(CFLAGS) -c -o gjarsigner-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gjavah-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjavah_CFLAGS) $(CFLAGS) -MT gjavah-toolwrapper.o -MD -MP -MF $(DEPDIR)/gjavah-toolwrapper.Tpo -c -o gjavah-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjavah-toolwrapper.Tpo $(DEPDIR)/gjavah-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjavah-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjavah_CFLAGS) $(CFLAGS) -c -o gjavah-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gjavah-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjavah_CFLAGS) $(CFLAGS) -MT gjavah-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gjavah-toolwrapper.Tpo -c -o gjavah-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjavah-toolwrapper.Tpo $(DEPDIR)/gjavah-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjavah-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjavah_CFLAGS) $(CFLAGS) -c -o gjavah-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gjdoc-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjdoc_CFLAGS) $(CFLAGS) -MT gjdoc-toolwrapper.o -MD -MP -MF $(DEPDIR)/gjdoc-toolwrapper.Tpo -c -o gjdoc-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjdoc-toolwrapper.Tpo $(DEPDIR)/gjdoc-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjdoc-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjdoc_CFLAGS) $(CFLAGS) -c -o gjdoc-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gjdoc-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjdoc_CFLAGS) $(CFLAGS) -MT gjdoc-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gjdoc-toolwrapper.Tpo -c -o gjdoc-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gjdoc-toolwrapper.Tpo $(DEPDIR)/gjdoc-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gjdoc-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gjdoc_CFLAGS) $(CFLAGS) -c -o gjdoc-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gkeytool-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gkeytool_CFLAGS) $(CFLAGS) -MT gkeytool-toolwrapper.o -MD -MP -MF $(DEPDIR)/gkeytool-toolwrapper.Tpo -c -o gkeytool-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gkeytool-toolwrapper.Tpo $(DEPDIR)/gkeytool-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gkeytool-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gkeytool_CFLAGS) $(CFLAGS) -c -o gkeytool-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gkeytool-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gkeytool_CFLAGS) $(CFLAGS) -MT gkeytool-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gkeytool-toolwrapper.Tpo -c -o gkeytool-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gkeytool-toolwrapper.Tpo $(DEPDIR)/gkeytool-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gkeytool-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gkeytool_CFLAGS) $(CFLAGS) -c -o gkeytool-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gnative2ascii-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gnative2ascii_CFLAGS) $(CFLAGS) -MT gnative2ascii-toolwrapper.o -MD -MP -MF $(DEPDIR)/gnative2ascii-toolwrapper.Tpo -c -o gnative2ascii-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gnative2ascii-toolwrapper.Tpo $(DEPDIR)/gnative2ascii-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gnative2ascii-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gnative2ascii_CFLAGS) $(CFLAGS) -c -o gnative2ascii-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gnative2ascii-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gnative2ascii_CFLAGS) $(CFLAGS) -MT gnative2ascii-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gnative2ascii-toolwrapper.Tpo -c -o gnative2ascii-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gnative2ascii-toolwrapper.Tpo $(DEPDIR)/gnative2ascii-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gnative2ascii-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gnative2ascii_CFLAGS) $(CFLAGS) -c -o gnative2ascii-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gorbd-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gorbd_CFLAGS) $(CFLAGS) -MT gorbd-toolwrapper.o -MD -MP -MF $(DEPDIR)/gorbd-toolwrapper.Tpo -c -o gorbd-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gorbd-toolwrapper.Tpo $(DEPDIR)/gorbd-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gorbd-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gorbd_CFLAGS) $(CFLAGS) -c -o gorbd-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gorbd-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gorbd_CFLAGS) $(CFLAGS) -MT gorbd-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gorbd-toolwrapper.Tpo -c -o gorbd-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gorbd-toolwrapper.Tpo $(DEPDIR)/gorbd-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gorbd-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gorbd_CFLAGS) $(CFLAGS) -c -o gorbd-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+grmic-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmic_CFLAGS) $(CFLAGS) -MT grmic-toolwrapper.o -MD -MP -MF $(DEPDIR)/grmic-toolwrapper.Tpo -c -o grmic-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/grmic-toolwrapper.Tpo $(DEPDIR)/grmic-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='grmic-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmic_CFLAGS) $(CFLAGS) -c -o grmic-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+grmic-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmic_CFLAGS) $(CFLAGS) -MT grmic-toolwrapper.obj -MD -MP -MF $(DEPDIR)/grmic-toolwrapper.Tpo -c -o grmic-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/grmic-toolwrapper.Tpo $(DEPDIR)/grmic-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='grmic-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmic_CFLAGS) $(CFLAGS) -c -o grmic-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+grmid-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmid_CFLAGS) $(CFLAGS) -MT grmid-toolwrapper.o -MD -MP -MF $(DEPDIR)/grmid-toolwrapper.Tpo -c -o grmid-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/grmid-toolwrapper.Tpo $(DEPDIR)/grmid-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='grmid-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmid_CFLAGS) $(CFLAGS) -c -o grmid-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+grmid-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmid_CFLAGS) $(CFLAGS) -MT grmid-toolwrapper.obj -MD -MP -MF $(DEPDIR)/grmid-toolwrapper.Tpo -c -o grmid-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/grmid-toolwrapper.Tpo $(DEPDIR)/grmid-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='grmid-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmid_CFLAGS) $(CFLAGS) -c -o grmid-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+grmiregistry-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmiregistry_CFLAGS) $(CFLAGS) -MT grmiregistry-toolwrapper.o -MD -MP -MF $(DEPDIR)/grmiregistry-toolwrapper.Tpo -c -o grmiregistry-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/grmiregistry-toolwrapper.Tpo $(DEPDIR)/grmiregistry-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='grmiregistry-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmiregistry_CFLAGS) $(CFLAGS) -c -o grmiregistry-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+grmiregistry-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmiregistry_CFLAGS) $(CFLAGS) -MT grmiregistry-toolwrapper.obj -MD -MP -MF $(DEPDIR)/grmiregistry-toolwrapper.Tpo -c -o grmiregistry-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/grmiregistry-toolwrapper.Tpo $(DEPDIR)/grmiregistry-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='grmiregistry-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(grmiregistry_CFLAGS) $(CFLAGS) -c -o grmiregistry-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gserialver-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gserialver_CFLAGS) $(CFLAGS) -MT gserialver-toolwrapper.o -MD -MP -MF $(DEPDIR)/gserialver-toolwrapper.Tpo -c -o gserialver-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gserialver-toolwrapper.Tpo $(DEPDIR)/gserialver-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gserialver-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gserialver_CFLAGS) $(CFLAGS) -c -o gserialver-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gserialver-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gserialver_CFLAGS) $(CFLAGS) -MT gserialver-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gserialver-toolwrapper.Tpo -c -o gserialver-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gserialver-toolwrapper.Tpo $(DEPDIR)/gserialver-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gserialver-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gserialver_CFLAGS) $(CFLAGS) -c -o gserialver-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+gtnameserv-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtnameserv_CFLAGS) $(CFLAGS) -MT gtnameserv-toolwrapper.o -MD -MP -MF $(DEPDIR)/gtnameserv-toolwrapper.Tpo -c -o gtnameserv-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gtnameserv-toolwrapper.Tpo $(DEPDIR)/gtnameserv-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gtnameserv-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtnameserv_CFLAGS) $(CFLAGS) -c -o gtnameserv-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+gtnameserv-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtnameserv_CFLAGS) $(CFLAGS) -MT gtnameserv-toolwrapper.obj -MD -MP -MF $(DEPDIR)/gtnameserv-toolwrapper.Tpo -c -o gtnameserv-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/gtnameserv-toolwrapper.Tpo $(DEPDIR)/gtnameserv-toolwrapper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='toolwrapper.c' object='gtnameserv-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtnameserv_CFLAGS) $(CFLAGS) -c -o gtnameserv-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool clean-local \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am: installcheck-binPROGRAMS installcheck-binSCRIPTS
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-local clean-noinstPROGRAMS \
+ ctags distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags dvi dvi-am html html-am info \
+ info-am install install-am install-binPROGRAMS \
+ install-binSCRIPTS install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am \
+ installcheck-binPROGRAMS installcheck-binSCRIPTS installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binPROGRAMS uninstall-binSCRIPTS
+
+@CREATE_WRAPPERS_FALSE@gappletviewer: gappletviewer.in
+@CREATE_WRAPPERS_FALSE@gjarsigner: gjarsigner.in
+@CREATE_WRAPPERS_FALSE@gkeytool: gkeytool.in
+@CREATE_WRAPPERS_FALSE@gjar: gjar.in
+@CREATE_WRAPPERS_FALSE@gnative2ascii: gnative2ascii.in
+@CREATE_WRAPPERS_FALSE@gserialver: gserialver.in
+@CREATE_WRAPPERS_FALSE@gjavah: gjavah.in
+@CREATE_WRAPPERS_FALSE@grmiregistry: grmiregistry.in
+@CREATE_WRAPPERS_FALSE@gtnameserv: gtnameserv.in
+@CREATE_WRAPPERS_FALSE@gorbd: gorbd.in
+@CREATE_WRAPPERS_FALSE@grmid: grmid.in
+@CREATE_WRAPPERS_FALSE@grmic: grmic.in
+@CREATE_GJDOC_TRUE@@CREATE_WRAPPERS_FALSE@gjdoc: gjdoc.in
+
+# Make sure everything is included in the distribution.
+dist-hook:
+ srcdir_cnt=`echo $(srcdir) | wc -c`; \
+ for file in $(ALL_TOOLS_FILES); do \
+ f=`echo $$file | cut -c$$srcdir_cnt-`; \
+ fdir=`dirname $$f`; \
+ if test ! -d $(distdir)/$$fdir; then \
+ echo "$(makeinstalldirs) $(distdir)/$$fdir"; \
+ $(mkinstalldirs) $(distdir)/$$fdir; \
+ fi; \
+ echo "cp -p $$file $(distdir)/$$f"; \
+ cp -p $$file $(distdir)/$$f; \
+ done
+
+# To generate the example zip just depend on the sources and ignore
+# the class files. Always regenerate all .class files and remove them
+# immediately. And copy the template files we use to the classes dir
+# so they get also included.
+$(TOOLS_ZIP): $(ALL_TOOLS_FILES)
+@CREATE_GJDOC_PARSER_TRUE@@CREATE_GJDOC_TRUE@@JAVA_MAINTAINER_MODE_TRUE@ @mkdir_p@ $(gjdoc_gendir)/gnu/classpath/tools/gjdoc/expr
+@CREATE_GJDOC_PARSER_TRUE@@CREATE_GJDOC_TRUE@@JAVA_MAINTAINER_MODE_TRUE@ $(ANTLR) -o $(gjdoc_gendir)/gnu/classpath/tools/gjdoc/expr/ \
+@CREATE_GJDOC_PARSER_TRUE@@CREATE_GJDOC_TRUE@@JAVA_MAINTAINER_MODE_TRUE@ $(srcdir)/gnu/classpath/tools/gjdoc/expr/java-expression.g
+ find $(srcdir)/external/asm -name '*.java' -print > asm.lst
+ find $(srcdir)/gnu/classpath/tools \
+ $(srcdir)/com/sun/javadoc \
+ $(srcdir)/com/sun/tools/doclets \
+ $(srcdir)/com/sun/tools/javadoc \
+ $(srcdir)/com/sun/tools/javac \
+ $(srcdir)/com/sun/tools/javah \
+ $(srcdir)/sun/rmi/rmic \
+ $(GJDOC_EX) \
+ -name '*.java' -print > classes.lst
+ if [ -f $(top_builddir)/../vm-tools-packages ]; then \
+ : > vm-tools.lst; \
+ for pkg in `cat $(top_builddir)/../vm-tools-packages`; do \
+ $(FIND) $(top_srcdir)/../$$pkg -follow -name '*.java' -print >> vm-tools.lst; \
+ done \
+ else \
+ echo -n > vm-tools.lst; \
+ fi
+ cat classes.lst asm.lst vm-tools.lst > all-classes.lst
+@JAVA_MAINTAINER_MODE_TRUE@ AC=`echo $(JCOMPILER) | sed -e 's/UTF-8/ISO-8859-1/g'`; \
+@JAVA_MAINTAINER_MODE_TRUE@ $$AC -g -w -d $(srcdir)/asm @asm.lst
+@JAVA_MAINTAINER_MODE_TRUE@ $(JCOMPILER) $(USE_JAVAC_FLAGS) -g -d $(srcdir)/classes @classes.lst @vm-tools.lst
+ @list=`cd $(srcdir)/resource && find gnu/classpath/tools com/sun/tools/javac \
+ sun/rmi/rmic $(GJDOC_EX) -name \*.properties -print -o -name \*.jav -print`; \
+ for p in $$list; do \
+ dirname=classes/`dirname $$p`; \
+ if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+ echo " cp $(srcdir)/resource/$$p classes/$$p"; \
+ cp $(srcdir)/resource/$$p classes/$$p; \
+ done
+ cp -pR $(srcdir)/asm .
+ cp -pR $(srcdir)/classes .
+ if [ -d asm/.svn ]; then \
+ find asm classes -depth -type d -name .svn -exec rm -rf \{\} \;; \
+ fi
+@CREATE_GJDOC_TRUE@ for res in $(gjdoc_resources); do \
+@CREATE_GJDOC_TRUE@ dir=classes/`dirname $$res`; \
+@CREATE_GJDOC_TRUE@ if ! test -d "$$dir"; then @mkdir_p@ "$$dir"; fi; \
+@CREATE_GJDOC_TRUE@ echo " cp $(srcdir)/resource/gnu/classpath/tools/gjdoc/$$res classes/$$res"; \
+@CREATE_GJDOC_TRUE@ cp $(srcdir)/resource/gnu/classpath/tools/gjdoc/$$res classes/$$res; \
+@CREATE_GJDOC_TRUE@ done
+
+ (cd classes; \
+ $(CREATE_TOOLS_ZIP); \
+ cd ..)
+ (cd asm; \
+ $(UPDATE_TOOLS_ZIP); \
+ cd ..)
+ rm -rf asm classes classes.lst asm.lst
+
+# Zip file be gone! (and make sure the classes are gone too)
+clean-local:
+ rm -rf $(TOOLS_ZIP) classes classes.lst asm asm.lst all-classes.lst
+@CREATE_GJDOC_PARSER_TRUE@ rm -rf $(gjdoc_gendir)
+
+# FIXME: remove this when GNU Classpath includes a bootstrap VM.
+installcheck-binSCRIPTS:
+ :
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libjava/classpath/tools/README b/libjava/classpath/tools/README
new file mode 100644
index 000000000..dc049d3b5
--- /dev/null
+++ b/libjava/classpath/tools/README
@@ -0,0 +1,58 @@
+The GNU Classpath tools are stored in the tools.zip. They can be invoked by
+putting this archive into classpath and specifying the tool main class as the
+class to run (parameters usually follow). The current release contains the
+following tools:
+
+== GIOP tools ==
+
+GIOP tools are used for creating the applications that use GIOP communication
+protocol. It provides necessary support for org.omg.* and javax.rmi.*
+packages.
+
+All GIOP tools support the --help option, for instance:
+ java -cp tools.zip gnu.classpath.tools.giop.IorParser --help
+
+The list of the currently available GIOP tools (name matches the main
+class in gnu.classpath.tools.giop package):
+
+* GRMIC - RMI-IIOP stub and tie generator.
+* NameService - GIOP transient naming service (this tool is called
+ tnameserv in Sun's package).
+* NameServicePersistent
+ - GIOP persistent naming service (this tool is called
+ orbd in Sun's package).
+* IorParser - Parses the stringified form of the interoperable
+ object references (IOR's).
+
+== RMI tools ==
+
+RMI tools provide support for java.rmi package. All tools support
+the --help key by printing more information, for instance:
+ java -cp tools.zip gnu.classpath.tools.rmi.RMIC --help
+
+The list of the currently available RMI tools (name matches the main tool class
+in gnu.classpath.tools.rmi package):
+
+* RMIC - RMI stub and tie source code generator (complements
+ the ASM based bytecode generator in the separate
+ cp-tools project). This tool is only needed for
+ research and backward-compatibile applications, as
+ Classpath supports the 1.5 feature to replace such
+ stubs by proxy classes.
+* REGISTRY - The persistent RMI naming service.
+* RMID - The persistent RMI activation daemon, supports the
+ java.rmi.activation package.
+
+== Security tools ==
+
+Security tools (currently) are used for signing and verifying JAR files
+as well as (planned) generating and managing cryptographic tokens and
+credentials.
+
+The list of individual tools, the name of their main class that should be
+invoked by the Java launcher, and a summary of what they provide follows:
+
+* jarsigner gnu.classpath.tools.jarsigner.Main
+ A drop-in replacement for the "jarsigner" tool.
+
+
diff --git a/libjava/classpath/tools/appletviewer.in b/libjava/classpath/tools/appletviewer.in
new file mode 100644
index 000000000..81e39ad91
--- /dev/null
+++ b/libjava/classpath/tools/appletviewer.in
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+## A simple shell script to launch the GNU Classpath appletviewer tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.appletviewer.Main $@
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationVisitor.class
new file mode 100644
index 000000000..acb0481dd
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationWriter.class b/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationWriter.class
new file mode 100644
index 000000000..69dd3cf35
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationWriter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/Attribute.class b/libjava/classpath/tools/asm/org/objectweb/asm/Attribute.class
new file mode 100644
index 000000000..d9bb13a75
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/Attribute.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/ByteVector.class b/libjava/classpath/tools/asm/org/objectweb/asm/ByteVector.class
new file mode 100644
index 000000000..a7b9ad75e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/ByteVector.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/ClassAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/ClassAdapter.class
new file mode 100644
index 000000000..81a402599
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/ClassAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/ClassReader.class b/libjava/classpath/tools/asm/org/objectweb/asm/ClassReader.class
new file mode 100644
index 000000000..ee5ea75ff
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/ClassReader.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/ClassVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/ClassVisitor.class
new file mode 100644
index 000000000..f4345b3e5
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/ClassVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/ClassWriter.class b/libjava/classpath/tools/asm/org/objectweb/asm/ClassWriter.class
new file mode 100644
index 000000000..07de7fcc6
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/ClassWriter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/Edge.class b/libjava/classpath/tools/asm/org/objectweb/asm/Edge.class
new file mode 100644
index 000000000..2cf713b4b
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/Edge.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/FieldVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/FieldVisitor.class
new file mode 100644
index 000000000..5f29c7b7b
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/FieldVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/FieldWriter.class b/libjava/classpath/tools/asm/org/objectweb/asm/FieldWriter.class
new file mode 100644
index 000000000..b316b7be2
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/FieldWriter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/Handler.class b/libjava/classpath/tools/asm/org/objectweb/asm/Handler.class
new file mode 100644
index 000000000..1cbcd3ff5
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/Handler.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/Item.class b/libjava/classpath/tools/asm/org/objectweb/asm/Item.class
new file mode 100644
index 000000000..5c0a0d0d0
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/Item.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/Label.class b/libjava/classpath/tools/asm/org/objectweb/asm/Label.class
new file mode 100644
index 000000000..0bd982b3c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/Label.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/MethodAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/MethodAdapter.class
new file mode 100644
index 000000000..3521003c5
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/MethodAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/MethodVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/MethodVisitor.class
new file mode 100644
index 000000000..d4bdd8f38
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/MethodVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/MethodWriter.class b/libjava/classpath/tools/asm/org/objectweb/asm/MethodWriter.class
new file mode 100644
index 000000000..e006aa43c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/MethodWriter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/Opcodes.class b/libjava/classpath/tools/asm/org/objectweb/asm/Opcodes.class
new file mode 100644
index 000000000..599491168
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/Opcodes.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/Type.class b/libjava/classpath/tools/asm/org/objectweb/asm/Type.class
new file mode 100644
index 000000000..e96ca26ef
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/Type.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapAttribute.class b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapAttribute.class
new file mode 100644
index 000000000..20bda6863
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapAttribute.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapFrame.class b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapFrame.class
new file mode 100644
index 000000000..0305d04dc
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapFrame.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapTableAttribute.class b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapTableAttribute.class
new file mode 100644
index 000000000..708ee0988
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapTableAttribute.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapType.class b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapType.class
new file mode 100644
index 000000000..ea6999b99
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapType.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/AdviceAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/AdviceAdapter.class
new file mode 100644
index 000000000..0f7b70aff
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/AdviceAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/EmptyVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/EmptyVisitor.class
new file mode 100644
index 000000000..47aa4b894
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/EmptyVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/GeneratorAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/GeneratorAdapter.class
new file mode 100644
index 000000000..11a2f13dc
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/GeneratorAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/LocalVariablesSorter.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/LocalVariablesSorter.class
new file mode 100644
index 000000000..de1a9db93
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/LocalVariablesSorter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/Method.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/Method.class
new file mode 100644
index 000000000..508cfb5fb
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/Method.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder$Item.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder$Item.class
new file mode 100644
index 000000000..9048fab59
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder$Item.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.class
new file mode 100644
index 000000000..ae5f315b0
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/StaticInitMerger.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/StaticInitMerger.class
new file mode 100644
index 000000000..53614d1f4
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/StaticInitMerger.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/commons/TableSwitchGenerator.class b/libjava/classpath/tools/asm/org/objectweb/asm/commons/TableSwitchGenerator.class
new file mode 100644
index 000000000..3da3b099f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/commons/TableSwitchGenerator.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.class
new file mode 100644
index 000000000..ce439d21e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.class
new file mode 100644
index 000000000..5f652ce4f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassOptimizer.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassOptimizer.class
new file mode 100644
index 000000000..d0510b6c9
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassOptimizer.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Constant.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Constant.class
new file mode 100644
index 000000000..c9eb21e2e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Constant.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ConstantPool.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ConstantPool.class
new file mode 100644
index 000000000..a23ba6570
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ConstantPool.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.class
new file mode 100644
index 000000000..57a0a12d9
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/JarOptimizer.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/JarOptimizer.class
new file mode 100644
index 000000000..0d6c4bdb5
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/JarOptimizer.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.class
new file mode 100644
index 000000000..11921a727
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodOptimizer.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodOptimizer.class
new file mode 100644
index 000000000..123484b24
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodOptimizer.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/NameMapping.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/NameMapping.class
new file mode 100644
index 000000000..e7ed57ef6
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/NameMapping.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker$ConstantComparator.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker$ConstantComparator.class
new file mode 100644
index 000000000..d03748d47
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker$ConstantComparator.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker.class b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker.class
new file mode 100644
index 000000000..bb87a280b
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureReader.class b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureReader.class
new file mode 100644
index 000000000..b3c4b9d3e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureReader.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureVisitor.class
new file mode 100644
index 000000000..98826f133
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureWriter.class b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureWriter.class
new file mode 100644
index 000000000..ec5f52710
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureWriter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/AbstractInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/AbstractInsnNode.class
new file mode 100644
index 000000000..1fee9f6c3
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/AbstractInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/AnnotationNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/AnnotationNode.class
new file mode 100644
index 000000000..4eee59d47
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/AnnotationNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/ClassNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/ClassNode.class
new file mode 100644
index 000000000..975cee2b4
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/ClassNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldInsnNode.class
new file mode 100644
index 000000000..ef9f743be
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldNode.class
new file mode 100644
index 000000000..92797f619
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/IincInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/IincInsnNode.class
new file mode 100644
index 000000000..10428be2e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/IincInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/InnerClassNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/InnerClassNode.class
new file mode 100644
index 000000000..35008f41a
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/InnerClassNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/InsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/InsnNode.class
new file mode 100644
index 000000000..0eb12d987
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/InsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/IntInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/IntInsnNode.class
new file mode 100644
index 000000000..f89b8fda4
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/IntInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/JumpInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/JumpInsnNode.class
new file mode 100644
index 000000000..fc6e78364
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/JumpInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/LabelNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LabelNode.class
new file mode 100644
index 000000000..2b375e49e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LabelNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/LdcInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LdcInsnNode.class
new file mode 100644
index 000000000..97a2e6d69
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LdcInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/LineNumberNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LineNumberNode.class
new file mode 100644
index 000000000..5b0abc6e2
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LineNumberNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/LocalVariableNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LocalVariableNode.class
new file mode 100644
index 000000000..7da757ccf
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LocalVariableNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.class
new file mode 100644
index 000000000..e307436c0
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/MemberNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MemberNode.class
new file mode 100644
index 000000000..541ac8976
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MemberNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodInsnNode.class
new file mode 100644
index 000000000..900d812b1
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode$1.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode$1.class
new file mode 100644
index 000000000..576603d92
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode$1.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode.class
new file mode 100644
index 000000000..dc6a56345
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.class
new file mode 100644
index 000000000..eff4e980c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/TableSwitchInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TableSwitchInsnNode.class
new file mode 100644
index 000000000..b4626e8ed
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TableSwitchInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/TryCatchBlockNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TryCatchBlockNode.class
new file mode 100644
index 000000000..ba882b366
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TryCatchBlockNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/TypeInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TypeInsnNode.class
new file mode 100644
index 000000000..577ff0aaa
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TypeInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/VarInsnNode.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/VarInsnNode.class
new file mode 100644
index 000000000..a86ac0570
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/VarInsnNode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Analyzer.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Analyzer.class
new file mode 100644
index 000000000..aa54fd6f4
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Analyzer.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/AnalyzerException.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/AnalyzerException.class
new file mode 100644
index 000000000..1c0e6b136
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/AnalyzerException.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.class
new file mode 100644
index 000000000..e0d2bd07f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicValue.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicValue.class
new file mode 100644
index 000000000..303e15543
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicValue.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicVerifier.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicVerifier.class
new file mode 100644
index 000000000..fd5f93822
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicVerifier.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.class
new file mode 100644
index 000000000..c87cf3308
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowValue.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowValue.class
new file mode 100644
index 000000000..41bb76b98
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowValue.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Frame.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Frame.class
new file mode 100644
index 000000000..c626859b0
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Frame.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/IntMap.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/IntMap.class
new file mode 100644
index 000000000..467749a1f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/IntMap.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Interpreter.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Interpreter.class
new file mode 100644
index 000000000..a1afe42a0
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Interpreter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.class
new file mode 100644
index 000000000..4c3d7bc09
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SmallSet.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SmallSet.class
new file mode 100644
index 000000000..be0993420
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SmallSet.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Subroutine.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Subroutine.class
new file mode 100644
index 000000000..3767ead89
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Subroutine.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Value.class b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Value.class
new file mode 100644
index 000000000..21de3a90e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Value.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.class
new file mode 100644
index 000000000..a819e6aaa
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.class
new file mode 100644
index 000000000..7fe6b7e90
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierClassVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierClassVisitor.class
new file mode 100644
index 000000000..60cba8345
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierClassVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierFieldVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierFieldVisitor.class
new file mode 100644
index 000000000..d98851491
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierFieldVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierMethodVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierMethodVisitor.class
new file mode 100644
index 000000000..43b18b737
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierMethodVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/AbstractVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/AbstractVisitor.class
new file mode 100644
index 000000000..a9aff218f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/AbstractVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckAnnotationAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckAnnotationAdapter.class
new file mode 100644
index 000000000..b96505315
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckAnnotationAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckClassAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckClassAdapter.class
new file mode 100644
index 000000000..d5b555d81
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckClassAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckFieldAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckFieldAdapter.class
new file mode 100644
index 000000000..db4b4b03b
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckFieldAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckMethodAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckMethodAdapter.class
new file mode 100644
index 000000000..57e63c020
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckMethodAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAbstractVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAbstractVisitor.class
new file mode 100644
index 000000000..0f103e2aa
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAbstractVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAnnotationVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAnnotationVisitor.class
new file mode 100644
index 000000000..50fc265f4
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAnnotationVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceClassVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceClassVisitor.class
new file mode 100644
index 000000000..93ef1acf7
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceClassVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceFieldVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceFieldVisitor.class
new file mode 100644
index 000000000..0035c01c0
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceFieldVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceMethodVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceMethodVisitor.class
new file mode 100644
index 000000000..ffd4f2635
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceMethodVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceSignatureVisitor.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceSignatureVisitor.class
new file mode 100644
index 000000000..b045ab556
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceSignatureVisitor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.class
new file mode 100644
index 000000000..ae2a692b5
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.class
new file mode 100644
index 000000000..f69d0d461
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMifiable.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMifiable.class
new file mode 100644
index 000000000..f1556bd52
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMifiable.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/Traceable.class b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/Traceable.class
new file mode 100644
index 000000000..bfd9350a6
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/Traceable.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationDefaultRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationDefaultRule.class
new file mode 100644
index 000000000..14eb11233
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationDefaultRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationParameterRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationParameterRule.class
new file mode 100644
index 000000000..9d4d40385
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationParameterRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationRule.class
new file mode 100644
index 000000000..22ae1b995
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueAnnotationRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueAnnotationRule.class
new file mode 100644
index 000000000..66ddcd17f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueAnnotationRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueArrayRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueArrayRule.class
new file mode 100644
index 000000000..7b98456e6
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueArrayRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueEnumRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueEnumRule.class
new file mode 100644
index 000000000..60b46867b
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueEnumRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueRule.class
new file mode 100644
index 000000000..fe5db3ed1
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ClassRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ClassRule.class
new file mode 100644
index 000000000..202f86512
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ClassRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionRule.class
new file mode 100644
index 000000000..d703d344c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionsRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionsRule.class
new file mode 100644
index 000000000..eadc21367
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionsRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$FieldRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$FieldRule.class
new file mode 100644
index 000000000..e7191d83d
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$FieldRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InnerClassRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InnerClassRule.class
new file mode 100644
index 000000000..c0ba92f01
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InnerClassRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfaceRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfaceRule.class
new file mode 100644
index 000000000..dff119ad9
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfaceRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfacesRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfacesRule.class
new file mode 100644
index 000000000..bbcc99706
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfacesRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LabelRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LabelRule.class
new file mode 100644
index 000000000..0539a070e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LabelRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LineNumberRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LineNumberRule.class
new file mode 100644
index 000000000..999db6957
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LineNumberRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LocalVarRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LocalVarRule.class
new file mode 100644
index 000000000..f011b4ce3
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LocalVarRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchLabelRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchLabelRule.class
new file mode 100644
index 000000000..ebe019650
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchLabelRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchRule.class
new file mode 100644
index 000000000..83fab9d1e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MaxRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MaxRule.class
new file mode 100644
index 000000000..72fbf45e1
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MaxRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MethodRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MethodRule.class
new file mode 100644
index 000000000..50511f4bb
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MethodRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Opcode.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Opcode.class
new file mode 100644
index 000000000..79606a85f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Opcode.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodeGroup.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodeGroup.class
new file mode 100644
index 000000000..215db6cf4
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodeGroup.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodesRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodesRule.class
new file mode 100644
index 000000000..510ea5381
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodesRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OuterClassRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OuterClassRule.class
new file mode 100644
index 000000000..6016a57f1
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OuterClassRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Rule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Rule.class
new file mode 100644
index 000000000..c42067229
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Rule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$RuleSet.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$RuleSet.class
new file mode 100644
index 000000000..0b99b723f
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$RuleSet.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$SourceRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$SourceRule.class
new file mode 100644
index 000000000..00edb912c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$SourceRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchLabelRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchLabelRule.class
new file mode 100644
index 000000000..bc01c17da
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchLabelRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchRule.class
new file mode 100644
index 000000000..96344f5c2
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TryCatchRule.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TryCatchRule.class
new file mode 100644
index 000000000..40121eb3c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TryCatchRule.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler.class
new file mode 100644
index 000000000..748c37b8c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ASMContentHandlerFactory.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ASMContentHandlerFactory.class
new file mode 100644
index 000000000..ca9c61579
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ASMContentHandlerFactory.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ContentHandlerFactory.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ContentHandlerFactory.class
new file mode 100644
index 000000000..db46833eb
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ContentHandlerFactory.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$EntryElement.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$EntryElement.class
new file mode 100644
index 000000000..8f5d5c63c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$EntryElement.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$InputSlicingHandler.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$InputSlicingHandler.class
new file mode 100644
index 000000000..5bfa3b34b
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$InputSlicingHandler.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$OutputSlicingHandler.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$OutputSlicingHandler.class
new file mode 100644
index 000000000..3d779780a
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$OutputSlicingHandler.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ProtectedInputStream.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ProtectedInputStream.class
new file mode 100644
index 000000000..6abc9359e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ProtectedInputStream.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriter.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriter.class
new file mode 100644
index 000000000..ecf42b662
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriterFactory.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriterFactory.class
new file mode 100644
index 000000000..916d3463e
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriterFactory.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SingleDocElement.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SingleDocElement.class
new file mode 100644
index 000000000..f7587d6bd
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SingleDocElement.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SubdocumentHandlerFactory.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SubdocumentHandlerFactory.class
new file mode 100644
index 000000000..f9a080042
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SubdocumentHandlerFactory.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$TransformerHandlerFactory.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$TransformerHandlerFactory.class
new file mode 100644
index 000000000..efea4d963
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$TransformerHandlerFactory.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ZipEntryElement.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ZipEntryElement.class
new file mode 100644
index 000000000..f383898ab
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ZipEntryElement.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor.class
new file mode 100644
index 000000000..e438d797a
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAdapter.class
new file mode 100644
index 000000000..f5347601c
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.class
new file mode 100644
index 000000000..ea7030426
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXClassAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXClassAdapter.class
new file mode 100644
index 000000000..492ee2c54
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXClassAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXCodeAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXCodeAdapter.class
new file mode 100644
index 000000000..a0656a5ef
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXCodeAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXFieldAdapter.class b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXFieldAdapter.class
new file mode 100644
index 000000000..7cdae94bb
--- /dev/null
+++ b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXFieldAdapter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/ClassDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/ClassDoc.class
new file mode 100644
index 000000000..8f362399f
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/ClassDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/ConstructorDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/ConstructorDoc.class
new file mode 100644
index 000000000..e9c221679
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/ConstructorDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/Doc.class b/libjava/classpath/tools/classes/com/sun/javadoc/Doc.class
new file mode 100644
index 000000000..8b98e6300
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/Doc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/DocErrorReporter.class b/libjava/classpath/tools/classes/com/sun/javadoc/DocErrorReporter.class
new file mode 100644
index 000000000..2dec23567
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/DocErrorReporter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/Doclet.class b/libjava/classpath/tools/classes/com/sun/javadoc/Doclet.class
new file mode 100644
index 000000000..2def74479
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/Doclet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/ExecutableMemberDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/ExecutableMemberDoc.class
new file mode 100644
index 000000000..84c69f1fa
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/ExecutableMemberDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/FieldDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/FieldDoc.class
new file mode 100644
index 000000000..da5da74ce
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/FieldDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/MemberDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/MemberDoc.class
new file mode 100644
index 000000000..50b630add
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/MemberDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/MethodDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/MethodDoc.class
new file mode 100644
index 000000000..7789f8b55
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/MethodDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/PackageDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/PackageDoc.class
new file mode 100644
index 000000000..ba51efc34
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/PackageDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/ParamTag.class b/libjava/classpath/tools/classes/com/sun/javadoc/ParamTag.class
new file mode 100644
index 000000000..c8da5294d
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/ParamTag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/Parameter.class b/libjava/classpath/tools/classes/com/sun/javadoc/Parameter.class
new file mode 100644
index 000000000..beff569c9
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/Parameter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/ProgramElementDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/ProgramElementDoc.class
new file mode 100644
index 000000000..1ec3cbb25
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/ProgramElementDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/RootDoc.class b/libjava/classpath/tools/classes/com/sun/javadoc/RootDoc.class
new file mode 100644
index 000000000..32409f6e9
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/RootDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/SeeTag.class b/libjava/classpath/tools/classes/com/sun/javadoc/SeeTag.class
new file mode 100644
index 000000000..f55cfde33
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/SeeTag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/SerialFieldTag.class b/libjava/classpath/tools/classes/com/sun/javadoc/SerialFieldTag.class
new file mode 100644
index 000000000..f57ecac01
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/SerialFieldTag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/SourcePosition.class b/libjava/classpath/tools/classes/com/sun/javadoc/SourcePosition.class
new file mode 100644
index 000000000..a2825817f
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/SourcePosition.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/Tag.class b/libjava/classpath/tools/classes/com/sun/javadoc/Tag.class
new file mode 100644
index 000000000..efeeab1a3
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/Tag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/ThrowsTag.class b/libjava/classpath/tools/classes/com/sun/javadoc/ThrowsTag.class
new file mode 100644
index 000000000..7d69e5693
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/ThrowsTag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/Type.class b/libjava/classpath/tools/classes/com/sun/javadoc/Type.class
new file mode 100644
index 000000000..e26400399
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/Type.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/javadoc/TypeVariable.class b/libjava/classpath/tools/classes/com/sun/javadoc/TypeVariable.class
new file mode 100644
index 000000000..c9fc10f04
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/javadoc/TypeVariable.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/tools/doclets/Taglet.class b/libjava/classpath/tools/classes/com/sun/tools/doclets/Taglet.class
new file mode 100644
index 000000000..929a3d408
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/tools/doclets/Taglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/tools/javac/Main.class b/libjava/classpath/tools/classes/com/sun/tools/javac/Main.class
new file mode 100644
index 000000000..c3b8636aa
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/tools/javac/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/tools/javac/Messages.class b/libjava/classpath/tools/classes/com/sun/tools/javac/Messages.class
new file mode 100644
index 000000000..50ced907d
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/tools/javac/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/tools/javadoc/Main.class b/libjava/classpath/tools/classes/com/sun/tools/javadoc/Main.class
new file mode 100644
index 000000000..50a486c56
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/tools/javadoc/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/com/sun/tools/javah/Main.class b/libjava/classpath/tools/classes/com/sun/tools/javah/Main.class
new file mode 100644
index 000000000..b1f830df2
--- /dev/null
+++ b/libjava/classpath/tools/classes/com/sun/tools/javah/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$FileStreamInfo.class b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$FileStreamInfo.class
new file mode 100644
index 000000000..e64ee9f79
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$FileStreamInfo.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$JarStreamInfo.class b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$JarStreamInfo.class
new file mode 100644
index 000000000..27a4843a4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$JarStreamInfo.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$StreamInfo.class b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$StreamInfo.class
new file mode 100644
index 000000000..85f53ae2e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$StreamInfo.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader.class b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader.class
new file mode 100644
index 000000000..cc4d74a6d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/IOToolkit.class b/libjava/classpath/tools/classes/gnu/classpath/tools/IOToolkit.class
new file mode 100644
index 000000000..967a3a8e8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/IOToolkit.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputEvent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputEvent.class
new file mode 100644
index 000000000..c3701b155
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputEvent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputListener.class b/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputListener.class
new file mode 100644
index 000000000..6a90af53e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputListener.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/NotifyingInputStreamReader.class b/libjava/classpath/tools/classes/gnu/classpath/tools/NotifyingInputStreamReader.class
new file mode 100644
index 000000000..424a86293
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/NotifyingInputStreamReader.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/StringToolkit.class b/libjava/classpath/tools/classes/gnu/classpath/tools/StringToolkit.class
new file mode 100644
index 000000000..1f6a48855
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/StringToolkit.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletClassLoader.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletClassLoader.class
new file mode 100644
index 000000000..50e61a6a9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletClassLoader.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletSecurityManager.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletSecurityManager.class
new file mode 100644
index 000000000..cab207c3f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletSecurityManager.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletTag.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletTag.class
new file mode 100644
index 000000000..141d5108f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletTag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletContext.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletContext.class
new file mode 100644
index 000000000..dbc0fb548
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletContext.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletStub.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletStub.class
new file mode 100644
index 000000000..13f91ee97
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletStub.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/ErrorApplet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/ErrorApplet.class
new file mode 100644
index 000000000..ed7bdf61a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/ErrorApplet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$1.class
new file mode 100644
index 000000000..d60ed70d8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$10.class
new file mode 100644
index 000000000..6bd79beb4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$2.class
new file mode 100644
index 000000000..6798e9744
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$3.class
new file mode 100644
index 000000000..f3fbb09c0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$4.class
new file mode 100644
index 000000000..578fae066
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$5.class
new file mode 100644
index 000000000..325a20c20
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$6.class
new file mode 100644
index 000000000..cc651d5c6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$7.class
new file mode 100644
index 000000000..917b0c423
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$8.class
new file mode 100644
index 000000000..9f431fc83
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$9.class
new file mode 100644
index 000000000..cd542dd20
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main.class
new file mode 100644
index 000000000..b357b7851
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Messages.class
new file mode 100644
index 000000000..efc34dfc9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletContext.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletContext.class
new file mode 100644
index 000000000..1511a5e9b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletContext.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletViewer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletViewer.class
new file mode 100644
index 000000000..e8dc01ec5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletViewer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletWindow.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletWindow.class
new file mode 100644
index 000000000..7e71885c8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletWindow.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletContext.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletContext.class
new file mode 100644
index 000000000..a307a7af4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletContext.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.class
new file mode 100644
index 000000000..82bdc431b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow$1.class
new file mode 100644
index 000000000..d6aee337d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.class
new file mode 100644
index 000000000..94ed808c6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/TagParser.class b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/TagParser.class
new file mode 100644
index 000000000..a3fdc693e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/TagParser.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/CallbackUtil.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/CallbackUtil.class
new file mode 100644
index 000000000..970232c7e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/CallbackUtil.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$1.class
new file mode 100644
index 000000000..812fb9432
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$2.class
new file mode 100644
index 000000000..803af4cac
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$AtFileArgumentCallback.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$AtFileArgumentCallback.class
new file mode 100644
index 000000000..96677cc81
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$AtFileArgumentCallback.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser.class
new file mode 100644
index 000000000..67c15788f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Messages.class
new file mode 100644
index 000000000..9b3d765a1
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent$ExitTask.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent$ExitTask.class
new file mode 100644
index 000000000..36daccbc4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent$ExitTask.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent.class
new file mode 100644
index 000000000..6a1e7519d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$1.class
new file mode 100644
index 000000000..727fd0a86
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$2.class
new file mode 100644
index 000000000..5ba4b6a5a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil.class
new file mode 100644
index 000000000..9cffbfecc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/common/SecurityProviderInfo.class b/libjava/classpath/tools/classes/gnu/classpath/tools/common/SecurityProviderInfo.class
new file mode 100644
index 000000000..8715ab8d4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/common/SecurityProviderInfo.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionGroup.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionGroup.class
new file mode 100644
index 000000000..56584bdbb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionGroup.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTag.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTag.class
new file mode 100644
index 000000000..939e890ce
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTaglet.class
new file mode 100644
index 000000000..d81864f04
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTagletPath.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTagletPath.class
new file mode 100644
index 000000000..9336e3584
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTagletPath.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$IndexKey.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$IndexKey.class
new file mode 100644
index 000000000..b3a2f7b42
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$IndexKey.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$InterfaceRelation.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$InterfaceRelation.class
new file mode 100644
index 000000000..0e061038e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$InterfaceRelation.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$UsageType.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$UsageType.class
new file mode 100644
index 000000000..c962bcc1c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$UsageType.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet.class
new file mode 100644
index 000000000..794d3568d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletConfigurationException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletConfigurationException.class
new file mode 100644
index 000000000..28d3cd17a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletConfigurationException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOption.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOption.class
new file mode 100644
index 000000000..5b491a4eb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOption.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionColonSeparated.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionColonSeparated.class
new file mode 100644
index 000000000..5f4f6b4a5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionColonSeparated.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFile.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFile.class
new file mode 100644
index 000000000..aac98a430
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFile.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFlag.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFlag.class
new file mode 100644
index 000000000..ae9466a0d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFlag.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.class
new file mode 100644
index 000000000..3f9d436cc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionString.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionString.class
new file mode 100644
index 000000000..79bbe2c51
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionString.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InlineTagRenderer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InlineTagRenderer.class
new file mode 100644
index 000000000..d938d6131
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InlineTagRenderer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InvalidPackageWildcardException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InvalidPackageWildcardException.class
new file mode 100644
index 000000000..0141cb1f4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InvalidPackageWildcardException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageGroup.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageGroup.class
new file mode 100644
index 000000000..c9bdbaa68
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageGroup.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageMatcher.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageMatcher.class
new file mode 100644
index 000000000..88ed2d53c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageMatcher.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/StandardTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/StandardTaglet.class
new file mode 100644
index 000000000..2422f3e53
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/StandardTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/TagletPrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/TagletPrinter.class
new file mode 100644
index 000000000..ac908c910
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/TagletPrinter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.class
new file mode 100644
index 000000000..0ddee8859
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/CssClass.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/CssClass.class
new file mode 100644
index 000000000..89ca9bb26
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/CssClass.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.class
new file mode 100644
index 000000000..16ffa3350
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$1.class
new file mode 100644
index 000000000..3576ed98e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$2.class
new file mode 100644
index 000000000..3d38a044d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$3.class
new file mode 100644
index 000000000..c6e6f121d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$TreeNode.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$TreeNode.class
new file mode 100644
index 000000000..be1eab391
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$TreeNode.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.class
new file mode 100644
index 000000000..1e86b0b06
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.class
new file mode 100644
index 000000000..ffa980d1e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.class
new file mode 100644
index 000000000..39fa437d4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$1.class
new file mode 100644
index 000000000..51027ef0e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$NullErrorReporter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$NullErrorReporter.class
new file mode 100644
index 000000000..42b2a7d38
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$NullErrorReporter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$UsageType.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$UsageType.class
new file mode 100644
index 000000000..dfd0a2251
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$UsageType.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver.class
new file mode 100644
index 000000000..f34cca511
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.class
new file mode 100644
index 000000000..e18500ad8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer$TagInfo.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer$TagInfo.class
new file mode 100644
index 000000000..7c0462beb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer$TagInfo.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.class
new file mode 100644
index 000000000..f153d7f0d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/TargetContext.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/TargetContext.class
new file mode 100644
index 000000000..9e4d11f26
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/TargetContext.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet$DocErrorReporterOutputStream.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet$DocErrorReporterOutputStream.class
new file mode 100644
index 000000000..d6d09c0fd
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet$DocErrorReporterOutputStream.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.class
new file mode 100644
index 000000000..fb76313b5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.class
new file mode 100644
index 000000000..e13119b5c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.class
new file mode 100644
index 000000000..01c62844e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.class
new file mode 100644
index 000000000..a21b9228f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.class
new file mode 100644
index 000000000..262031d4a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.class b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.class
new file mode 100644
index 000000000..3b14f2323
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/FileArgumentCallback.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/FileArgumentCallback.class
new file mode 100644
index 000000000..de9d9a63a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/FileArgumentCallback.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Messages.class
new file mode 100644
index 000000000..f86b8f70c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Option.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Option.class
new file mode 100644
index 000000000..c97800034
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Option.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionException.class
new file mode 100644
index 000000000..1f06b6f12
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionGroup.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionGroup.class
new file mode 100644
index 000000000..2467f7816
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionGroup.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$1.class
new file mode 100644
index 000000000..352177e25
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$2.class
new file mode 100644
index 000000000..013fcb919
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$3.class
new file mode 100644
index 000000000..63abbdb5b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser.class b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser.class
new file mode 100644
index 000000000..1e0586d28
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/AbstractTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/AbstractTagImpl.class
new file mode 100644
index 000000000..6f8b42089
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/AbstractTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.class
new file mode 100644
index 000000000..2a21e67a2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BlockSourceComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BlockSourceComponent.class
new file mode 100644
index 000000000..5d89719d4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BlockSourceComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BracketClose.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BracketClose.class
new file mode 100644
index 000000000..3802e3405
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BracketClose.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassComponent.class
new file mode 100644
index 000000000..5d2f22bd8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocImpl.class
new file mode 100644
index 000000000..36049302b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocProxy.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocProxy.class
new file mode 100644
index 000000000..de3c21147
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocProxy.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.class
new file mode 100644
index 000000000..7f8381f91
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/CommentComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/CommentComponent.class
new file mode 100644
index 000000000..ce853e171
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/CommentComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ConstructorDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ConstructorDocImpl.class
new file mode 100644
index 000000000..8ab08afb2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ConstructorDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Debug.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Debug.class
new file mode 100644
index 000000000..fb026a0b7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Debug.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree$FileNode.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree$FileNode.class
new file mode 100644
index 000000000..6d963c31b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree$FileNode.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree.class
new file mode 100644
index 000000000..3d6bf8c6a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DocImpl.class
new file mode 100644
index 000000000..2963ccf59
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/EmptyStatementComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/EmptyStatementComponent.class
new file mode 100644
index 000000000..7c9903dc5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/EmptyStatementComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ErrorReporter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ErrorReporter.class
new file mode 100644
index 000000000..d32b961f8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ErrorReporter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.class
new file mode 100644
index 000000000..4ca710dd9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldComponent.class
new file mode 100644
index 000000000..a38964f0f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldDocImpl.class
new file mode 100644
index 000000000..b68553892
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FunctionComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FunctionComponent.class
new file mode 100644
index 000000000..11549cf7f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FunctionComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocPackageDoc.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocPackageDoc.class
new file mode 100644
index 000000000..0932db26e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocPackageDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocRootDoc.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocRootDoc.class
new file mode 100644
index 000000000..7ad3e4081
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocRootDoc.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/IgnoredFileParseException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/IgnoredFileParseException.class
new file mode 100644
index 000000000..5b5aff152
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/IgnoredFileParseException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ImportComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ImportComponent.class
new file mode 100644
index 000000000..884422294
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ImportComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/InheritDocTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/InheritDocTagImpl.class
new file mode 100644
index 000000000..715d01c5a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/InheritDocTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/JavadocWrapper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/JavadocWrapper.class
new file mode 100644
index 000000000..d38c2bfd4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/JavadocWrapper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/LinkTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/LinkTagImpl.class
new file mode 100644
index 000000000..b470a9af5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/LinkTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$1.class
new file mode 100644
index 000000000..2ba0ccf09
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$10.class
new file mode 100644
index 000000000..597a142cf
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$11.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$11.class
new file mode 100644
index 000000000..bf1c99a43
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$11.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$12.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$12.class
new file mode 100644
index 000000000..7bf3e4cb4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$12.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$13.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$13.class
new file mode 100644
index 000000000..41645e8e9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$13.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$14.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$14.class
new file mode 100644
index 000000000..ed2e3427e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$14.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$15.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$15.class
new file mode 100644
index 000000000..68ec87447
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$15.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$16.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$16.class
new file mode 100644
index 000000000..54fefac98
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$16.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$17.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$17.class
new file mode 100644
index 000000000..81583d897
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$17.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$18.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$18.class
new file mode 100644
index 000000000..a39529959
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$18.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$19.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$19.class
new file mode 100644
index 000000000..61bf1f808
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$19.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$2.class
new file mode 100644
index 000000000..60869e5f8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$20.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$20.class
new file mode 100644
index 000000000..5a9d84828
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$20.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$21.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$21.class
new file mode 100644
index 000000000..12a49837f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$21.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$22.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$22.class
new file mode 100644
index 000000000..32e26ffa4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$22.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$23.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$23.class
new file mode 100644
index 000000000..fd99e130d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$23.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$24.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$24.class
new file mode 100644
index 000000000..991629a16
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$24.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$25.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$25.class
new file mode 100644
index 000000000..441b8dac2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$25.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$3.class
new file mode 100644
index 000000000..b5015e391
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$4.class
new file mode 100644
index 000000000..8690a7e73
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$5.class
new file mode 100644
index 000000000..6dbf679ee
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$6.class
new file mode 100644
index 000000000..2a4473bbd
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$7.class
new file mode 100644
index 000000000..50d017049
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$8.class
new file mode 100644
index 000000000..5dde313d4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$9.class
new file mode 100644
index 000000000..19e991a62
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$OptionProcessor.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$OptionProcessor.class
new file mode 100644
index 000000000..afa9335a8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$OptionProcessor.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main.class
new file mode 100644
index 000000000..2f46dd282
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MemberDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MemberDocImpl.class
new file mode 100644
index 000000000..bdf920109
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MemberDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MethodDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MethodDocImpl.class
new file mode 100644
index 000000000..5bff1ce28
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MethodDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageComponent.class
new file mode 100644
index 000000000..e9947add8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageDocImpl.class
new file mode 100644
index 000000000..2ef9d54d9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParamTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParamTagImpl.class
new file mode 100644
index 000000000..e2fadecfd
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParamTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParameterImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParameterImpl.class
new file mode 100644
index 000000000..93575d269
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParameterImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParseException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParseException.class
new file mode 100644
index 000000000..52c67ef01
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParseException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$1.class
new file mode 100644
index 000000000..55600beac
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$Context.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$Context.class
new file mode 100644
index 000000000..f89d66204
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$Context.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser.class
new file mode 100644
index 000000000..037311b3b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.class
new file mode 100644
index 000000000..50d6e5200
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImport.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImport.class
new file mode 100644
index 000000000..803eb60e8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImport.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportClassFile.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportClassFile.class
new file mode 100644
index 000000000..a82823a90
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportClassFile.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportNotFound.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportNotFound.class
new file mode 100644
index 000000000..68af45072
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportNotFound.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportPackageFile.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportPackageFile.class
new file mode 100644
index 000000000..4302abeb2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportPackageFile.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionClass.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionClass.class
new file mode 100644
index 000000000..c0b66ddc3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionClass.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionPackage.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionPackage.class
new file mode 100644
index 000000000..2069ee6d1
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionPackage.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ScheduledClass.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ScheduledClass.class
new file mode 100644
index 000000000..9c76827c8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ScheduledClass.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl.class
new file mode 100644
index 000000000..3db73689d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SeeTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SeeTagImpl.class
new file mode 100644
index 000000000..324fb5be0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SeeTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.class
new file mode 100644
index 000000000..5f75b5a20
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SlashSlashCommentComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SlashSlashCommentComponent.class
new file mode 100644
index 000000000..470c80c2d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SlashSlashCommentComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourceComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourceComponent.class
new file mode 100644
index 000000000..804802be5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourceComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourcePositionImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourcePositionImpl.class
new file mode 100644
index 000000000..3f94fd128
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourcePositionImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/StaticBlockComponent.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/StaticBlockComponent.class
new file mode 100644
index 000000000..b59c7fdc6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/StaticBlockComponent.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagContainer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagContainer.class
new file mode 100644
index 000000000..6ff3032e4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagContainer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagImpl.class
new file mode 100644
index 000000000..536c10741
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TemporaryStore.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TemporaryStore.class
new file mode 100644
index 000000000..cf42c61f5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TemporaryStore.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TextTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TextTagImpl.class
new file mode 100644
index 000000000..73e550299
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TextTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ThrowsTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ThrowsTagImpl.class
new file mode 100644
index 000000000..06cc77ca3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ThrowsTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Timer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Timer.class
new file mode 100644
index 000000000..8f5dc6109
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Timer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet$1.class
new file mode 100644
index 000000000..e34089973
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet.class
new file mode 100644
index 000000000..965ef1c33
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeImpl.class
new file mode 100644
index 000000000..50bb53e8f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeVariableImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeVariableImpl.class
new file mode 100644
index 000000000..2ebf595d7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeVariableImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ValueTagImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ValueTagImpl.class
new file mode 100644
index 000000000..872c40309
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ValueTagImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Whitespace.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Whitespace.class
new file mode 100644
index 000000000..965c1aa41
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Whitespace.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/WritableType.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/WritableType.class
new file mode 100644
index 000000000..8c61a4ab7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/WritableType.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AdditionExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AdditionExpression.class
new file mode 100644
index 000000000..ef3bbff79
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AdditionExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AndExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AndExpression.class
new file mode 100644
index 000000000..b5f1deb3c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AndExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.class
new file mode 100644
index 000000000..b83ad6606
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.class
new file mode 100644
index 000000000..d56220d95
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.class
new file mode 100644
index 000000000..52c0522fc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryExpression.class
new file mode 100644
index 000000000..688a12209
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.class
new file mode 100644
index 000000000..ea6978d47
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.class
new file mode 100644
index 000000000..72a6fc8d4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.class
new file mode 100644
index 000000000..5726e7a38
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.class
new file mode 100644
index 000000000..e1f37d576
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.class
new file mode 100644
index 000000000..f1a21239a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.class
new file mode 100644
index 000000000..87114d6cb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.class
new file mode 100644
index 000000000..2ee7e5452
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantByte.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantByte.class
new file mode 100644
index 000000000..3eacffbfb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantByte.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantChar.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantChar.class
new file mode 100644
index 000000000..c4de797ec
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantChar.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantDouble.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantDouble.class
new file mode 100644
index 000000000..38700c723
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantDouble.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantExpression.class
new file mode 100644
index 000000000..3d194a9b5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantFloat.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantFloat.class
new file mode 100644
index 000000000..61b969fe0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantFloat.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantInteger.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantInteger.class
new file mode 100644
index 000000000..278ab37d2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantInteger.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantLong.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantLong.class
new file mode 100644
index 000000000..726914985
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantLong.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantNull.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantNull.class
new file mode 100644
index 000000000..d2c3574d8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantNull.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantShort.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantShort.class
new file mode 100644
index 000000000..691a01933
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantShort.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantString.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantString.class
new file mode 100644
index 000000000..67ef94819
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantString.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Context.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Context.class
new file mode 100644
index 000000000..0a21eff60
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Context.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/DivisionExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/DivisionExpression.class
new file mode 100644
index 000000000..95cc47b5c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/DivisionExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EqualExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EqualExpression.class
new file mode 100644
index 000000000..2fd2087c8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EqualExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Evaluator.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Evaluator.class
new file mode 100644
index 000000000..45c686d3c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Evaluator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.class
new file mode 100644
index 000000000..5ff7b1902
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.class
new file mode 100644
index 000000000..0474dd4a4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Expression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Expression.class
new file mode 100644
index 000000000..52b5f9322
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Expression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.class
new file mode 100644
index 000000000..33a88296a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.class
new file mode 100644
index 000000000..f864c02c4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.class
new file mode 100644
index 000000000..8b2526638
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.class
new file mode 100644
index 000000000..312246f29
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.class
new file mode 100644
index 000000000..8ac3c2295
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaLexer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaLexer.class
new file mode 100644
index 000000000..3367c3676
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaLexer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.class
new file mode 100644
index 000000000..ec48917c2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.class
new file mode 100644
index 000000000..39e584d68
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanExpression.class
new file mode 100644
index 000000000..d0d6923af
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.class
new file mode 100644
index 000000000..e40f85658
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.class
new file mode 100644
index 000000000..da9124b42
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.class
new file mode 100644
index 000000000..055856eef
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.class
new file mode 100644
index 000000000..8ed300494
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ModuloExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ModuloExpression.class
new file mode 100644
index 000000000..ec9870c0b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ModuloExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.class
new file mode 100644
index 000000000..770c4f4f6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NegateExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NegateExpression.class
new file mode 100644
index 000000000..6745a5096
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NegateExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.class
new file mode 100644
index 000000000..8a830ca80
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotExpression.class
new file mode 100644
index 000000000..964460800
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.class
new file mode 100644
index 000000000..f7f21d213
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.class
new file mode 100644
index 000000000..afa890a03
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.class
new file mode 100644
index 000000000..e7496b3d4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Type.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Type.class
new file mode 100644
index 000000000..59a4e3fb9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Type.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.class
new file mode 100644
index 000000000..2f16d29b9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnaryExpression.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnaryExpression.class
new file mode 100644
index 000000000..7189a2938
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnaryExpression.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.class
new file mode 100644
index 000000000..3e678af89
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Action.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Action.class
new file mode 100644
index 000000000..513df1ca3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Action.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.class
new file mode 100644
index 000000000..20d5f849f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Entry.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Entry.class
new file mode 100644
index 000000000..b517df743
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Entry.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Extractor.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Extractor.class
new file mode 100644
index 000000000..c0d819e4c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Extractor.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Indexer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Indexer.class
new file mode 100644
index 000000000..bea2d0f3d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Indexer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Lister.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Lister.class
new file mode 100644
index 000000000..81cdaec2a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Lister.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$1.class
new file mode 100644
index 000000000..1823aeb87
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$2.class
new file mode 100644
index 000000000..22a34b09a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$3.class
new file mode 100644
index 000000000..e2273aac7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$4.class
new file mode 100644
index 000000000..db23620a6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$5.class
new file mode 100644
index 000000000..feadf3801
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$6.class
new file mode 100644
index 000000000..4795844b9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$7.class
new file mode 100644
index 000000000..57a9742d1
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$HandleFile.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$HandleFile.class
new file mode 100644
index 000000000..6d7c301d9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$HandleFile.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$JarParser.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$JarParser.class
new file mode 100644
index 000000000..db164f202
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$JarParser.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$ModeOption.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$ModeOption.class
new file mode 100644
index 000000000..394b4e02e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$ModeOption.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main.class
new file mode 100644
index 000000000..c8eb12d07
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Messages.class
new file mode 100644
index 000000000..6d26c6693
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Updater.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Updater.class
new file mode 100644
index 000000000..e9f19b75b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Updater.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jar/WorkSet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/WorkSet.class
new file mode 100644
index 000000000..5e792e60d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/WorkSet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/HashUtils.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/HashUtils.class
new file mode 100644
index 000000000..0081db4bc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/HashUtils.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarSigner.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarSigner.class
new file mode 100644
index 000000000..3f0e38365
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarSigner.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarVerifier.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarVerifier.class
new file mode 100644
index 000000000..987781f3f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarVerifier.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$1.class
new file mode 100644
index 000000000..22ed506ff
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$10.class
new file mode 100644
index 000000000..e0bf16b3a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$11.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$11.class
new file mode 100644
index 000000000..444dbc624
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$11.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$12.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$12.class
new file mode 100644
index 000000000..dfdeb3acc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$12.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$2.class
new file mode 100644
index 000000000..153248656
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$3.class
new file mode 100644
index 000000000..8781f7c65
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$4.class
new file mode 100644
index 000000000..3a2d7b9fe
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$5.class
new file mode 100644
index 000000000..08cb8635a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$6.class
new file mode 100644
index 000000000..4b393a059
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$7.class
new file mode 100644
index 000000000..61a170a43
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$8.class
new file mode 100644
index 000000000..c04f28491
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$9.class
new file mode 100644
index 000000000..e65131c72
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParser.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParser.class
new file mode 100644
index 000000000..ba2e90978
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParser.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParserCallback.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParserCallback.class
new file mode 100644
index 000000000..e84dad5d6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParserCallback.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main.class
new file mode 100644
index 000000000..e62e7e801
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Messages.class
new file mode 100644
index 000000000..2619d766a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/SFHelper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/SFHelper.class
new file mode 100644
index 000000000..a8d5b6770
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/SFHelper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml$State.class b/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml$State.class
new file mode 100644
index 000000000..f056c6252
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml$State.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml.class b/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml.class
new file mode 100644
index 000000000..17de273a0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class
new file mode 100644
index 000000000..d8694184a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class
new file mode 100644
index 000000000..6cbf96959
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class
new file mode 100644
index 000000000..c1a13fede
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class
new file mode 100644
index 000000000..559adbf2a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class
new file mode 100644
index 000000000..3d6f235bb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$1.class
new file mode 100644
index 000000000..37f0ce5fc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$2.class
new file mode 100644
index 000000000..47cf33089
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$3.class
new file mode 100644
index 000000000..4c4bfdd88
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$4.class
new file mode 100644
index 000000000..9099ce89e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$5.class
new file mode 100644
index 000000000..29425b055
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$6.class
new file mode 100644
index 000000000..e71bd6824
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$7.class
new file mode 100644
index 000000000..429523848
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$8.class
new file mode 100644
index 000000000..6b613078b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$9.class
new file mode 100644
index 000000000..6ad457f1b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain.class
new file mode 100644
index 000000000..1efd92d69
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniHelper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniHelper.class
new file mode 100644
index 000000000..8f09f16e2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniHelper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class
new file mode 100644
index 000000000..c31f88ae6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniPrintStream.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniPrintStream.class
new file mode 100644
index 000000000..d8f006c14
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniPrintStream.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class
new file mode 100644
index 000000000..b7c8453df
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class
new file mode 100644
index 000000000..97b0b76fd
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class
new file mode 100644
index 000000000..ca86d0404
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class
new file mode 100644
index 000000000..ea003e4f0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class
new file mode 100644
index 000000000..560a505a0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class
new file mode 100644
index 000000000..cd7143a5c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class
new file mode 100644
index 000000000..88ea4ee1a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class
new file mode 100644
index 000000000..fee2bd107
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class
new file mode 100644
index 000000000..bb6d72a3e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class
new file mode 100644
index 000000000..44390e127
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class
new file mode 100644
index 000000000..28bf6e998
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class
new file mode 100644
index 000000000..013a6553e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class
new file mode 100644
index 000000000..57adaabe3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class
new file mode 100644
index 000000000..fe4f73270
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PackageWrapper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PackageWrapper.class
new file mode 100644
index 000000000..68f16fb41
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PackageWrapper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$1.class
new file mode 100644
index 000000000..43d816d14
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$2.class
new file mode 100644
index 000000000..c49e59fc0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$3.class
new file mode 100644
index 000000000..333b8ea96
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$4.class
new file mode 100644
index 000000000..c925e9805
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$5.class
new file mode 100644
index 000000000..001ebeb80
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$6.class
new file mode 100644
index 000000000..724920b9a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup.class
new file mode 100644
index 000000000..1608c7127
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class
new file mode 100644
index 000000000..94bc20c09
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Text.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Text.class
new file mode 100644
index 000000000..e084d89a7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Text.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$1.class
new file mode 100644
index 000000000..b2424cfc3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$2.class
new file mode 100644
index 000000000..980c5742b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$3.class
new file mode 100644
index 000000000..81dddccc2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$4.class
new file mode 100644
index 000000000..7f8d6df99
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$5.class
new file mode 100644
index 000000000..fc1e47b6a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$6.class
new file mode 100644
index 000000000..3fd3a7aa8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd.class
new file mode 100644
index 000000000..8b0ca1299
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$1.class
new file mode 100644
index 000000000..effe78b1e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$10.class
new file mode 100644
index 000000000..6b6accd89
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$2.class
new file mode 100644
index 000000000..6952425ce
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$3.class
new file mode 100644
index 000000000..db64eaf8c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$4.class
new file mode 100644
index 000000000..bc646ad42
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$5.class
new file mode 100644
index 000000000..e1a50767e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$6.class
new file mode 100644
index 000000000..76ee43711
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$7.class
new file mode 100644
index 000000000..5da8d3af6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$8.class
new file mode 100644
index 000000000..c55f69774
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$9.class
new file mode 100644
index 000000000..f04e4fe17
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd.class
new file mode 100644
index 000000000..3ee202afb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command$ShutdownHook.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command$ShutdownHook.class
new file mode 100644
index 000000000..d1b0f5c3c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command$ShutdownHook.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command.class
new file mode 100644
index 000000000..49134bca8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$1.class
new file mode 100644
index 000000000..eb6a38cbe
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$2.class
new file mode 100644
index 000000000..e4844ab9b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$3.class
new file mode 100644
index 000000000..d31c08ab4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$4.class
new file mode 100644
index 000000000..9d7761ea9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$5.class
new file mode 100644
index 000000000..6e605756f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$6.class
new file mode 100644
index 000000000..4b9ed7623
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd.class
new file mode 100644
index 000000000..d4ec536c3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$1.class
new file mode 100644
index 000000000..bfcb9bf85
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$2.class
new file mode 100644
index 000000000..22aa46e2b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$3.class
new file mode 100644
index 000000000..946663b85
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$4.class
new file mode 100644
index 000000000..9aaf960ab
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$5.class
new file mode 100644
index 000000000..6f9f4b60c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$6.class
new file mode 100644
index 000000000..c61efc978
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$7.class
new file mode 100644
index 000000000..1d4eb0fb0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$8.class
new file mode 100644
index 000000000..d1a751940
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd.class
new file mode 100644
index 000000000..84af3c107
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$1.class
new file mode 100644
index 000000000..265b4a496
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$10.class
new file mode 100644
index 000000000..24cfab080
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$11.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$11.class
new file mode 100644
index 000000000..7ff671269
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$11.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$12.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$12.class
new file mode 100644
index 000000000..7a1e0e935
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$12.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$2.class
new file mode 100644
index 000000000..8c101c4af
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$3.class
new file mode 100644
index 000000000..9225073f1
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$4.class
new file mode 100644
index 000000000..1958f3d6a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$5.class
new file mode 100644
index 000000000..805197d5a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$6.class
new file mode 100644
index 000000000..6d1470079
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$7.class
new file mode 100644
index 000000000..843889385
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$8.class
new file mode 100644
index 000000000..715f1be23
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$9.class
new file mode 100644
index 000000000..a0b1bbafd
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd.class
new file mode 100644
index 000000000..96a529411
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$1.class
new file mode 100644
index 000000000..83f604aa8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$2.class
new file mode 100644
index 000000000..90e2114b2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$3.class
new file mode 100644
index 000000000..cb495c068
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$4.class
new file mode 100644
index 000000000..0550d7d12
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$5.class
new file mode 100644
index 000000000..b73da2ce7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$6.class
new file mode 100644
index 000000000..c47ced6c3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd.class
new file mode 100644
index 000000000..b002f93cb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$1.class
new file mode 100644
index 000000000..a122bc6aa
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$10.class
new file mode 100644
index 000000000..d7dd85ae0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$2.class
new file mode 100644
index 000000000..c1f498889
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$3.class
new file mode 100644
index 000000000..e02f774fe
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$4.class
new file mode 100644
index 000000000..3768d8154
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$5.class
new file mode 100644
index 000000000..9cd40fd19
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$6.class
new file mode 100644
index 000000000..adeba9d4d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$7.class
new file mode 100644
index 000000000..c6b2e47e7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$8.class
new file mode 100644
index 000000000..269af2b93
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$9.class
new file mode 100644
index 000000000..e93f35726
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd.class
new file mode 100644
index 000000000..e55964372
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$1.class
new file mode 100644
index 000000000..cfe315d0e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$2.class
new file mode 100644
index 000000000..b7b6a9109
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$3.class
new file mode 100644
index 000000000..73f9233df
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$4.class
new file mode 100644
index 000000000..5904a985f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$5.class
new file mode 100644
index 000000000..7511cc320
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$6.class
new file mode 100644
index 000000000..f42087f7c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$7.class
new file mode 100644
index 000000000..e6ccd4e76
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$8.class
new file mode 100644
index 000000000..c1247a50a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$9.class
new file mode 100644
index 000000000..888203bfb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd.class
new file mode 100644
index 000000000..d211eedbb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$1.class
new file mode 100644
index 000000000..ca06350ec
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$2.class
new file mode 100644
index 000000000..5c4cb367b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$3.class
new file mode 100644
index 000000000..3adcc94e3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$4.class
new file mode 100644
index 000000000..2240bbca5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$5.class
new file mode 100644
index 000000000..cdfd6323b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$6.class
new file mode 100644
index 000000000..ee0755e4d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$7.class
new file mode 100644
index 000000000..5e5206359
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$8.class
new file mode 100644
index 000000000..641550b8f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd.class
new file mode 100644
index 000000000..2913f9218
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$1.class
new file mode 100644
index 000000000..a9d18608f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$2.class
new file mode 100644
index 000000000..3bb2623f9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$3.class
new file mode 100644
index 000000000..42c7078eb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$4.class
new file mode 100644
index 000000000..23c02c402
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$5.class
new file mode 100644
index 000000000..435f92d00
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$6.class
new file mode 100644
index 000000000..d1f9fceb4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$7.class
new file mode 100644
index 000000000..84281a401
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd.class
new file mode 100644
index 000000000..8b9368664
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$NoParseOption.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$NoParseOption.class
new file mode 100644
index 000000000..c545200c6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$NoParseOption.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$ShutdownHook.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$ShutdownHook.class
new file mode 100644
index 000000000..c80502410
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$ShutdownHook.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main.class
new file mode 100644
index 000000000..92e58ab1a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Messages.class
new file mode 100644
index 000000000..60939a6c4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$1.class
new file mode 100644
index 000000000..c235028fc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$2.class
new file mode 100644
index 000000000..796154c92
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd.class
new file mode 100644
index 000000000..f328b5480
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$1.class
new file mode 100644
index 000000000..22f45be4b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$10.class
new file mode 100644
index 000000000..b605bd903
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$2.class
new file mode 100644
index 000000000..a53b20002
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$3.class
new file mode 100644
index 000000000..984b442e9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$4.class
new file mode 100644
index 000000000..ef51b17d7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$5.class
new file mode 100644
index 000000000..9cd2cf63a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$6.class
new file mode 100644
index 000000000..248399de8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$7.class
new file mode 100644
index 000000000..d6ad472ac
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$8.class
new file mode 100644
index 000000000..c993d543d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$9.class
new file mode 100644
index 000000000..c53b21a21
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd.class
new file mode 100644
index 000000000..136cfa6e9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$1.class
new file mode 100644
index 000000000..1c2dcac87
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$2.class
new file mode 100644
index 000000000..9221f8540
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$3.class
new file mode 100644
index 000000000..dd58e5a30
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$4.class
new file mode 100644
index 000000000..aa5557d9d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$5.class
new file mode 100644
index 000000000..75c316a5e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$6.class
new file mode 100644
index 000000000..ca9c253c7
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd.class b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd.class
new file mode 100644
index 000000000..fe9ea3e4c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Messages.class
new file mode 100644
index 000000000..8162e115b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$1.class
new file mode 100644
index 000000000..7d8087cf6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$2.class
new file mode 100644
index 000000000..be26525db
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$3.class
new file mode 100644
index 000000000..841b795e6
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$HandleFile.class b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$HandleFile.class
new file mode 100644
index 000000000..e7f6eab48
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$HandleFile.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII.class b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII.class
new file mode 100644
index 000000000..3a2bd54af
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$1.class
new file mode 100644
index 000000000..81975151a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$2.class
new file mode 100644
index 000000000..f87a12e80
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$3.class
new file mode 100644
index 000000000..f5a91597b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$4.class
new file mode 100644
index 000000000..df3cba930
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$5.class
new file mode 100644
index 000000000..0c082d0d0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main.class
new file mode 100644
index 000000000..53468e348
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Messages.class
new file mode 100644
index 000000000..f80eceb55
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContext.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContext.class
new file mode 100644
index 000000000..fef9e8bf0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContext.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContextMap.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContextMap.class
new file mode 100644
index 000000000..09d84c05e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContextMap.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap$Entry.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap$Entry.class
new file mode 100644
index 000000000..843d74127
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap$Entry.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap.class b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap.class
new file mode 100644
index 000000000..4fd26d6f3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/AbstractMethodGenerator.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/AbstractMethodGenerator.class
new file mode 100644
index 000000000..a930096be
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/AbstractMethodGenerator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler$MethodRef.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler$MethodRef.class
new file mode 100644
index 000000000..313ad8786
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler$MethodRef.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler.class
new file mode 100644
index 000000000..8f5efc349
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/CompilationError.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/CompilationError.class
new file mode 100644
index 000000000..8953e5c7f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/CompilationError.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Generator.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Generator.class
new file mode 100644
index 000000000..2161af5c8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Generator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/GiopIo.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/GiopIo.class
new file mode 100644
index 000000000..2f8ed63d0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/GiopIo.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/HashFinder.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/HashFinder.class
new file mode 100644
index 000000000..16602c561
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/HashFinder.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$1.class
new file mode 100644
index 000000000..a1d9d5ad0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$10.class
new file mode 100644
index 000000000..2fca747eb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$10.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$11.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$11.class
new file mode 100644
index 000000000..595b1c334
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$11.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$12.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$12.class
new file mode 100644
index 000000000..25b43e13e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$12.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$13.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$13.class
new file mode 100644
index 000000000..164a8b191
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$13.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$14.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$14.class
new file mode 100644
index 000000000..525c849f9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$14.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$15.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$15.class
new file mode 100644
index 000000000..e49a39de9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$15.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$16.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$16.class
new file mode 100644
index 000000000..7dc9274e9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$16.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$17.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$17.class
new file mode 100644
index 000000000..d162862fd
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$17.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$18.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$18.class
new file mode 100644
index 000000000..5eb04cf91
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$18.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$2.class
new file mode 100644
index 000000000..4ab4ef52c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$3.class
new file mode 100644
index 000000000..f4e3f569a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$4.class
new file mode 100644
index 000000000..bff2a625b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$5.class
new file mode 100644
index 000000000..1e8a4a49d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$6.class
new file mode 100644
index 000000000..6472ff9f4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$7.class
new file mode 100644
index 000000000..68bc216ef
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$7.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$8.class
new file mode 100644
index 000000000..57fa66e4e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$8.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$9.class
new file mode 100644
index 000000000..1aafd5883
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$9.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main.class
new file mode 100644
index 000000000..f86dafaf9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Messages.class
new file mode 100644
index 000000000..1a73827b3
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/MethodGenerator.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/MethodGenerator.class
new file mode 100644
index 000000000..1dcbac85b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/MethodGenerator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RMICException.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RMICException.class
new file mode 100644
index 000000000..221530b6b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RMICException.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmiMethodGenerator.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmiMethodGenerator.class
new file mode 100644
index 000000000..e6a69af16
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmiMethodGenerator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmicBackend.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmicBackend.class
new file mode 100644
index 000000000..7c08d1aa4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmicBackend.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.class
new file mode 100644
index 000000000..955983bf1
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceRmicCompiler.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceRmicCompiler.class
new file mode 100644
index 000000000..a8f2f7ab0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceRmicCompiler.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Variables.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Variables.class
new file mode 100644
index 000000000..c9b4581dc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Variables.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/WrapUnWrapper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/WrapUnWrapper.class
new file mode 100644
index 000000000..f1518ea6c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/WrapUnWrapper.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl.class
new file mode 100644
index 000000000..a40f04b94
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.class
new file mode 100644
index 000000000..8b798b3ad
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$1.class
new file mode 100644
index 000000000..734ee8ede
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$2.class
new file mode 100644
index 000000000..ed0bbd52e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$3.class
new file mode 100644
index 000000000..ec4d93890
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$4.class
new file mode 100644
index 000000000..3e135b64e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$5.class
new file mode 100644
index 000000000..e1262c249
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$6.class
new file mode 100644
index 000000000..4857ddf44
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main.class
new file mode 100644
index 000000000..5e51a69f0
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Messages.class
new file mode 100644
index 000000000..0c639221c
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$AdaptedReader.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$AdaptedReader.class
new file mode 100644
index 000000000..e45236487
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$AdaptedReader.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$WriteToDiskTask.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$WriteToDiskTask.class
new file mode 100644
index 000000000..d2bf71d7b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$WriteToDiskTask.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable.class
new file mode 100644
index 000000000..f7f22a036
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$1.class
new file mode 100644
index 000000000..997c9aafb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$2.class
new file mode 100644
index 000000000..c085e4898
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$3.class
new file mode 100644
index 000000000..89f61c98b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$4.class
new file mode 100644
index 000000000..d202e7f74
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$5.class
new file mode 100644
index 000000000..4f96cb76b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$5.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$6.class
new file mode 100644
index 000000000..34ef99e72
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$6.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main.class
new file mode 100644
index 000000000..3c80e67b9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Messages.class
new file mode 100644
index 000000000..b100ea716
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable$WriteToDiskTask.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable$WriteToDiskTask.class
new file mode 100644
index 000000000..f08619a5e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable$WriteToDiskTask.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable.class
new file mode 100644
index 000000000..92304dccb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl.class
new file mode 100644
index 000000000..a369b063f
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.class
new file mode 100644
index 000000000..50d6faf3d
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.class b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.class
new file mode 100644
index 000000000..19b12483e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/Messages.class
new file mode 100644
index 000000000..d670a68cf
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$1.class
new file mode 100644
index 000000000..5d3be8209
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$2.class
new file mode 100644
index 000000000..a0a4470b9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$3.class
new file mode 100644
index 000000000..5a544fdbd
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer.class
new file mode 100644
index 000000000..fd84c775a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet$EmailReplacement.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet$EmailReplacement.class
new file mode 100644
index 000000000..1cc5913e8
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet$EmailReplacement.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet.class
new file mode 100644
index 000000000..5050e4f9e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CodeTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CodeTaglet.class
new file mode 100644
index 000000000..051e7849a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CodeTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CopyrightTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CopyrightTaglet.class
new file mode 100644
index 000000000..d957f4cd4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CopyrightTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/DeprecatedTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/DeprecatedTaglet.class
new file mode 100644
index 000000000..5e5946eca
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/DeprecatedTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GenericTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GenericTaglet.class
new file mode 100644
index 000000000..6b767ee48
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GenericTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GnuExtendedTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GnuExtendedTaglet.class
new file mode 100644
index 000000000..b05eabb18
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GnuExtendedTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/SinceTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/SinceTaglet.class
new file mode 100644
index 000000000..484814018
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/SinceTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/TagletContext.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/TagletContext.class
new file mode 100644
index 000000000..9eb4b599a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/TagletContext.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/ValueTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/ValueTaglet.class
new file mode 100644
index 000000000..185f8e4b5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/ValueTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/VersionTaglet.class b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/VersionTaglet.class
new file mode 100644
index 000000000..cde2ca6bf
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/VersionTaglet.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$1.class
new file mode 100644
index 000000000..ee6404f80
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$2.class
new file mode 100644
index 000000000..620e9d484
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main.class
new file mode 100644
index 000000000..f09eb77db
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Messages.class b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Messages.class
new file mode 100644
index 000000000..c9b9175cc
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$PtrMarks.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$PtrMarks.class
new file mode 100644
index 000000000..59094b9c9
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$PtrMarks.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$SizeKind.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$SizeKind.class
new file mode 100644
index 000000000..10f7cd4d2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$SizeKind.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap.class
new file mode 100644
index 000000000..a95d09c82
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BytePtr.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BytePtr.class
new file mode 100644
index 000000000..c5a812e90
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BytePtr.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ItemList.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ItemList.class
new file mode 100644
index 000000000..9dede17d2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ItemList.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1$Info.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1$Info.class
new file mode 100644
index 000000000..139b2f72b
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1$Info.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1.class
new file mode 100644
index 000000000..b4df37b3e
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$2.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$2.class
new file mode 100644
index 000000000..62b81fcc4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$2.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$3.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$3.class
new file mode 100644
index 000000000..8c6fb89c5
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$3.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$4.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$4.class
new file mode 100644
index 000000000..427ee70fa
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$4.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$OptionParser.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$OptionParser.class
new file mode 100644
index 000000000..c600eadd4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$OptionParser.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$SubstringComparator.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$SubstringComparator.class
new file mode 100644
index 000000000..6205c1936
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$SubstringComparator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze.class
new file mode 100644
index 000000000..999617030
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$Range.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$Range.class
new file mode 100644
index 000000000..72d9ee0a4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$Range.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$RangeComparator.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$RangeComparator.class
new file mode 100644
index 000000000..7f2521b62
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$RangeComparator.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap.class
new file mode 100644
index 000000000..24b70a22a
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap$ObjectItem.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap$ObjectItem.class
new file mode 100644
index 000000000..4a27d3fd4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap$ObjectItem.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap.class
new file mode 100644
index 000000000..9c7d96da4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolLookup.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolLookup.class
new file mode 100644
index 000000000..7099959e2
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolLookup.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolTable.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolTable.class
new file mode 100644
index 000000000..5195657c4
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolTable.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ToolPrefix.class b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ToolPrefix.class
new file mode 100644
index 000000000..2224a23bb
--- /dev/null
+++ b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ToolPrefix.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/sun/rmi/rmic/Main.class b/libjava/classpath/tools/classes/sun/rmi/rmic/Main.class
new file mode 100644
index 000000000..42ce06a00
--- /dev/null
+++ b/libjava/classpath/tools/classes/sun/rmi/rmic/Main.class
Binary files differ
diff --git a/libjava/classpath/tools/classes/sun/rmi/rmic/Messages.class b/libjava/classpath/tools/classes/sun/rmi/rmic/Messages.class
new file mode 100644
index 000000000..87b8b987c
--- /dev/null
+++ b/libjava/classpath/tools/classes/sun/rmi/rmic/Messages.class
Binary files differ
diff --git a/libjava/classpath/tools/com/sun/javadoc/ClassDoc.java b/libjava/classpath/tools/com/sun/javadoc/ClassDoc.java
new file mode 100644
index 000000000..6309f9472
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/ClassDoc.java
@@ -0,0 +1,321 @@
+/* ClassDoc.java -- Document a Java class or interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+public interface ClassDoc extends ProgramElementDoc, Type
+{
+
+/**
+ * This method tests whether or not the class represented by this object
+ * is abstract.
+ *
+ * @return <code>true</code> if the class is abstract, <code>false</code>,
+ * otherwise.
+ */
+public abstract boolean
+isAbstract();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not the class represented by this object
+ * is serializable. That is, whether or not the class implements the
+ * <code>java.io.Serializable</code> interface. This includes classes
+ * which are externalizable.
+ *
+ * @return <code>true</code> if the class is serializable,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isSerializable();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not the class represented by this object
+ * is externalizable. That is, whether or not the class implements the
+ * <code>java.io.Externalizable</code> interface.
+ *
+ * @return <code>true</code> if the class is externalizable,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isExternalizable();
+
+/*************************************************************************/
+
+/**
+ * This method returns the serialization methods for the class
+ * represented by this object. Is the custom readObject/writeObject
+ * methods?
+ *
+ * @return The serialization methods for this class.
+ */
+public abstract MethodDoc[]
+serializationMethods();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of fields that are serialized in this
+ * class. This will return either the list of fields with an
+ * "@serial" declaration, or, if it exists, the
+ * <code>serialPersistentField</code> field.
+ *
+ * @return The list of serializable fields.
+ */
+public abstract FieldDoc[]
+serializableFields();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not the class represented by this object
+ * specifically defines its serializable fields in a
+ * <code>serialPersistentFields</code> field.
+ *
+ * @return <code>true</code> if this class explicitly defines its
+ * serializable fields, <code>false</code> otherwise.
+ */
+public abstract boolean
+definesSerializableFields();
+
+/*************************************************************************/
+
+/**
+ * This method returns the superclass of the class represented by this
+ * object.
+ *
+ * @return The superclass of this class.
+ */
+public abstract ClassDoc
+superclass();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not the class represented by this object is
+ * a subclass of the specified class.
+ *
+ * @param cls The <code>ClassDoc</code> object of the class to test against.
+ *
+ * @return <code>true</code> if this class is a subclass of the specified
+ * class, <code>false</code> otherwise.
+ */
+public abstract boolean
+subclassOf(ClassDoc cls);
+
+/*************************************************************************/
+
+/**
+ * This method returns this list of interfaces implemented (or in the case
+ * of interfaces, extended) by this class. This list will only include
+ * interfaces directly implemented by this class, not those inherited by
+ * interfaced implemented in this class.
+ *
+ * @return The list of interfaces this class implements.
+ */
+public abstract ClassDoc[]
+interfaces();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of fields that are visible to the user in
+ * this class, or the list of all fields in this class.
+ *
+ * @param filtered if true, only return visible (included) fields;
+ * otherwise, return all fields.
+ *
+ * @return The list of visible fields in this class, or the list of
+ * all fields in this class.
+ */
+public abstract FieldDoc[]
+fields(boolean filtered);
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of fields that are visible to the user in
+ * this class. Does this depend on the -private -protected, etc flags
+ * passed to javadoc?
+ *
+ * @return The list of visible fields in this class.
+ */
+public abstract FieldDoc[]
+fields();
+
+/*************************************************************************/
+
+/**
+ * This method returns either the list of methods that are visible to
+ * the user in the class represented by this object, or a list of all
+ * methods, excluding constructor methods.
+ *
+ * @param filtered if true, only return visible (included) methods;
+ * otherwise, return all methods.
+ *
+ * @return The list of all methods in this class, or the list of
+ * visible methods in this class.
+ */
+public abstract MethodDoc[]
+methods(boolean filtered);
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of methods that are visible to the user in
+ * the class represented by this object, excluding constructor methods.
+ *
+ * @return The list of visible methods in this class.
+ */
+public abstract MethodDoc[]
+methods();
+
+/*************************************************************************/
+
+/**
+ * This method returns either the list of constructors that are
+ * visible to the user in the class represented by this object, or
+ * the list of all constructors.
+ *
+ * @param filtered if true, only return visible (included)
+ * constructors; otherwise, return all constructors.
+ *
+ * @return The list of all constructors in this class, or the list
+ * of visible constructors in this class.
+ */
+public abstract ConstructorDoc[]
+constructors(boolean filtered);
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of constructors that are visible to the user
+ * in the class represented by this object.
+ *
+ * @return The list visible constructors in this class.
+ */
+public abstract ConstructorDoc[]
+constructors();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of inner classes that are visible to
+ * the user within the class represented by this object.
+ *
+ * @return The list of visible inner classes for this object.
+ */
+public abstract ClassDoc[]
+innerClasses();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of all inner classes within the class
+ * represented by this object, or the list of visible inner classes
+ * in this class.
+ *
+ * @param filtered if true, only return visible (included) inner
+ * classes; otherwise, return all inner classes.
+ *
+ * @return The list of all inner classes for this object, or the list
+ * of visible inner classes.
+ */
+public abstract ClassDoc[]
+innerClasses(boolean filtered);
+
+/*************************************************************************/
+
+/**
+ * This method returns a <code>ClassDoc</code> for the named class. The
+ * following search order is used:
+ * <p>
+ * <ol>
+ * <li>Fully qualified class name.
+ * <li>Inner classes within this class.
+ * <li>In the current package.
+ * <li>In the imports for this class.
+ * </ol>
+ *
+ * @param name The name of the class to find.
+ *
+ * @return The requested class, or <code>null</code> if the requested
+ * class cannot be found.
+ */
+public abstract ClassDoc
+findClass(String name);
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of classes that are imported. This
+ * excludes any imports of complete packages.
+ *
+ * @return The list of imported classes.
+ */
+public abstract ClassDoc[]
+importedClasses();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of packages that are imported. This
+ * excludes any individual class imports.
+ *
+ * @return The list of imported packages.
+ */
+public abstract PackageDoc[]
+importedPackages();
+
+/*************************************************************************/
+
+/**
+ * This method returns the formal type parameters of this class.
+ * The returned array is empty if the class does not represent a
+ * parameterized type.
+ *
+ * @return The list of type parameters.
+ * @since 1.5
+ */
+TypeVariable[]
+typeParameters();
+
+} // interface ClassDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/ConstructorDoc.java b/libjava/classpath/tools/com/sun/javadoc/ConstructorDoc.java
new file mode 100644
index 000000000..88c8d3ddb
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/ConstructorDoc.java
@@ -0,0 +1,56 @@
+/* ConstructorDoc.java -- Document a Java class constructor
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface is used for documenting constructors.
+ */
+public interface ConstructorDoc extends ExecutableMemberDoc
+{
+
+/**
+ * This method returns the qualified name of the constructor. What is this
+ * really?
+ *
+ * @return The qualified name of the constructor.
+ */
+public abstract String
+qualifiedName();
+
+} // interface ConstructorDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/Doc.java b/libjava/classpath/tools/com/sun/javadoc/Doc.java
new file mode 100644
index 000000000..554720d69
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/Doc.java
@@ -0,0 +1,264 @@
+/* Doc.java -- Model of an item to document.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface is the super-interface of all items that can have
+ * Javadoc comments associated with them.
+ */
+public interface Doc extends java.io.Serializable, Comparable
+{
+
+/**
+ * This method returns the text of the comment for this item, with all
+ * tags stripped.
+ *
+ * @return The comment text for this item.
+ */
+public abstract String
+commentText();
+
+/*************************************************************************/
+
+/**
+ * This method returns an array of all the tags in this item.
+ *
+ * @return An array of tags for this item.
+ */
+public abstract Tag[]
+tags();
+
+/*************************************************************************/
+
+/**
+ * This method returns an array of all the tags of the specified type
+ * in this item.
+ *
+ * @param tagtype The name of the tag type to return.
+ *
+ * @return A list of all tags of the specified type.
+ */
+public abstract Tag[]
+tags(String tagtype);
+
+/*************************************************************************/
+
+/**
+ * This method returns an array of all tags of the "@see" type.
+ *
+ * @return An array of tags of the "@see" type
+ */
+public abstract SeeTag[]
+seeTags();
+
+/*************************************************************************/
+
+/**
+ * This method returns the comment text as an array of tags. This will
+ * include any inline tags, but no regular tags. Regular text is returned
+ * as a type of <code>Text</code>. Inline "@see" tags are returned as
+ * type <code>SeeTag</code>.
+ *
+ * @return The comment text as tags.
+ */
+public abstract Tag[]
+inlineTags();
+
+/*************************************************************************/
+
+/**
+ * This method returns the first sentence of the comment text as an array
+ * of tags. This will include any inline tags, but no regular tags.
+ * Regular text is returned as a type of <code>Text</code>. Inline "@see"
+ * tags are returned as type <code>SeeTag</code>.
+ *
+ * @return An array of tags representing the first sentence of the comment
+ * text.
+ */
+public abstract Tag[]
+firstSentenceTags();
+
+/*************************************************************************/
+
+/**
+ * This method returns the text of the comment in an unprocessed format.
+ * Any Javadoc tags will remain as written in the text.
+ *
+ * @return The unprocessed comment text.
+ */
+public abstract String
+getRawCommentText();
+
+/*************************************************************************/
+
+/**
+ * This method sets the unprocessed comment text for this item.
+ *
+ * @param rawtext The unprocessed comment text for this itme.
+ */
+public abstract void
+setRawCommentText(String rawtext);
+
+/*************************************************************************/
+
+/**
+ * This method returns the name of this item.
+ *
+ * @return The name of this item.
+ */
+public abstract String
+name();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is a field.
+ *
+ * @return <code>true</code> if this item is a field, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isField();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is a method.
+ *
+ * @return <code>true</code> if this item is a method, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isMethod();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is a constructor.
+ *
+ * @return <code>true</code> if this item is a constructor,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isConstructor();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is an interface.
+ *
+ * @return <code>true</code> if this item is an interface,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isInterface();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is an exception.
+ *
+ * @return <code>true</code> if this item is an exception,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isException();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is an error.
+ *
+ * @return <code>true</code> if this item is an error,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isError();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is a class. Interfaces
+ * do not count as classes.
+ *
+ * @return <code>true</code> if this item is a class,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isClass();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is an ordinary class. An
+ * ordinary class is a class that is not an exception or an error.
+ * Interfaces also do not count because they are not considered classes at
+ * all.
+ *
+ * @return <code>true</code> if this item is an ordinary class,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isOrdinaryClass();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this item is part of the active set,
+ * whatever that is.
+ *
+ * @return <code>true</code> if this item is part of the active set,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isIncluded();
+
+/*************************************************************************/
+
+/**
+ * This method returns the location of the item within the Java
+ * source code.
+ *
+ * @return an object describing the file, line and column where this
+ * item is defined.
+ */
+public abstract SourcePosition
+position();
+
+} // interface Doc
diff --git a/libjava/classpath/tools/com/sun/javadoc/DocErrorReporter.java b/libjava/classpath/tools/com/sun/javadoc/DocErrorReporter.java
new file mode 100644
index 000000000..2e801b848
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/DocErrorReporter.java
@@ -0,0 +1,76 @@
+/* DocErrorReporter.java -- Log errors/warnings during doc generation.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface provides a mechanism for a doclet to log messages
+ * during its run.
+ */
+public interface DocErrorReporter
+{
+
+/**
+ * This method prints the specified error message.
+ *
+ * @param err The error message to print.
+ */
+public abstract void
+printError(String err);
+
+/*************************************************************************/
+
+/**
+ * This method prints the specified warning message.
+ *
+ * @param warn The warning message to print.
+ */
+public abstract void
+printWarning(String warn);
+
+/*************************************************************************/
+
+/**
+ * This method prints the specifed message.
+ *
+ * @param msg The message to print.
+ */
+public abstract void
+printNotice(String notice);
+
+} // interface DocErrorReporter
diff --git a/libjava/classpath/tools/com/sun/javadoc/Doclet.java b/libjava/classpath/tools/com/sun/javadoc/Doclet.java
new file mode 100644
index 000000000..172387ebb
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/Doclet.java
@@ -0,0 +1,98 @@
+/* Doclet.java -- Doclet API
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This class documents the method that must be implemented by a doclet.
+ * It may be used as the superclass of a doclet, but this is not required.
+ * As long as the doclet implements the <code>start</code> method, all is ok.
+ */
+public abstract class Doclet
+{
+
+/**
+ * This is the entry point to a doclet. All doclets must implement this
+ * method.
+ *
+ * @param rd The <code>RootDoc</code> instance for this javadoc run.
+ *
+ * @return <code>true</code> on success, <code>false</code> on failure.
+ */
+public static boolean
+start(RootDoc root)
+{
+ return(false);
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the number of arguments to the option, including
+ * the option itself. This is not required of doclets.
+ *
+ * @param opt The option to check.
+ *
+ * @return The number of arguments to the option, or zero if the option is
+ * unknown, or a negative number if an error occurred.
+ */
+public static int
+optionLength(String opt)
+{
+ return(0);
+}
+
+/*************************************************************************/
+
+/**
+ * This method is called to verify that the options supplied by the caller
+ * are valid. This is not required of doclets.
+ *
+ * @param opts The list of options supplied by the user.
+ * @param logger A mechanism for this method to report errors to the user.
+ *
+ * @return <code>true</code> if the options are valid, <code>false</code>
+ * otherwise.
+ */
+public static boolean
+validOptions(String[][] opts, DocErrorReporter logger)
+{
+ return(true);
+}
+
+} // class Doclet
diff --git a/libjava/classpath/tools/com/sun/javadoc/ExecutableMemberDoc.java b/libjava/classpath/tools/com/sun/javadoc/ExecutableMemberDoc.java
new file mode 100644
index 000000000..ac0ca06f7
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/ExecutableMemberDoc.java
@@ -0,0 +1,137 @@
+/* ExecutableMemberDoc.java -- Document methods and constructors
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This is the super-interface for interfaces describing constructors and
+ * methods.
+ */
+public interface ExecutableMemberDoc extends MemberDoc
+{
+
+/**
+ * This method returns a list of all the execeptions that are declared
+ * to be thrown in this method or constructor.
+ *
+ * @return The list of exceptions for this method.
+ */
+public abstract ClassDoc[]
+thrownExceptions();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this method/constructor is native.
+ *
+ * @return <code>true</code> if the method is native, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isNative();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this method/constructor is
+ * synchronized.
+ *
+ * @return <code>true</code> if the method is synchronized,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isSynchronized();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of parameters for this method/constructor.
+ *
+ * @return The list of parameters for this method.
+ */
+public abstract Parameter[]
+parameters();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of "@throws" and "@exception" tags in this
+ * method/constructor.
+ *
+ * @return The list of exception doc tags.
+ */
+public abstract ThrowsTag[]
+throwsTags();
+
+/*************************************************************************/
+
+/**
+ * This method return the list of "@param" tags in this method/constructor.
+ *
+ * @return The list of parameter doc tags for this method.
+ */
+public abstract ParamTag[]
+paramTags();
+
+/*************************************************************************/
+
+/**
+ * This method returns the signature of this method in pseudo-code format,
+ * with fully qualified class references. For example, the method
+ * <code>read(String str, boolean bool)</code> would have the signature
+ * <code>(java.lang.String, boolean)</code> returned by this method.
+ *
+ * @return The signature for this method.
+ */
+public abstract String
+signature();
+
+/*************************************************************************/
+
+/**
+ * This method returns the signature of this method in pseudo-code format,
+ * with uqualified class references. For example, the method
+ * <code>read(String str, boolean bool)</code> would have the signature
+ * <code>(String, boolean)</code> returned by this method.
+ *
+ * @return The signature for this method.
+ */
+public abstract String
+flatSignature();
+
+} // interface ExecutableMemberDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/FieldDoc.java b/libjava/classpath/tools/com/sun/javadoc/FieldDoc.java
new file mode 100644
index 000000000..1fd0c7b83
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/FieldDoc.java
@@ -0,0 +1,112 @@
+/* FieldDoc.java -- Document a field
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This package is used for documenting fields.
+ */
+public interface FieldDoc extends MemberDoc
+{
+
+/**
+ * This method returns the type of this field.
+ *
+ * @return The type of this field.
+ */
+public abstract Type
+type();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not the field is transient.
+ *
+ * @return <code>true</code> if the field is transient, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isTransient();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not the field is volatile.
+ *
+ * @return <code>true</code> if the field is volatile, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isVolatile();
+
+/*************************************************************************/
+
+/**
+ * This method returns a list of all "@serialField" tags defined in this
+ * field.
+ *
+ * @return The list of "@serialField" tags for this field.
+ */
+public abstract SerialFieldTag[]
+serialFieldTags();
+
+/*************************************************************************/
+
+/**
+ * This method returns the value of this static field.
+ *
+ * @return The value of this static field.
+ */
+public abstract Object
+constantValue();
+
+
+/*************************************************************************/
+
+/**
+ * This method returns the value of this static field converted to a
+ * human-readable string.
+ *
+ * @return The value of this static field as a human-readable string.
+ */
+public abstract String
+constantValueExpression();
+
+
+
+} // interface FieldDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/MemberDoc.java b/libjava/classpath/tools/com/sun/javadoc/MemberDoc.java
new file mode 100644
index 000000000..9e755bbd6
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/MemberDoc.java
@@ -0,0 +1,59 @@
+/* MemberDoc.java -- Common ops for documenting fields, methods,
+ and constructors
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This is the common super-interface for documentation about fields,
+ * methods, and constructors.
+ */
+public interface MemberDoc extends ProgramElementDoc
+{
+
+/**
+ * This method tests whether the member in question was created implicitly
+ * by the compiler.
+ *
+ * @return <code>true</code> if this member was synthesized by the compiler,
+ * </code>false</code> otherwise.
+ */
+public abstract boolean
+isSynthetic();
+
+} // interface MemberDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/MethodDoc.java b/libjava/classpath/tools/com/sun/javadoc/MethodDoc.java
new file mode 100644
index 000000000..87129ef44
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/MethodDoc.java
@@ -0,0 +1,79 @@
+/* MethodDoc.java -- Document a method
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface is used for documenting ordinary (ie, non-constructor)
+ * methods.
+ */
+public interface MethodDoc extends ExecutableMemberDoc
+{
+
+/**
+ * This method tests whether or not the method to be documented is abstract.
+ *
+ * @return <code>true</code> if the method is abstract, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isAbstract();
+
+/*************************************************************************/
+
+/**
+ * This method returns the return type of the method to be documented.
+ *
+ * @return The return type of the method to be documented.
+ */
+public abstract Type
+returnType();
+
+/*************************************************************************/
+
+/**
+ * This method returns the class containing the method that this method is
+ * overriding.
+ *
+ * @return The class containing the method that this method is overriding,
+ * or <code>null</code> if this class is not overriding a method.
+ */
+public abstract ClassDoc
+overriddenClass();
+
+} // interface MethodDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/PackageDoc.java b/libjava/classpath/tools/com/sun/javadoc/PackageDoc.java
new file mode 100644
index 000000000..4518b4eba
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/PackageDoc.java
@@ -0,0 +1,108 @@
+/* PackageDoc.java -- Document a package
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+public interface PackageDoc extends Doc
+{
+
+/**
+ * This method returns a list of all the classes and interfaces in
+ * this package. This list will included exceptions and errors.
+ *
+ * @return The list of classes and interfaces for this package.
+ */
+public abstract ClassDoc[]
+allClasses();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of ordinary classes in this package. This
+ * list will not include any interface, exceptions or errors.
+ *
+ * @return The list of ordinary classes in this package.
+ */
+public abstract ClassDoc[]
+ordinaryClasses();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of exceptions in this package.
+ *
+ * @return The list of exceptions in this package.
+ */
+public abstract ClassDoc[]
+exceptions();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of errors in this package.
+ *
+ * @return The list of errors in this package.
+ */
+public abstract ClassDoc[]
+errors();
+
+/*************************************************************************/
+
+/**
+ * This method returns the list of interfaces in this package.
+ *
+ * @return The list of interfaces in this package.
+ */
+public abstract ClassDoc[]
+interfaces();
+
+/*************************************************************************/
+
+/**
+ * This method returns a <code>ClassDoc</code> instance for the specified
+ * class.
+ *
+ * @param name The name of the class to return.
+ *
+ * @return The requested <code>ClassDoc</code> or <code>null</code> if
+ * this class not part of this javadoc run.
+ */
+public abstract ClassDoc
+findClass(String cls);
+
+} // interface PackageDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/ParamTag.java b/libjava/classpath/tools/com/sun/javadoc/ParamTag.java
new file mode 100644
index 000000000..9c060e901
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/ParamTag.java
@@ -0,0 +1,65 @@
+/* ParamTag.java -- Documentation tag for method parameters
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface represents an "@param" tag.
+ */
+public interface ParamTag extends Tag
+{
+
+/**
+ * This method returns the comment text for the parameter.
+ *
+ * @return The comment text for the parameter.
+ */
+public abstract String
+parameterComment();
+
+/*************************************************************************/
+
+/**
+ * This method returns the name of the parameter.
+ *
+ * @return The name of the parameter.
+ */
+public abstract String
+parameterName();
+
+} // interface ParamTag
diff --git a/libjava/classpath/tools/com/sun/javadoc/Parameter.java b/libjava/classpath/tools/com/sun/javadoc/Parameter.java
new file mode 100644
index 000000000..300a3355a
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/Parameter.java
@@ -0,0 +1,87 @@
+/* Parameter.java -- Information about parameters to methods.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface models a parameter to a method.
+ */
+public interface Parameter extends java.io.Serializable
+{
+
+/**
+ * This method returns the type of the parameter.
+ *
+ * @return The parameter type.
+ */
+public abstract Type
+type();
+
+/*************************************************************************/
+
+/**
+ * This method returns the name of the parameter.
+ *
+ * @return The parameter name.
+ */
+public abstract String
+name();
+
+/*************************************************************************/
+
+/**
+ * This method returns the name of the type of the parameter as a
+ * <code>String</code>.
+ *
+ * @return The name of the type of this parameter.
+ */
+public abstract String
+typeName();
+
+/*************************************************************************/
+
+/**
+ * This method returns this parameter as a <code>String</code> that
+ * contains both the type name and parameter name.
+ *
+ * @return This parameter as a <code>String</code>.
+ */
+public abstract String
+toString();
+
+} // interaface Parameter
diff --git a/libjava/classpath/tools/com/sun/javadoc/ProgramElementDoc.java b/libjava/classpath/tools/com/sun/javadoc/ProgramElementDoc.java
new file mode 100644
index 000000000..061e327e1
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/ProgramElementDoc.java
@@ -0,0 +1,169 @@
+/* ProgramElementDoc.java -- Common ops for all program elements.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This is the comment super-interface of all items that are "program
+ * elements". This includes classes, interfaces, fields, constructors,
+ * and methods.
+ */
+public interface ProgramElementDoc extends Doc
+{
+
+/**
+ * This method returns the class which contains this element. If this
+ * is a class that is not an inner class, <code>null</code> will be
+ * returned.
+ *
+ * @returned The class element that contains this item, or <code>null</code>
+ * if this item is a class that is not an inner class.
+ */
+public abstract ClassDoc
+containingClass();
+
+/*************************************************************************/
+
+/**
+ * This method returns the package which contains this element. If this
+ * element is in the default generic package, then the name of the
+ * package element returned will be "".
+ *
+ * @return The package element that contains this item.
+ */
+public abstract PackageDoc
+containingPackage();
+
+/*************************************************************************/
+
+/**
+ * This method returns the fully qualified name of this element.
+ *
+ * @return The fully qualified name of this element.
+ */
+public abstract String
+qualifiedName();
+
+/*************************************************************************/
+
+/**
+ * This method returns the modifier specificier number, which is what?
+ *
+ * @return The modifier for this element.
+ */
+public abstract int
+modifierSpecifier();
+
+/*************************************************************************/
+
+/**
+ * This method returns a string with the element modifiers. For example,
+ * the modifiers of a method declaration might be "protected abstract".
+ *
+ * @return The modifier string.
+ */
+public abstract String
+modifiers();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this element is public.
+ *
+ * @return <code>true</code> if this element is public, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isPublic();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this element is protected.
+ *
+ * @return <code>true</code> if this element is protected, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isProtected();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this element is private.
+ *
+ * @return <code>true</code> if this element is private, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isPrivate();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this element is package private.
+ *
+ * @return <code>true</code> if this element is package private,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isPackagePrivate();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this element is static.
+ *
+ * @return <code>true</code> if this element is static, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isStatic();
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not this element is final.
+ *
+ * @return <code>true</code> if this element is final, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+isFinal();
+
+} // interface ProgramElementDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/RootDoc.java b/libjava/classpath/tools/com/sun/javadoc/RootDoc.java
new file mode 100644
index 000000000..18be71dde
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/RootDoc.java
@@ -0,0 +1,111 @@
+/* RootDoc.java -- Information about a javadoc run.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package com.sun.javadoc;
+
+/**
+ * This interface is the root of the javadoc application. All the properties and
+ * arguments are attached to the class that will implements this interface. You
+ * can retrieve all the options of the tool with this interface.
+ */
+public interface RootDoc extends Doc, DocErrorReporter
+{
+
+ /**
+ * This method returns the command line element used to invoke this instance
+ * of javadoc.
+ *
+ * @return The command line arguments for this run.
+ */
+ public abstract String[][] options();
+
+ /** ********************************************************************** */
+
+ /**
+ * This method returns the list of packages that were specified on the command
+ * line.
+ *
+ * @return The packages specified on the command line.
+ */
+ public abstract PackageDoc[] specifiedPackages();
+
+ /** ********************************************************************** */
+
+ /**
+ * This method returns the list of classes that were specified on the command
+ * line.
+ *
+ * @return The classes specified on the command line.
+ */
+ public abstract ClassDoc[] specifiedClasses();
+
+ /** ********************************************************************** */
+
+ /**
+ * This method returns the list of classes and interfaces to be documented.
+ *
+ * @return The list of classes and interfaces to be documented.
+ */
+ public abstract ClassDoc[] classes();
+
+ /** ********************************************************************** */
+
+ /**
+ * This method returns a <code>ClassDoc</code> instance for the name class
+ * or interface.
+ *
+ * @param name
+ * The class or interface to look up.
+ * @return The requested <code>ClassDoc</code>, or null if the specified
+ * class is not part of this javadoc run.
+ */
+ public abstract ClassDoc classNamed(String name);
+
+ /** ********************************************************************** */
+
+ /**
+ * This method returns a <code>PackageDoc</code> instance for the named
+ * package.
+ *
+ * @param name
+ * The package to look up.
+ * @return The requested <code>PackageDoc</code>, or null if the specified
+ * package is not part of this javadoc run.
+ */
+ public abstract PackageDoc packageNamed(String name);
+
+} // interface RootDoc
diff --git a/libjava/classpath/tools/com/sun/javadoc/SeeTag.java b/libjava/classpath/tools/com/sun/javadoc/SeeTag.java
new file mode 100644
index 000000000..7e5b305ae
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/SeeTag.java
@@ -0,0 +1,108 @@
+/* SeeTag.java -- Information about "@see" tags.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface models an "@see" tag.
+ */
+public interface SeeTag extends Tag
+{
+
+/**
+ * This method returns the label for this tag. What is this????
+ *
+ * @return The label for this tag.
+ */
+public abstract String
+label();
+
+/*************************************************************************/
+
+/**
+ * This method returns the package of the referenced item.
+ *
+ * @return The package of the referenced item, or <code>null</code> if no
+ * package is found.
+ */
+public abstract PackageDoc
+referencedPackage();
+
+/*************************************************************************/
+
+/**
+ * This method returns the name of the class referenced in the tag.
+ *
+ * @return The name of the class referenced in the tag.
+ */
+public abstract String
+referencedClassName();
+
+/*************************************************************************/
+
+/**
+ * This method returns a <code>ClassDoc</code> instance for the class
+ * referenced in the tag.
+ *
+ * @return A <code>ClassDoc</code> for the class referenced in the tag.
+ */
+public abstract ClassDoc
+referencedClass();
+
+/*************************************************************************/
+
+/**
+ * This method returns the name of the member referenced in the tag.
+ *
+ * @return The name of the member referenced in the tag.
+ */
+public abstract String
+referencedMemberName();
+
+/*************************************************************************/
+
+/**
+ * This method returns a <code>MemberDoc</code> instance for the member
+ * referenced in the tag.
+ *
+ * @return A <code>MemberDoc</code> for the member referenced in the tag.
+ */
+public abstract MemberDoc
+referencedMember();
+
+} // interface SeeTag
diff --git a/libjava/classpath/tools/com/sun/javadoc/SerialFieldTag.java b/libjava/classpath/tools/com/sun/javadoc/SerialFieldTag.java
new file mode 100644
index 000000000..ef692834c
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/SerialFieldTag.java
@@ -0,0 +1,101 @@
+/* SerialFieldTag.java -- Information about the "@serialField" tag.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface models the "@serialField" tag.
+ */
+public interface SerialFieldTag extends Tag, Comparable
+{
+
+/**
+ * This method returns the name of the field.
+ *
+ * @return The name of the field.
+ */
+public abstract String
+fieldName();
+
+/*************************************************************************/
+
+/**
+ * This method returns the type name of the field.
+ *
+ * @return The type name of the field.
+ */
+public abstract String
+fieldType();
+
+/*************************************************************************/
+
+/**
+ * This method returns a <code>ClassDoc</code> instance for the type of
+ * the field. What about primitive types???
+ *
+ * @return A <code>ClassDoc</code> for the field type.
+ */
+public abstract ClassDoc
+fieldTypeDoc();
+
+/*************************************************************************/
+
+/**
+ * This method returns the description of the field.
+ *
+ * @return The description of the field.
+ */
+public abstract String
+description();
+
+/*************************************************************************/
+
+/**
+ * This method compares this object with the specified object in order to
+ * determine proper ordering.
+ *
+ * @param obj The object to compare against.
+ *
+ * @return A negative number if this object is less than the specified
+ * object, zero if the objects are equal, or a positive number if this object
+ * is greater than the specified object.
+ */
+public abstract int
+compareTo(Object obj);
+
+} // interface SerialFieldTag
diff --git a/libjava/classpath/tools/com/sun/javadoc/SourcePosition.java b/libjava/classpath/tools/com/sun/javadoc/SourcePosition.java
new file mode 100644
index 000000000..fff25595f
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/SourcePosition.java
@@ -0,0 +1,68 @@
+/* SourcePosition.java -- Model of a location in a source file.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+import java.io.File;
+
+/**
+ * Represents a location in a source file. This is used by {@link
+ * Doc} to specify at which location an item is defined.
+ */
+public interface SourcePosition
+{
+ /**
+ * Return a File object pointing to the source file.
+ */
+ public File file();
+
+ /**
+ * Return the 1-based line number within the source file.
+ */
+ public int line();
+
+ /**
+ * Return the 1-based column number within the source file.
+ */
+ public int column();
+
+ /**
+ * Return a string in the format "file.toString():line"
+ */
+ public String toString();
+}
diff --git a/libjava/classpath/tools/com/sun/javadoc/Tag.java b/libjava/classpath/tools/com/sun/javadoc/Tag.java
new file mode 100644
index 000000000..88745cb98
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/Tag.java
@@ -0,0 +1,106 @@
+/* Tag.java -- Common operations on Javadoc tags.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This is the super-interface for all Javadoc tags.
+ */
+public interface Tag extends java.io.Serializable
+{
+/**
+ * This method returns the name of the tag.
+ *
+ * @return The name of the tag.
+ */
+public abstract String
+name();
+
+/*************************************************************************/
+
+/**
+ * This method returns the kind of tag. ????
+ *
+ * @return The kind of the tag.
+ */
+public abstract String
+kind();
+
+/*************************************************************************/
+
+/**
+ * This method returns the text for this tag.
+ *
+ * @return The text for this tag.
+ */
+public abstract String
+text();
+
+/*************************************************************************/
+
+/**
+ * This method returns the tag as a <code>String</code>. What kind of
+ * string?
+ *
+ * @return This tag as a <code>String</code>.
+ */
+public abstract String
+toString();
+
+/*************************************************************************/
+
+/**
+ * This method returns the inline tags for this comment.
+ *
+ * @return The inline tags for this comment.
+ */
+public abstract Tag[]
+inlineTags();
+
+/*************************************************************************/
+
+/**
+ * This method returns the first sentence of the doc comment as an array
+ * of <code>Tag</code>'s.
+ *
+ * @return The first sentence of the comment as tags.
+ */
+public abstract Tag[]
+firstSentenceTags();
+
+} // interface Tag
diff --git a/libjava/classpath/tools/com/sun/javadoc/ThrowsTag.java b/libjava/classpath/tools/com/sun/javadoc/ThrowsTag.java
new file mode 100644
index 000000000..0d5a98e85
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/ThrowsTag.java
@@ -0,0 +1,75 @@
+/* ThrowsTag.java -- Information about "@throws" and "@exception" tags.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This interface models an "@exception" or "@throws" tag.
+ */
+public interface ThrowsTag extends Tag
+{
+
+/**
+ * This method returns the name of the exception.
+ *
+ * @return The name of the exception.
+ */
+public abstract String
+exceptionName();
+
+/*************************************************************************/
+
+/**
+ * This method returns the comment text of the exception.
+ *
+ * @return The comment text of the exception.
+ */
+public abstract String
+exceptionComment();
+
+/*************************************************************************/
+
+/**
+ * This method returns the exception class as a <code>ClassDoc</code>.
+ *
+ * @return The exception class as a <code>ClassDoc</code>.
+ */
+public abstract ClassDoc
+exception();
+
+} // interface ThrowsTag
diff --git a/libjava/classpath/tools/com/sun/javadoc/Type.java b/libjava/classpath/tools/com/sun/javadoc/Type.java
new file mode 100644
index 000000000..0aabe0e78
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/Type.java
@@ -0,0 +1,119 @@
+/* Type.java -- Documentation information about Java types.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This class is used for holding information about Java types needed for
+ * documentation.
+ */
+public interface Type extends java.io.Serializable
+{
+
+/**
+ * This method returns the unqualified name of the type, excluding any array
+ * dimension information or brackets.
+ *
+ * @return The unqualified type name, sans array information or brackets.
+ */
+public abstract String
+typeName();
+
+/*************************************************************************/
+
+/**
+ * This method returns the fully qualified name of the type, excluding any
+ * array dimension information or brackets.
+ *
+ * @return The fully qualified type name, sans array information or brackets.
+ */
+public abstract String
+qualifiedTypeName();
+
+/*************************************************************************/
+
+/**
+ * This method returns the array dimensions as brackets.
+ *
+ * @param The array dimensions.
+ */
+public abstract String
+dimension();
+
+/*************************************************************************/
+
+/**
+ * This method returns the unqualfied name of the type, and includes array
+ * dimension information.
+ *
+ * @return The unqualified name of the type, including array dimension info.
+ */
+public abstract String
+toString();
+
+/*************************************************************************/
+
+/**
+ * This method returns this type as a <code>ClassDoc</object>. This is not
+ * a valid operation for primitive types.
+ *
+ * @return A <code>ClassDoc</code> for this type, or <code>null</code> if
+ * this is a primitive type.
+ */
+public abstract ClassDoc
+asClassDoc();
+
+/**
+ * This method returns whether this type represents one of the
+ * built-in Java primitive types.
+ */
+public abstract boolean
+isPrimitive();
+
+/**
+ * Returns this type as a <code>TypeVariable</code>, if it is an
+ * instance of the <code>TypeVariable</code> class. Otherwise,
+ * it returns null.
+ *
+ * @return this cast to a <code>TypeVariable</code> instance, or null
+ * if this is not a type variable.
+ */
+TypeVariable
+asTypeVariable();
+
+} // interface Type
diff --git a/libjava/classpath/tools/com/sun/javadoc/TypeVariable.java b/libjava/classpath/tools/com/sun/javadoc/TypeVariable.java
new file mode 100644
index 000000000..94da50507
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/javadoc/TypeVariable.java
@@ -0,0 +1,73 @@
+/* TypeVariable.java -- Document a Java type variable.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.javadoc;
+
+/**
+ * This class represents a type variable, which is used to parameterize
+ * the types used in a method or class. For example,
+ * <code>List&lt;E&gt;</code> has the type variable, <code>E</code>. Type
+ * variables may have explicit bounds, such as <code>&lt;T extends
+ * Book&gt;</code>, which specifies that the type is a sub-class of
+ * <code>Book</code>.
+ *
+ * @since 1.5
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ */
+public interface TypeVariable
+ extends Type
+{
+
+ /**
+ * Returns the bounds of this type variable. These are the types
+ * represented in the <code>extends</code> clause.
+ *
+ * @return an array of types which specify the bounds of this variable.
+ * The array is empty if there are no explicit bounds.
+ */
+ Type[] bounds();
+
+ /**
+ * Returns the class, interface, method or constructor in which this
+ * type variable was declared.
+ *
+ * @return the owning program element for this type variable.
+ */
+ ProgramElementDoc owner();
+
+}
diff --git a/libjava/classpath/tools/com/sun/tools/doclets/Taglet.java b/libjava/classpath/tools/com/sun/tools/doclets/Taglet.java
new file mode 100644
index 000000000..f4f348d67
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/tools/doclets/Taglet.java
@@ -0,0 +1,63 @@
+/* com.sun.tools.doclets.Taglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package com.sun.tools.doclets;
+
+import com.sun.javadoc.Tag;
+
+public interface Taglet {
+
+ public String getName();
+
+ public boolean inConstructor();
+
+ public boolean inField();
+
+ public boolean inMethod();
+
+ public boolean inOverview();
+
+ public boolean inPackage();
+
+ public boolean inType();
+
+ public boolean isInlineTag();
+
+ public String toString(Tag tag);
+
+ public String toString(Tag[] tagArray);
+}
diff --git a/libjava/classpath/tools/com/sun/tools/javac/Main.java b/libjava/classpath/tools/com/sun/tools/javac/Main.java
new file mode 100644
index 000000000..5c5bc2f25
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/tools/javac/Main.java
@@ -0,0 +1,158 @@
+/* Main.java -- implement com.sun.tools.javac.Main
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.tools.javac;
+
+import gnu.classpath.Configuration;
+import java.io.File;
+import java.io.PrintWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.text.MessageFormat;
+
+public class Main
+{
+ static Constructor ecjConstructor = null;
+ static Method ecjMethod = null;
+
+ static
+ {
+ String classname = "org.eclipse.jdt.internal.compiler.batch.Main";
+ Class klass = null;
+ try
+ {
+ klass = Class.forName(classname);
+ }
+ catch (ClassNotFoundException e)
+ {
+ File jar = new File(Configuration.ECJ_JAR);
+ if (!jar.exists() || !jar.canRead())
+ {
+ String message
+ = MessageFormat.format(Messages.getString("Main.FailedToRead"),
+ new Object[] { Configuration.ECJ_JAR });
+ System.err.println(message);
+ }
+
+ ClassLoader loader = null;
+ try
+ {
+ loader = new URLClassLoader(new URL[] {jar.toURL()});
+ }
+ catch (MalformedURLException f)
+ {
+ String message
+ = MessageFormat.format(Messages.getString("Main.MalformedURL"),
+ new Object[] { Configuration.ECJ_JAR });
+ System.err.println(message);
+ f.printStackTrace();
+ }
+
+ try
+ {
+ klass = loader.loadClass(classname);
+ }
+ catch (ClassNotFoundException g)
+ {
+ String message
+ = MessageFormat.format(Messages.getString("Main.FailedToLoad"),
+ new Object[] { classname,
+ Configuration.ECJ_JAR });
+ System.err.println(message);
+ g.printStackTrace();
+ }
+ }
+
+ try
+ {
+ ecjConstructor = klass.getConstructor(new Class[] {
+ PrintWriter.class,
+ PrintWriter.class,
+ Boolean.TYPE});
+ }
+ catch (NoSuchMethodException h)
+ {
+ System.err.println(Messages.getString("Main.FailedConstructor"));
+ h.printStackTrace();
+ }
+
+ try
+ {
+ ecjMethod = klass.getMethod("compile", new Class[] {String[].class});
+ }
+ catch (NoSuchMethodException i)
+ {
+ System.err.println(Messages.getString("Main.FailedCompile"));
+ i.printStackTrace();
+ }
+ }
+
+ public static int compile(String[] args, PrintWriter p) throws Exception
+ {
+ /*
+ * This code depends on the patch in Comment #10 in this bug
+ * report:
+ *
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=88364
+ */
+ Object ecjInstance = ecjConstructor.newInstance(new Object[]
+ {
+ p,
+ new PrintWriter(System.err),
+ Boolean.FALSE
+ });
+ String[] runArgs = new String[args.length + 1];
+ runArgs[0] = "-1.5";
+ System.arraycopy(args, 0, runArgs, 1, args.length);
+ return ((Boolean) ecjMethod.invoke(ecjInstance, new Object[]
+ { runArgs })).booleanValue() ? 0 : -1;
+ }
+
+ public static int compile(String[] args) throws Exception
+ {
+ return compile(args, new PrintWriter(System.out));
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ Runtime.getRuntime().exit(Main.compile(args));
+ }
+}
diff --git a/libjava/classpath/tools/com/sun/tools/javac/Messages.java b/libjava/classpath/tools/com/sun/tools/javac/Messages.java
new file mode 100644
index 000000000..17f22ac44
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/tools/javac/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for com.sun.tools.javac
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.tools.javac;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "com.sun.tools.javac.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/com/sun/tools/javadoc/Main.java b/libjava/classpath/tools/com/sun/tools/javadoc/Main.java
new file mode 100644
index 000000000..0082d411e
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/tools/javadoc/Main.java
@@ -0,0 +1,46 @@
+/* com.sun.tools.javadoc.Main - Main wrapper for GJDoc
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package com.sun.tools.javadoc;
+
+public class Main
+{
+ public static void main(String[] args)
+ {
+ gnu.classpath.tools.gjdoc.Main.main(args);
+ }
+}
diff --git a/libjava/classpath/tools/com/sun/tools/javah/Main.java b/libjava/classpath/tools/com/sun/tools/javah/Main.java
new file mode 100644
index 000000000..7faab594e
--- /dev/null
+++ b/libjava/classpath/tools/com/sun/tools/javah/Main.java
@@ -0,0 +1,58 @@
+/* Main.java -- implement com.sun.tools.javah.Main
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package com.sun.tools.javah;
+
+import java.io.IOException;
+
+public class Main
+{
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ gnu.classpath.tools.javah.Main.main(args);
+ }
+ catch (IOException e)
+ {
+ throw new IllegalArgumentException("An I/O error occurred " +
+ "in executing javah", e);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationVisitor.java
new file mode 100644
index 000000000..835b3e0ca
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationVisitor.java
@@ -0,0 +1,88 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A visitor to visit a Java annotation. The methods of this interface must be
+ * called in the following order: (<tt>visit<tt> | <tt>visitEnum<tt> |
+ * <tt>visitAnnotation<tt> | <tt>visitArray<tt>)* <tt>visitEnd<tt>.
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+public interface AnnotationVisitor {
+
+ /**
+ * Visits a primitive value of the annotation.
+ *
+ * @param name the value name.
+ * @param value the actual value, whose type must be {@link Byte},
+ * {@link Boolean}, {@link Character}, {@link Short},
+ * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
+ * {@link String} or {@link Type}.
+ */
+ void visit(String name, Object value);
+
+ /**
+ * Visits an enumeration value of the annotation.
+ *
+ * @param name the value name.
+ * @param desc the class descriptor of the enumeration class.
+ * @param value the actual enumeration value.
+ */
+ void visitEnum(String name, String desc, String value);
+
+ /**
+ * Visits a nested annotation value of the annotation.
+ *
+ * @param name the value name.
+ * @param desc the class descriptor of the nested annotation class.
+ * @return a non null visitor to visit the actual nested annotation value.
+ * <i>The nested annotation value must be fully visited before
+ * calling other methods on this annotation visitor</i>.
+ */
+ AnnotationVisitor visitAnnotation(String name, String desc);
+
+ /**
+ * Visits an array value of the annotation.
+ *
+ * @param name the value name.
+ * @return a non null visitor to visit the actual array value elements. The
+ * 'name' parameters passed to the methods of this visitor are
+ * ignored. <i>All the array values must be visited before calling
+ * other methods on this annotation visitor</i>.
+ */
+ AnnotationVisitor visitArray(String name);
+
+ /**
+ * Visits the end of the annotation.
+ */
+ void visitEnd();
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationWriter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationWriter.java
new file mode 100644
index 000000000..bf06bc95b
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationWriter.java
@@ -0,0 +1,311 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * An {@link AnnotationVisitor} that generates annotations in bytecode form.
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+final class AnnotationWriter implements AnnotationVisitor {
+
+ /**
+ * The class writer to which this annotation must be added.
+ */
+ private final ClassWriter cw;
+
+ /**
+ * The number of values in this annotation.
+ */
+ private int size;
+
+ /**
+ * <tt>true<tt> if values are named, <tt>false</tt> otherwise. Annotation
+ * writers used for annotation default and annotation arrays use unnamed
+ * values.
+ */
+ private final boolean named;
+
+ /**
+ * The annotation values in bytecode form. This byte vector only contains
+ * the values themselves, i.e. the number of values must be stored as a
+ * unsigned short just before these bytes.
+ */
+ private final ByteVector bv;
+
+ /**
+ * The byte vector to be used to store the number of values of this
+ * annotation. See {@link #bv}.
+ */
+ private final ByteVector parent;
+
+ /**
+ * Where the number of values of this annotation must be stored in
+ * {@link #parent}.
+ */
+ private final int offset;
+
+ /**
+ * Next annotation writer. This field is used to store annotation lists.
+ */
+ AnnotationWriter next;
+
+ /**
+ * Previous annotation writer. This field is used to store annotation lists.
+ */
+ AnnotationWriter prev;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs a new {@link AnnotationWriter}.
+ *
+ * @param cw the class writer to which this annotation must be added.
+ * @param named <tt>true<tt> if values are named, <tt>false</tt> otherwise.
+ * @param bv where the annotation values must be stored.
+ * @param parent where the number of annotation values must be stored.
+ * @param offset where in <tt>parent</tt> the number of annotation values must
+ * be stored.
+ */
+ AnnotationWriter(
+ final ClassWriter cw,
+ final boolean named,
+ final ByteVector bv,
+ final ByteVector parent,
+ final int offset)
+ {
+ this.cw = cw;
+ this.named = named;
+ this.bv = bv;
+ this.parent = parent;
+ this.offset = offset;
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the AnnotationVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(final String name, final Object value) {
+ ++size;
+ if (named) {
+ bv.putShort(cw.newUTF8(name));
+ }
+ if (value instanceof String) {
+ bv.put12('s', cw.newUTF8((String) value));
+ } else if (value instanceof Byte) {
+ bv.put12('B', cw.newInteger(((Byte) value).byteValue()).index);
+ } else if (value instanceof Boolean) {
+ int v = ((Boolean) value).booleanValue() ? 1 : 0;
+ bv.put12('Z', cw.newInteger(v).index);
+ } else if (value instanceof Character) {
+ bv.put12('C', cw.newInteger(((Character) value).charValue()).index);
+ } else if (value instanceof Short) {
+ bv.put12('S', cw.newInteger(((Short) value).shortValue()).index);
+ } else if (value instanceof Type) {
+ bv.put12('c', cw.newUTF8(((Type) value).getDescriptor()));
+ } else if (value instanceof byte[]) {
+ byte[] v = (byte[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('B', cw.newInteger(v[i]).index);
+ }
+ } else if (value instanceof boolean[]) {
+ boolean[] v = (boolean[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('Z', cw.newInteger(v[i] ? 1 : 0).index);
+ }
+ } else if (value instanceof short[]) {
+ short[] v = (short[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('S', cw.newInteger(v[i]).index);
+ }
+ } else if (value instanceof char[]) {
+ char[] v = (char[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('C', cw.newInteger(v[i]).index);
+ }
+ } else if (value instanceof int[]) {
+ int[] v = (int[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('I', cw.newInteger(v[i]).index);
+ }
+ } else if (value instanceof long[]) {
+ long[] v = (long[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('J', cw.newLong(v[i]).index);
+ }
+ } else if (value instanceof float[]) {
+ float[] v = (float[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('F', cw.newFloat(v[i]).index);
+ }
+ } else if (value instanceof double[]) {
+ double[] v = (double[]) value;
+ bv.put12('[', v.length);
+ for (int i = 0; i < v.length; i++) {
+ bv.put12('D', cw.newDouble(v[i]).index);
+ }
+ } else {
+ Item i = cw.newConstItem(value);
+ bv.put12(".s.IFJDCS".charAt(i.type), i.index);
+ }
+ }
+
+ public void visitEnum(
+ final String name,
+ final String desc,
+ final String value)
+ {
+ ++size;
+ if (named) {
+ bv.putShort(cw.newUTF8(name));
+ }
+ bv.put12('e', cw.newUTF8(desc)).putShort(cw.newUTF8(value));
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String name,
+ final String desc)
+ {
+ ++size;
+ if (named) {
+ bv.putShort(cw.newUTF8(name));
+ }
+ // write tag and type, and reserve space for values count
+ bv.put12('@', cw.newUTF8(desc)).putShort(0);
+ return new AnnotationWriter(cw, true, bv, bv, bv.length - 2);
+ }
+
+ public AnnotationVisitor visitArray(final String name) {
+ ++size;
+ if (named) {
+ bv.putShort(cw.newUTF8(name));
+ }
+ // write tag, and reserve space for array size
+ bv.put12('[', 0);
+ return new AnnotationWriter(cw, false, bv, bv, bv.length - 2);
+ }
+
+ public void visitEnd() {
+ if (parent != null) {
+ byte[] data = parent.data;
+ data[offset] = (byte) (size >>> 8);
+ data[offset + 1] = (byte) size;
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the size of this annotation writer list.
+ *
+ * @return the size of this annotation writer list.
+ */
+ int getSize() {
+ int size = 0;
+ AnnotationWriter aw = this;
+ while (aw != null) {
+ size += aw.bv.length;
+ aw = aw.next;
+ }
+ return size;
+ }
+
+ /**
+ * Puts the annotations of this annotation writer list into the given byte
+ * vector.
+ *
+ * @param out where the annotations must be put.
+ */
+ void put(final ByteVector out) {
+ int n = 0;
+ int size = 2;
+ AnnotationWriter aw = this;
+ AnnotationWriter last = null;
+ while (aw != null) {
+ ++n;
+ size += aw.bv.length;
+ aw.visitEnd(); // in case user forgot to call visitEnd
+ aw.prev = last;
+ last = aw;
+ aw = aw.next;
+ }
+ out.putInt(size);
+ out.putShort(n);
+ aw = last;
+ while (aw != null) {
+ out.putByteArray(aw.bv.data, 0, aw.bv.length);
+ aw = aw.prev;
+ }
+ }
+
+ /**
+ * Puts the given annotation lists into the given byte vector.
+ *
+ * @param panns an array of annotation writer lists.
+ * @param out where the annotations must be put.
+ */
+ static void put(final AnnotationWriter[] panns, final ByteVector out) {
+ int size = 1 + 2 * panns.length;
+ for (int i = 0; i < panns.length; ++i) {
+ size += panns[i] == null ? 0 : panns[i].getSize();
+ }
+ out.putInt(size).putByte(panns.length);
+ for (int i = 0; i < panns.length; ++i) {
+ AnnotationWriter aw = panns[i];
+ AnnotationWriter last = null;
+ int n = 0;
+ while (aw != null) {
+ ++n;
+ aw.visitEnd(); // in case user forgot to call visitEnd
+ aw.prev = last;
+ last = aw;
+ aw = aw.next;
+ }
+ out.putShort(n);
+ aw = last;
+ while (aw != null) {
+ out.putByteArray(aw.bv.data, 0, aw.bv.length);
+ aw = aw.prev;
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/Attribute.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/Attribute.java
new file mode 100644
index 000000000..897a33c79
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/Attribute.java
@@ -0,0 +1,254 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A non standard class, field, method or code attribute.
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+public class Attribute {
+
+ /**
+ * The type of this attribute.
+ */
+ public final String type;
+
+ /**
+ * The raw value of this attribute, used only for unknown attributes.
+ */
+ byte[] value;
+
+ /**
+ * The next attribute in this attribute list. May be <tt>null</tt>.
+ */
+ Attribute next;
+
+ /**
+ * Constructs a new empty attribute.
+ *
+ * @param type the type of the attribute.
+ */
+ protected Attribute(final String type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns <tt>true</tt> if this type of attribute is unknown. The default
+ * implementation of this method always returns <tt>true</tt>.
+ *
+ * @return <tt>true</tt> if this type of attribute is unknown.
+ */
+ public boolean isUnknown() {
+ return true;
+ }
+
+ /**
+ * Returns <tt>true</tt> if this type of attribute is a code attribute.
+ *
+ * @return <tt>true</tt> if this type of attribute is a code attribute.
+ */
+ public boolean isCodeAttribute() {
+ return false;
+ }
+
+ /**
+ * Returns the labels corresponding to this attribute.
+ *
+ * @return the labels corresponding to this attribute, or <tt>null</tt> if
+ * this attribute is not a code attribute that contains labels.
+ */
+ protected Label[] getLabels() {
+ return null;
+ }
+
+ /**
+ * Reads a {@link #type type} attribute. This method must return a <i>new</i>
+ * {@link Attribute} object, of type {@link #type type}, corresponding to
+ * the <tt>len</tt> bytes starting at the given offset, in the given class
+ * reader.
+ *
+ * @param cr the class that contains the attribute to be read.
+ * @param off index of the first byte of the attribute's content in {@link
+ * ClassReader#b cr.b}. The 6 attribute header bytes, containing the
+ * type and the length of the attribute, are not taken into account
+ * here.
+ * @param len the length of the attribute's content.
+ * @param buf buffer to be used to call
+ * {@link ClassReader#readUTF8 readUTF8},
+ * {@link ClassReader#readClass(int,char[]) readClass} or
+ * {@link ClassReader#readConst readConst}.
+ * @param codeOff index of the first byte of code's attribute content in
+ * {@link ClassReader#b cr.b}, or -1 if the attribute to be read is
+ * not a code attribute. The 6 attribute header bytes, containing the
+ * type and the length of the attribute, are not taken into account
+ * here.
+ * @param labels the labels of the method's code, or <tt>null</tt> if the
+ * attribute to be read is not a code attribute.
+ * @return a <i>new</i> {@link Attribute} object corresponding to the given
+ * bytes.
+ */
+ protected Attribute read(
+ ClassReader cr,
+ int off,
+ int len,
+ char[] buf,
+ int codeOff,
+ Label[] labels)
+ {
+ Attribute attr = new Attribute(type);
+ attr.value = new byte[len];
+ System.arraycopy(cr.b, off, attr.value, 0, len);
+ return attr;
+ }
+
+ /**
+ * Returns the byte array form of this attribute.
+ *
+ * @param cw the class to which this attribute must be added. This parameter
+ * can be used to add to the constant pool of this class the items
+ * that corresponds to this attribute.
+ * @param code the bytecode of the method corresponding to this code
+ * attribute, or <tt>null</tt> if this attribute is not a code
+ * attributes.
+ * @param len the length of the bytecode of the method corresponding to this
+ * code attribute, or <tt>null</tt> if this attribute is not a code
+ * attribute.
+ * @param maxStack the maximum stack size of the method corresponding to
+ * this code attribute, or -1 if this attribute is not a code
+ * attribute.
+ * @param maxLocals the maximum number of local variables of the method
+ * corresponding to this code attribute, or -1 if this attribute is
+ * not a code attribute.
+ * @return the byte array form of this attribute.
+ */
+ protected ByteVector write(
+ ClassWriter cw,
+ byte[] code,
+ int len,
+ int maxStack,
+ int maxLocals)
+ {
+ ByteVector v = new ByteVector();
+ v.data = value;
+ v.length = value.length;
+ return v;
+ }
+
+ /**
+ * Returns the length of the attribute list that begins with this attribute.
+ *
+ * @return the length of the attribute list that begins with this attribute.
+ */
+ final int getCount() {
+ int count = 0;
+ Attribute attr = this;
+ while (attr != null) {
+ count += 1;
+ attr = attr.next;
+ }
+ return count;
+ }
+
+ /**
+ * Returns the size of all the attributes in this attribute list.
+ *
+ * @param cw the class writer to be used to convert the attributes into byte
+ * arrays, with the {@link #write write} method.
+ * @param code the bytecode of the method corresponding to these code
+ * attributes, or <tt>null</tt> if these attributes are not code
+ * attributes.
+ * @param len the length of the bytecode of the method corresponding to
+ * these code attributes, or <tt>null</tt> if these attributes are
+ * not code attributes.
+ * @param maxStack the maximum stack size of the method corresponding to
+ * these code attributes, or -1 if these attributes are not code
+ * attributes.
+ * @param maxLocals the maximum number of local variables of the method
+ * corresponding to these code attributes, or -1 if these attributes
+ * are not code attributes.
+ * @return the size of all the attributes in this attribute list. This size
+ * includes the size of the attribute headers.
+ */
+ final int getSize(
+ final ClassWriter cw,
+ final byte[] code,
+ final int len,
+ final int maxStack,
+ final int maxLocals)
+ {
+ Attribute attr = this;
+ int size = 0;
+ while (attr != null) {
+ cw.newUTF8(attr.type);
+ size += attr.write(cw, code, len, maxStack, maxLocals).length + 6;
+ attr = attr.next;
+ }
+ return size;
+ }
+
+ /**
+ * Writes all the attributes of this attribute list in the given byte
+ * vector.
+ *
+ * @param cw the class writer to be used to convert the attributes into byte
+ * arrays, with the {@link #write write} method.
+ * @param code the bytecode of the method corresponding to these code
+ * attributes, or <tt>null</tt> if these attributes are not code
+ * attributes.
+ * @param len the length of the bytecode of the method corresponding to
+ * these code attributes, or <tt>null</tt> if these attributes are
+ * not code attributes.
+ * @param maxStack the maximum stack size of the method corresponding to
+ * these code attributes, or -1 if these attributes are not code
+ * attributes.
+ * @param maxLocals the maximum number of local variables of the method
+ * corresponding to these code attributes, or -1 if these attributes
+ * are not code attributes.
+ * @param out where the attributes must be written.
+ */
+ final void put(
+ final ClassWriter cw,
+ final byte[] code,
+ final int len,
+ final int maxStack,
+ final int maxLocals,
+ final ByteVector out)
+ {
+ Attribute attr = this;
+ while (attr != null) {
+ ByteVector b = attr.write(cw, code, len, maxStack, maxLocals);
+ out.putShort(cw.newUTF8(attr.type)).putInt(b.length);
+ out.putByteArray(b.data, 0, b.length);
+ attr = attr.next;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/ByteVector.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/ByteVector.java
new file mode 100644
index 000000000..a1bc32517
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/ByteVector.java
@@ -0,0 +1,293 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A dynamically extensible vector of bytes. This class is roughly equivalent to
+ * a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient.
+ *
+ * @author Eric Bruneton
+ */
+public class ByteVector {
+
+ /**
+ * The content of this vector.
+ */
+ byte[] data;
+
+ /**
+ * Actual number of bytes in this vector.
+ */
+ int length;
+
+ /**
+ * Constructs a new {@link ByteVector ByteVector} with a default initial
+ * size.
+ */
+ public ByteVector() {
+ data = new byte[64];
+ }
+
+ /**
+ * Constructs a new {@link ByteVector ByteVector} with the given initial
+ * size.
+ *
+ * @param initialSize the initial size of the byte vector to be constructed.
+ */
+ public ByteVector(final int initialSize) {
+ data = new byte[initialSize];
+ }
+
+ /**
+ * Puts a byte into this byte vector. The byte vector is automatically
+ * enlarged if necessary.
+ *
+ * @param b a byte.
+ * @return this byte vector.
+ */
+ public ByteVector putByte(final int b) {
+ int length = this.length;
+ if (length + 1 > data.length) {
+ enlarge(1);
+ }
+ data[length++] = (byte) b;
+ this.length = length;
+ return this;
+ }
+
+ /**
+ * Puts two bytes into this byte vector. The byte vector is automatically
+ * enlarged if necessary.
+ *
+ * @param b1 a byte.
+ * @param b2 another byte.
+ * @return this byte vector.
+ */
+ ByteVector put11(final int b1, final int b2) {
+ int length = this.length;
+ if (length + 2 > data.length) {
+ enlarge(2);
+ }
+ byte[] data = this.data;
+ data[length++] = (byte) b1;
+ data[length++] = (byte) b2;
+ this.length = length;
+ return this;
+ }
+
+ /**
+ * Puts a short into this byte vector. The byte vector is automatically
+ * enlarged if necessary.
+ *
+ * @param s a short.
+ * @return this byte vector.
+ */
+ public ByteVector putShort(final int s) {
+ int length = this.length;
+ if (length + 2 > data.length) {
+ enlarge(2);
+ }
+ byte[] data = this.data;
+ data[length++] = (byte) (s >>> 8);
+ data[length++] = (byte) s;
+ this.length = length;
+ return this;
+ }
+
+ /**
+ * Puts a byte and a short into this byte vector. The byte vector is
+ * automatically enlarged if necessary.
+ *
+ * @param b a byte.
+ * @param s a short.
+ * @return this byte vector.
+ */
+ ByteVector put12(final int b, final int s) {
+ int length = this.length;
+ if (length + 3 > data.length) {
+ enlarge(3);
+ }
+ byte[] data = this.data;
+ data[length++] = (byte) b;
+ data[length++] = (byte) (s >>> 8);
+ data[length++] = (byte) s;
+ this.length = length;
+ return this;
+ }
+
+ /**
+ * Puts an int into this byte vector. The byte vector is automatically
+ * enlarged if necessary.
+ *
+ * @param i an int.
+ * @return this byte vector.
+ */
+ public ByteVector putInt(final int i) {
+ int length = this.length;
+ if (length + 4 > data.length) {
+ enlarge(4);
+ }
+ byte[] data = this.data;
+ data[length++] = (byte) (i >>> 24);
+ data[length++] = (byte) (i >>> 16);
+ data[length++] = (byte) (i >>> 8);
+ data[length++] = (byte) i;
+ this.length = length;
+ return this;
+ }
+
+ /**
+ * Puts a long into this byte vector. The byte vector is automatically
+ * enlarged if necessary.
+ *
+ * @param l a long.
+ * @return this byte vector.
+ */
+ public ByteVector putLong(final long l) {
+ int length = this.length;
+ if (length + 8 > data.length) {
+ enlarge(8);
+ }
+ byte[] data = this.data;
+ int i = (int) (l >>> 32);
+ data[length++] = (byte) (i >>> 24);
+ data[length++] = (byte) (i >>> 16);
+ data[length++] = (byte) (i >>> 8);
+ data[length++] = (byte) i;
+ i = (int) l;
+ data[length++] = (byte) (i >>> 24);
+ data[length++] = (byte) (i >>> 16);
+ data[length++] = (byte) (i >>> 8);
+ data[length++] = (byte) i;
+ this.length = length;
+ return this;
+ }
+
+ /**
+ * Puts an UTF8 string into this byte vector. The byte vector is
+ * automatically enlarged if necessary.
+ *
+ * @param s a String.
+ * @return this byte vector.
+ */
+ public ByteVector putUTF8(final String s) {
+ int charLength = s.length();
+ if (length + 2 + charLength > data.length) {
+ enlarge(2 + charLength);
+ }
+ int len = length;
+ byte[] data = this.data;
+ // optimistic algorithm: instead of computing the byte length and then
+ // serializing the string (which requires two loops), we assume the byte
+ // length is equal to char length (which is the most frequent case), and
+ // we start serializing the string right away. During the serialization,
+ // if we find that this assumption is wrong, we continue with the
+ // general method.
+ data[len++] = (byte) (charLength >>> 8);
+ data[len++] = (byte) (charLength);
+ for (int i = 0; i < charLength; ++i) {
+ char c = s.charAt(i);
+ if (c >= '\001' && c <= '\177') {
+ data[len++] = (byte) c;
+ } else {
+ int byteLength = i;
+ for (int j = i; j < charLength; ++j) {
+ c = s.charAt(j);
+ if (c >= '\001' && c <= '\177') {
+ byteLength++;
+ } else if (c > '\u07FF') {
+ byteLength += 3;
+ } else {
+ byteLength += 2;
+ }
+ }
+ data[length] = (byte) (byteLength >>> 8);
+ data[length + 1] = (byte) (byteLength);
+ if (length + 2 + byteLength > data.length) {
+ length = len;
+ enlarge(2 + byteLength);
+ data = this.data;
+ }
+ for (int j = i; j < charLength; ++j) {
+ c = s.charAt(j);
+ if (c >= '\001' && c <= '\177') {
+ data[len++] = (byte) c;
+ } else if (c > '\u07FF') {
+ data[len++] = (byte) (0xE0 | c >> 12 & 0xF);
+ data[len++] = (byte) (0x80 | c >> 6 & 0x3F);
+ data[len++] = (byte) (0x80 | c & 0x3F);
+ } else {
+ data[len++] = (byte) (0xC0 | c >> 6 & 0x1F);
+ data[len++] = (byte) (0x80 | c & 0x3F);
+ }
+ }
+ break;
+ }
+ }
+ length = len;
+ return this;
+ }
+
+ /**
+ * Puts an array of bytes into this byte vector. The byte vector is
+ * automatically enlarged if necessary.
+ *
+ * @param b an array of bytes. May be <tt>null</tt> to put <tt>len</tt>
+ * null bytes into this byte vector.
+ * @param off index of the fist byte of b that must be copied.
+ * @param len number of bytes of b that must be copied.
+ * @return this byte vector.
+ */
+ public ByteVector putByteArray(final byte[] b, final int off, final int len)
+ {
+ if (length + len > data.length) {
+ enlarge(len);
+ }
+ if (b != null) {
+ System.arraycopy(b, off, data, length, len);
+ }
+ length += len;
+ return this;
+ }
+
+ /**
+ * Enlarge this byte vector so that it can receive n more bytes.
+ *
+ * @param size number of additional bytes that this byte vector should be
+ * able to receive.
+ */
+ private void enlarge(final int size) {
+ int length1 = 2 * data.length;
+ int length2 = length + size;
+ byte[] newData = new byte[length1 > length2 ? length1 : length2];
+ System.arraycopy(data, 0, newData, 0, length);
+ data = newData;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassAdapter.java
new file mode 100644
index 000000000..24e34bb99
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassAdapter.java
@@ -0,0 +1,121 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * An empty {@link ClassVisitor} that delegates to another {@link ClassVisitor}.
+ * This class can be used as a super class to quickly implement usefull class
+ * adapter classes, just by overriding the necessary methods.
+ *
+ * @author Eric Bruneton
+ */
+public class ClassAdapter implements ClassVisitor {
+
+ /**
+ * The {@link ClassVisitor} to which this adapter delegates calls.
+ */
+ protected ClassVisitor cv;
+
+ /**
+ * Constructs a new {@link ClassAdapter} object.
+ *
+ * @param cv the class visitor to which this adapter must delegate calls.
+ */
+ public ClassAdapter(final ClassVisitor cv) {
+ this.cv = cv;
+ }
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ cv.visit(version, access, name, signature, superName, interfaces);
+ }
+
+ public void visitSource(final String source, final String debug) {
+ cv.visitSource(source, debug);
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ cv.visitOuterClass(owner, name, desc);
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ return cv.visitAnnotation(desc, visible);
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ cv.visitAttribute(attr);
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ cv.visitInnerClass(name, outerName, innerName, access);
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ return cv.visitField(access, name, desc, signature, value);
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ return cv.visitMethod(access, name, desc, signature, exceptions);
+ }
+
+ public void visitEnd() {
+ cv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassReader.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassReader.java
new file mode 100644
index 000000000..9d94a42d4
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassReader.java
@@ -0,0 +1,1606 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * A Java class parser to make a {@link ClassVisitor} visit an existing class.
+ * This class parses a byte array conforming to the Java class file format and
+ * calls the appropriate visit methods of a given class visitor for each field,
+ * method and bytecode instruction encountered.
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+public class ClassReader {
+
+ /**
+ * The class to be parsed. <i>The content of this array must not be
+ * modified. This field is intended for {@link Attribute} sub classes, and
+ * is normally not needed by class generators or adapters.</i>
+ */
+ public final byte[] b;
+
+ /**
+ * The start index of each constant pool item in {@link #b b}, plus one.
+ * The one byte offset skips the constant pool item tag that indicates its
+ * type.
+ */
+ private int[] items;
+
+ /**
+ * The String objects corresponding to the CONSTANT_Utf8 items. This cache
+ * avoids multiple parsing of a given CONSTANT_Utf8 constant pool item,
+ * which GREATLY improves performances (by a factor 2 to 3). This caching
+ * strategy could be extended to all constant pool items, but its benefit
+ * would not be so great for these items (because they are much less
+ * expensive to parse than CONSTANT_Utf8 items).
+ */
+ private String[] strings;
+
+ /**
+ * Maximum length of the strings contained in the constant pool of the
+ * class.
+ */
+ private int maxStringLength;
+
+ /**
+ * Start index of the class header information (access, name...) in
+ * {@link #b b}.
+ */
+ public final int header;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs a new {@link ClassReader} object.
+ *
+ * @param b the bytecode of the class to be read.
+ */
+ public ClassReader(final byte[] b) {
+ this(b, 0, b.length);
+ }
+
+ /**
+ * Constructs a new {@link ClassReader} object.
+ *
+ * @param b the bytecode of the class to be read.
+ * @param off the start offset of the class data.
+ * @param len the length of the class data.
+ */
+ public ClassReader(final byte[] b, final int off, final int len) {
+ this.b = b;
+ // parses the constant pool
+ items = new int[readUnsignedShort(off + 8)];
+ int ll = items.length;
+ strings = new String[ll];
+ int max = 0;
+ int index = off + 10;
+ for (int i = 1; i < ll; ++i) {
+ items[i] = index + 1;
+ int tag = b[index];
+ int size;
+ switch (tag) {
+ case ClassWriter.FIELD:
+ case ClassWriter.METH:
+ case ClassWriter.IMETH:
+ case ClassWriter.INT:
+ case ClassWriter.FLOAT:
+ case ClassWriter.NAME_TYPE:
+ size = 5;
+ break;
+ case ClassWriter.LONG:
+ case ClassWriter.DOUBLE:
+ size = 9;
+ ++i;
+ break;
+ case ClassWriter.UTF8:
+ size = 3 + readUnsignedShort(index + 1);
+ if (size > max) {
+ max = size;
+ }
+ break;
+ // case ClassWriter.CLASS:
+ // case ClassWriter.STR:
+ default:
+ size = 3;
+ break;
+ }
+ index += size;
+ }
+ maxStringLength = max;
+ // the class header information starts just after the constant pool
+ header = index;
+ }
+
+ /**
+ * Copies the constant pool data into the given {@link ClassWriter}. Should
+ * be called before the {@link #accept(ClassVisitor,boolean)} method.
+ *
+ * @param classWriter the {@link ClassWriter} to copy constant pool into.
+ */
+ void copyPool(final ClassWriter classWriter) {
+ char[] buf = new char[maxStringLength];
+ int ll = items.length;
+ Item[] items2 = new Item[ll];
+ for (int i = 1; i < ll; i++) {
+ int index = items[i];
+ int tag = b[index - 1];
+ Item item = new Item(i);
+ int nameType;
+ switch (tag) {
+ case ClassWriter.FIELD:
+ case ClassWriter.METH:
+ case ClassWriter.IMETH:
+ nameType = items[readUnsignedShort(index + 2)];
+ item.set(tag,
+ readClass(index, buf),
+ readUTF8(nameType, buf),
+ readUTF8(nameType + 2, buf));
+ break;
+
+ case ClassWriter.INT:
+ item.set(readInt(index));
+ break;
+
+ case ClassWriter.FLOAT:
+ item.set(Float.intBitsToFloat(readInt(index)));
+ break;
+
+ case ClassWriter.NAME_TYPE:
+ item.set(tag,
+ readUTF8(index, buf),
+ readUTF8(index + 2, buf),
+ null);
+ break;
+
+ case ClassWriter.LONG:
+ item.set(readLong(index));
+ ++i;
+ break;
+
+ case ClassWriter.DOUBLE:
+ item.set(Double.longBitsToDouble(readLong(index)));
+ ++i;
+ break;
+
+ case ClassWriter.UTF8: {
+ String s = strings[i];
+ if (s == null) {
+ index = items[i];
+ s = strings[i] = readUTF(index + 2,
+ readUnsignedShort(index),
+ buf);
+ }
+ item.set(tag, s, null, null);
+ }
+ break;
+
+ // case ClassWriter.STR:
+ // case ClassWriter.CLASS:
+ default:
+ item.set(tag, readUTF8(index, buf), null, null);
+ break;
+ }
+
+ int index2 = item.hashCode % items2.length;
+ item.next = items2[index2];
+ items2[index2] = item;
+ }
+
+ int off = items[1] - 1;
+ classWriter.pool.putByteArray(b, off, header - off);
+ classWriter.items = items2;
+ classWriter.threshold = (int) (0.75d * ll);
+ classWriter.index = ll;
+ }
+
+ /**
+ * Constructs a new {@link ClassReader} object.
+ *
+ * @param is an input stream from which to read the class.
+ * @throws IOException if a problem occurs during reading.
+ */
+ public ClassReader(final InputStream is) throws IOException {
+ this(readClass(is));
+ }
+
+ /**
+ * Constructs a new {@link ClassReader} object.
+ *
+ * @param name the fully qualified name of the class to be read.
+ * @throws IOException if an exception occurs during reading.
+ */
+ public ClassReader(final String name) throws IOException {
+ this(ClassLoader.getSystemResourceAsStream(name.replace('.', '/')
+ + ".class"));
+ }
+
+ /**
+ * Reads the bytecode of a class.
+ *
+ * @param is an input stream from which to read the class.
+ * @return the bytecode read from the given input stream.
+ * @throws IOException if a problem occurs during reading.
+ */
+ private static byte[] readClass(final InputStream is) throws IOException {
+ if (is == null) {
+ throw new IOException("Class not found");
+ }
+ byte[] b = new byte[is.available()];
+ int len = 0;
+ while (true) {
+ int n = is.read(b, len, b.length - len);
+ if (n == -1) {
+ if (len < b.length) {
+ byte[] c = new byte[len];
+ System.arraycopy(b, 0, c, 0, len);
+ b = c;
+ }
+ return b;
+ }
+ len += n;
+ if (len == b.length) {
+ byte[] c = new byte[b.length + 1000];
+ System.arraycopy(b, 0, c, 0, len);
+ b = c;
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Public methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Makes the given visitor visit the Java class of this {@link ClassReader}.
+ * This class is the one specified in the constructor (see
+ * {@link #ClassReader(byte[]) ClassReader}).
+ *
+ * @param classVisitor the visitor that must visit this class.
+ * @param skipDebug <tt>true</tt> if the debug information of the class
+ * must not be visited. In this case the
+ * {@link MethodVisitor#visitLocalVariable visitLocalVariable} and
+ * {@link MethodVisitor#visitLineNumber visitLineNumber} methods will
+ * not be called.
+ */
+ public void accept(final ClassVisitor classVisitor, final boolean skipDebug)
+ {
+ accept(classVisitor, new Attribute[0], skipDebug);
+ }
+
+ /**
+ * Makes the given visitor visit the Java class of this {@link ClassReader}.
+ * This class is the one specified in the constructor (see
+ * {@link #ClassReader(byte[]) ClassReader}).
+ *
+ * @param classVisitor the visitor that must visit this class.
+ * @param attrs prototypes of the attributes that must be parsed during the
+ * visit of the class. Any attribute whose type is not equal to the
+ * type of one the prototypes will be ignored.
+ * @param skipDebug <tt>true</tt> if the debug information of the class
+ * must not be visited. In this case the
+ * {@link MethodVisitor#visitLocalVariable visitLocalVariable} and
+ * {@link MethodVisitor#visitLineNumber visitLineNumber} methods will
+ * not be called.
+ */
+ public void accept(
+ final ClassVisitor classVisitor,
+ final Attribute[] attrs,
+ final boolean skipDebug)
+ {
+ byte[] b = this.b; // the bytecode array
+ char[] c = new char[maxStringLength]; // buffer used to read strings
+ int i, j, k; // loop variables
+ int u, v, w; // indexes in b
+ Attribute attr;
+
+ int access;
+ String name;
+ String desc;
+ String attrName;
+ String signature;
+ int anns = 0;
+ int ianns = 0;
+ Attribute cattrs = null;
+
+ // visits the header
+ u = header;
+ access = readUnsignedShort(u);
+ name = readClass(u + 2, c);
+ v = items[readUnsignedShort(u + 4)];
+ String superClassName = v == 0 ? null : readUTF8(v, c);
+ String[] implementedItfs = new String[readUnsignedShort(u + 6)];
+ w = 0;
+ u += 8;
+ for (i = 0; i < implementedItfs.length; ++i) {
+ implementedItfs[i] = readClass(u, c);
+ u += 2;
+ }
+
+ // skips fields and methods
+ v = u;
+ i = readUnsignedShort(v);
+ v += 2;
+ for (; i > 0; --i) {
+ j = readUnsignedShort(v + 6);
+ v += 8;
+ for (; j > 0; --j) {
+ v += 6 + readInt(v + 2);
+ }
+ }
+ i = readUnsignedShort(v);
+ v += 2;
+ for (; i > 0; --i) {
+ j = readUnsignedShort(v + 6);
+ v += 8;
+ for (; j > 0; --j) {
+ v += 6 + readInt(v + 2);
+ }
+ }
+ // reads the class's attributes
+ signature = null;
+ String sourceFile = null;
+ String sourceDebug = null;
+ String enclosingOwner = null;
+ String enclosingName = null;
+ String enclosingDesc = null;
+
+ i = readUnsignedShort(v);
+ v += 2;
+ for (; i > 0; --i) {
+ attrName = readUTF8(v, c);
+ if (attrName.equals("SourceFile")) {
+ sourceFile = readUTF8(v + 6, c);
+ } else if (attrName.equals("Deprecated")) {
+ access |= Opcodes.ACC_DEPRECATED;
+ } else if (attrName.equals("Synthetic")) {
+ access |= Opcodes.ACC_SYNTHETIC;
+ } else if (attrName.equals("Annotation")) {
+ access |= Opcodes.ACC_ANNOTATION;
+ } else if (attrName.equals("Enum")) {
+ access |= Opcodes.ACC_ENUM;
+ } else if (attrName.equals("InnerClasses")) {
+ w = v + 6;
+ } else if (attrName.equals("Signature")) {
+ signature = readUTF8(v + 6, c);
+ } else if (attrName.equals("SourceDebugExtension")) {
+ int len = readInt(v + 2);
+ sourceDebug = readUTF(v + 6, len, new char[len]);
+ } else if (attrName.equals("EnclosingMethod")) {
+ enclosingOwner = readClass(v + 6, c);
+ int item = readUnsignedShort(v + 8);
+ if (item != 0) {
+ enclosingName = readUTF8(items[item], c);
+ enclosingDesc = readUTF8(items[item] + 2, c);
+ }
+ } else if (attrName.equals("RuntimeVisibleAnnotations")) {
+ anns = v + 6;
+ } else if (attrName.equals("RuntimeInvisibleAnnotations")) {
+ ianns = v + 6;
+ } else {
+ attr = readAttribute(attrs,
+ attrName,
+ v + 6,
+ readInt(v + 2),
+ c,
+ -1,
+ null);
+ if (attr != null) {
+ attr.next = cattrs;
+ cattrs = attr;
+ }
+ }
+ v += 6 + readInt(v + 2);
+ }
+ // calls the visit method
+ classVisitor.visit(readInt(4),
+ access,
+ name,
+ signature,
+ superClassName,
+ implementedItfs);
+
+ // calls the visitSource method
+ if (sourceFile != null || sourceDebug != null) {
+ classVisitor.visitSource(sourceFile, sourceDebug);
+ }
+
+ // calls the visitOuterClass method
+ if (enclosingOwner != null) {
+ classVisitor.visitOuterClass(enclosingOwner,
+ enclosingName,
+ enclosingDesc);
+ }
+
+ // visits the class annotations
+ for (i = 1; i >= 0; --i) {
+ v = i == 0 ? ianns : anns;
+ if (v != 0) {
+ j = readUnsignedShort(v);
+ v += 2;
+ for (; j > 0; --j) {
+ desc = readUTF8(v, c);
+ v += 2;
+ v = readAnnotationValues(v,
+ c,
+ classVisitor.visitAnnotation(desc, i != 0));
+ }
+ }
+ }
+
+ // visits the class attributes
+ while (cattrs != null) {
+ attr = cattrs.next;
+ cattrs.next = null;
+ classVisitor.visitAttribute(cattrs);
+ cattrs = attr;
+ }
+
+ // class the visitInnerClass method
+ if (w != 0) {
+ i = readUnsignedShort(w);
+ w += 2;
+ for (; i > 0; --i) {
+ classVisitor.visitInnerClass(readUnsignedShort(w) == 0
+ ? null
+ : readClass(w, c), readUnsignedShort(w + 2) == 0
+ ? null
+ : readClass(w + 2, c), readUnsignedShort(w + 4) == 0
+ ? null
+ : readUTF8(w + 4, c), readUnsignedShort(w + 6));
+ w += 8;
+ }
+ }
+
+ // visits the fields
+ i = readUnsignedShort(u);
+ u += 2;
+ for (; i > 0; --i) {
+ access = readUnsignedShort(u);
+ name = readUTF8(u + 2, c);
+ desc = readUTF8(u + 4, c);
+ // visits the field's attributes and looks for a ConstantValue
+ // attribute
+ int fieldValueItem = 0;
+ signature = null;
+ anns = 0;
+ ianns = 0;
+ cattrs = null;
+
+ j = readUnsignedShort(u + 6);
+ u += 8;
+ for (; j > 0; --j) {
+ attrName = readUTF8(u, c);
+ if (attrName.equals("ConstantValue")) {
+ fieldValueItem = readUnsignedShort(u + 6);
+ } else if (attrName.equals("Synthetic")) {
+ access |= Opcodes.ACC_SYNTHETIC;
+ } else if (attrName.equals("Deprecated")) {
+ access |= Opcodes.ACC_DEPRECATED;
+ } else if (attrName.equals("Enum")) {
+ access |= Opcodes.ACC_ENUM;
+ } else if (attrName.equals("Signature")) {
+ signature = readUTF8(u + 6, c);
+ } else if (attrName.equals("RuntimeVisibleAnnotations")) {
+ anns = u + 6;
+ } else if (attrName.equals("RuntimeInvisibleAnnotations")) {
+ ianns = u + 6;
+ } else {
+ attr = readAttribute(attrs,
+ attrName,
+ u + 6,
+ readInt(u + 2),
+ c,
+ -1,
+ null);
+ if (attr != null) {
+ attr.next = cattrs;
+ cattrs = attr;
+ }
+ }
+ u += 6 + readInt(u + 2);
+ }
+ // reads the field's value, if any
+ Object value = (fieldValueItem == 0
+ ? null
+ : readConst(fieldValueItem, c));
+ // visits the field
+ FieldVisitor fv = classVisitor.visitField(access,
+ name,
+ desc,
+ signature,
+ value);
+ // visits the field annotations and attributes
+ if (fv != null) {
+ for (j = 1; j >= 0; --j) {
+ v = j == 0 ? ianns : anns;
+ if (v != 0) {
+ k = readUnsignedShort(v);
+ v += 2;
+ for (; k > 0; --k) {
+ desc = readUTF8(v, c);
+ v += 2;
+ v = readAnnotationValues(v,
+ c,
+ fv.visitAnnotation(desc, j != 0));
+ }
+ }
+ }
+ while (cattrs != null) {
+ attr = cattrs.next;
+ cattrs.next = null;
+ fv.visitAttribute(cattrs);
+ cattrs = attr;
+ }
+ fv.visitEnd();
+ }
+ }
+
+ // visits the methods
+ i = readUnsignedShort(u);
+ u += 2;
+ for (; i > 0; --i) {
+ int u0 = u + 6;
+ access = readUnsignedShort(u);
+ name = readUTF8(u + 2, c);
+ desc = readUTF8(u + 4, c);
+ signature = null;
+ anns = 0;
+ ianns = 0;
+ int dann = 0;
+ int mpanns = 0;
+ int impanns = 0;
+ cattrs = null;
+ v = 0;
+ w = 0;
+
+ // looks for Code and Exceptions attributes
+ j = readUnsignedShort(u + 6);
+ u += 8;
+ for (; j > 0; --j) {
+ attrName = readUTF8(u, c);
+ u += 2;
+ int attrSize = readInt(u);
+ u += 4;
+ if (attrName.equals("Code")) {
+ v = u;
+ } else if (attrName.equals("Exceptions")) {
+ w = u;
+ } else if (attrName.equals("Synthetic")) {
+ access |= Opcodes.ACC_SYNTHETIC;
+ } else if (attrName.equals("Varargs")) {
+ access |= Opcodes.ACC_VARARGS;
+ } else if (attrName.equals("Bridge")) {
+ access |= Opcodes.ACC_BRIDGE;
+ } else if (attrName.equals("Deprecated")) {
+ access |= Opcodes.ACC_DEPRECATED;
+ } else if (attrName.equals("Signature")) {
+ signature = readUTF8(u, c);
+ } else if (attrName.equals("AnnotationDefault")) {
+ dann = u;
+ } else if (attrName.equals("RuntimeVisibleAnnotations")) {
+ anns = u;
+ } else if (attrName.equals("RuntimeInvisibleAnnotations")) {
+ ianns = u;
+ } else if (attrName.equals("RuntimeVisibleParameterAnnotations"))
+ {
+ mpanns = u;
+ } else if (attrName.equals("RuntimeInvisibleParameterAnnotations"))
+ {
+ impanns = u;
+ } else {
+ attr = readAttribute(attrs,
+ attrName,
+ u,
+ attrSize,
+ c,
+ -1,
+ null);
+ if (attr != null) {
+ attr.next = cattrs;
+ cattrs = attr;
+ }
+ }
+ u += attrSize;
+ }
+ // reads declared exceptions
+ String[] exceptions;
+ if (w == 0) {
+ exceptions = null;
+ } else {
+ exceptions = new String[readUnsignedShort(w)];
+ w += 2;
+ for (j = 0; j < exceptions.length; ++j) {
+ exceptions[j] = readClass(w, c);
+ w += 2;
+ }
+ }
+
+ // visits the method's code, if any
+ MethodVisitor mv = classVisitor.visitMethod(access,
+ name,
+ desc,
+ signature,
+ exceptions);
+
+ if (mv != null) {
+ /*
+ * if the returned MethodVisitor is in fact a MethodWriter, it
+ * means there is no method adapter between the reader and the
+ * writer. If, in addition, the writer's constant pool was
+ * copied from this reader (mw.cw.cr == this), and the signature
+ * and exceptions of the method have not been changed, then it
+ * is possible to skip all visit events and just copy the
+ * original code of the method to the writer (the access, name
+ * and descriptor can have been changed, this is not important
+ * since they are not copied as is from the reader).
+ */
+ if (mv instanceof MethodWriter) {
+ MethodWriter mw = (MethodWriter) mv;
+ if (mw.cw.cr == this) {
+ if (signature == mw.signature) {
+ boolean sameExceptions = false;
+ if (exceptions == null) {
+ sameExceptions = mw.exceptionCount == 0;
+ } else {
+ if (exceptions.length == mw.exceptionCount) {
+ sameExceptions = true;
+ for (j = exceptions.length - 1; j >= 0; --j)
+ {
+ w -= 2;
+ if (mw.exceptions[j] != readUnsignedShort(w))
+ {
+ sameExceptions = false;
+ break;
+ }
+ }
+ }
+ }
+ if (sameExceptions) {
+ /*
+ * we do not copy directly the code into
+ * MethodWriter to save a byte array copy
+ * operation. The real copy will be done in
+ * ClassWriter.toByteArray().
+ */
+ mw.classReaderOffset = u0;
+ mw.classReaderLength = u - u0;
+ continue;
+ }
+ }
+ }
+ }
+ if (dann != 0) {
+ AnnotationVisitor dv = mv.visitAnnotationDefault();
+ readAnnotationValue(dann, c, null, dv);
+ dv.visitEnd();
+ }
+ for (j = 1; j >= 0; --j) {
+ w = j == 0 ? ianns : anns;
+ if (w != 0) {
+ k = readUnsignedShort(w);
+ w += 2;
+ for (; k > 0; --k) {
+ desc = readUTF8(w, c);
+ w += 2;
+ w = readAnnotationValues(w,
+ c,
+ mv.visitAnnotation(desc, j != 0));
+ }
+ }
+ }
+ if (mpanns != 0) {
+ readParameterAnnotations(mpanns, c, true, mv);
+ }
+ if (impanns != 0) {
+ readParameterAnnotations(impanns, c, false, mv);
+ }
+ while (cattrs != null) {
+ attr = cattrs.next;
+ cattrs.next = null;
+ mv.visitAttribute(cattrs);
+ cattrs = attr;
+ }
+ }
+
+ if (mv != null && v != 0) {
+ int maxStack = readUnsignedShort(v);
+ int maxLocals = readUnsignedShort(v + 2);
+ int codeLength = readInt(v + 4);
+ v += 8;
+
+ int codeStart = v;
+ int codeEnd = v + codeLength;
+
+ mv.visitCode();
+
+ // 1st phase: finds the labels
+ int label;
+ Label[] labels = new Label[codeLength + 1];
+ while (v < codeEnd) {
+ int opcode = b[v] & 0xFF;
+ switch (ClassWriter.TYPE[opcode]) {
+ case ClassWriter.NOARG_INSN:
+ case ClassWriter.IMPLVAR_INSN:
+ v += 1;
+ break;
+ case ClassWriter.LABEL_INSN:
+ label = v - codeStart + readShort(v + 1);
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ v += 3;
+ break;
+ case ClassWriter.LABELW_INSN:
+ label = v - codeStart + readInt(v + 1);
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ v += 5;
+ break;
+ case ClassWriter.WIDE_INSN:
+ opcode = b[v + 1] & 0xFF;
+ if (opcode == Opcodes.IINC) {
+ v += 6;
+ } else {
+ v += 4;
+ }
+ break;
+ case ClassWriter.TABL_INSN:
+ // skips 0 to 3 padding bytes
+ w = v - codeStart;
+ v = v + 4 - (w & 3);
+ // reads instruction
+ label = w + readInt(v);
+ v += 4;
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ j = readInt(v);
+ v += 4;
+ j = readInt(v) - j + 1;
+ v += 4;
+ for (; j > 0; --j) {
+ label = w + readInt(v);
+ v += 4;
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ }
+ break;
+ case ClassWriter.LOOK_INSN:
+ // skips 0 to 3 padding bytes
+ w = v - codeStart;
+ v = v + 4 - (w & 3);
+ // reads instruction
+ label = w + readInt(v);
+ v += 4;
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ j = readInt(v);
+ v += 4;
+ for (; j > 0; --j) {
+ v += 4; // skips key
+ label = w + readInt(v);
+ v += 4;
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ }
+ break;
+ case ClassWriter.VAR_INSN:
+ case ClassWriter.SBYTE_INSN:
+ case ClassWriter.LDC_INSN:
+ v += 2;
+ break;
+ case ClassWriter.SHORT_INSN:
+ case ClassWriter.LDCW_INSN:
+ case ClassWriter.FIELDORMETH_INSN:
+ case ClassWriter.TYPE_INSN:
+ case ClassWriter.IINC_INSN:
+ v += 3;
+ break;
+ case ClassWriter.ITFMETH_INSN:
+ v += 5;
+ break;
+ // case MANA_INSN:
+ default:
+ v += 4;
+ break;
+ }
+ }
+ // parses the try catch entries
+ j = readUnsignedShort(v);
+ v += 2;
+ for (; j > 0; --j) {
+ label = readUnsignedShort(v);
+ Label start = labels[label];
+ if (start == null) {
+ labels[label] = start = new Label();
+ }
+ label = readUnsignedShort(v + 2);
+ Label end = labels[label];
+ if (end == null) {
+ labels[label] = end = new Label();
+ }
+ label = readUnsignedShort(v + 4);
+ Label handler = labels[label];
+ if (handler == null) {
+ labels[label] = handler = new Label();
+ }
+
+ int type = readUnsignedShort(v + 6);
+ if (type == 0) {
+ mv.visitTryCatchBlock(start, end, handler, null);
+ } else {
+ mv.visitTryCatchBlock(start,
+ end,
+ handler,
+ readUTF8(items[type], c));
+ }
+ v += 8;
+ }
+ // parses the local variable, line number tables, and code
+ // attributes
+ int varTable = 0;
+ int varTypeTable = 0;
+ cattrs = null;
+ j = readUnsignedShort(v);
+ v += 2;
+ for (; j > 0; --j) {
+ attrName = readUTF8(v, c);
+ if (attrName.equals("LocalVariableTable")) {
+ if (!skipDebug) {
+ varTable = v + 6;
+ k = readUnsignedShort(v + 6);
+ w = v + 8;
+ for (; k > 0; --k) {
+ label = readUnsignedShort(w);
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ label += readUnsignedShort(w + 2);
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ w += 10;
+ }
+ }
+ } else if (attrName.equals("LocalVariableTypeTable")) {
+ varTypeTable = v + 6;
+ } else if (attrName.equals("LineNumberTable")) {
+ if (!skipDebug) {
+ k = readUnsignedShort(v + 6);
+ w = v + 8;
+ for (; k > 0; --k) {
+ label = readUnsignedShort(w);
+ if (labels[label] == null) {
+ labels[label] = new Label();
+ }
+ labels[label].line = readUnsignedShort(w + 2);
+ w += 4;
+ }
+ }
+ } else {
+ for (k = 0; k < attrs.length; ++k) {
+ if (attrs[k].type.equals(attrName)) {
+ attr = attrs[k].read(this,
+ v + 6,
+ readInt(v + 2),
+ c,
+ codeStart - 8,
+ labels);
+ if (attr != null) {
+ attr.next = cattrs;
+ cattrs = attr;
+ }
+ }
+ }
+ }
+ v += 6 + readInt(v + 2);
+ }
+
+ // 2nd phase: visits each instruction
+ v = codeStart;
+ Label l;
+ while (v < codeEnd) {
+ w = v - codeStart;
+ l = labels[w];
+ if (l != null) {
+ mv.visitLabel(l);
+ if (!skipDebug && l.line > 0) {
+ mv.visitLineNumber(l.line, l);
+ }
+ }
+ int opcode = b[v] & 0xFF;
+ switch (ClassWriter.TYPE[opcode]) {
+ case ClassWriter.NOARG_INSN:
+ mv.visitInsn(opcode);
+ v += 1;
+ break;
+ case ClassWriter.IMPLVAR_INSN:
+ if (opcode > Opcodes.ISTORE) {
+ opcode -= 59; // ISTORE_0
+ mv.visitVarInsn(Opcodes.ISTORE + (opcode >> 2),
+ opcode & 0x3);
+ } else {
+ opcode -= 26; // ILOAD_0
+ mv.visitVarInsn(Opcodes.ILOAD + (opcode >> 2),
+ opcode & 0x3);
+ }
+ v += 1;
+ break;
+ case ClassWriter.LABEL_INSN:
+ mv.visitJumpInsn(opcode, labels[w
+ + readShort(v + 1)]);
+ v += 3;
+ break;
+ case ClassWriter.LABELW_INSN:
+ mv.visitJumpInsn(opcode - 33, labels[w
+ + readInt(v + 1)]);
+ v += 5;
+ break;
+ case ClassWriter.WIDE_INSN:
+ opcode = b[v + 1] & 0xFF;
+ if (opcode == Opcodes.IINC) {
+ mv.visitIincInsn(readUnsignedShort(v + 2),
+ readShort(v + 4));
+ v += 6;
+ } else {
+ mv.visitVarInsn(opcode,
+ readUnsignedShort(v + 2));
+ v += 4;
+ }
+ break;
+ case ClassWriter.TABL_INSN:
+ // skips 0 to 3 padding bytes
+ v = v + 4 - (w & 3);
+ // reads instruction
+ label = w + readInt(v);
+ v += 4;
+ int min = readInt(v);
+ v += 4;
+ int max = readInt(v);
+ v += 4;
+ Label[] table = new Label[max - min + 1];
+ for (j = 0; j < table.length; ++j) {
+ table[j] = labels[w + readInt(v)];
+ v += 4;
+ }
+ mv.visitTableSwitchInsn(min,
+ max,
+ labels[label],
+ table);
+ break;
+ case ClassWriter.LOOK_INSN:
+ // skips 0 to 3 padding bytes
+ v = v + 4 - (w & 3);
+ // reads instruction
+ label = w + readInt(v);
+ v += 4;
+ j = readInt(v);
+ v += 4;
+ int[] keys = new int[j];
+ Label[] values = new Label[j];
+ for (j = 0; j < keys.length; ++j) {
+ keys[j] = readInt(v);
+ v += 4;
+ values[j] = labels[w + readInt(v)];
+ v += 4;
+ }
+ mv.visitLookupSwitchInsn(labels[label],
+ keys,
+ values);
+ break;
+ case ClassWriter.VAR_INSN:
+ mv.visitVarInsn(opcode, b[v + 1] & 0xFF);
+ v += 2;
+ break;
+ case ClassWriter.SBYTE_INSN:
+ mv.visitIntInsn(opcode, b[v + 1]);
+ v += 2;
+ break;
+ case ClassWriter.SHORT_INSN:
+ mv.visitIntInsn(opcode, readShort(v + 1));
+ v += 3;
+ break;
+ case ClassWriter.LDC_INSN:
+ mv.visitLdcInsn(readConst(b[v + 1] & 0xFF, c));
+ v += 2;
+ break;
+ case ClassWriter.LDCW_INSN:
+ mv.visitLdcInsn(readConst(readUnsignedShort(v + 1),
+ c));
+ v += 3;
+ break;
+ case ClassWriter.FIELDORMETH_INSN:
+ case ClassWriter.ITFMETH_INSN:
+ int cpIndex = items[readUnsignedShort(v + 1)];
+ String iowner = readClass(cpIndex, c);
+ cpIndex = items[readUnsignedShort(cpIndex + 2)];
+ String iname = readUTF8(cpIndex, c);
+ String idesc = readUTF8(cpIndex + 2, c);
+ if (opcode < Opcodes.INVOKEVIRTUAL) {
+ mv.visitFieldInsn(opcode, iowner, iname, idesc);
+ } else {
+ mv.visitMethodInsn(opcode, iowner, iname, idesc);
+ }
+ if (opcode == Opcodes.INVOKEINTERFACE) {
+ v += 5;
+ } else {
+ v += 3;
+ }
+ break;
+ case ClassWriter.TYPE_INSN:
+ mv.visitTypeInsn(opcode, readClass(v + 1, c));
+ v += 3;
+ break;
+ case ClassWriter.IINC_INSN:
+ mv.visitIincInsn(b[v + 1] & 0xFF, b[v + 2]);
+ v += 3;
+ break;
+ // case MANA_INSN:
+ default:
+ mv.visitMultiANewArrayInsn(readClass(v + 1, c),
+ b[v + 3] & 0xFF);
+ v += 4;
+ break;
+ }
+ }
+ l = labels[codeEnd - codeStart];
+ if (l != null) {
+ mv.visitLabel(l);
+ }
+
+ // visits the local variable tables
+ if (!skipDebug && varTable != 0) {
+ int[] typeTable = null;
+ if (varTypeTable != 0) {
+ w = varTypeTable;
+ k = readUnsignedShort(w) * 3;
+ w += 2;
+ typeTable = new int[k];
+ while (k > 0) {
+ typeTable[--k] = w + 6; // signature
+ typeTable[--k] = readUnsignedShort(w + 8); // index
+ typeTable[--k] = readUnsignedShort(w); // start
+ w += 10;
+ }
+ }
+ w = varTable;
+ k = readUnsignedShort(w);
+ w += 2;
+ for (; k > 0; --k) {
+ int start = readUnsignedShort(w);
+ int length = readUnsignedShort(w + 2);
+ int index = readUnsignedShort(w + 8);
+ String vsignature = null;
+ if (typeTable != null) {
+ for (int a = 0; a < typeTable.length; a += 3) {
+ if (typeTable[a] == start
+ && typeTable[a + 1] == index)
+ {
+ vsignature = readUTF8(typeTable[a + 2], c);
+ break;
+ }
+ }
+ }
+ mv.visitLocalVariable(readUTF8(w + 4, c),
+ readUTF8(w + 6, c),
+ vsignature,
+ labels[start],
+ labels[start + length],
+ index);
+ w += 10;
+ }
+ }
+ // visits the other attributes
+ while (cattrs != null) {
+ attr = cattrs.next;
+ cattrs.next = null;
+ mv.visitAttribute(cattrs);
+ cattrs = attr;
+ }
+ // visits the max stack and max locals values
+ mv.visitMaxs(maxStack, maxLocals);
+ }
+
+ if (mv != null) {
+ mv.visitEnd();
+ }
+ }
+
+ // visits the end of the class
+ classVisitor.visitEnd();
+ }
+
+ /**
+ * Reads parameter annotations and makes the given visitor visit them.
+ *
+ * @param v start offset in {@link #b b} of the annotations to be read.
+ * @param buf buffer to be used to call {@link #readUTF8 readUTF8},
+ * {@link #readClass(int,char[]) readClass} or
+ * {@link #readConst readConst}.
+ * @param visible <tt>true</tt> if the annotations to be read are visible
+ * at runtime.
+ * @param mv the visitor that must visit the annotations.
+ */
+ private void readParameterAnnotations(
+ int v,
+ final char[] buf,
+ final boolean visible,
+ final MethodVisitor mv)
+ {
+ int n = b[v++] & 0xFF;
+ for (int i = 0; i < n; ++i) {
+ int j = readUnsignedShort(v);
+ v += 2;
+ for (; j > 0; --j) {
+ String desc = readUTF8(v, buf);
+ v += 2;
+ AnnotationVisitor av = mv.visitParameterAnnotation(i,
+ desc,
+ visible);
+ v = readAnnotationValues(v, buf, av);
+ }
+ }
+ }
+
+ /**
+ * Reads the values of an annotation and makes the given visitor visit them.
+ *
+ * @param v the start offset in {@link #b b} of the values to be read
+ * (including the unsigned short that gives the number of values).
+ * @param buf buffer to be used to call {@link #readUTF8 readUTF8},
+ * {@link #readClass(int,char[]) readClass} or
+ * {@link #readConst readConst}.
+ * @param av the visitor that must visit the values.
+ * @return the end offset of the annotations values.
+ */
+ private int readAnnotationValues(
+ int v,
+ final char[] buf,
+ final AnnotationVisitor av)
+ {
+ int i = readUnsignedShort(v);
+ v += 2;
+ for (; i > 0; --i) {
+ String name = readUTF8(v, buf);
+ v += 2;
+ v = readAnnotationValue(v, buf, name, av);
+ }
+ av.visitEnd();
+ return v;
+ }
+
+ /**
+ * Reads a value of an annotation and makes the given visitor visit it.
+ *
+ * @param v the start offset in {@link #b b} of the value to be read (<i>not
+ * including the value name constant pool index</i>).
+ * @param buf buffer to be used to call {@link #readUTF8 readUTF8},
+ * {@link #readClass(int,char[]) readClass} or
+ * {@link #readConst readConst}.
+ * @param name the name of the value to be read.
+ * @param av the visitor that must visit the value.
+ * @return the end offset of the annotation value.
+ */
+ private int readAnnotationValue(
+ int v,
+ final char[] buf,
+ final String name,
+ final AnnotationVisitor av)
+ {
+ int i;
+ switch (readByte(v++)) {
+ case 'I': // pointer to CONSTANT_Integer
+ case 'J': // pointer to CONSTANT_Long
+ case 'F': // pointer to CONSTANT_Float
+ case 'D': // pointer to CONSTANT_Double
+ av.visit(name, readConst(readUnsignedShort(v), buf));
+ v += 2;
+ break;
+ case 'B': // pointer to CONSTANT_Byte
+ av.visit(name,
+ new Byte((byte) readInt(items[readUnsignedShort(v)])));
+ v += 2;
+ break;
+ case 'Z': // pointer to CONSTANT_Boolean
+ boolean b = readInt(items[readUnsignedShort(v)]) == 0;
+ av.visit(name, b ? Boolean.FALSE : Boolean.TRUE);
+ v += 2;
+ break;
+ case 'S': // pointer to CONSTANT_Short
+ av.visit(name,
+ new Short((short) readInt(items[readUnsignedShort(v)])));
+ v += 2;
+ break;
+ case 'C': // pointer to CONSTANT_Char
+ av.visit(name,
+ new Character((char) readInt(items[readUnsignedShort(v)])));
+ v += 2;
+ break;
+ case 's': // pointer to CONSTANT_Utf8
+ av.visit(name, readUTF8(v, buf));
+ v += 2;
+ break;
+ case 'e': // enum_const_value
+ av.visitEnum(name, readUTF8(v, buf), readUTF8(v + 2, buf));
+ v += 4;
+ break;
+ case 'c': // class_info
+ av.visit(name, Type.getType(readUTF8(v, buf)));
+ v += 2;
+ break;
+ case '@': // annotation_value
+ String desc = readUTF8(v, buf);
+ v += 2;
+ v = readAnnotationValues(v, buf, av.visitAnnotation(name, desc));
+ break;
+ case '[': // array_value
+ int size = readUnsignedShort(v);
+ v += 2;
+ if (size == 0) {
+ av.visitArray(name).visitEnd();
+ return v;
+ }
+ switch (readByte(v++)) {
+ case 'B':
+ byte[] bv = new byte[size];
+ for (i = 0; i < size; i++) {
+ bv[i] = (byte) readInt(items[readUnsignedShort(v)]);
+ v += 3;
+ }
+ av.visit(name, bv);
+ --v;
+ break;
+ case 'Z':
+ boolean[] zv = new boolean[size];
+ for (i = 0; i < size; i++) {
+ zv[i] = readInt(items[readUnsignedShort(v)]) != 0;
+ v += 3;
+ }
+ av.visit(name, zv);
+ --v;
+ break;
+ case 'S':
+ short[] sv = new short[size];
+ for (i = 0; i < size; i++) {
+ sv[i] = (short) readInt(items[readUnsignedShort(v)]);
+ v += 3;
+ }
+ av.visit(name, sv);
+ --v;
+ break;
+ case 'C':
+ char[] cv = new char[size];
+ for (i = 0; i < size; i++) {
+ cv[i] = (char) readInt(items[readUnsignedShort(v)]);
+ v += 3;
+ }
+ av.visit(name, cv);
+ --v;
+ break;
+ case 'I':
+ int[] iv = new int[size];
+ for (i = 0; i < size; i++) {
+ iv[i] = readInt(items[readUnsignedShort(v)]);
+ v += 3;
+ }
+ av.visit(name, iv);
+ --v;
+ break;
+ case 'J':
+ long[] lv = new long[size];
+ for (i = 0; i < size; i++) {
+ lv[i] = readLong(items[readUnsignedShort(v)]);
+ v += 3;
+ }
+ av.visit(name, lv);
+ --v;
+ break;
+ case 'F':
+ float[] fv = new float[size];
+ for (i = 0; i < size; i++) {
+ fv[i] = Float.intBitsToFloat(readInt(items[readUnsignedShort(v)]));
+ v += 3;
+ }
+ av.visit(name, fv);
+ --v;
+ break;
+ case 'D':
+ double[] dv = new double[size];
+ for (i = 0; i < size; i++) {
+ dv[i] = Double.longBitsToDouble(readLong(items[readUnsignedShort(v)]));
+ v += 3;
+ }
+ av.visit(name, dv);
+ --v;
+ break;
+ default:
+ v--;
+ AnnotationVisitor aav = av.visitArray(name);
+ for (i = size; i > 0; --i) {
+ v = readAnnotationValue(v, buf, null, aav);
+ }
+ aav.visitEnd();
+ }
+ }
+ return v;
+ }
+
+ /**
+ * Reads an attribute in {@link #b b}.
+ *
+ * @param attrs prototypes of the attributes that must be parsed during the
+ * visit of the class. Any attribute whose type is not equal to the
+ * type of one the prototypes is ignored (i.e. an empty
+ * {@link Attribute} instance is returned).
+ * @param type the type of the attribute.
+ * @param off index of the first byte of the attribute's content in
+ * {@link #b b}. The 6 attribute header bytes, containing the type
+ * and the length of the attribute, are not taken into account here
+ * (they have already been read).
+ * @param len the length of the attribute's content.
+ * @param buf buffer to be used to call {@link #readUTF8 readUTF8},
+ * {@link #readClass(int,char[]) readClass} or
+ * {@link #readConst readConst}.
+ * @param codeOff index of the first byte of code's attribute content in
+ * {@link #b b}, or -1 if the attribute to be read is not a code
+ * attribute. The 6 attribute header bytes, containing the type and
+ * the length of the attribute, are not taken into account here.
+ * @param labels the labels of the method's code, or <tt>null</tt> if the
+ * attribute to be read is not a code attribute.
+ * @return the attribute that has been read, or <tt>null</tt> to skip this
+ * attribute.
+ */
+ private Attribute readAttribute(
+ final Attribute[] attrs,
+ final String type,
+ final int off,
+ final int len,
+ final char[] buf,
+ final int codeOff,
+ final Label[] labels)
+ {
+ for (int i = 0; i < attrs.length; ++i) {
+ if (attrs[i].type.equals(type)) {
+ return attrs[i].read(this, off, len, buf, codeOff, labels);
+ }
+ }
+ return new Attribute(type).read(this, off, len, null, -1, null);
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods: low level parsing
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the start index of the constant pool item in {@link #b b}, plus
+ * one. <i>This method is intended for {@link Attribute} sub classes, and is
+ * normally not needed by class generators or adapters.</i>
+ *
+ * @param item the index a constant pool item.
+ * @return the start index of the constant pool item in {@link #b b}, plus
+ * one.
+ */
+ public int getItem(final int item) {
+ return items[item];
+ }
+
+ /**
+ * Reads a byte value in {@link #b b}. <i>This method is intended for
+ * {@link Attribute} sub classes, and is normally not needed by class
+ * generators or adapters.</i>
+ *
+ * @param index the start index of the value to be read in {@link #b b}.
+ * @return the read value.
+ */
+ public int readByte(final int index) {
+ return b[index] & 0xFF;
+ }
+
+ /**
+ * Reads an unsigned short value in {@link #b b}. <i>This method is
+ * intended for {@link Attribute} sub classes, and is normally not needed by
+ * class generators or adapters.</i>
+ *
+ * @param index the start index of the value to be read in {@link #b b}.
+ * @return the read value.
+ */
+ public int readUnsignedShort(final int index) {
+ byte[] b = this.b;
+ return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF);
+ }
+
+ /**
+ * Reads a signed short value in {@link #b b}. <i>This method is intended
+ * for {@link Attribute} sub classes, and is normally not needed by class
+ * generators or adapters.</i>
+ *
+ * @param index the start index of the value to be read in {@link #b b}.
+ * @return the read value.
+ */
+ public short readShort(final int index) {
+ byte[] b = this.b;
+ return (short) (((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF));
+ }
+
+ /**
+ * Reads a signed int value in {@link #b b}. <i>This method is intended for
+ * {@link Attribute} sub classes, and is normally not needed by class
+ * generators or adapters.</i>
+ *
+ * @param index the start index of the value to be read in {@link #b b}.
+ * @return the read value.
+ */
+ public int readInt(final int index) {
+ byte[] b = this.b;
+ return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16)
+ | ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);
+ }
+
+ /**
+ * Reads a signed long value in {@link #b b}. <i>This method is intended
+ * for {@link Attribute} sub classes, and is normally not needed by class
+ * generators or adapters.</i>
+ *
+ * @param index the start index of the value to be read in {@link #b b}.
+ * @return the read value.
+ */
+ public long readLong(final int index) {
+ long l1 = readInt(index);
+ long l0 = readInt(index + 4) & 0xFFFFFFFFL;
+ return (l1 << 32) | l0;
+ }
+
+ /**
+ * Reads an UTF8 string constant pool item in {@link #b b}. <i>This method
+ * is intended for {@link Attribute} sub classes, and is normally not needed
+ * by class generators or adapters.</i>
+ *
+ * @param index the start index of an unsigned short value in {@link #b b},
+ * whose value is the index of an UTF8 constant pool item.
+ * @param buf buffer to be used to read the item. This buffer must be
+ * sufficiently large. It is not automatically resized.
+ * @return the String corresponding to the specified UTF8 item.
+ */
+ public String readUTF8(int index, final char[] buf) {
+ int item = readUnsignedShort(index);
+ String s = strings[item];
+ if (s != null) {
+ return s;
+ }
+ index = items[item];
+ return strings[item] = readUTF(index + 2, readUnsignedShort(index), buf);
+ }
+
+ /**
+ * Reads UTF8 string in {@link #b b}.
+ *
+ * @param index start offset of the UTF8 string to be read.
+ * @param utfLen length of the UTF8 string to be read.
+ * @param buf buffer to be used to read the string. This buffer must be
+ * sufficiently large. It is not automatically resized.
+ * @return the String corresponding to the specified UTF8 string.
+ */
+ private String readUTF(int index, int utfLen, char[] buf) {
+ int endIndex = index + utfLen;
+ byte[] b = this.b;
+ int strLen = 0;
+ int c, d, e;
+ while (index < endIndex) {
+ c = b[index++] & 0xFF;
+ switch (c >> 4) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ // 0xxxxxxx
+ buf[strLen++] = (char) c;
+ break;
+ case 12:
+ case 13:
+ // 110x xxxx 10xx xxxx
+ d = b[index++];
+ buf[strLen++] = (char) (((c & 0x1F) << 6) | (d & 0x3F));
+ break;
+ default:
+ // 1110 xxxx 10xx xxxx 10xx xxxx
+ d = b[index++];
+ e = b[index++];
+ buf[strLen++] = (char) (((c & 0x0F) << 12)
+ | ((d & 0x3F) << 6) | (e & 0x3F));
+ break;
+ }
+ }
+ return new String(buf, 0, strLen);
+ }
+
+ /**
+ * Reads a class constant pool item in {@link #b b}. <i>This method is
+ * intended for {@link Attribute} sub classes, and is normally not needed by
+ * class generators or adapters.</i>
+ *
+ * @param index the start index of an unsigned short value in {@link #b b},
+ * whose value is the index of a class constant pool item.
+ * @param buf buffer to be used to read the item. This buffer must be
+ * sufficiently large. It is not automatically resized.
+ * @return the String corresponding to the specified class item.
+ */
+ public String readClass(final int index, final char[] buf) {
+ // computes the start index of the CONSTANT_Class item in b
+ // and reads the CONSTANT_Utf8 item designated by
+ // the first two bytes of this CONSTANT_Class item
+ return readUTF8(items[readUnsignedShort(index)], buf);
+ }
+
+ /**
+ * Reads a numeric or string constant pool item in {@link #b b}. <i>This
+ * method is intended for {@link Attribute} sub classes, and is normally not
+ * needed by class generators or adapters.</i>
+ *
+ * @param item the index of a constant pool item.
+ * @param buf buffer to be used to read the item. This buffer must be
+ * sufficiently large. It is not automatically resized.
+ * @return the {@link Integer}, {@link Float}, {@link Long},
+ * {@link Double}, {@link String} or {@link Type} corresponding to
+ * the given constant pool item.
+ */
+ public Object readConst(final int item, final char[] buf) {
+ int index = items[item];
+ switch (b[index - 1]) {
+ case ClassWriter.INT:
+ return new Integer(readInt(index));
+ case ClassWriter.FLOAT:
+ return new Float(Float.intBitsToFloat(readInt(index)));
+ case ClassWriter.LONG:
+ return new Long(readLong(index));
+ case ClassWriter.DOUBLE:
+ return new Double(Double.longBitsToDouble(readLong(index)));
+ case ClassWriter.CLASS:
+ String s = readUTF8(index, buf);
+ return Type.getType(s.charAt(0) == '[' ? s : "L" + s + ";");
+ // case ClassWriter.STR:
+ default:
+ return readUTF8(index, buf);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassVisitor.java
new file mode 100644
index 000000000..edeb58765
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassVisitor.java
@@ -0,0 +1,195 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A visitor to visit a Java class. The methods of this interface must be called
+ * in the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
+ * <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
+ * <tt>visitAttribute</tt> )* (<tt>visitInnerClass</tt> |
+ * <tt>visitField</tt> | <tt>visitMethod</tt> )* <tt>visitEnd</tt>.
+ *
+ * @author Eric Bruneton
+ */
+public interface ClassVisitor {
+
+ /**
+ * Visits the header of the class.
+ *
+ * @param version the class version.
+ * @param access the class's access flags (see {@link Opcodes}). This
+ * parameter also indicates if the class is deprecated.
+ * @param name the internal name of the class (see
+ * {@link Type#getInternalName() getInternalName}).
+ * @param signature the signature of this class. May be <tt>null</tt> if
+ * the class is not a generic one, and does not extend or implement
+ * generic classes or interfaces.
+ * @param superName the internal of name of the super class (see
+ * {@link Type#getInternalName() getInternalName}). For interfaces,
+ * the super class is {@link Object}. May be <tt>null</tt>, but
+ * only for the {@link Object} class.
+ * @param interfaces the internal names of the class's interfaces (see
+ * {@link Type#getInternalName() getInternalName}). May be
+ * <tt>null</tt>.
+ */
+ void visit(
+ int version,
+ int access,
+ String name,
+ String signature,
+ String superName,
+ String[] interfaces);
+
+ /**
+ * Visits the source of the class.
+ *
+ * @param source the name of the source file from which the class was
+ * compiled. May be <tt>null</tt>.
+ * @param debug additional debug information to compute the correspondance
+ * between source and compiled elements of the class. May be
+ * <tt>null</tt>.
+ */
+ void visitSource(String source, String debug);
+
+ /**
+ * Visits the enclosing class of the class. This method must be called only
+ * if the class has an enclosing class.
+ *
+ * @param owner internal name of the enclosing class of the class.
+ * @param name the name of the method that contains the class, or
+ * <tt>null</tt> if the class is not enclosed in a method of its
+ * enclosing class.
+ * @param desc the descriptor of the method that contains the class, or
+ * <tt>null</tt> if the class is not enclosed in a method of its
+ * enclosing class.
+ */
+ void visitOuterClass(String owner, String name, String desc);
+
+ /**
+ * Visits an annotation of the class.
+ *
+ * @param desc the class descriptor of the annotation class.
+ * @param visible <tt>true</tt> if the annotation is visible at runtime.
+ * @return a non null visitor to visit the annotation values.
+ */
+ AnnotationVisitor visitAnnotation(String desc, boolean visible);
+
+ /**
+ * Visits a non standard attribute of the class.
+ *
+ * @param attr an attribute.
+ */
+ void visitAttribute(Attribute attr);
+
+ /**
+ * Visits information about an inner class. This inner class is not
+ * necessarily a member of the class being visited.
+ *
+ * @param name the internal name of an inner class (see
+ * {@link Type#getInternalName() getInternalName}).
+ * @param outerName the internal name of the class to which the inner class
+ * belongs (see {@link Type#getInternalName() getInternalName}). May
+ * be <tt>null</tt>.
+ * @param innerName the (simple) name of the inner class inside its
+ * enclosing class. May be <tt>null</tt> for anonymous inner
+ * classes.
+ * @param access the access flags of the inner class as originally declared
+ * in the enclosing class.
+ */
+ void visitInnerClass(
+ String name,
+ String outerName,
+ String innerName,
+ int access);
+
+ /**
+ * Visits a field of the class.
+ *
+ * @param access the field's access flags (see {@link Opcodes}). This
+ * parameter also indicates if the field is synthetic and/or
+ * deprecated.
+ * @param name the field's name.
+ * @param desc the field's descriptor (see {@link Type Type}).
+ * @param signature the field's signature. May be <tt>null</tt> if the
+ * field's type does not use generic types.
+ * @param value the field's initial value. This parameter, which may be
+ * <tt>null</tt> if the field does not have an initial value, must
+ * be an {@link Integer}, a {@link Float}, a {@link Long}, a
+ * {@link Double} or a {@link String} (for <tt>int</tt>,
+ * <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
+ * respectively). <i>This parameter is only used for static fields</i>.
+ * Its value is ignored for non static fields, which must be
+ * initialized through bytecode instructions in constructors or
+ * methods.
+ * @return a visitor to visit field annotations and attributes, or
+ * <tt>null</tt> if this class visitor is not interested in
+ * visiting these annotations and attributes.
+ */
+ FieldVisitor visitField(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ Object value);
+
+ /**
+ * Visits a method of the class. This method <i>must</i> return a new
+ * {@link MethodVisitor} instance (or <tt>null</tt>) each time it is
+ * called, i.e., it should not return a previously returned visitor.
+ *
+ * @param access the method's access flags (see {@link Opcodes}). This
+ * parameter also indicates if the method is synthetic and/or
+ * deprecated.
+ * @param name the method's name.
+ * @param desc the method's descriptor (see {@link Type Type}).
+ * @param signature the method's signature. May be <tt>null</tt> if the
+ * method parameters, return type and exceptions do not use generic
+ * types.
+ * @param exceptions the internal names of the method's exception classes
+ * (see {@link Type#getInternalName() getInternalName}). May be
+ * <tt>null</tt>.
+ * @return an object to visit the byte code of the method, or <tt>null</tt>
+ * if this class visitor is not interested in visiting the code of
+ * this method.
+ */
+ MethodVisitor visitMethod(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ String[] exceptions);
+
+ /**
+ * Visits the end of the class. This method, which is the last one to be
+ * called, is used to inform the visitor that all the fields and methods of
+ * the class have been visited.
+ */
+ void visitEnd();
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassWriter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassWriter.java
new file mode 100644
index 000000000..81eeeb7d6
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/ClassWriter.java
@@ -0,0 +1,1162 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A {@link ClassVisitor} that generates classes in bytecode form. More
+ * precisely this visitor generates a byte array conforming to the Java class
+ * file format. It can be used alone, to generate a Java class "from scratch",
+ * or with one or more {@link ClassReader ClassReader} and adapter class visitor
+ * to generate a modified class from one or more existing Java classes.
+ *
+ * @author Eric Bruneton
+ */
+public class ClassWriter implements ClassVisitor {
+
+ /**
+ * The type of instructions without any argument.
+ */
+ final static int NOARG_INSN = 0;
+
+ /**
+ * The type of instructions with an signed byte argument.
+ */
+ final static int SBYTE_INSN = 1;
+
+ /**
+ * The type of instructions with an signed short argument.
+ */
+ final static int SHORT_INSN = 2;
+
+ /**
+ * The type of instructions with a local variable index argument.
+ */
+ final static int VAR_INSN = 3;
+
+ /**
+ * The type of instructions with an implicit local variable index argument.
+ */
+ final static int IMPLVAR_INSN = 4;
+
+ /**
+ * The type of instructions with a type descriptor argument.
+ */
+ final static int TYPE_INSN = 5;
+
+ /**
+ * The type of field and method invocations instructions.
+ */
+ final static int FIELDORMETH_INSN = 6;
+
+ /**
+ * The type of the INVOKEINTERFACE instruction.
+ */
+ final static int ITFMETH_INSN = 7;
+
+ /**
+ * The type of instructions with a 2 bytes bytecode offset label.
+ */
+ final static int LABEL_INSN = 8;
+
+ /**
+ * The type of instructions with a 4 bytes bytecode offset label.
+ */
+ final static int LABELW_INSN = 9;
+
+ /**
+ * The type of the LDC instruction.
+ */
+ final static int LDC_INSN = 10;
+
+ /**
+ * The type of the LDC_W and LDC2_W instructions.
+ */
+ final static int LDCW_INSN = 11;
+
+ /**
+ * The type of the IINC instruction.
+ */
+ final static int IINC_INSN = 12;
+
+ /**
+ * The type of the TABLESWITCH instruction.
+ */
+ final static int TABL_INSN = 13;
+
+ /**
+ * The type of the LOOKUPSWITCH instruction.
+ */
+ final static int LOOK_INSN = 14;
+
+ /**
+ * The type of the MULTIANEWARRAY instruction.
+ */
+ final static int MANA_INSN = 15;
+
+ /**
+ * The type of the WIDE instruction.
+ */
+ final static int WIDE_INSN = 16;
+
+ /**
+ * The instruction types of all JVM opcodes.
+ */
+ static byte[] TYPE;
+
+ /**
+ * The type of CONSTANT_Class constant pool items.
+ */
+ final static int CLASS = 7;
+
+ /**
+ * The type of CONSTANT_Fieldref constant pool items.
+ */
+ final static int FIELD = 9;
+
+ /**
+ * The type of CONSTANT_Methodref constant pool items.
+ */
+ final static int METH = 10;
+
+ /**
+ * The type of CONSTANT_InterfaceMethodref constant pool items.
+ */
+ final static int IMETH = 11;
+
+ /**
+ * The type of CONSTANT_String constant pool items.
+ */
+ final static int STR = 8;
+
+ /**
+ * The type of CONSTANT_Integer constant pool items.
+ */
+ final static int INT = 3;
+
+ /**
+ * The type of CONSTANT_Float constant pool items.
+ */
+ final static int FLOAT = 4;
+
+ /**
+ * The type of CONSTANT_Long constant pool items.
+ */
+ final static int LONG = 5;
+
+ /**
+ * The type of CONSTANT_Double constant pool items.
+ */
+ final static int DOUBLE = 6;
+
+ /**
+ * The type of CONSTANT_NameAndType constant pool items.
+ */
+ final static int NAME_TYPE = 12;
+
+ /**
+ * The type of CONSTANT_Utf8 constant pool items.
+ */
+ final static int UTF8 = 1;
+
+ /**
+ * The class reader from which this class writer was constructed, if any.
+ */
+ ClassReader cr;
+
+ /**
+ * Minor and major version numbers of the class to be generated.
+ */
+ int version;
+
+ /**
+ * Index of the next item to be added in the constant pool.
+ */
+ int index;
+
+ /**
+ * The constant pool of this class.
+ */
+ ByteVector pool;
+
+ /**
+ * The constant pool's hash table data.
+ */
+ Item[] items;
+
+ /**
+ * The threshold of the constant pool's hash table.
+ */
+ int threshold;
+
+ /**
+ * A reusable key used to look for items in the hash {@link #items items}.
+ */
+ Item key;
+
+ /**
+ * A reusable key used to look for items in the hash {@link #items items}.
+ */
+ Item key2;
+
+ /**
+ * A reusable key used to look for items in the hash {@link #items items}.
+ */
+ Item key3;
+
+ /**
+ * The access flags of this class.
+ */
+ private int access;
+
+ /**
+ * The constant pool item that contains the internal name of this class.
+ */
+ private int name;
+
+ /**
+ * The constant pool item that contains the signature of this class.
+ */
+ private int signature;
+
+ /**
+ * The constant pool item that contains the internal name of the super class
+ * of this class.
+ */
+ private int superName;
+
+ /**
+ * Number of interfaces implemented or extended by this class or interface.
+ */
+ private int interfaceCount;
+
+ /**
+ * The interfaces implemented or extended by this class or interface. More
+ * precisely, this array contains the indexes of the constant pool items
+ * that contain the internal names of these interfaces.
+ */
+ private int[] interfaces;
+
+ /**
+ * The index of the constant pool item that contains the name of the source
+ * file from which this class was compiled.
+ */
+ private int sourceFile;
+
+ /**
+ * The SourceDebug attribute of this class.
+ */
+ private ByteVector sourceDebug;
+
+ /**
+ * The constant pool item that contains the name of the enclosing class of
+ * this class.
+ */
+ private int enclosingMethodOwner;
+
+ /**
+ * The constant pool item that contains the name and descriptor of the
+ * enclosing method of this class.
+ */
+ private int enclosingMethod;
+
+ /**
+ * The runtime visible annotations of this class.
+ */
+ private AnnotationWriter anns;
+
+ /**
+ * The runtime invisible annotations of this class.
+ */
+ private AnnotationWriter ianns;
+
+ /**
+ * The non standard attributes of this class.
+ */
+ private Attribute attrs;
+
+ /**
+ * The number of entries in the InnerClasses attribute.
+ */
+ private int innerClassesCount;
+
+ /**
+ * The InnerClasses attribute.
+ */
+ private ByteVector innerClasses;
+
+ /**
+ * The fields of this class. These fields are stored in a linked list of
+ * {@link FieldWriter} objects, linked to each other by their
+ * {@link FieldWriter#next} field. This field stores the first element of
+ * this list.
+ */
+ FieldWriter firstField;
+
+ /**
+ * The fields of this class. These fields are stored in a linked list of
+ * {@link FieldWriter} objects, linked to each other by their
+ * {@link FieldWriter#next} field. This field stores the last element of
+ * this list.
+ */
+ FieldWriter lastField;
+
+ /**
+ * The methods of this class. These methods are stored in a linked list of
+ * {@link MethodWriter} objects, linked to each other by their
+ * {@link MethodWriter#next} field. This field stores the first element of
+ * this list.
+ */
+ MethodWriter firstMethod;
+
+ /**
+ * The methods of this class. These methods are stored in a linked list of
+ * {@link MethodWriter} objects, linked to each other by their
+ * {@link MethodWriter#next} field. This field stores the last element of
+ * this list.
+ */
+ MethodWriter lastMethod;
+
+ /**
+ * <tt>true</tt> if the maximum stack size and number of local variables
+ * must be automatically computed.
+ */
+ private boolean computeMaxs;
+
+ // ------------------------------------------------------------------------
+ // Static initializer
+ // ------------------------------------------------------------------------
+
+ /**
+ * Computes the instruction types of JVM opcodes.
+ */
+ static {
+ int i;
+ byte[] b = new byte[220];
+ String s = "AAAAAAAAAAAAAAAABCKLLDDDDDEEEEEEEEEEEEEEEEEEEEAAAAAAAADD"
+ + "DDDEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ + "AAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAIIIIIIIIIIIIIIIIDNOAA"
+ + "AAAAGGGGGGGHAFBFAAFFAAQPIIJJIIIIIIIIIIIIIIIIII";
+ for (i = 0; i < b.length; ++i) {
+ b[i] = (byte) (s.charAt(i) - 'A');
+ }
+ TYPE = b;
+
+ // code to generate the above string
+ //
+ // // SBYTE_INSN instructions
+ // b[Constants.NEWARRAY] = SBYTE_INSN;
+ // b[Constants.BIPUSH] = SBYTE_INSN;
+ //
+ // // SHORT_INSN instructions
+ // b[Constants.SIPUSH] = SHORT_INSN;
+ //
+ // // (IMPL)VAR_INSN instructions
+ // b[Constants.RET] = VAR_INSN;
+ // for (i = Constants.ILOAD; i <= Constants.ALOAD; ++i) {
+ // b[i] = VAR_INSN;
+ // }
+ // for (i = Constants.ISTORE; i <= Constants.ASTORE; ++i) {
+ // b[i] = VAR_INSN;
+ // }
+ // for (i = 26; i <= 45; ++i) { // ILOAD_0 to ALOAD_3
+ // b[i] = IMPLVAR_INSN;
+ // }
+ // for (i = 59; i <= 78; ++i) { // ISTORE_0 to ASTORE_3
+ // b[i] = IMPLVAR_INSN;
+ // }
+ //
+ // // TYPE_INSN instructions
+ // b[Constants.NEW] = TYPE_INSN;
+ // b[Constants.ANEWARRAY] = TYPE_INSN;
+ // b[Constants.CHECKCAST] = TYPE_INSN;
+ // b[Constants.INSTANCEOF] = TYPE_INSN;
+ //
+ // // (Set)FIELDORMETH_INSN instructions
+ // for (i = Constants.GETSTATIC; i <= Constants.INVOKESTATIC; ++i) {
+ // b[i] = FIELDORMETH_INSN;
+ // }
+ // b[Constants.INVOKEINTERFACE] = ITFMETH_INSN;
+ //
+ // // LABEL(W)_INSN instructions
+ // for (i = Constants.IFEQ; i <= Constants.JSR; ++i) {
+ // b[i] = LABEL_INSN;
+ // }
+ // b[Constants.IFNULL] = LABEL_INSN;
+ // b[Constants.IFNONNULL] = LABEL_INSN;
+ // b[200] = LABELW_INSN; // GOTO_W
+ // b[201] = LABELW_INSN; // JSR_W
+ // // temporary opcodes used internally by ASM - see Label and
+ // MethodWriter
+ // for (i = 202; i < 220; ++i) {
+ // b[i] = LABEL_INSN;
+ // }
+ //
+ // // LDC(_W) instructions
+ // b[Constants.LDC] = LDC_INSN;
+ // b[19] = LDCW_INSN; // LDC_W
+ // b[20] = LDCW_INSN; // LDC2_W
+ //
+ // // special instructions
+ // b[Constants.IINC] = IINC_INSN;
+ // b[Constants.TABLESWITCH] = TABL_INSN;
+ // b[Constants.LOOKUPSWITCH] = LOOK_INSN;
+ // b[Constants.MULTIANEWARRAY] = MANA_INSN;
+ // b[196] = WIDE_INSN; // WIDE
+ //
+ // for (i = 0; i < b.length; ++i) {
+ // System.err.print((char)('A' + b[i]));
+ // }
+ // System.err.println();
+ }
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs a new {@link ClassWriter ClassWriter} object.
+ *
+ * @param computeMaxs <tt>true</tt> if the maximum stack size and the
+ * maximum number of local variables must be automatically computed.
+ * If this flag is <tt>true</tt>, then the arguments of the
+ * {@link MethodVisitor#visitMaxs visitMaxs} method of the
+ * {@link MethodVisitor} returned by the
+ * {@link #visitMethod visitMethod} method will be ignored, and
+ * computed automatically from the signature and the bytecode of each
+ * method.
+ */
+ public ClassWriter(final boolean computeMaxs) {
+ this(computeMaxs, false);
+ }
+
+ /**
+ * Constructs a new {@link ClassWriter} object.
+ *
+ * @param computeMaxs <tt>true</tt> if the maximum stack size and the
+ * maximum number of local variables must be automatically computed.
+ * If this flag is <tt>true</tt>, then the arguments of the
+ * {@link MethodVisitor#visitMaxs visitMaxs} method of the
+ * {@link MethodVisitor} returned by the
+ * {@link #visitMethod visitMethod} method will be ignored, and
+ * computed automatically from the signature and the bytecode of each
+ * method.
+ * @param skipUnknownAttributes <b>Deprecated</b>. The value of this
+ * parameter is ignored.
+ */
+ public ClassWriter(
+ final boolean computeMaxs,
+ final boolean skipUnknownAttributes)
+ {
+ index = 1;
+ pool = new ByteVector();
+ items = new Item[256];
+ threshold = (int) (0.75d * items.length);
+ key = new Item();
+ key2 = new Item();
+ key3 = new Item();
+ this.computeMaxs = computeMaxs;
+ }
+
+ /**
+ * Constructs a new {@link ClassWriter} object and enables optimizations for
+ * "mostly add" bytecode transformations. These optimizations are the
+ * following:
+ *
+ * <ul> <li>The constant pool from the original class is copied as is in
+ * the new class, which saves time. New constant pool entries will be added
+ * at the end if necessary, but unused constant pool entries <i>won't be
+ * removed</i>.</li> <li>Methods that are not transformed are copied as
+ * is in the new class, directly from the original class bytecode (i.e.
+ * without emitting visit events for all the method instructions), which
+ * saves a <i>lot</i> of time. Untransformed methods are detected by the
+ * fact that the {@link ClassReader} receives {@link MethodVisitor} objects
+ * that come from a {@link ClassWriter} (and not from a custom
+ * {@link ClassAdapter} or any other {@link ClassVisitor} instance).</li>
+ * </ul>
+ *
+ * @param classReader the {@link ClassReader} used to read the original
+ * class. It will be used to copy the entire constant pool from the
+ * original class and also to copy other fragments of original
+ * bytecode where applicable.
+ * @param computeMaxs <tt>true</tt> if the maximum stack size and the
+ * maximum number of local variables must be automatically computed.
+ * If this flag is <tt>true</tt>, then the arguments of the
+ * {@link MethodVisitor#visitMaxs visitMaxs} method of the
+ * {@link MethodVisitor} returned by the
+ * {@link #visitMethod visitMethod} method will be ignored, and
+ * computed automatically from the signature and the bytecode of each
+ * method.
+ */
+ public ClassWriter(
+ final ClassReader classReader,
+ final boolean computeMaxs)
+ {
+ this(computeMaxs, false);
+ classReader.copyPool(this);
+ this.cr = classReader;
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the ClassVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ this.version = version;
+ this.access = access;
+ this.name = newClass(name);
+ if (signature != null) {
+ this.signature = newUTF8(signature);
+ }
+ this.superName = superName == null ? 0 : newClass(superName);
+ if (interfaces != null && interfaces.length > 0) {
+ interfaceCount = interfaces.length;
+ this.interfaces = new int[interfaceCount];
+ for (int i = 0; i < interfaceCount; ++i) {
+ this.interfaces[i] = newClass(interfaces[i]);
+ }
+ }
+ }
+
+ public void visitSource(final String file, final String debug) {
+ if (file != null) {
+ sourceFile = newUTF8(file);
+ }
+ if (debug != null) {
+ sourceDebug = new ByteVector().putUTF8(debug);
+ }
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ enclosingMethodOwner = newClass(owner);
+ if (name != null && desc != null) {
+ enclosingMethod = newNameType(name, desc);
+ }
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ ByteVector bv = new ByteVector();
+ // write type, and reserve space for values count
+ bv.putShort(newUTF8(desc)).putShort(0);
+ AnnotationWriter aw = new AnnotationWriter(this, true, bv, bv, 2);
+ if (visible) {
+ aw.next = anns;
+ anns = aw;
+ } else {
+ aw.next = ianns;
+ ianns = aw;
+ }
+ return aw;
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ attr.next = attrs;
+ attrs = attr;
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ if (innerClasses == null) {
+ innerClasses = new ByteVector();
+ }
+ ++innerClassesCount;
+ innerClasses.putShort(name == null ? 0 : newClass(name));
+ innerClasses.putShort(outerName == null ? 0 : newClass(outerName));
+ innerClasses.putShort(innerName == null ? 0 : newUTF8(innerName));
+ innerClasses.putShort(access);
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ return new FieldWriter(this, access, name, desc, signature, value);
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ return new MethodWriter(this,
+ access,
+ name,
+ desc,
+ signature,
+ exceptions,
+ computeMaxs);
+ }
+
+ public void visitEnd() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Other public methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the bytecode of the class that was build with this class writer.
+ *
+ * @return the bytecode of the class that was build with this class writer.
+ */
+ public byte[] toByteArray() {
+ // computes the real size of the bytecode of this class
+ int size = 24 + 2 * interfaceCount;
+ int nbFields = 0;
+ FieldWriter fb = firstField;
+ while (fb != null) {
+ ++nbFields;
+ size += fb.getSize();
+ fb = fb.next;
+ }
+ int nbMethods = 0;
+ MethodWriter mb = firstMethod;
+ while (mb != null) {
+ ++nbMethods;
+ size += mb.getSize();
+ mb = mb.next;
+ }
+ int attributeCount = 0;
+ if (signature != 0) {
+ ++attributeCount;
+ size += 8;
+ newUTF8("Signature");
+ }
+ if (sourceFile != 0) {
+ ++attributeCount;
+ size += 8;
+ newUTF8("SourceFile");
+ }
+ if (sourceDebug != null) {
+ ++attributeCount;
+ size += sourceDebug.length + 4;
+ newUTF8("SourceDebugExtension");
+ }
+ if (enclosingMethodOwner != 0) {
+ ++attributeCount;
+ size += 10;
+ newUTF8("EnclosingMethod");
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ ++attributeCount;
+ size += 6;
+ newUTF8("Deprecated");
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (version & 0xffff) < Opcodes.V1_5)
+ {
+ ++attributeCount;
+ size += 6;
+ newUTF8("Synthetic");
+ }
+ if (version == Opcodes.V1_4) {
+ if ((access & Opcodes.ACC_ANNOTATION) != 0) {
+ ++attributeCount;
+ size += 6;
+ newUTF8("Annotation");
+ }
+ if ((access & Opcodes.ACC_ENUM) != 0) {
+ ++attributeCount;
+ size += 6;
+ newUTF8("Enum");
+ }
+ }
+ if (innerClasses != null) {
+ ++attributeCount;
+ size += 8 + innerClasses.length;
+ newUTF8("InnerClasses");
+ }
+ if (anns != null) {
+ ++attributeCount;
+ size += 8 + anns.getSize();
+ newUTF8("RuntimeVisibleAnnotations");
+ }
+ if (ianns != null) {
+ ++attributeCount;
+ size += 8 + ianns.getSize();
+ newUTF8("RuntimeInvisibleAnnotations");
+ }
+ if (attrs != null) {
+ attributeCount += attrs.getCount();
+ size += attrs.getSize(this, null, 0, -1, -1);
+ }
+ size += pool.length;
+ // allocates a byte vector of this size, in order to avoid unnecessary
+ // arraycopy operations in the ByteVector.enlarge() method
+ ByteVector out = new ByteVector(size);
+ out.putInt(0xCAFEBABE).putInt(version);
+ out.putShort(index).putByteArray(pool.data, 0, pool.length);
+ out.putShort(access).putShort(name).putShort(superName);
+ out.putShort(interfaceCount);
+ for (int i = 0; i < interfaceCount; ++i) {
+ out.putShort(interfaces[i]);
+ }
+ out.putShort(nbFields);
+ fb = firstField;
+ while (fb != null) {
+ fb.put(out);
+ fb = fb.next;
+ }
+ out.putShort(nbMethods);
+ mb = firstMethod;
+ while (mb != null) {
+ mb.put(out);
+ mb = mb.next;
+ }
+ out.putShort(attributeCount);
+ if (signature != 0) {
+ out.putShort(newUTF8("Signature")).putInt(2).putShort(signature);
+ }
+ if (sourceFile != 0) {
+ out.putShort(newUTF8("SourceFile")).putInt(2).putShort(sourceFile);
+ }
+ if (sourceDebug != null) {
+ int len = sourceDebug.length - 2;
+ out.putShort(newUTF8("SourceDebugExtension")).putInt(len);
+ out.putByteArray(sourceDebug.data, 2, len);
+ }
+ if (enclosingMethodOwner != 0) {
+ out.putShort(newUTF8("EnclosingMethod")).putInt(4);
+ out.putShort(enclosingMethodOwner).putShort(enclosingMethod);
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ out.putShort(newUTF8("Deprecated")).putInt(0);
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (version & 0xffff) < Opcodes.V1_5)
+ {
+ out.putShort(newUTF8("Synthetic")).putInt(0);
+ }
+ if (version == Opcodes.V1_4) {
+ if ((access & Opcodes.ACC_ANNOTATION) != 0) {
+ out.putShort(newUTF8("Annotation")).putInt(0);
+ }
+ if ((access & Opcodes.ACC_ENUM) != 0) {
+ out.putShort(newUTF8("Enum")).putInt(0);
+ }
+ }
+ if (innerClasses != null) {
+ out.putShort(newUTF8("InnerClasses"));
+ out.putInt(innerClasses.length + 2).putShort(innerClassesCount);
+ out.putByteArray(innerClasses.data, 0, innerClasses.length);
+ }
+ if (anns != null) {
+ out.putShort(newUTF8("RuntimeVisibleAnnotations"));
+ anns.put(out);
+ }
+ if (ianns != null) {
+ out.putShort(newUTF8("RuntimeInvisibleAnnotations"));
+ ianns.put(out);
+ }
+ if (attrs != null) {
+ attrs.put(this, null, 0, -1, -1, out);
+ }
+ return out.data;
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods: constant pool management
+ // ------------------------------------------------------------------------
+
+ /**
+ * Adds a number or string constant to the constant pool of the class being
+ * build. Does nothing if the constant pool already contains a similar item.
+ *
+ * @param cst the value of the constant to be added to the constant pool.
+ * This parameter must be an {@link Integer}, a {@link Float}, a
+ * {@link Long}, a {@link Double}, a {@link String} or a
+ * {@link Type}.
+ * @return a new or already existing constant item with the given value.
+ */
+ Item newConstItem(final Object cst) {
+ if (cst instanceof Integer) {
+ int val = ((Integer) cst).intValue();
+ return newInteger(val);
+ } else if (cst instanceof Byte) {
+ int val = ((Byte) cst).intValue();
+ return newInteger(val);
+ } else if (cst instanceof Character) {
+ int val = ((Character) cst).charValue();
+ return newInteger(val);
+ } else if (cst instanceof Short) {
+ int val = ((Short) cst).intValue();
+ return newInteger(val);
+ } else if (cst instanceof Boolean) {
+ int val = ((Boolean) cst).booleanValue() ? 1 : 0;
+ return newInteger(val);
+ } else if (cst instanceof Float) {
+ float val = ((Float) cst).floatValue();
+ return newFloat(val);
+ } else if (cst instanceof Long) {
+ long val = ((Long) cst).longValue();
+ return newLong(val);
+ } else if (cst instanceof Double) {
+ double val = ((Double) cst).doubleValue();
+ return newDouble(val);
+ } else if (cst instanceof String) {
+ return newString((String) cst);
+ } else if (cst instanceof Type) {
+ Type t = (Type) cst;
+ return newClassItem(t.getSort() == Type.OBJECT
+ ? t.getInternalName()
+ : t.getDescriptor());
+ } else {
+ throw new IllegalArgumentException("value " + cst);
+ }
+ }
+
+ /**
+ * Adds a number or string constant to the constant pool of the class being
+ * build. Does nothing if the constant pool already contains a similar item.
+ * <i>This method is intended for {@link Attribute} sub classes, and is
+ * normally not needed by class generators or adapters.</i>
+ *
+ * @param cst the value of the constant to be added to the constant pool.
+ * This parameter must be an {@link Integer}, a {@link Float}, a
+ * {@link Long}, a {@link Double} or a {@link String}.
+ * @return the index of a new or already existing constant item with the
+ * given value.
+ */
+ public int newConst(final Object cst) {
+ return newConstItem(cst).index;
+ }
+
+ /**
+ * Adds an UTF8 string to the constant pool of the class being build. Does
+ * nothing if the constant pool already contains a similar item. <i>This
+ * method is intended for {@link Attribute} sub classes, and is normally not
+ * needed by class generators or adapters.</i>
+ *
+ * @param value the String value.
+ * @return the index of a new or already existing UTF8 item.
+ */
+ public int newUTF8(final String value) {
+ key.set(UTF8, value, null, null);
+ Item result = get(key);
+ if (result == null) {
+ pool.putByte(UTF8).putUTF8(value);
+ result = new Item(index++, key);
+ put(result);
+ }
+ return result.index;
+ }
+
+ /**
+ * Adds a class reference to the constant pool of the class being build.
+ * Does nothing if the constant pool already contains a similar item.
+ * <i>This method is intended for {@link Attribute} sub classes, and is
+ * normally not needed by class generators or adapters.</i>
+ *
+ * @param value the internal name of the class.
+ * @return the index of a new or already existing class reference item.
+ */
+ public int newClass(final String value) {
+ return newClassItem(value).index;
+ }
+
+ /**
+ * Adds a class reference to the constant pool of the class being build.
+ * Does nothing if the constant pool already contains a similar item.
+ * <i>This method is intended for {@link Attribute} sub classes, and is
+ * normally not needed by class generators or adapters.</i>
+ *
+ * @param value the internal name of the class.
+ * @return a new or already existing class reference item.
+ */
+ private Item newClassItem(final String value) {
+ key2.set(CLASS, value, null, null);
+ Item result = get(key2);
+ if (result == null) {
+ pool.put12(CLASS, newUTF8(value));
+ result = new Item(index++, key2);
+ put(result);
+ }
+ return result;
+ }
+
+ /**
+ * Adds a field reference to the constant pool of the class being build.
+ * Does nothing if the constant pool already contains a similar item.
+ * <i>This method is intended for {@link Attribute} sub classes, and is
+ * normally not needed by class generators or adapters.</i>
+ *
+ * @param owner the internal name of the field's owner class.
+ * @param name the field's name.
+ * @param desc the field's descriptor.
+ * @return the index of a new or already existing field reference item.
+ */
+ public int newField(final String owner, final String name, final String desc)
+ {
+ key3.set(FIELD, owner, name, desc);
+ Item result = get(key3);
+ if (result == null) {
+ put122(FIELD, newClass(owner), newNameType(name, desc));
+ result = new Item(index++, key3);
+ put(result);
+ }
+ return result.index;
+ }
+
+ /**
+ * Adds a method reference to the constant pool of the class being build.
+ * Does nothing if the constant pool already contains a similar item.
+ *
+ * @param owner the internal name of the method's owner class.
+ * @param name the method's name.
+ * @param desc the method's descriptor.
+ * @param itf <tt>true</tt> if <tt>owner</tt> is an interface.
+ * @return a new or already existing method reference item.
+ */
+ Item newMethodItem(
+ final String owner,
+ final String name,
+ final String desc,
+ final boolean itf)
+ {
+ int type = itf ? IMETH : METH;
+ key3.set(type, owner, name, desc);
+ Item result = get(key3);
+ if (result == null) {
+ put122(type, newClass(owner), newNameType(name, desc));
+ result = new Item(index++, key3);
+ put(result);
+ }
+ return result;
+ }
+
+ /**
+ * Adds a method reference to the constant pool of the class being build.
+ * Does nothing if the constant pool already contains a similar item.
+ * <i>This method is intended for {@link Attribute} sub classes, and is
+ * normally not needed by class generators or adapters.</i>
+ *
+ * @param owner the internal name of the method's owner class.
+ * @param name the method's name.
+ * @param desc the method's descriptor.
+ * @param itf <tt>true</tt> if <tt>owner</tt> is an interface.
+ * @return the index of a new or already existing method reference item.
+ */
+ public int newMethod(
+ final String owner,
+ final String name,
+ final String desc,
+ final boolean itf)
+ {
+ return newMethodItem(owner, name, desc, itf).index;
+ }
+
+ /**
+ * Adds an integer to the constant pool of the class being build. Does
+ * nothing if the constant pool already contains a similar item.
+ *
+ * @param value the int value.
+ * @return a new or already existing int item.
+ */
+ Item newInteger(final int value) {
+ key.set(value);
+ Item result = get(key);
+ if (result == null) {
+ pool.putByte(INT).putInt(value);
+ result = new Item(index++, key);
+ put(result);
+ }
+ return result;
+ }
+
+ /**
+ * Adds a float to the constant pool of the class being build. Does nothing
+ * if the constant pool already contains a similar item.
+ *
+ * @param value the float value.
+ * @return a new or already existing float item.
+ */
+ Item newFloat(final float value) {
+ key.set(value);
+ Item result = get(key);
+ if (result == null) {
+ pool.putByte(FLOAT).putInt(Float.floatToIntBits(value));
+ result = new Item(index++, key);
+ put(result);
+ }
+ return result;
+ }
+
+ /**
+ * Adds a long to the constant pool of the class being build. Does nothing
+ * if the constant pool already contains a similar item.
+ *
+ * @param value the long value.
+ * @return a new or already existing long item.
+ */
+ Item newLong(final long value) {
+ key.set(value);
+ Item result = get(key);
+ if (result == null) {
+ pool.putByte(LONG).putLong(value);
+ result = new Item(index, key);
+ put(result);
+ index += 2;
+ }
+ return result;
+ }
+
+ /**
+ * Adds a double to the constant pool of the class being build. Does nothing
+ * if the constant pool already contains a similar item.
+ *
+ * @param value the double value.
+ * @return a new or already existing double item.
+ */
+ Item newDouble(final double value) {
+ key.set(value);
+ Item result = get(key);
+ if (result == null) {
+ pool.putByte(DOUBLE).putLong(Double.doubleToLongBits(value));
+ result = new Item(index, key);
+ put(result);
+ index += 2;
+ }
+ return result;
+ }
+
+ /**
+ * Adds a string to the constant pool of the class being build. Does nothing
+ * if the constant pool already contains a similar item.
+ *
+ * @param value the String value.
+ * @return a new or already existing string item.
+ */
+ private Item newString(final String value) {
+ key2.set(STR, value, null, null);
+ Item result = get(key2);
+ if (result == null) {
+ pool.put12(STR, newUTF8(value));
+ result = new Item(index++, key2);
+ put(result);
+ }
+ return result;
+ }
+
+ /**
+ * Adds a name and type to the constant pool of the class being build. Does
+ * nothing if the constant pool already contains a similar item. <i>This
+ * method is intended for {@link Attribute} sub classes, and is normally not
+ * needed by class generators or adapters.</i>
+ *
+ * @param name a name.
+ * @param desc a type descriptor.
+ * @return the index of a new or already existing name and type item.
+ */
+ public int newNameType(final String name, final String desc) {
+ key2.set(NAME_TYPE, name, desc, null);
+ Item result = get(key2);
+ if (result == null) {
+ put122(NAME_TYPE, newUTF8(name), newUTF8(desc));
+ result = new Item(index++, key2);
+ put(result);
+ }
+ return result.index;
+ }
+
+ /**
+ * Returns the constant pool's hash table item which is equal to the given
+ * item.
+ *
+ * @param key a constant pool item.
+ * @return the constant pool's hash table item which is equal to the given
+ * item, or <tt>null</tt> if there is no such item.
+ */
+ private Item get(final Item key) {
+ Item i = items[key.hashCode % items.length];
+ while (i != null && !key.isEqualTo(i)) {
+ i = i.next;
+ }
+ return i;
+ }
+
+ /**
+ * Puts the given item in the constant pool's hash table. The hash table
+ * <i>must</i> not already contains this item.
+ *
+ * @param i the item to be added to the constant pool's hash table.
+ */
+ private void put(final Item i) {
+ if (index > threshold) {
+ int ll = items.length;
+ int nl = ll * 2 + 1;
+ Item[] newItems = new Item[nl];
+ for (int l = ll - 1; l >= 0; --l) {
+ Item j = items[l];
+ while (j != null) {
+ int index = j.hashCode % newItems.length;
+ Item k = j.next;
+ j.next = newItems[index];
+ newItems[index] = j;
+ j = k;
+ }
+ }
+ items = newItems;
+ threshold = (int) (nl * 0.75);
+ }
+ int index = i.hashCode % items.length;
+ i.next = items[index];
+ items[index] = i;
+ }
+
+ /**
+ * Puts one byte and two shorts into the constant pool.
+ *
+ * @param b a byte.
+ * @param s1 a short.
+ * @param s2 another short.
+ */
+ private void put122(final int b, final int s1, final int s2) {
+ pool.put12(b, s1).putShort(s2);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/Edge.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/Edge.java
new file mode 100644
index 000000000..5bada4e9a
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/Edge.java
@@ -0,0 +1,57 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * An edge in the control flow graph of a method body. See {@link Label Label}.
+ *
+ * @author Eric Bruneton
+ */
+class Edge {
+
+ /**
+ * The (relative) stack size in the basic block from which this edge
+ * originates. This size is equal to the stack size at the "jump"
+ * instruction to which this edge corresponds, relatively to the stack size
+ * at the beginning of the originating basic block.
+ */
+ int stackSize;
+
+ /**
+ * The successor block of the basic block from which this edge originates.
+ */
+ Label successor;
+
+ /**
+ * The next edge in the list of successors of the originating basic block.
+ * See {@link Label#successors successors}.
+ */
+ Edge next;
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/FieldVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/FieldVisitor.java
new file mode 100644
index 000000000..a05cb5a3c
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/FieldVisitor.java
@@ -0,0 +1,63 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A visitor to visit a Java field. The methods of this interface must be called
+ * in the following order: ( <tt>visitAnnotation</tt> |
+ * <tt>visitAttribute</tt> )* <tt>visitEnd</tt>.
+ *
+ * @author Eric Bruneton
+ */
+public interface FieldVisitor {
+
+ /**
+ * Visits an annotation of the field.
+ *
+ * @param desc the class descriptor of the annotation class.
+ * @param visible <tt>true</tt> if the annotation is visible at runtime.
+ * @return a non null visitor to visit the annotation values.
+ */
+ AnnotationVisitor visitAnnotation(String desc, boolean visible);
+
+ /**
+ * Visits a non standard attribute of the field.
+ *
+ * @param attr an attribute.
+ */
+ void visitAttribute(Attribute attr);
+
+ /**
+ * Visits the end of the field. This method, which is the last one to be
+ * called, is used to inform the visitor that all the annotations and
+ * attributes of the field have been visited.
+ */
+ void visitEnd();
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/FieldWriter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/FieldWriter.java
new file mode 100644
index 000000000..0adbea91a
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/FieldWriter.java
@@ -0,0 +1,276 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * An {@link FieldVisitor} that generates Java fields in bytecode form.
+ *
+ * @author Eric Bruneton
+ */
+final class FieldWriter implements FieldVisitor {
+
+ /**
+ * Next field writer (see {@link ClassWriter#firstField firstField}).
+ */
+ FieldWriter next;
+
+ /**
+ * The class writer to which this field must be added.
+ */
+ private ClassWriter cw;
+
+ /**
+ * Access flags of this field.
+ */
+ private int access;
+
+ /**
+ * The index of the constant pool item that contains the name of this
+ * method.
+ */
+ private int name;
+
+ /**
+ * The index of the constant pool item that contains the descriptor of this
+ * field.
+ */
+ private int desc;
+
+ /**
+ * The index of the constant pool item that contains the signature of this
+ * field.
+ */
+ private int signature;
+
+ /**
+ * The index of the constant pool item that contains the constant value of
+ * this field.
+ */
+ private int value;
+
+ /**
+ * The runtime visible annotations of this field. May be <tt>null</tt>.
+ */
+ private AnnotationWriter anns;
+
+ /**
+ * The runtime invisible annotations of this field. May be <tt>null</tt>.
+ */
+ private AnnotationWriter ianns;
+
+ /**
+ * The non standard attributes of this field. May be <tt>null</tt>.
+ */
+ private Attribute attrs;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs a new {@link FieldWriter}.
+ *
+ * @param cw the class writer to which this field must be added.
+ * @param access the field's access flags (see {@link Opcodes}).
+ * @param name the field's name.
+ * @param desc the field's descriptor (see {@link Type}).
+ * @param signature the field's signature. May be <tt>null</tt>.
+ * @param value the field's constant value. May be <tt>null</tt>.
+ */
+ protected FieldWriter(
+ final ClassWriter cw,
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ if (cw.firstField == null) {
+ cw.firstField = this;
+ } else {
+ cw.lastField.next = this;
+ }
+ cw.lastField = this;
+ this.cw = cw;
+ this.access = access;
+ this.name = cw.newUTF8(name);
+ this.desc = cw.newUTF8(desc);
+ if (signature != null) {
+ this.signature = cw.newUTF8(signature);
+ }
+ if (value != null) {
+ this.value = cw.newConstItem(value).index;
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the FieldVisitor interface
+ // ------------------------------------------------------------------------
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ ByteVector bv = new ByteVector();
+ // write type, and reserve space for values count
+ bv.putShort(cw.newUTF8(desc)).putShort(0);
+ AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv, 2);
+ if (visible) {
+ aw.next = anns;
+ anns = aw;
+ } else {
+ aw.next = ianns;
+ ianns = aw;
+ }
+ return aw;
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ attr.next = attrs;
+ attrs = attr;
+ }
+
+ public void visitEnd() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the size of this field.
+ *
+ * @return the size of this field.
+ */
+ int getSize() {
+ int size = 8;
+ if (value != 0) {
+ cw.newUTF8("ConstantValue");
+ size += 8;
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (cw.version & 0xffff) < Opcodes.V1_5)
+ {
+ cw.newUTF8("Synthetic");
+ size += 6;
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ cw.newUTF8("Deprecated");
+ size += 6;
+ }
+ if (cw.version == Opcodes.V1_4 && (access & Opcodes.ACC_ENUM) != 0) {
+ cw.newUTF8("Enum");
+ size += 6;
+ }
+ if (signature != 0) {
+ cw.newUTF8("Signature");
+ size += 8;
+ }
+ if (anns != null) {
+ cw.newUTF8("RuntimeVisibleAnnotations");
+ size += 8 + anns.getSize();
+ }
+ if (ianns != null) {
+ cw.newUTF8("RuntimeInvisibleAnnotations");
+ size += 8 + ianns.getSize();
+ }
+ if (attrs != null) {
+ size += attrs.getSize(cw, null, 0, -1, -1);
+ }
+ return size;
+ }
+
+ /**
+ * Puts the content of this field into the given byte vector.
+ *
+ * @param out where the content of this field must be put.
+ */
+ void put(final ByteVector out) {
+ out.putShort(access).putShort(name).putShort(desc);
+ int attributeCount = 0;
+ if (value != 0) {
+ ++attributeCount;
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (cw.version & 0xffff) < Opcodes.V1_5)
+ {
+ ++attributeCount;
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ ++attributeCount;
+ }
+ if (cw.version == Opcodes.V1_4 && (access & Opcodes.ACC_ENUM) != 0) {
+ ++attributeCount;
+ }
+ if (signature != 0) {
+ ++attributeCount;
+ }
+ if (anns != null) {
+ ++attributeCount;
+ }
+ if (ianns != null) {
+ ++attributeCount;
+ }
+ if (attrs != null) {
+ attributeCount += attrs.getCount();
+ }
+ out.putShort(attributeCount);
+ if (value != 0) {
+ out.putShort(cw.newUTF8("ConstantValue"));
+ out.putInt(2).putShort(value);
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (cw.version & 0xffff) < Opcodes.V1_5)
+ {
+ out.putShort(cw.newUTF8("Synthetic")).putInt(0);
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ out.putShort(cw.newUTF8("Deprecated")).putInt(0);
+ }
+ if (cw.version == Opcodes.V1_4 && (access & Opcodes.ACC_ENUM) != 0) {
+ out.putShort(cw.newUTF8("Enum")).putInt(0);
+ }
+ if (signature != 0) {
+ out.putShort(cw.newUTF8("Signature"));
+ out.putInt(2).putShort(signature);
+ }
+ if (anns != null) {
+ out.putShort(cw.newUTF8("RuntimeVisibleAnnotations"));
+ anns.put(out);
+ }
+ if (ianns != null) {
+ out.putShort(cw.newUTF8("RuntimeInvisibleAnnotations"));
+ ianns.put(out);
+ }
+ if (attrs != null) {
+ attrs.put(cw, null, 0, -1, -1, out);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/Handler.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/Handler.java
new file mode 100644
index 000000000..a1211ae2d
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/Handler.java
@@ -0,0 +1,70 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * Information about an exception handler block.
+ *
+ * @author Eric Bruneton
+ */
+class Handler {
+
+ /**
+ * Beginning of the exception handler's scope (inclusive).
+ */
+ Label start;
+
+ /**
+ * End of the exception handler's scope (exclusive).
+ */
+ Label end;
+
+ /**
+ * Beginning of the exception handler's code.
+ */
+ Label handler;
+
+ /**
+ * Internal name of the type of exceptions handled by this handler, or
+ * <tt>null</tt> to catch any exceptions.
+ */
+ String desc;
+
+ /**
+ * Constant pool index of the internal name of the type of exceptions
+ * handled by this handler, or 0 to catch any exceptions.
+ */
+ int type;
+
+ /**
+ * Next exception handler block info.
+ */
+ Handler next;
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/Item.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/Item.java
new file mode 100644
index 000000000..fc67b0194
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/Item.java
@@ -0,0 +1,252 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A constant pool item. Constant pool items can be created with the 'newXXX'
+ * methods in the {@link ClassWriter} class.
+ *
+ * @author Eric Bruneton
+ */
+final class Item {
+
+ /**
+ * Index of this item in the constant pool.
+ */
+ int index;
+
+ /**
+ * Type of this constant pool item. A single class is used to represent all
+ * constant pool item types, in order to minimize the bytecode size of this
+ * package. The value of this field is one of {@link ClassWriter#INT},
+ * {@link ClassWriter#LONG}, {@link ClassWriter#FLOAT},
+ * {@link ClassWriter#DOUBLE}, {@link ClassWriter#UTF8},
+ * {@link ClassWriter#STR}, {@link ClassWriter#CLASS},
+ * {@link ClassWriter#NAME_TYPE}, {@link ClassWriter#FIELD},
+ * {@link ClassWriter#METH}, {@link ClassWriter#IMETH}.
+ */
+ int type;
+
+ /**
+ * Value of this item, for an integer item.
+ */
+ int intVal;
+
+ /**
+ * Value of this item, for a long item.
+ */
+ long longVal;
+
+ /**
+ * Value of this item, for a float item.
+ */
+ float floatVal;
+
+ /**
+ * Value of this item, for a double item.
+ */
+ double doubleVal;
+
+ /**
+ * First part of the value of this item, for items that do not hold a
+ * primitive value.
+ */
+ String strVal1;
+
+ /**
+ * Second part of the value of this item, for items that do not hold a
+ * primitive value.
+ */
+ String strVal2;
+
+ /**
+ * Third part of the value of this item, for items that do not hold a
+ * primitive value.
+ */
+ String strVal3;
+
+ /**
+ * The hash code value of this constant pool item.
+ */
+ int hashCode;
+
+ /**
+ * Link to another constant pool item, used for collision lists in the
+ * constant pool's hash table.
+ */
+ Item next;
+
+ /**
+ * Constructs an uninitialized {@link Item}.
+ */
+ Item() {
+ }
+
+ Item(int index) {
+ this.index = index;
+ }
+
+ /**
+ * Constructs a copy of the given item.
+ *
+ * @param index index of the item to be constructed.
+ * @param i the item that must be copied into the item to be constructed.
+ */
+ Item(final int index, final Item i) {
+ this.index = index;
+ type = i.type;
+ intVal = i.intVal;
+ longVal = i.longVal;
+ floatVal = i.floatVal;
+ doubleVal = i.doubleVal;
+ strVal1 = i.strVal1;
+ strVal2 = i.strVal2;
+ strVal3 = i.strVal3;
+ hashCode = i.hashCode;
+ }
+
+ /**
+ * Sets this item to an integer item.
+ *
+ * @param intVal the value of this item.
+ */
+ void set(final int intVal) {
+ this.type = ClassWriter.INT;
+ this.intVal = intVal;
+ this.hashCode = 0x7FFFFFFF & (type + intVal);
+ }
+
+ /**
+ * Sets this item to a long item.
+ *
+ * @param longVal the value of this item.
+ */
+ void set(final long longVal) {
+ this.type = ClassWriter.LONG;
+ this.longVal = longVal;
+ this.hashCode = 0x7FFFFFFF & (type + (int) longVal);
+ }
+
+ /**
+ * Sets this item to a float item.
+ *
+ * @param floatVal the value of this item.
+ */
+ void set(final float floatVal) {
+ this.type = ClassWriter.FLOAT;
+ this.floatVal = floatVal;
+ this.hashCode = 0x7FFFFFFF & (type + (int) floatVal);
+ }
+
+ /**
+ * Sets this item to a double item.
+ *
+ * @param doubleVal the value of this item.
+ */
+ void set(final double doubleVal) {
+ this.type = ClassWriter.DOUBLE;
+ this.doubleVal = doubleVal;
+ this.hashCode = 0x7FFFFFFF & (type + (int) doubleVal);
+ }
+
+ /**
+ * Sets this item to an item that do not hold a primitive value.
+ *
+ * @param type the type of this item.
+ * @param strVal1 first part of the value of this item.
+ * @param strVal2 second part of the value of this item.
+ * @param strVal3 third part of the value of this item.
+ */
+ void set(
+ final int type,
+ final String strVal1,
+ final String strVal2,
+ final String strVal3)
+ {
+ this.type = type;
+ this.strVal1 = strVal1;
+ this.strVal2 = strVal2;
+ this.strVal3 = strVal3;
+ switch (type) {
+ case ClassWriter.UTF8:
+ case ClassWriter.STR:
+ case ClassWriter.CLASS:
+ hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());
+ return;
+ case ClassWriter.NAME_TYPE:
+ hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()
+ * strVal2.hashCode());
+ return;
+ // ClassWriter.FIELD:
+ // ClassWriter.METH:
+ // ClassWriter.IMETH:
+ default:
+ hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()
+ * strVal2.hashCode() * strVal3.hashCode());
+ }
+ }
+
+ /**
+ * Indicates if the given item is equal to this one.
+ *
+ * @param i the item to be compared to this one.
+ * @return <tt>true</tt> if the given item if equal to this one,
+ * <tt>false</tt> otherwise.
+ */
+ boolean isEqualTo(final Item i) {
+ if (i.type == type) {
+ switch (type) {
+ case ClassWriter.INT:
+ return i.intVal == intVal;
+ case ClassWriter.LONG:
+ return i.longVal == longVal;
+ case ClassWriter.FLOAT:
+ return i.floatVal == floatVal;
+ case ClassWriter.DOUBLE:
+ return i.doubleVal == doubleVal;
+ case ClassWriter.UTF8:
+ case ClassWriter.STR:
+ case ClassWriter.CLASS:
+ return i.strVal1.equals(strVal1);
+ case ClassWriter.NAME_TYPE:
+ return i.strVal1.equals(strVal1)
+ && i.strVal2.equals(strVal2);
+ // ClassWriter.FIELD:
+ // ClassWriter.METH:
+ // ClassWriter.IMETH:
+ default:
+ return i.strVal1.equals(strVal1)
+ && i.strVal2.equals(strVal2)
+ && i.strVal3.equals(strVal3);
+ }
+ }
+ return false;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/Label.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/Label.java
new file mode 100644
index 000000000..3998e5a86
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/Label.java
@@ -0,0 +1,299 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A label represents a position in the bytecode of a method. Labels are used
+ * for jump, goto, and switch instructions, and for try catch blocks.
+ *
+ * @author Eric Bruneton
+ */
+public class Label {
+
+ /**
+ * The line number corresponding to this label, if known.
+ */
+ int line;
+
+ /**
+ * Indicates if the position of this label is known.
+ */
+ boolean resolved;
+
+ /**
+ * The position of this label in the code, if known.
+ */
+ int position;
+
+ /**
+ * If the label position has been updated, after instruction resizing.
+ */
+ boolean resized;
+
+ /**
+ * Number of forward references to this label, times two.
+ */
+ private int referenceCount;
+
+ /**
+ * Informations about forward references. Each forward reference is
+ * described by two consecutive integers in this array: the first one is the
+ * position of the first byte of the bytecode instruction that contains the
+ * forward reference, while the second is the position of the first byte of
+ * the forward reference itself. In fact the sign of the first integer
+ * indicates if this reference uses 2 or 4 bytes, and its absolute value
+ * gives the position of the bytecode instruction.
+ */
+ private int[] srcAndRefPositions;
+
+ /*
+ * Fields for the control flow graph analysis algorithm (used to compute the
+ * maximum stack size). A control flow graph contains one node per "basic
+ * block", and one edge per "jump" from one basic block to another. Each
+ * node (i.e., each basic block) is represented by the Label object that
+ * corresponds to the first instruction of this basic block. Each node also
+ * stores the list of it successors in the graph, as a linked list of Edge
+ * objects.
+ */
+
+ /**
+ * The stack size at the beginning of this basic block. This size is
+ * initially unknown. It is computed by the control flow analysis algorithm
+ * (see {@link MethodWriter#visitMaxs visitMaxs}).
+ */
+ int beginStackSize;
+
+ /**
+ * The (relative) maximum stack size corresponding to this basic block. This
+ * size is relative to the stack size at the beginning of the basic block,
+ * i.e., the true maximum stack size is equal to {@link #beginStackSize
+ * beginStackSize} + {@link #maxStackSize maxStackSize}.
+ */
+ int maxStackSize;
+
+ /**
+ * The successors of this node in the control flow graph. These successors
+ * are stored in a linked list of {@link Edge Edge} objects, linked to each
+ * other by their {@link Edge#next} field.
+ */
+ Edge successors;
+
+ /**
+ * The next basic block in the basic block stack. See
+ * {@link MethodWriter#visitMaxs visitMaxs}.
+ */
+ Label next;
+
+ /**
+ * <tt>true</tt> if this basic block has been pushed in the basic block
+ * stack. See {@link MethodWriter#visitMaxs visitMaxs}.
+ */
+ boolean pushed;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs a new label.
+ */
+ public Label() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods to compute offsets and to manage forward references
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the offset corresponding to this label. This offset is computed
+ * from the start of the method's bytecode. <i>This method is intended for
+ * {@link Attribute} sub classes, and is normally not needed by class
+ * generators or adapters.</i>
+ *
+ * @return the offset corresponding to this label.
+ * @throws IllegalStateException if this label is not resolved yet.
+ */
+ public int getOffset() {
+ if (!resolved) {
+ throw new IllegalStateException("Label offset position has not been resolved yet");
+ }
+ return position;
+ }
+
+ /**
+ * Puts a reference to this label in the bytecode of a method. If the
+ * position of the label is known, the offset is computed and written
+ * directly. Otherwise, a null offset is written and a new forward reference
+ * is declared for this label.
+ *
+ * @param owner the code writer that calls this method.
+ * @param out the bytecode of the method.
+ * @param source the position of first byte of the bytecode instruction that
+ * contains this label.
+ * @param wideOffset <tt>true</tt> if the reference must be stored in 4
+ * bytes, or <tt>false</tt> if it must be stored with 2 bytes.
+ * @throws IllegalArgumentException if this label has not been created by
+ * the given code writer.
+ */
+ void put(
+ final MethodWriter owner,
+ final ByteVector out,
+ final int source,
+ final boolean wideOffset)
+ {
+ if (resolved) {
+ if (wideOffset) {
+ out.putInt(position - source);
+ } else {
+ out.putShort(position - source);
+ }
+ } else {
+ if (wideOffset) {
+ addReference(-1 - source, out.length);
+ out.putInt(-1);
+ } else {
+ addReference(source, out.length);
+ out.putShort(-1);
+ }
+ }
+ }
+
+ /**
+ * Adds a forward reference to this label. This method must be called only
+ * for a true forward reference, i.e. only if this label is not resolved
+ * yet. For backward references, the offset of the reference can be, and
+ * must be, computed and stored directly.
+ *
+ * @param sourcePosition the position of the referencing instruction. This
+ * position will be used to compute the offset of this forward
+ * reference.
+ * @param referencePosition the position where the offset for this forward
+ * reference must be stored.
+ */
+ private void addReference(
+ final int sourcePosition,
+ final int referencePosition)
+ {
+ if (srcAndRefPositions == null) {
+ srcAndRefPositions = new int[6];
+ }
+ if (referenceCount >= srcAndRefPositions.length) {
+ int[] a = new int[srcAndRefPositions.length + 6];
+ System.arraycopy(srcAndRefPositions,
+ 0,
+ a,
+ 0,
+ srcAndRefPositions.length);
+ srcAndRefPositions = a;
+ }
+ srcAndRefPositions[referenceCount++] = sourcePosition;
+ srcAndRefPositions[referenceCount++] = referencePosition;
+ }
+
+ /**
+ * Resolves all forward references to this label. This method must be called
+ * when this label is added to the bytecode of the method, i.e. when its
+ * position becomes known. This method fills in the blanks that where left
+ * in the bytecode by each forward reference previously added to this label.
+ *
+ * @param owner the code writer that calls this method.
+ * @param position the position of this label in the bytecode.
+ * @param data the bytecode of the method.
+ * @return <tt>true</tt> if a blank that was left for this label was to
+ * small to store the offset. In such a case the corresponding jump
+ * instruction is replaced with a pseudo instruction (using unused
+ * opcodes) using an unsigned two bytes offset. These pseudo
+ * instructions will need to be replaced with true instructions with
+ * wider offsets (4 bytes instead of 2). This is done in
+ * {@link MethodWriter#resizeInstructions}.
+ * @throws IllegalArgumentException if this label has already been resolved,
+ * or if it has not been created by the given code writer.
+ */
+ boolean resolve(
+ final MethodWriter owner,
+ final int position,
+ final byte[] data)
+ {
+ boolean needUpdate = false;
+ this.resolved = true;
+ this.position = position;
+ int i = 0;
+ while (i < referenceCount) {
+ int source = srcAndRefPositions[i++];
+ int reference = srcAndRefPositions[i++];
+ int offset;
+ if (source >= 0) {
+ offset = position - source;
+ if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) {
+ /*
+ * changes the opcode of the jump instruction, in order to
+ * be able to find it later (see resizeInstructions in
+ * MethodWriter). These temporary opcodes are similar to
+ * jump instruction opcodes, except that the 2 bytes offset
+ * is unsigned (and can therefore represent values from 0 to
+ * 65535, which is sufficient since the size of a method is
+ * limited to 65535 bytes).
+ */
+ int opcode = data[reference - 1] & 0xFF;
+ if (opcode <= Opcodes.JSR) {
+ // changes IFEQ ... JSR to opcodes 202 to 217
+ data[reference - 1] = (byte) (opcode + 49);
+ } else {
+ // changes IFNULL and IFNONNULL to opcodes 218 and 219
+ data[reference - 1] = (byte) (opcode + 20);
+ }
+ needUpdate = true;
+ }
+ data[reference++] = (byte) (offset >>> 8);
+ data[reference] = (byte) offset;
+ } else {
+ offset = position + source + 1;
+ data[reference++] = (byte) (offset >>> 24);
+ data[reference++] = (byte) (offset >>> 16);
+ data[reference++] = (byte) (offset >>> 8);
+ data[reference] = (byte) offset;
+ }
+ }
+ return needUpdate;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overriden Object methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns a string representation of this label.
+ *
+ * @return a string representation of this label.
+ */
+ public String toString() {
+ return "L" + System.identityHashCode(this);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodAdapter.java
new file mode 100644
index 000000000..a038ac713
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodAdapter.java
@@ -0,0 +1,185 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * An empty {@link MethodVisitor} that delegates to another
+ * {@link MethodVisitor}. This class can be used as a super class to quickly
+ * implement usefull method adapter classes, just by overriding the necessary
+ * methods.
+ *
+ * @author Eric Bruneton
+ */
+public class MethodAdapter implements MethodVisitor {
+
+ /**
+ * The {@link MethodVisitor} to which this adapter delegates calls.
+ */
+ protected MethodVisitor mv;
+
+ /**
+ * Constructs a new {@link MethodAdapter} object.
+ *
+ * @param mv the code visitor to which this adapter must delegate calls.
+ */
+ public MethodAdapter(final MethodVisitor mv) {
+ this.mv = mv;
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ return mv.visitAnnotationDefault();
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ return mv.visitAnnotation(desc, visible);
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ return mv.visitParameterAnnotation(parameter, desc, visible);
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ mv.visitAttribute(attr);
+ }
+
+ public void visitCode() {
+ mv.visitCode();
+ }
+
+ public void visitInsn(final int opcode) {
+ mv.visitInsn(opcode);
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ mv.visitIntInsn(opcode, operand);
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ mv.visitVarInsn(opcode, var);
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ mv.visitTypeInsn(opcode, desc);
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ mv.visitFieldInsn(opcode, owner, name, desc);
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ mv.visitMethodInsn(opcode, owner, name, desc);
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ mv.visitJumpInsn(opcode, label);
+ }
+
+ public void visitLabel(final Label label) {
+ mv.visitLabel(label);
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ mv.visitLdcInsn(cst);
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ mv.visitIincInsn(var, increment);
+ }
+
+ public void visitTableSwitchInsn(
+ final int min,
+ final int max,
+ final Label dflt,
+ final Label labels[])
+ {
+ mv.visitTableSwitchInsn(min, max, dflt, labels);
+ }
+
+ public void visitLookupSwitchInsn(
+ final Label dflt,
+ final int keys[],
+ final Label labels[])
+ {
+ mv.visitLookupSwitchInsn(dflt, keys, labels);
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ mv.visitMultiANewArrayInsn(desc, dims);
+ }
+
+ public void visitTryCatchBlock(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ mv.visitTryCatchBlock(start, end, handler, type);
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ mv.visitLocalVariable(name, desc, signature, start, end, index);
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ mv.visitLineNumber(line, start);
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ mv.visitMaxs(maxStack, maxLocals);
+ }
+
+ public void visitEnd() {
+ mv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodVisitor.java
new file mode 100644
index 000000000..d56b3bd1c
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodVisitor.java
@@ -0,0 +1,334 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A visitor to visit a Java method. The methods of this interface must be
+ * called in the following order: [ <tt>visitAnnotationDefault</tt> ] (
+ * <tt>visitAnnotation</tt> | <tt>visitParameterAnnotation</tt> |
+ * <tt>visitAttribute</tt> )* [ <tt>visitCode</tt> ( <tt>visit</tt><i>X</i>Insn</tt> |
+ * <tt>visitLabel</tt> | <tt>visitTryCatchBlock</tt> | <tt>visitLocalVariable</tt> |
+ * <tt>visitLineNumber</tt>)* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In
+ * addition, the <tt>visit</tt><i>X</i>Insn</tt> and <tt>visitLabel</tt>
+ * methods must be called in the sequential order of the bytecode instructions
+ * of the visited code, and the <tt>visitLocalVariable</tt> and <tt>visitLineNumber</tt>
+ * methods must be called <i>after</i> the labels passed as arguments have been
+ * visited.
+ *
+ * @author Eric Bruneton
+ */
+public interface MethodVisitor {
+
+ // -------------------------------------------------------------------------
+ // Annotations and non standard attributes
+ // -------------------------------------------------------------------------
+
+ /**
+ * Visits the default value of this annotation interface method.
+ *
+ * @return a non null visitor to the visit the actual default value of this
+ * annotation interface method. The 'name' parameters passed to the
+ * methods of this annotation visitor are ignored. Moreover, exacly
+ * one visit method must be called on this annotation visitor,
+ * followed by visitEnd.
+ */
+ AnnotationVisitor visitAnnotationDefault();
+
+ /**
+ * Visits an annotation of this method.
+ *
+ * @param desc the class descriptor of the annotation class.
+ * @param visible <tt>true</tt> if the annotation is visible at runtime.
+ * @return a non null visitor to visit the annotation values.
+ */
+ AnnotationVisitor visitAnnotation(String desc, boolean visible);
+
+ /**
+ * Visits an annotation of a parameter this method.
+ *
+ * @param parameter the parameter index.
+ * @param desc the class descriptor of the annotation class.
+ * @param visible <tt>true</tt> if the annotation is visible at runtime.
+ * @return a non null visitor to visit the annotation values.
+ */
+ AnnotationVisitor visitParameterAnnotation(
+ int parameter,
+ String desc,
+ boolean visible);
+
+ /**
+ * Visits a non standard attribute of this method.
+ *
+ * @param attr an attribute.
+ */
+ void visitAttribute(Attribute attr);
+
+ /**
+ * Starts the visit of the method's code, if any (i.e. non abstract method).
+ */
+ void visitCode();
+
+ // -------------------------------------------------------------------------
+ // Normal instructions
+ // -------------------------------------------------------------------------
+
+ /**
+ * Visits a zero operand instruction.
+ *
+ * @param opcode the opcode of the instruction to be visited. This opcode is
+ * either 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, IALOAD, LALOAD, FALOAD,
+ * DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, 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,
+ * I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B,
+ * I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN,
+ * FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW,
+ * MONITORENTER, or MONITOREXIT.
+ */
+ void visitInsn(int opcode);
+
+ /**
+ * Visits an instruction with a single int operand.
+ *
+ * @param opcode the opcode of the instruction to be visited. This opcode is
+ * either BIPUSH, SIPUSH or NEWARRAY.
+ * @param operand the operand of the instruction to be visited.<br>
+ * When opcode is BIPUSH, operand value should be between
+ * Byte.MIN_VALUE and Byte.MAX_VALUE.<br>
+ * When opcode is SIPUSH, operand value should be between
+ * Short.MIN_VALUE and Short.MAX_VALUE.<br>
+ * When opcode is NEWARRAY, operand value should be one of
+ * {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR},
+ * {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE},
+ * {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT},
+ * {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}.
+ */
+ void visitIntInsn(int opcode, int operand);
+
+ /**
+ * Visits a local variable instruction. A local variable instruction is an
+ * instruction that loads or stores the value of a local variable.
+ *
+ * @param opcode the opcode of the local variable instruction to be visited.
+ * This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE,
+ * LSTORE, FSTORE, DSTORE, ASTORE or RET.
+ * @param var the operand of the instruction to be visited. This operand is
+ * the index of a local variable.
+ */
+ void visitVarInsn(int opcode, int var);
+
+ /**
+ * Visits a type instruction. A type instruction is an instruction that
+ * takes a type descriptor as parameter.
+ *
+ * @param opcode the opcode of the type instruction to be visited. This
+ * opcode is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
+ * @param desc the operand of the instruction to be visited. This operand is
+ * must be a fully qualified class name in internal form, or the type
+ * descriptor of an array type (see {@link Type Type}).
+ */
+ void visitTypeInsn(int opcode, String desc);
+
+ /**
+ * Visits a field instruction. A field instruction is an instruction that
+ * loads or stores the value of a field of an object.
+ *
+ * @param opcode the opcode of the type instruction to be visited. This
+ * opcode is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
+ * @param owner the internal name of the field's owner class (see {@link
+ * Type#getInternalName() getInternalName}).
+ * @param name the field's name.
+ * @param desc the field's descriptor (see {@link Type Type}).
+ */
+ void visitFieldInsn(int opcode, String owner, String name, String desc);
+
+ /**
+ * Visits a method instruction. A method instruction is an instruction that
+ * invokes a method.
+ *
+ * @param opcode the opcode of the type instruction to be visited. This
+ * opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
+ * INVOKEINTERFACE.
+ * @param owner the internal name of the method's owner class (see {@link
+ * Type#getInternalName() getInternalName}).
+ * @param name the method's name.
+ * @param desc the method's descriptor (see {@link Type Type}).
+ */
+ void visitMethodInsn(int opcode, String owner, String name, String desc);
+
+ /**
+ * Visits a jump instruction. A jump instruction is an instruction that may
+ * jump to another instruction.
+ *
+ * @param opcode the opcode of the type instruction to be visited. This
+ * opcode is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
+ * IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ,
+ * IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
+ * @param label the operand of the instruction to be visited. This operand
+ * is a label that designates the instruction to which the jump
+ * instruction may jump.
+ */
+ void visitJumpInsn(int opcode, Label label);
+
+ /**
+ * Visits a label. A label designates the instruction that will be visited
+ * just after it.
+ *
+ * @param label a {@link Label Label} object.
+ */
+ void visitLabel(Label label);
+
+ // -------------------------------------------------------------------------
+ // Special instructions
+ // -------------------------------------------------------------------------
+
+ /**
+ * Visits a LDC instruction.
+ *
+ * @param cst the constant to be loaded on the stack. This parameter must be
+ * a non null {@link Integer}, a {@link Float}, a {@link Long}, a
+ * {@link Double} a {@link String} (or a {@link Type} for
+ * <tt>.class</tt> constants, for classes whose version is 49.0 or
+ * more).
+ */
+ void visitLdcInsn(Object cst);
+
+ /**
+ * Visits an IINC instruction.
+ *
+ * @param var index of the local variable to be incremented.
+ * @param increment amount to increment the local variable by.
+ */
+ void visitIincInsn(int var, int increment);
+
+ /**
+ * Visits a TABLESWITCH instruction.
+ *
+ * @param min the minimum key value.
+ * @param max the maximum key value.
+ * @param dflt beginning of the default handler block.
+ * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
+ * the beginning of the handler block for the <tt>min + i</tt> key.
+ */
+ void visitTableSwitchInsn(int min, int max, Label dflt, Label labels[]);
+
+ /**
+ * Visits a LOOKUPSWITCH instruction.
+ *
+ * @param dflt beginning of the default handler block.
+ * @param keys the values of the keys.
+ * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
+ * the beginning of the handler block for the <tt>keys[i]</tt> key.
+ */
+ void visitLookupSwitchInsn(Label dflt, int keys[], Label labels[]);
+
+ /**
+ * Visits a MULTIANEWARRAY instruction.
+ *
+ * @param desc an array type descriptor (see {@link Type Type}).
+ * @param dims number of dimensions of the array to allocate.
+ */
+ void visitMultiANewArrayInsn(String desc, int dims);
+
+ // -------------------------------------------------------------------------
+ // Exceptions table entries, debug information,
+ // max stack size and max locals
+ // -------------------------------------------------------------------------
+
+ /**
+ * Visits a try catch block.
+ *
+ * @param start beginning of the exception handler's scope (inclusive).
+ * @param end end of the exception handler's scope (exclusive).
+ * @param handler beginning of the exception handler's code.
+ * @param type internal name of the type of exceptions handled by the
+ * handler, or <tt>null</tt> to catch any exceptions (for "finally"
+ * blocks).
+ */
+ void visitTryCatchBlock(Label start, Label end, Label handler, String type);
+
+ /**
+ * Visits a local variable declaration.
+ *
+ * @param name the name of a local variable.
+ * @param desc the type descriptor of this local variable.
+ * @param signature the type signature of this local variable. May be
+ * <tt>null</tt> if the local variable type does not use generic
+ * types.
+ * @param start the first instruction corresponding to the scope of this
+ * local variable (inclusive).
+ * @param end the last instruction corresponding to the scope of this local
+ * variable (exclusive).
+ * @param index the local variable's index.
+ * @throws IllegalArgumentException if one of the labels has not already
+ * been visited by this visitor (by the
+ * {@link #visitLabel visitLabel} method).
+ */
+ void visitLocalVariable(
+ String name,
+ String desc,
+ String signature,
+ Label start,
+ Label end,
+ int index);
+
+ /**
+ * Visits a line number declaration.
+ *
+ * @param line a line number. This number refers to the source file from
+ * which the class was compiled.
+ * @param start the first instruction corresponding to this line number.
+ * @throws IllegalArgumentException if <tt>start</tt> has not already been
+ * visited by this visitor (by the {@link #visitLabel visitLabel}
+ * method).
+ */
+ void visitLineNumber(int line, Label start);
+
+ /**
+ * Visits the maximum stack size and the maximum number of local variables
+ * of the method.
+ *
+ * @param maxStack maximum stack size of the method.
+ * @param maxLocals maximum number of local variables for the method.
+ */
+ void visitMaxs(int maxStack, int maxLocals);
+
+ /**
+ * Visits the end of the method. This method, which is the last one to be
+ * called, is used to inform the visitor that all the annotations and
+ * attributes of the method have been visited.
+ */
+ void visitEnd();
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodWriter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodWriter.java
new file mode 100644
index 000000000..5b841d5fc
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/MethodWriter.java
@@ -0,0 +1,2022 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * A {@link MethodVisitor} that generates methods in bytecode form. Each visit
+ * method of this class appends the bytecode corresponding to the visited
+ * instruction to a byte vector, in the order these methods are called.
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+class MethodWriter implements MethodVisitor {
+
+ /**
+ * Next method writer (see {@link ClassWriter#firstMethod firstMethod}).
+ */
+ MethodWriter next;
+
+ /**
+ * The class writer to which this method must be added.
+ */
+ ClassWriter cw;
+
+ /**
+ * Access flags of this method.
+ */
+ private int access;
+
+ /**
+ * The index of the constant pool item that contains the name of this
+ * method.
+ */
+ private int name;
+
+ /**
+ * The index of the constant pool item that contains the descriptor of this
+ * method.
+ */
+ private int desc;
+
+ /**
+ * The descriptor of this method.
+ */
+ private String descriptor;
+
+ /**
+ * If not zero, indicates that the code of this method must be copied from
+ * the ClassReader associated to this writer in <code>cw.cr</code>. More
+ * precisely, this field gives the index of the first byte to copied from
+ * <code>cw.cr.b</code>.
+ */
+ int classReaderOffset;
+
+ /**
+ * If not zero, indicates that the code of this method must be copied from
+ * the ClassReader associated to this writer in <code>cw.cr</code>. More
+ * precisely, this field gives the number of bytes to copied from
+ * <code>cw.cr.b</code>.
+ */
+ int classReaderLength;
+
+ /**
+ * The signature of this method.
+ */
+ String signature;
+
+ /**
+ * Number of exceptions that can be thrown by this method.
+ */
+ int exceptionCount;
+
+ /**
+ * The exceptions that can be thrown by this method. More precisely, this
+ * array contains the indexes of the constant pool items that contain the
+ * internal names of these exception classes.
+ */
+ int[] exceptions;
+
+ /**
+ * The annotation default attribute of this method. May be <tt>null</tt>.
+ */
+ private ByteVector annd;
+
+ /**
+ * The runtime visible annotations of this method. May be <tt>null</tt>.
+ */
+ private AnnotationWriter anns;
+
+ /**
+ * The runtime invisible annotations of this method. May be <tt>null</tt>.
+ */
+ private AnnotationWriter ianns;
+
+ /**
+ * The runtime visible parameter annotations of this method. May be
+ * <tt>null</tt>.
+ */
+ private AnnotationWriter[] panns;
+
+ /**
+ * The runtime invisible parameter annotations of this method. May be
+ * <tt>null</tt>.
+ */
+ private AnnotationWriter[] ipanns;
+
+ /**
+ * The non standard attributes of the method.
+ */
+ private Attribute attrs;
+
+ /**
+ * The bytecode of this method.
+ */
+ private ByteVector code = new ByteVector();
+
+ /**
+ * Maximum stack size of this method.
+ */
+ private int maxStack;
+
+ /**
+ * Maximum number of local variables for this method.
+ */
+ private int maxLocals;
+
+ /**
+ * Number of entries in the catch table of this method.
+ */
+ private int catchCount;
+
+ /**
+ * The catch table of this method.
+ */
+ private Handler catchTable;
+
+ /**
+ * The last element in the catchTable handler list.
+ */
+ private Handler lastHandler;
+
+ /**
+ * Number of entries in the LocalVariableTable attribute.
+ */
+ private int localVarCount;
+
+ /**
+ * The LocalVariableTable attribute.
+ */
+ private ByteVector localVar;
+
+ /**
+ * Number of entries in the LocalVariableTypeTable attribute.
+ */
+ private int localVarTypeCount;
+
+ /**
+ * The LocalVariableTypeTable attribute.
+ */
+ private ByteVector localVarType;
+
+ /**
+ * Number of entries in the LineNumberTable attribute.
+ */
+ private int lineNumberCount;
+
+ /**
+ * The LineNumberTable attribute.
+ */
+ private ByteVector lineNumber;
+
+ /**
+ * The non standard attributes of the method's code.
+ */
+ private Attribute cattrs;
+
+ /**
+ * Indicates if some jump instructions are too small and need to be resized.
+ */
+ private boolean resize;
+
+ /*
+ * Fields for the control flow graph analysis algorithm (used to compute the
+ * maximum stack size). A control flow graph contains one node per "basic
+ * block", and one edge per "jump" from one basic block to another. Each
+ * node (i.e., each basic block) is represented by the Label object that
+ * corresponds to the first instruction of this basic block. Each node also
+ * stores the list of its successors in the graph, as a linked list of Edge
+ * objects.
+ */
+
+ /**
+ * <tt>true</tt> if the maximum stack size and number of local variables
+ * must be automatically computed.
+ */
+ private final boolean computeMaxs;
+
+ /**
+ * The (relative) stack size after the last visited instruction. This size
+ * is relative to the beginning of the current basic block, i.e., the true
+ * stack size after the last visited instruction is equal to the {@link
+ * Label#beginStackSize beginStackSize} of the current basic block plus
+ * <tt>stackSize</tt>.
+ */
+ private int stackSize;
+
+ /**
+ * The (relative) maximum stack size after the last visited instruction.
+ * This size is relative to the beginning of the current basic block, i.e.,
+ * the true maximum stack size after the last visited instruction is equal
+ * to the {@link Label#beginStackSize beginStackSize} of the current basic
+ * block plus <tt>stackSize</tt>.
+ */
+ private int maxStackSize;
+
+ /**
+ * The current basic block. This block is the basic block to which the next
+ * instruction to be visited must be added.
+ */
+ private Label currentBlock;
+
+ /**
+ * The basic block stack used by the control flow analysis algorithm. This
+ * stack is represented by a linked list of {@link Label Label} objects,
+ * linked to each other by their {@link Label#next} field. This stack must
+ * not be confused with the JVM stack used to execute the JVM instructions!
+ */
+ private Label blockStack;
+
+ /**
+ * The stack size variation corresponding to each JVM instruction. This
+ * stack variation is equal to the size of the values produced by an
+ * instruction, minus the size of the values consumed by this instruction.
+ */
+ private final static int[] SIZE;
+
+ // ------------------------------------------------------------------------
+ // Static initializer
+ // ------------------------------------------------------------------------
+
+ /**
+ * Computes the stack size variation corresponding to each JVM instruction.
+ */
+ static {
+ int i;
+ int[] b = new int[202];
+ String s = "EFFFFFFFFGGFFFGGFFFEEFGFGFEEEEEEEEEEEEEEEEEEEEDEDEDDDDD"
+ + "CDCDEEEEEEEEEEEEEEEEEEEEBABABBBBDCFFFGGGEDCDCDCDCDCDCDCDCD"
+ + "CDCEEEEDDDDDDDCDCDCEFEFDDEEFFDEDEEEBDDBBDDDDDDCCCCCCCCEFED"
+ + "DDCDCDEEEEEEEEEEFEEEEEEDDEEDDEE";
+ for (i = 0; i < b.length; ++i) {
+ b[i] = s.charAt(i) - 'E';
+ }
+ SIZE = b;
+
+ // code to generate the above string
+ //
+ // int NA = 0; // not applicable (unused opcode or variable size opcode)
+ //
+ // b = new int[] {
+ // 0, //NOP, // visitInsn
+ // 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, // visitIntInsn
+ // 1, //SIPUSH, // -
+ // 1, //LDC, // visitLdcInsn
+ // NA, //LDC_W, // -
+ // NA, //LDC2_W, // -
+ // 1, //ILOAD, // visitVarInsn
+ // 2, //LLOAD, // -
+ // 1, //FLOAD, // -
+ // 2, //DLOAD, // -
+ // 1, //ALOAD, // -
+ // NA, //ILOAD_0, // -
+ // NA, //ILOAD_1, // -
+ // NA, //ILOAD_2, // -
+ // NA, //ILOAD_3, // -
+ // NA, //LLOAD_0, // -
+ // NA, //LLOAD_1, // -
+ // NA, //LLOAD_2, // -
+ // NA, //LLOAD_3, // -
+ // NA, //FLOAD_0, // -
+ // NA, //FLOAD_1, // -
+ // NA, //FLOAD_2, // -
+ // NA, //FLOAD_3, // -
+ // NA, //DLOAD_0, // -
+ // NA, //DLOAD_1, // -
+ // NA, //DLOAD_2, // -
+ // NA, //DLOAD_3, // -
+ // NA, //ALOAD_0, // -
+ // NA, //ALOAD_1, // -
+ // NA, //ALOAD_2, // -
+ // NA, //ALOAD_3, // -
+ // -1, //IALOAD, // visitInsn
+ // 0, //LALOAD, // -
+ // -1, //FALOAD, // -
+ // 0, //DALOAD, // -
+ // -1, //AALOAD, // -
+ // -1, //BALOAD, // -
+ // -1, //CALOAD, // -
+ // -1, //SALOAD, // -
+ // -1, //ISTORE, // visitVarInsn
+ // -2, //LSTORE, // -
+ // -1, //FSTORE, // -
+ // -2, //DSTORE, // -
+ // -1, //ASTORE, // -
+ // NA, //ISTORE_0, // -
+ // NA, //ISTORE_1, // -
+ // NA, //ISTORE_2, // -
+ // NA, //ISTORE_3, // -
+ // NA, //LSTORE_0, // -
+ // NA, //LSTORE_1, // -
+ // NA, //LSTORE_2, // -
+ // NA, //LSTORE_3, // -
+ // NA, //FSTORE_0, // -
+ // NA, //FSTORE_1, // -
+ // NA, //FSTORE_2, // -
+ // NA, //FSTORE_3, // -
+ // NA, //DSTORE_0, // -
+ // NA, //DSTORE_1, // -
+ // NA, //DSTORE_2, // -
+ // NA, //DSTORE_3, // -
+ // NA, //ASTORE_0, // -
+ // NA, //ASTORE_1, // -
+ // NA, //ASTORE_2, // -
+ // NA, //ASTORE_3, // -
+ // -3, //IASTORE, // visitInsn
+ // -4, //LASTORE, // -
+ // -3, //FASTORE, // -
+ // -4, //DASTORE, // -
+ // -3, //AASTORE, // -
+ // -3, //BASTORE, // -
+ // -3, //CASTORE, // -
+ // -3, //SASTORE, // -
+ // -1, //POP, // -
+ // -2, //POP2, // -
+ // 1, //DUP, // -
+ // 1, //DUP_X1, // -
+ // 1, //DUP_X2, // -
+ // 2, //DUP2, // -
+ // 2, //DUP2_X1, // -
+ // 2, //DUP2_X2, // -
+ // 0, //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, // -
+ // 0, //INEG, // -
+ // 0, //LNEG, // -
+ // 0, //FNEG, // -
+ // 0, //DNEG, // -
+ // -1, //ISHL, // -
+ // -1, //LSHL, // -
+ // -1, //ISHR, // -
+ // -1, //LSHR, // -
+ // -1, //IUSHR, // -
+ // -1, //LUSHR, // -
+ // -1, //IAND, // -
+ // -2, //LAND, // -
+ // -1, //IOR, // -
+ // -2, //LOR, // -
+ // -1, //IXOR, // -
+ // -2, //LXOR, // -
+ // 0, //IINC, // visitIincInsn
+ // 1, //I2L, // visitInsn
+ // 0, //I2F, // -
+ // 1, //I2D, // -
+ // -1, //L2I, // -
+ // -1, //L2F, // -
+ // 0, //L2D, // -
+ // 0, //F2I, // -
+ // 1, //F2L, // -
+ // 1, //F2D, // -
+ // -1, //D2I, // -
+ // 0, //D2L, // -
+ // -1, //D2F, // -
+ // 0, //I2B, // -
+ // 0, //I2C, // -
+ // 0, //I2S, // -
+ // -3, //LCMP, // -
+ // -1, //FCMPL, // -
+ // -1, //FCMPG, // -
+ // -3, //DCMPL, // -
+ // -3, //DCMPG, // -
+ // -1, //IFEQ, // visitJumpInsn
+ // -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, // -
+ // 1, //JSR, // -
+ // 0, //RET, // visitVarInsn
+ // -1, //TABLESWITCH, // visiTableSwitchInsn
+ // -1, //LOOKUPSWITCH, // visitLookupSwitch
+ // -1, //IRETURN, // visitInsn
+ // -2, //LRETURN, // -
+ // -1, //FRETURN, // -
+ // -2, //DRETURN, // -
+ // -1, //ARETURN, // -
+ // 0, //RETURN, // -
+ // NA, //GETSTATIC, // visitFieldInsn
+ // NA, //PUTSTATIC, // -
+ // NA, //GETFIELD, // -
+ // NA, //PUTFIELD, // -
+ // NA, //INVOKEVIRTUAL, // visitMethodInsn
+ // NA, //INVOKESPECIAL, // -
+ // NA, //INVOKESTATIC, // -
+ // NA, //INVOKEINTERFACE, // -
+ // NA, //UNUSED, // NOT VISITED
+ // 1, //NEW, // visitTypeInsn
+ // 0, //NEWARRAY, // visitIntInsn
+ // 0, //ANEWARRAY, // visitTypeInsn
+ // 0, //ARRAYLENGTH, // visitInsn
+ // NA, //ATHROW, // -
+ // 0, //CHECKCAST, // visitTypeInsn
+ // 0, //INSTANCEOF, // -
+ // -1, //MONITORENTER, // visitInsn
+ // -1, //MONITOREXIT, // -
+ // NA, //WIDE, // NOT VISITED
+ // NA, //MULTIANEWARRAY, // visitMultiANewArrayInsn
+ // -1, //IFNULL, // visitJumpInsn
+ // -1, //IFNONNULL, // -
+ // NA, //GOTO_W, // -
+ // NA, //JSR_W, // -
+ // };
+ // for (i = 0; i < b.length; ++i) {
+ // System.err.print((char)('E' + b[i]));
+ // }
+ // System.err.println();
+ }
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs a new {@link MethodWriter}.
+ *
+ * @param cw the class writer in which the method must be added.
+ * @param access the method's access flags (see {@link Opcodes}).
+ * @param name the method's name.
+ * @param desc the method's descriptor (see {@link Type}).
+ * @param signature the method's signature. May be <tt>null</tt>.
+ * @param exceptions the internal names of the method's exceptions. May be
+ * <tt>null</tt>.
+ * @param computeMaxs <tt>true</tt> if the maximum stack size and number
+ * of local variables must be automatically computed.
+ */
+ MethodWriter(
+ final ClassWriter cw,
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions,
+ final boolean computeMaxs)
+ {
+ if (cw.firstMethod == null) {
+ cw.firstMethod = this;
+ } else {
+ cw.lastMethod.next = this;
+ }
+ cw.lastMethod = this;
+ this.cw = cw;
+ this.access = access;
+ this.name = cw.newUTF8(name);
+ this.desc = cw.newUTF8(desc);
+ this.descriptor = desc;
+ this.signature = signature;
+ if (exceptions != null && exceptions.length > 0) {
+ exceptionCount = exceptions.length;
+ this.exceptions = new int[exceptionCount];
+ for (int i = 0; i < exceptionCount; ++i) {
+ this.exceptions[i] = cw.newClass(exceptions[i]);
+ }
+ }
+ this.computeMaxs = computeMaxs;
+ if (computeMaxs) {
+ // updates maxLocals
+ int size = getArgumentsAndReturnSizes(desc) >> 2;
+ if ((access & Opcodes.ACC_STATIC) != 0) {
+ --size;
+ }
+ maxLocals = size;
+ // pushes the first block onto the stack of blocks to be visited
+ currentBlock = new Label();
+ currentBlock.pushed = true;
+ blockStack = currentBlock;
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the MethodVisitor interface
+ // ------------------------------------------------------------------------
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ annd = new ByteVector();
+ return new AnnotationWriter(cw, false, annd, null, 0);
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ ByteVector bv = new ByteVector();
+ // write type, and reserve space for values count
+ bv.putShort(cw.newUTF8(desc)).putShort(0);
+ AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv, 2);
+ if (visible) {
+ aw.next = anns;
+ anns = aw;
+ } else {
+ aw.next = ianns;
+ ianns = aw;
+ }
+ return aw;
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ ByteVector bv = new ByteVector();
+ // write type, and reserve space for values count
+ bv.putShort(cw.newUTF8(desc)).putShort(0);
+ AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv, 2);
+ if (visible) {
+ if (panns == null) {
+ panns = new AnnotationWriter[Type.getArgumentTypes(descriptor).length];
+ }
+ aw.next = panns[parameter];
+ panns[parameter] = aw;
+ } else {
+ if (ipanns == null) {
+ ipanns = new AnnotationWriter[Type.getArgumentTypes(descriptor).length];
+ }
+ aw.next = ipanns[parameter];
+ ipanns[parameter] = aw;
+ }
+ return aw;
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ if (attr.isCodeAttribute()) {
+ attr.next = cattrs;
+ cattrs = attr;
+ } else {
+ attr.next = attrs;
+ attrs = attr;
+ }
+ }
+
+ public void visitCode() {
+ }
+
+ public void visitInsn(final int opcode) {
+ if (computeMaxs) {
+ // updates current and max stack sizes
+ int size = stackSize + SIZE[opcode];
+ if (size > maxStackSize) {
+ maxStackSize = size;
+ }
+ stackSize = size;
+ // if opcode == ATHROW or xRETURN, ends current block (no successor)
+ if ((opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN)
+ || opcode == Opcodes.ATHROW)
+ {
+ if (currentBlock != null) {
+ currentBlock.maxStackSize = maxStackSize;
+ currentBlock = null;
+ }
+ }
+ }
+ // adds the instruction to the bytecode of the method
+ code.putByte(opcode);
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ if (computeMaxs && opcode != Opcodes.NEWARRAY) {
+ // updates current and max stack sizes only if opcode == NEWARRAY
+ // (stack size variation = 0 for BIPUSH or SIPUSH)
+ int size = stackSize + 1;
+ if (size > maxStackSize) {
+ maxStackSize = size;
+ }
+ stackSize = size;
+ }
+ // adds the instruction to the bytecode of the method
+ if (opcode == Opcodes.SIPUSH) {
+ code.put12(opcode, operand);
+ } else { // BIPUSH or NEWARRAY
+ code.put11(opcode, operand);
+ }
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ if (computeMaxs) {
+ // updates current and max stack sizes
+ if (opcode == Opcodes.RET) {
+ // no stack change, but end of current block (no successor)
+ if (currentBlock != null) {
+ currentBlock.maxStackSize = maxStackSize;
+ currentBlock = null;
+ }
+ } else { // xLOAD or xSTORE
+ int size = stackSize + SIZE[opcode];
+ if (size > maxStackSize) {
+ maxStackSize = size;
+ }
+ stackSize = size;
+ }
+ // updates max locals
+ int n;
+ if (opcode == Opcodes.LLOAD || opcode == Opcodes.DLOAD
+ || opcode == Opcodes.LSTORE || opcode == Opcodes.DSTORE)
+ {
+ n = var + 2;
+ } else {
+ n = var + 1;
+ }
+ if (n > maxLocals) {
+ maxLocals = n;
+ }
+ }
+ // adds the instruction to the bytecode of the method
+ if (var < 4 && opcode != Opcodes.RET) {
+ int opt;
+ if (opcode < Opcodes.ISTORE) {
+ /* ILOAD_0 */
+ opt = 26 + ((opcode - Opcodes.ILOAD) << 2) + var;
+ } else {
+ /* ISTORE_0 */
+ opt = 59 + ((opcode - Opcodes.ISTORE) << 2) + var;
+ }
+ code.putByte(opt);
+ } else if (var >= 256) {
+ code.putByte(196 /* WIDE */).put12(opcode, var);
+ } else {
+ code.put11(opcode, var);
+ }
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ if (computeMaxs && opcode == Opcodes.NEW) {
+ // updates current and max stack sizes only if opcode == NEW
+ // (stack size variation = 0 for ANEWARRAY, CHECKCAST, INSTANCEOF)
+ int size = stackSize + 1;
+ if (size > maxStackSize) {
+ maxStackSize = size;
+ }
+ stackSize = size;
+ }
+ // adds the instruction to the bytecode of the method
+ code.put12(opcode, cw.newClass(desc));
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ if (computeMaxs) {
+ int size;
+ // computes the stack size variation
+ char c = desc.charAt(0);
+ switch (opcode) {
+ case Opcodes.GETSTATIC:
+ size = stackSize + (c == 'D' || c == 'J' ? 2 : 1);
+ break;
+ case Opcodes.PUTSTATIC:
+ size = stackSize + (c == 'D' || c == 'J' ? -2 : -1);
+ break;
+ case Opcodes.GETFIELD:
+ size = stackSize + (c == 'D' || c == 'J' ? 1 : 0);
+ break;
+ // case Constants.PUTFIELD:
+ default:
+ size = stackSize + (c == 'D' || c == 'J' ? -3 : -2);
+ break;
+ }
+ // updates current and max stack sizes
+ if (size > maxStackSize) {
+ maxStackSize = size;
+ }
+ stackSize = size;
+ }
+ // adds the instruction to the bytecode of the method
+ code.put12(opcode, cw.newField(owner, name, desc));
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ boolean itf = opcode == Opcodes.INVOKEINTERFACE;
+ Item i = cw.newMethodItem(owner, name, desc, itf);
+ int argSize = i.intVal;
+ if (computeMaxs) {
+ /*
+ * computes the stack size variation. In order not to recompute
+ * several times this variation for the same Item, we use the intVal
+ * field of this item to store this variation, once it has been
+ * computed. More precisely this intVal field stores the sizes of
+ * the arguments and of the return value corresponding to desc.
+ */
+ if (argSize == 0) {
+ // the above sizes have not been computed yet, so we compute
+ // them...
+ argSize = getArgumentsAndReturnSizes(desc);
+ // ... and we save them in order not to recompute them in the
+ // future
+ i.intVal = argSize;
+ }
+ int size;
+ if (opcode == Opcodes.INVOKESTATIC) {
+ size = stackSize - (argSize >> 2) + (argSize & 0x03) + 1;
+ } else {
+ size = stackSize - (argSize >> 2) + (argSize & 0x03);
+ }
+ // updates current and max stack sizes
+ if (size > maxStackSize) {
+ maxStackSize = size;
+ }
+ stackSize = size;
+ }
+ // adds the instruction to the bytecode of the method
+ if (itf) {
+ if (!computeMaxs) {
+ if (argSize == 0) {
+ argSize = getArgumentsAndReturnSizes(desc);
+ i.intVal = argSize;
+ }
+ }
+ code.put12(Opcodes.INVOKEINTERFACE, i.index).put11(argSize >> 2, 0);
+ } else {
+ code.put12(opcode, i.index);
+ }
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ if (computeMaxs) {
+ if (opcode == Opcodes.GOTO) {
+ // no stack change, but end of current block (with one new
+ // successor)
+ if (currentBlock != null) {
+ currentBlock.maxStackSize = maxStackSize;
+ addSuccessor(stackSize, label);
+ currentBlock = null;
+ }
+ } else if (opcode == Opcodes.JSR) {
+ if (currentBlock != null) {
+ addSuccessor(stackSize + 1, label);
+ }
+ } else {
+ // updates current stack size (max stack size unchanged because
+ // stack size variation always negative in this case)
+ stackSize += SIZE[opcode];
+ if (currentBlock != null) {
+ addSuccessor(stackSize, label);
+ }
+ }
+ }
+ // adds the instruction to the bytecode of the method
+ if (label.resolved && label.position - code.length < Short.MIN_VALUE) {
+ /*
+ * case of a backward jump with an offset < -32768. In this case we
+ * automatically replace GOTO with GOTO_W, JSR with JSR_W and IFxxx
+ * <l> with IFNOTxxx <l'> GOTO_W <l>, where IFNOTxxx is the
+ * "opposite" opcode of IFxxx (i.e., IFNE for IFEQ) and where <l'>
+ * designates the instruction just after the GOTO_W.
+ */
+ if (opcode == Opcodes.GOTO) {
+ code.putByte(200); // GOTO_W
+ } else if (opcode == Opcodes.JSR) {
+ code.putByte(201); // JSR_W
+ } else {
+ code.putByte(opcode <= 166
+ ? ((opcode + 1) ^ 1) - 1
+ : opcode ^ 1);
+ code.putShort(8); // jump offset
+ code.putByte(200); // GOTO_W
+ }
+ label.put(this, code, code.length - 1, true);
+ } else {
+ /*
+ * case of a backward jump with an offset >= -32768, or of a forward
+ * jump with, of course, an unknown offset. In these cases we store
+ * the offset in 2 bytes (which will be increased in
+ * resizeInstructions, if needed).
+ */
+ code.putByte(opcode);
+ label.put(this, code, code.length - 1, false);
+ }
+ }
+
+ public void visitLabel(final Label label) {
+ if (computeMaxs) {
+ if (currentBlock != null) {
+ // ends current block (with one new successor)
+ currentBlock.maxStackSize = maxStackSize;
+ addSuccessor(stackSize, label);
+ }
+ // begins a new current block,
+ // resets the relative current and max stack sizes
+ currentBlock = label;
+ stackSize = 0;
+ maxStackSize = 0;
+ }
+ // resolves previous forward references to label, if any
+ resize |= label.resolve(this, code.length, code.data);
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ Item i = cw.newConstItem(cst);
+ if (computeMaxs) {
+ int size;
+ // computes the stack size variation
+ if (i.type == ClassWriter.LONG || i.type == ClassWriter.DOUBLE) {
+ size = stackSize + 2;
+ } else {
+ size = stackSize + 1;
+ }
+ // updates current and max stack sizes
+ if (size > maxStackSize) {
+ maxStackSize = size;
+ }
+ stackSize = size;
+ }
+ // adds the instruction to the bytecode of the method
+ int index = i.index;
+ if (i.type == ClassWriter.LONG || i.type == ClassWriter.DOUBLE) {
+ code.put12(20 /* LDC2_W */, index);
+ } else if (index >= 256) {
+ code.put12(19 /* LDC_W */, index);
+ } else {
+ code.put11(Opcodes.LDC, index);
+ }
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ if (computeMaxs) {
+ // updates max locals only (no stack change)
+ int n = var + 1;
+ if (n > maxLocals) {
+ maxLocals = n;
+ }
+ }
+ // adds the instruction to the bytecode of the method
+ if ((var > 255) || (increment > 127) || (increment < -128)) {
+ code.putByte(196 /* WIDE */)
+ .put12(Opcodes.IINC, var)
+ .putShort(increment);
+ } else {
+ code.putByte(Opcodes.IINC).put11(var, increment);
+ }
+ }
+
+ public void visitTableSwitchInsn(
+ final int min,
+ final int max,
+ final Label dflt,
+ final Label labels[])
+ {
+ if (computeMaxs) {
+ // updates current stack size (max stack size unchanged)
+ --stackSize;
+ // ends current block (with many new successors)
+ if (currentBlock != null) {
+ currentBlock.maxStackSize = maxStackSize;
+ addSuccessor(stackSize, dflt);
+ for (int i = 0; i < labels.length; ++i) {
+ addSuccessor(stackSize, labels[i]);
+ }
+ currentBlock = null;
+ }
+ }
+ // adds the instruction to the bytecode of the method
+ int source = code.length;
+ code.putByte(Opcodes.TABLESWITCH);
+ while (code.length % 4 != 0) {
+ code.putByte(0);
+ }
+ dflt.put(this, code, source, true);
+ code.putInt(min).putInt(max);
+ for (int i = 0; i < labels.length; ++i) {
+ labels[i].put(this, code, source, true);
+ }
+ }
+
+ public void visitLookupSwitchInsn(
+ final Label dflt,
+ final int keys[],
+ final Label labels[])
+ {
+ if (computeMaxs) {
+ // updates current stack size (max stack size unchanged)
+ --stackSize;
+ // ends current block (with many new successors)
+ if (currentBlock != null) {
+ currentBlock.maxStackSize = maxStackSize;
+ addSuccessor(stackSize, dflt);
+ for (int i = 0; i < labels.length; ++i) {
+ addSuccessor(stackSize, labels[i]);
+ }
+ currentBlock = null;
+ }
+ }
+ // adds the instruction to the bytecode of the method
+ int source = code.length;
+ code.putByte(Opcodes.LOOKUPSWITCH);
+ while (code.length % 4 != 0) {
+ code.putByte(0);
+ }
+ dflt.put(this, code, source, true);
+ code.putInt(labels.length);
+ for (int i = 0; i < labels.length; ++i) {
+ code.putInt(keys[i]);
+ labels[i].put(this, code, source, true);
+ }
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ if (computeMaxs) {
+ // updates current stack size (max stack size unchanged because
+ // stack size variation always negative or null)
+ stackSize += 1 - dims;
+ }
+ // adds the instruction to the bytecode of the method
+ code.put12(Opcodes.MULTIANEWARRAY, cw.newClass(desc)).putByte(dims);
+ }
+
+ public void visitTryCatchBlock(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ if (computeMaxs) {
+ // pushes handler block onto the stack of blocks to be visited
+ if (!handler.pushed) {
+ handler.beginStackSize = 1;
+ handler.pushed = true;
+ handler.next = blockStack;
+ blockStack = handler;
+ }
+ }
+ ++catchCount;
+ Handler h = new Handler();
+ h.start = start;
+ h.end = end;
+ h.handler = handler;
+ h.desc = type;
+ h.type = type != null ? cw.newClass(type) : 0;
+ if (lastHandler == null) {
+ catchTable = h;
+ } else {
+ lastHandler.next = h;
+ }
+ lastHandler = h;
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ if (signature != null) {
+ if (localVarType == null) {
+ localVarType = new ByteVector();
+ }
+ ++localVarTypeCount;
+ localVarType.putShort(start.position)
+ .putShort(end.position - start.position)
+ .putShort(cw.newUTF8(name))
+ .putShort(cw.newUTF8(signature))
+ .putShort(index);
+ }
+ if (localVar == null) {
+ localVar = new ByteVector();
+ }
+ ++localVarCount;
+ localVar.putShort(start.position)
+ .putShort(end.position - start.position)
+ .putShort(cw.newUTF8(name))
+ .putShort(cw.newUTF8(desc))
+ .putShort(index);
+
+ if(computeMaxs) {
+ // updates max locals
+ char c = desc.charAt(0);
+ int n = index + ( c=='L' || c=='D' ? 2 : 1);
+ if (n > maxLocals) {
+ maxLocals = n;
+ }
+ }
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ if (lineNumber == null) {
+ lineNumber = new ByteVector();
+ }
+ ++lineNumberCount;
+ lineNumber.putShort(start.position);
+ lineNumber.putShort(line);
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ if (computeMaxs) {
+ // true (non relative) max stack size
+ int max = 0;
+ /*
+ * control flow analysis algorithm: while the block stack is not
+ * empty, pop a block from this stack, update the max stack size,
+ * compute the true (non relative) begin stack size of the
+ * successors of this block, and push these successors onto the
+ * stack (unless they have already been pushed onto the stack).
+ * Note: by hypothesis, the {@link Label#beginStackSize} of the
+ * blocks in the block stack are the true (non relative) beginning
+ * stack sizes of these blocks.
+ */
+ Label stack = blockStack;
+ while (stack != null) {
+ // pops a block from the stack
+ Label l = stack;
+ stack = stack.next;
+ // computes the true (non relative) max stack size of this block
+ int start = l.beginStackSize;
+ int blockMax = start + l.maxStackSize;
+ // updates the global max stack size
+ if (blockMax > max) {
+ max = blockMax;
+ }
+ // analyses the successors of the block
+ Edge b = l.successors;
+ while (b != null) {
+ l = b.successor;
+ // if this successor has not already been pushed onto the
+ // stack...
+ if (!l.pushed) {
+ // computes the true beginning stack size of this
+ // successor block
+ l.beginStackSize = start + b.stackSize;
+ // pushes this successor onto the stack
+ l.pushed = true;
+ l.next = stack;
+ stack = l;
+ }
+ b = b.next;
+ }
+ }
+ this.maxStack = max;
+ } else {
+ this.maxStack = maxStack;
+ this.maxLocals = maxLocals;
+ }
+ }
+
+ public void visitEnd() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods: control flow analysis algorithm
+ // ------------------------------------------------------------------------
+
+ /**
+ * Computes the size of the arguments and of the return value of a method.
+ *
+ * @param desc the descriptor of a method.
+ * @return the size of the arguments of the method (plus one for the
+ * implicit this argument), argSize, and the size of its return
+ * value, retSize, packed into a single int i =
+ * <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal
+ * to <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
+ */
+ private static int getArgumentsAndReturnSizes(final String desc) {
+ int n = 1;
+ int c = 1;
+ while (true) {
+ char car = desc.charAt(c++);
+ if (car == ')') {
+ car = desc.charAt(c);
+ return n << 2
+ | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
+ } else if (car == 'L') {
+ while (desc.charAt(c++) != ';') {
+ }
+ n += 1;
+ } else if (car == '[') {
+ while ((car = desc.charAt(c)) == '[') {
+ ++c;
+ }
+ if (car == 'D' || car == 'J') {
+ n -= 1;
+ }
+ } else if (car == 'D' || car == 'J') {
+ n += 2;
+ } else {
+ n += 1;
+ }
+ }
+ }
+
+ /**
+ * Adds a successor to the {@link #currentBlock currentBlock} block.
+ *
+ * @param stackSize the current (relative) stack size in the current block.
+ * @param successor the successor block to be added to the current block.
+ */
+ private void addSuccessor(final int stackSize, final Label successor) {
+ Edge b = new Edge();
+ // initializes the previous Edge object...
+ b.stackSize = stackSize;
+ b.successor = successor;
+ // ...and adds it to the successor list of the currentBlock block
+ b.next = currentBlock.successors;
+ currentBlock.successors = b;
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods: dump bytecode array
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the size of the bytecode of this method.
+ *
+ * @return the size of the bytecode of this method.
+ */
+ final int getSize() {
+ if (classReaderOffset != 0) {
+ return 6 + classReaderLength;
+ }
+ if (resize) {
+ // replaces the temporary jump opcodes introduced by Label.resolve.
+ resizeInstructions(new int[0], new int[0], 0);
+ }
+ int size = 8;
+ if (code.length > 0) {
+ cw.newUTF8("Code");
+ size += 18 + code.length + 8 * catchCount;
+ if (localVar != null) {
+ cw.newUTF8("LocalVariableTable");
+ size += 8 + localVar.length;
+ }
+ if (localVarType != null) {
+ cw.newUTF8("LocalVariableTypeTable");
+ size += 8 + localVarType.length;
+ }
+ if (lineNumber != null) {
+ cw.newUTF8("LineNumberTable");
+ size += 8 + lineNumber.length;
+ }
+ if (cattrs != null) {
+ size += cattrs.getSize(cw,
+ code.data,
+ code.length,
+ maxStack,
+ maxLocals);
+ }
+ }
+ if (exceptionCount > 0) {
+ cw.newUTF8("Exceptions");
+ size += 8 + 2 * exceptionCount;
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (cw.version & 0xffff) < Opcodes.V1_5)
+ {
+ cw.newUTF8("Synthetic");
+ size += 6;
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ cw.newUTF8("Deprecated");
+ size += 6;
+ }
+ if (cw.version == Opcodes.V1_4) {
+ if ((access & Opcodes.ACC_VARARGS) != 0) {
+ cw.newUTF8("Varargs");
+ size += 6;
+ }
+ if ((access & Opcodes.ACC_BRIDGE) != 0) {
+ cw.newUTF8("Bridge");
+ size += 6;
+ }
+ }
+ if (signature != null) {
+ cw.newUTF8("Signature");
+ cw.newUTF8(signature);
+ size += 8;
+ }
+ if (annd != null) {
+ cw.newUTF8("AnnotationDefault");
+ size += 6 + annd.length;
+ }
+ if (anns != null) {
+ cw.newUTF8("RuntimeVisibleAnnotations");
+ size += 8 + anns.getSize();
+ }
+ if (ianns != null) {
+ cw.newUTF8("RuntimeInvisibleAnnotations");
+ size += 8 + ianns.getSize();
+ }
+ if (panns != null) {
+ cw.newUTF8("RuntimeVisibleParameterAnnotations");
+ size += 7 + 2 * panns.length;
+ for (int i = panns.length - 1; i >= 0; --i) {
+ size += panns[i] == null ? 0 : panns[i].getSize();
+ }
+ }
+ if (ipanns != null) {
+ cw.newUTF8("RuntimeInvisibleParameterAnnotations");
+ size += 7 + 2 * ipanns.length;
+ for (int i = ipanns.length - 1; i >= 0; --i) {
+ size += ipanns[i] == null ? 0 : ipanns[i].getSize();
+ }
+ }
+ if (attrs != null) {
+ size += attrs.getSize(cw, null, 0, -1, -1);
+ }
+ return size;
+ }
+
+ /**
+ * Puts the bytecode of this method in the given byte vector.
+ *
+ * @param out the byte vector into which the bytecode of this method must be
+ * copied.
+ */
+ final void put(final ByteVector out) {
+ out.putShort(access).putShort(name).putShort(desc);
+ if (classReaderOffset != 0) {
+ out.putByteArray(cw.cr.b, classReaderOffset, classReaderLength);
+ return;
+ }
+ int attributeCount = 0;
+ if (code.length > 0) {
+ ++attributeCount;
+ }
+ if (exceptionCount > 0) {
+ ++attributeCount;
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (cw.version & 0xffff) < Opcodes.V1_5)
+ {
+ ++attributeCount;
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ ++attributeCount;
+ }
+ if (cw.version == Opcodes.V1_4) {
+ if ((access & Opcodes.ACC_VARARGS) != 0) {
+ ++attributeCount;
+ }
+ if ((access & Opcodes.ACC_BRIDGE) != 0) {
+ ++attributeCount;
+ }
+ }
+ if (signature != null) {
+ ++attributeCount;
+ }
+ if (annd != null) {
+ ++attributeCount;
+ }
+ if (anns != null) {
+ ++attributeCount;
+ }
+ if (ianns != null) {
+ ++attributeCount;
+ }
+ if (panns != null) {
+ ++attributeCount;
+ }
+ if (ipanns != null) {
+ ++attributeCount;
+ }
+ if (attrs != null) {
+ attributeCount += attrs.getCount();
+ }
+ out.putShort(attributeCount);
+ if (code.length > 0) {
+ int size = 12 + code.length + 8 * catchCount;
+ if (localVar != null) {
+ size += 8 + localVar.length;
+ }
+ if (localVarType != null) {
+ size += 8 + localVarType.length;
+ }
+ if (lineNumber != null) {
+ size += 8 + lineNumber.length;
+ }
+ if (cattrs != null) {
+ size += cattrs.getSize(cw,
+ code.data,
+ code.length,
+ maxStack,
+ maxLocals);
+ }
+ out.putShort(cw.newUTF8("Code")).putInt(size);
+ out.putShort(maxStack).putShort(maxLocals);
+ out.putInt(code.length).putByteArray(code.data, 0, code.length);
+ out.putShort(catchCount);
+ if (catchCount > 0) {
+ Handler h = catchTable;
+ while (h != null) {
+ out.putShort(h.start.position)
+ .putShort(h.end.position)
+ .putShort(h.handler.position)
+ .putShort(h.type);
+ h = h.next;
+ }
+ }
+ attributeCount = 0;
+ if (localVar != null) {
+ ++attributeCount;
+ }
+ if (localVarType != null) {
+ ++attributeCount;
+ }
+ if (lineNumber != null) {
+ ++attributeCount;
+ }
+ if (cattrs != null) {
+ attributeCount += cattrs.getCount();
+ }
+ out.putShort(attributeCount);
+ if (localVar != null) {
+ out.putShort(cw.newUTF8("LocalVariableTable"));
+ out.putInt(localVar.length + 2).putShort(localVarCount);
+ out.putByteArray(localVar.data, 0, localVar.length);
+ }
+ if (localVarType != null) {
+ out.putShort(cw.newUTF8("LocalVariableTypeTable"));
+ out.putInt(localVarType.length + 2).putShort(localVarTypeCount);
+ out.putByteArray(localVarType.data, 0, localVarType.length);
+ }
+ if (lineNumber != null) {
+ out.putShort(cw.newUTF8("LineNumberTable"));
+ out.putInt(lineNumber.length + 2).putShort(lineNumberCount);
+ out.putByteArray(lineNumber.data, 0, lineNumber.length);
+ }
+ if (cattrs != null) {
+ cattrs.put(cw, code.data, code.length, maxLocals, maxStack, out);
+ }
+ }
+ if (exceptionCount > 0) {
+ out.putShort(cw.newUTF8("Exceptions"))
+ .putInt(2 * exceptionCount + 2);
+ out.putShort(exceptionCount);
+ for (int i = 0; i < exceptionCount; ++i) {
+ out.putShort(exceptions[i]);
+ }
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0
+ && (cw.version & 0xffff) < Opcodes.V1_5)
+ {
+ out.putShort(cw.newUTF8("Synthetic")).putInt(0);
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ out.putShort(cw.newUTF8("Deprecated")).putInt(0);
+ }
+ if (cw.version == Opcodes.V1_4) {
+ if ((access & Opcodes.ACC_VARARGS) != 0) {
+ out.putShort(cw.newUTF8("Varargs")).putInt(0);
+ }
+ if ((access & Opcodes.ACC_BRIDGE) != 0) {
+ out.putShort(cw.newUTF8("Bridge")).putInt(0);
+ }
+ }
+ if (signature != null) {
+ out.putShort(cw.newUTF8("Signature"))
+ .putInt(2)
+ .putShort(cw.newUTF8(signature));
+ }
+ if (annd != null) {
+ out.putShort(cw.newUTF8("AnnotationDefault"));
+ out.putInt(annd.length);
+ out.putByteArray(annd.data, 0, annd.length);
+ }
+ if (anns != null) {
+ out.putShort(cw.newUTF8("RuntimeVisibleAnnotations"));
+ anns.put(out);
+ }
+ if (ianns != null) {
+ out.putShort(cw.newUTF8("RuntimeInvisibleAnnotations"));
+ ianns.put(out);
+ }
+ if (panns != null) {
+ out.putShort(cw.newUTF8("RuntimeVisibleParameterAnnotations"));
+ AnnotationWriter.put(panns, out);
+ }
+ if (ipanns != null) {
+ out.putShort(cw.newUTF8("RuntimeInvisibleParameterAnnotations"));
+ AnnotationWriter.put(ipanns, out);
+ }
+ if (attrs != null) {
+ attrs.put(cw, null, 0, -1, -1, out);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods: instruction resizing (used to handle GOTO_W and JSR_W)
+ // ------------------------------------------------------------------------
+
+ /**
+ * Resizes the designated instructions, while keeping jump offsets and
+ * instruction addresses consistent. This may require to resize other
+ * existing instructions, or even to introduce new instructions: for
+ * example, increasing the size of an instruction by 2 at the middle of a
+ * method can increases the offset of an IFEQ instruction from 32766 to
+ * 32768, in which case IFEQ 32766 must be replaced with IFNEQ 8 GOTO_W
+ * 32765. This, in turn, may require to increase the size of another jump
+ * instruction, and so on... All these operations are handled automatically
+ * by this method. <p> <i>This method must be called after all the method
+ * that is being built has been visited</i>. In particular, the
+ * {@link Label Label} objects used to construct the method are no longer
+ * valid after this method has been called.
+ *
+ * @param indexes current positions of the instructions to be resized. Each
+ * instruction must be designated by the index of its <i>last</i>
+ * byte, plus one (or, in other words, by the index of the <i>first</i>
+ * byte of the <i>next</i> instruction).
+ * @param sizes the number of bytes to be <i>added</i> to the above
+ * instructions. More precisely, for each i &lt; <tt>len</tt>,
+ * <tt>sizes</tt>[i] bytes will be added at the end of the
+ * instruction designated by <tt>indexes</tt>[i] or, if
+ * <tt>sizes</tt>[i] is negative, the <i>last</i> |<tt>sizes[i]</tt>|
+ * bytes of the instruction will be removed (the instruction size
+ * <i>must not</i> become negative or null). The gaps introduced by
+ * this method must be filled in "manually" in {@link #code code}
+ * method.
+ * @param len the number of instruction to be resized. Must be smaller than
+ * or equal to <tt>indexes</tt>.length and <tt>sizes</tt>.length.
+ * @return the <tt>indexes</tt> array, which now contains the new
+ * positions of the resized instructions (designated as above).
+ */
+ private int[] resizeInstructions(
+ final int[] indexes,
+ final int[] sizes,
+ final int len)
+ {
+ byte[] b = code.data; // bytecode of the method
+ int u, v, label; // indexes in b
+ int i, j; // loop indexes
+
+ /*
+ * 1st step: As explained above, resizing an instruction may require to
+ * resize another one, which may require to resize yet another one, and
+ * so on. The first step of the algorithm consists in finding all the
+ * instructions that need to be resized, without modifying the code.
+ * This is done by the following "fix point" algorithm:
+ *
+ * Parse the code to find the jump instructions whose offset will need
+ * more than 2 bytes to be stored (the future offset is computed from
+ * the current offset and from the number of bytes that will be inserted
+ * or removed between the source and target instructions). For each such
+ * instruction, adds an entry in (a copy of) the indexes and sizes
+ * arrays (if this has not already been done in a previous iteration!).
+ *
+ * If at least one entry has been added during the previous step, go
+ * back to the beginning, otherwise stop.
+ *
+ * In fact the real algorithm is complicated by the fact that the size
+ * of TABLESWITCH and LOOKUPSWITCH instructions depends on their
+ * position in the bytecode (because of padding). In order to ensure the
+ * convergence of the algorithm, the number of bytes to be added or
+ * removed from these instructions is over estimated during the previous
+ * loop, and computed exactly only after the loop is finished (this
+ * requires another pass to parse the bytecode of the method).
+ */
+ int[] allIndexes = new int[len]; // copy of indexes
+ int[] allSizes = new int[len]; // copy of sizes
+ boolean[] resize; // instructions to be resized
+ int newOffset; // future offset of a jump instruction
+
+ System.arraycopy(indexes, 0, allIndexes, 0, len);
+ System.arraycopy(sizes, 0, allSizes, 0, len);
+ resize = new boolean[code.length];
+
+ // 3 = loop again, 2 = loop ended, 1 = last pass, 0 = done
+ int state = 3;
+ do {
+ if (state == 3) {
+ state = 2;
+ }
+ u = 0;
+ while (u < b.length) {
+ int opcode = b[u] & 0xFF; // opcode of current instruction
+ int insert = 0; // bytes to be added after this instruction
+
+ switch (ClassWriter.TYPE[opcode]) {
+ case ClassWriter.NOARG_INSN:
+ case ClassWriter.IMPLVAR_INSN:
+ u += 1;
+ break;
+ case ClassWriter.LABEL_INSN:
+ if (opcode > 201) {
+ // converts temporary opcodes 202 to 217, 218 and
+ // 219 to IFEQ ... JSR (inclusive), IFNULL and
+ // IFNONNULL
+ opcode = opcode < 218 ? opcode - 49 : opcode - 20;
+ label = u + readUnsignedShort(b, u + 1);
+ } else {
+ label = u + readShort(b, u + 1);
+ }
+ newOffset = getNewOffset(allIndexes, allSizes, u, label);
+ if (newOffset < Short.MIN_VALUE
+ || newOffset > Short.MAX_VALUE)
+ {
+ if (!resize[u]) {
+ if (opcode == Opcodes.GOTO
+ || opcode == Opcodes.JSR)
+ {
+ // two additional bytes will be required to
+ // replace this GOTO or JSR instruction with
+ // a GOTO_W or a JSR_W
+ insert = 2;
+ } else {
+ // five additional bytes will be required to
+ // replace this IFxxx <l> instruction with
+ // IFNOTxxx <l'> GOTO_W <l>, where IFNOTxxx
+ // is the "opposite" opcode of IFxxx (i.e.,
+ // IFNE for IFEQ) and where <l'> designates
+ // the instruction just after the GOTO_W.
+ insert = 5;
+ }
+ resize[u] = true;
+ }
+ }
+ u += 3;
+ break;
+ case ClassWriter.LABELW_INSN:
+ u += 5;
+ break;
+ case ClassWriter.TABL_INSN:
+ if (state == 1) {
+ // true number of bytes to be added (or removed)
+ // from this instruction = (future number of padding
+ // bytes - current number of padding byte) -
+ // previously over estimated variation =
+ // = ((3 - newOffset%4) - (3 - u%4)) - u%4
+ // = (-newOffset%4 + u%4) - u%4
+ // = -(newOffset & 3)
+ newOffset = getNewOffset(allIndexes, allSizes, 0, u);
+ insert = -(newOffset & 3);
+ } else if (!resize[u]) {
+ // over estimation of the number of bytes to be
+ // added to this instruction = 3 - current number
+ // of padding bytes = 3 - (3 - u%4) = u%4 = u & 3
+ insert = u & 3;
+ resize[u] = true;
+ }
+ // skips instruction
+ u = u + 4 - (u & 3);
+ u += 4 * (readInt(b, u + 8) - readInt(b, u + 4) + 1) + 12;
+ break;
+ case ClassWriter.LOOK_INSN:
+ if (state == 1) {
+ // like TABL_INSN
+ newOffset = getNewOffset(allIndexes, allSizes, 0, u);
+ insert = -(newOffset & 3);
+ } else if (!resize[u]) {
+ // like TABL_INSN
+ insert = u & 3;
+ resize[u] = true;
+ }
+ // skips instruction
+ u = u + 4 - (u & 3);
+ u += 8 * readInt(b, u + 4) + 8;
+ break;
+ case ClassWriter.WIDE_INSN:
+ opcode = b[u + 1] & 0xFF;
+ if (opcode == Opcodes.IINC) {
+ u += 6;
+ } else {
+ u += 4;
+ }
+ break;
+ case ClassWriter.VAR_INSN:
+ case ClassWriter.SBYTE_INSN:
+ case ClassWriter.LDC_INSN:
+ u += 2;
+ break;
+ case ClassWriter.SHORT_INSN:
+ case ClassWriter.LDCW_INSN:
+ case ClassWriter.FIELDORMETH_INSN:
+ case ClassWriter.TYPE_INSN:
+ case ClassWriter.IINC_INSN:
+ u += 3;
+ break;
+ case ClassWriter.ITFMETH_INSN:
+ u += 5;
+ break;
+ // case ClassWriter.MANA_INSN:
+ default:
+ u += 4;
+ break;
+ }
+ if (insert != 0) {
+ // adds a new (u, insert) entry in the allIndexes and
+ // allSizes arrays
+ int[] newIndexes = new int[allIndexes.length + 1];
+ int[] newSizes = new int[allSizes.length + 1];
+ System.arraycopy(allIndexes,
+ 0,
+ newIndexes,
+ 0,
+ allIndexes.length);
+ System.arraycopy(allSizes, 0, newSizes, 0, allSizes.length);
+ newIndexes[allIndexes.length] = u;
+ newSizes[allSizes.length] = insert;
+ allIndexes = newIndexes;
+ allSizes = newSizes;
+ if (insert > 0) {
+ state = 3;
+ }
+ }
+ }
+ if (state < 3) {
+ --state;
+ }
+ } while (state != 0);
+
+ // 2nd step:
+ // copies the bytecode of the method into a new bytevector, updates the
+ // offsets, and inserts (or removes) bytes as requested.
+
+ ByteVector newCode = new ByteVector(code.length);
+
+ u = 0;
+ while (u < code.length) {
+ for (i = allIndexes.length - 1; i >= 0; --i) {
+ if (allIndexes[i] == u) {
+ if (i < len) {
+ if (sizes[i] > 0) {
+ newCode.putByteArray(null, 0, sizes[i]);
+ } else {
+ newCode.length += sizes[i];
+ }
+ indexes[i] = newCode.length;
+ }
+ }
+ }
+ int opcode = b[u] & 0xFF;
+ switch (ClassWriter.TYPE[opcode]) {
+ case ClassWriter.NOARG_INSN:
+ case ClassWriter.IMPLVAR_INSN:
+ newCode.putByte(opcode);
+ u += 1;
+ break;
+ case ClassWriter.LABEL_INSN:
+ if (opcode > 201) {
+ // changes temporary opcodes 202 to 217 (inclusive), 218
+ // and 219 to IFEQ ... JSR (inclusive), IFNULL and
+ // IFNONNULL
+ opcode = opcode < 218 ? opcode - 49 : opcode - 20;
+ label = u + readUnsignedShort(b, u + 1);
+ } else {
+ label = u + readShort(b, u + 1);
+ }
+ newOffset = getNewOffset(allIndexes, allSizes, u, label);
+ if (resize[u]) {
+ // replaces GOTO with GOTO_W, JSR with JSR_W and IFxxx
+ // <l> with IFNOTxxx <l'> GOTO_W <l>, where IFNOTxxx is
+ // the "opposite" opcode of IFxxx (i.e., IFNE for IFEQ)
+ // and where <l'> designates the instruction just after
+ // the GOTO_W.
+ if (opcode == Opcodes.GOTO) {
+ newCode.putByte(200); // GOTO_W
+ } else if (opcode == Opcodes.JSR) {
+ newCode.putByte(201); // JSR_W
+ } else {
+ newCode.putByte(opcode <= 166
+ ? ((opcode + 1) ^ 1) - 1
+ : opcode ^ 1);
+ newCode.putShort(8); // jump offset
+ newCode.putByte(200); // GOTO_W
+ // newOffset now computed from start of GOTO_W
+ newOffset -= 3;
+ }
+ newCode.putInt(newOffset);
+ } else {
+ newCode.putByte(opcode);
+ newCode.putShort(newOffset);
+ }
+ u += 3;
+ break;
+ case ClassWriter.LABELW_INSN:
+ label = u + readInt(b, u + 1);
+ newOffset = getNewOffset(allIndexes, allSizes, u, label);
+ newCode.putByte(opcode);
+ newCode.putInt(newOffset);
+ u += 5;
+ break;
+ case ClassWriter.TABL_INSN:
+ // skips 0 to 3 padding bytes
+ v = u;
+ u = u + 4 - (v & 3);
+ // reads and copies instruction
+ newCode.putByte(Opcodes.TABLESWITCH);
+ while (newCode.length % 4 != 0) {
+ newCode.putByte(0);
+ }
+ label = v + readInt(b, u);
+ u += 4;
+ newOffset = getNewOffset(allIndexes, allSizes, v, label);
+ newCode.putInt(newOffset);
+ j = readInt(b, u);
+ u += 4;
+ newCode.putInt(j);
+ j = readInt(b, u) - j + 1;
+ u += 4;
+ newCode.putInt(readInt(b, u - 4));
+ for (; j > 0; --j) {
+ label = v + readInt(b, u);
+ u += 4;
+ newOffset = getNewOffset(allIndexes, allSizes, v, label);
+ newCode.putInt(newOffset);
+ }
+ break;
+ case ClassWriter.LOOK_INSN:
+ // skips 0 to 3 padding bytes
+ v = u;
+ u = u + 4 - (v & 3);
+ // reads and copies instruction
+ newCode.putByte(Opcodes.LOOKUPSWITCH);
+ while (newCode.length % 4 != 0) {
+ newCode.putByte(0);
+ }
+ label = v + readInt(b, u);
+ u += 4;
+ newOffset = getNewOffset(allIndexes, allSizes, v, label);
+ newCode.putInt(newOffset);
+ j = readInt(b, u);
+ u += 4;
+ newCode.putInt(j);
+ for (; j > 0; --j) {
+ newCode.putInt(readInt(b, u));
+ u += 4;
+ label = v + readInt(b, u);
+ u += 4;
+ newOffset = getNewOffset(allIndexes, allSizes, v, label);
+ newCode.putInt(newOffset);
+ }
+ break;
+ case ClassWriter.WIDE_INSN:
+ opcode = b[u + 1] & 0xFF;
+ if (opcode == Opcodes.IINC) {
+ newCode.putByteArray(b, u, 6);
+ u += 6;
+ } else {
+ newCode.putByteArray(b, u, 4);
+ u += 4;
+ }
+ break;
+ case ClassWriter.VAR_INSN:
+ case ClassWriter.SBYTE_INSN:
+ case ClassWriter.LDC_INSN:
+ newCode.putByteArray(b, u, 2);
+ u += 2;
+ break;
+ case ClassWriter.SHORT_INSN:
+ case ClassWriter.LDCW_INSN:
+ case ClassWriter.FIELDORMETH_INSN:
+ case ClassWriter.TYPE_INSN:
+ case ClassWriter.IINC_INSN:
+ newCode.putByteArray(b, u, 3);
+ u += 3;
+ break;
+ case ClassWriter.ITFMETH_INSN:
+ newCode.putByteArray(b, u, 5);
+ u += 5;
+ break;
+ // case MANA_INSN:
+ default:
+ newCode.putByteArray(b, u, 4);
+ u += 4;
+ break;
+ }
+ }
+
+ // updates the exception handler block labels
+ Handler h = catchTable;
+ while (h != null) {
+ getNewOffset(allIndexes, allSizes, h.start);
+ getNewOffset(allIndexes, allSizes, h.end);
+ getNewOffset(allIndexes, allSizes, h.handler);
+ h = h.next;
+ }
+ for (i = 0; i < 2; ++i) {
+ ByteVector bv = i == 0 ? localVar : localVarType;
+ if (bv != null) {
+ b = bv.data;
+ u = 0;
+ while (u < bv.length) {
+ label = readUnsignedShort(b, u);
+ newOffset = getNewOffset(allIndexes, allSizes, 0, label);
+ writeShort(b, u, newOffset);
+ label += readUnsignedShort(b, u + 2);
+ newOffset = getNewOffset(allIndexes, allSizes, 0, label)
+ - newOffset;
+ writeShort(b, u + 2, newOffset);
+ u += 10;
+ }
+ }
+ }
+ if (lineNumber != null) {
+ b = lineNumber.data;
+ u = 0;
+ while (u < lineNumber.length) {
+ writeShort(b, u, getNewOffset(allIndexes,
+ allSizes,
+ 0,
+ readUnsignedShort(b, u)));
+ u += 4;
+ }
+ }
+ // updates the labels of the other attributes
+ while (cattrs != null) {
+ Label[] labels = cattrs.getLabels();
+ if (labels != null) {
+ for (i = labels.length - 1; i >= 0; --i) {
+ if (!labels[i].resized) {
+ labels[i].position = getNewOffset(allIndexes,
+ allSizes,
+ 0,
+ labels[i].position);
+ labels[i].resized = true;
+ }
+ }
+ }
+ }
+
+ // replaces old bytecodes with new ones
+ code = newCode;
+
+ // returns the positions of the resized instructions
+ return indexes;
+ }
+
+ /**
+ * Reads an unsigned short value in the given byte array.
+ *
+ * @param b a byte array.
+ * @param index the start index of the value to be read.
+ * @return the read value.
+ */
+ static int readUnsignedShort(final byte[] b, final int index) {
+ return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF);
+ }
+
+ /**
+ * Reads a signed short value in the given byte array.
+ *
+ * @param b a byte array.
+ * @param index the start index of the value to be read.
+ * @return the read value.
+ */
+ static short readShort(final byte[] b, final int index) {
+ return (short) (((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF));
+ }
+
+ /**
+ * Reads a signed int value in the given byte array.
+ *
+ * @param b a byte array.
+ * @param index the start index of the value to be read.
+ * @return the read value.
+ */
+ static int readInt(final byte[] b, final int index) {
+ return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16)
+ | ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);
+ }
+
+ /**
+ * Writes a short value in the given byte array.
+ *
+ * @param b a byte array.
+ * @param index where the first byte of the short value must be written.
+ * @param s the value to be written in the given byte array.
+ */
+ static void writeShort(final byte[] b, final int index, final int s) {
+ b[index] = (byte) (s >>> 8);
+ b[index + 1] = (byte) s;
+ }
+
+ /**
+ * Computes the future value of a bytecode offset. <p> Note: it is possible
+ * to have several entries for the same instruction in the <tt>indexes</tt>
+ * and <tt>sizes</tt>: two entries (index=a,size=b) and (index=a,size=b')
+ * are equivalent to a single entry (index=a,size=b+b').
+ *
+ * @param indexes current positions of the instructions to be resized. Each
+ * instruction must be designated by the index of its <i>last</i>
+ * byte, plus one (or, in other words, by the index of the <i>first</i>
+ * byte of the <i>next</i> instruction).
+ * @param sizes the number of bytes to be <i>added</i> to the above
+ * instructions. More precisely, for each i < <tt>len</tt>,
+ * <tt>sizes</tt>[i] bytes will be added at the end of the
+ * instruction designated by <tt>indexes</tt>[i] or, if
+ * <tt>sizes</tt>[i] is negative, the <i>last</i> |<tt>sizes[i]</tt>|
+ * bytes of the instruction will be removed (the instruction size
+ * <i>must not</i> become negative or null).
+ * @param begin index of the first byte of the source instruction.
+ * @param end index of the first byte of the target instruction.
+ * @return the future value of the given bytecode offset.
+ */
+ static int getNewOffset(
+ final int[] indexes,
+ final int[] sizes,
+ final int begin,
+ final int end)
+ {
+ int offset = end - begin;
+ for (int i = 0; i < indexes.length; ++i) {
+ if (begin < indexes[i] && indexes[i] <= end) {
+ // forward jump
+ offset += sizes[i];
+ } else if (end < indexes[i] && indexes[i] <= begin) {
+ // backward jump
+ offset -= sizes[i];
+ }
+ }
+ return offset;
+ }
+
+ /**
+ * Updates the offset of the given label.
+ *
+ * @param indexes current positions of the instructions to be resized. Each
+ * instruction must be designated by the index of its <i>last</i>
+ * byte, plus one (or, in other words, by the index of the <i>first</i>
+ * byte of the <i>next</i> instruction).
+ * @param sizes the number of bytes to be <i>added</i> to the above
+ * instructions. More precisely, for each i < <tt>len</tt>,
+ * <tt>sizes</tt>[i] bytes will be added at the end of the
+ * instruction designated by <tt>indexes</tt>[i] or, if
+ * <tt>sizes</tt>[i] is negative, the <i>last</i> |<tt>sizes[i]</tt>|
+ * bytes of the instruction will be removed (the instruction size
+ * <i>must not</i> become negative or null).
+ * @param label the label whose offset must be updated.
+ */
+ static void getNewOffset(
+ final int[] indexes,
+ final int[] sizes,
+ final Label label)
+ {
+ if (!label.resized) {
+ label.position = getNewOffset(indexes, sizes, 0, label.position);
+ label.resized = true;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/Opcodes.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/Opcodes.java
new file mode 100644
index 000000000..2728d96b5
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/Opcodes.java
@@ -0,0 +1,295 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+/**
+ * Defines the JVM opcodes, access flags and array type codes. This interface
+ * does not define all the JVM opcodes because some opcodes are automatically
+ * handled. For example, the xLOAD and xSTORE opcodes are automatically replaced
+ * by xLOAD_n and xSTORE_n opcodes when possible. The xLOAD_n and xSTORE_n
+ * opcodes are therefore not defined in this interface. Likewise for LDC,
+ * automatically replaced by LDC_W or LDC2_W when necessary, WIDE, GOTO_W and
+ * JSR_W.
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+public interface Opcodes {
+
+ // versions
+
+ int V1_1 = 3 << 16 | 45;
+ int V1_2 = 0 << 16 | 46;
+ int V1_3 = 0 << 16 | 47;
+ int V1_4 = 0 << 16 | 48;
+ int V1_5 = 0 << 16 | 49;
+ int V1_6 = 0 << 16 | 50;
+
+ // access flags
+
+ int ACC_PUBLIC = 0x0001; // class, field, method
+ int ACC_PRIVATE = 0x0002; // class, field, method
+ int ACC_PROTECTED = 0x0004; // class, field, method
+ int ACC_STATIC = 0x0008; // field, method
+ int ACC_FINAL = 0x0010; // class, field, method
+ int ACC_SUPER = 0x0020; // class
+ int ACC_SYNCHRONIZED = 0x0020; // method
+ int ACC_VOLATILE = 0x0040; // field
+ int ACC_BRIDGE = 0x0040; // method
+ int ACC_VARARGS = 0x0080; // method
+ int ACC_TRANSIENT = 0x0080; // field
+ int ACC_NATIVE = 0x0100; // method
+ int ACC_INTERFACE = 0x0200; // class
+ int ACC_ABSTRACT = 0x0400; // class, method
+ int ACC_STRICT = 0x0800; // method
+ int ACC_SYNTHETIC = 0x1000; // class, field, method
+ int ACC_ANNOTATION = 0x2000; // class
+ int ACC_ENUM = 0x4000; // class(?) field inner
+
+ // ASM specific pseudo access flags
+
+ int ACC_DEPRECATED = 131072; // class, field, method
+
+ // types for NEWARRAY
+
+ int T_BOOLEAN = 4;
+ int T_CHAR = 5;
+ int T_FLOAT = 6;
+ int T_DOUBLE = 7;
+ int T_BYTE = 8;
+ int T_SHORT = 9;
+ int T_INT = 10;
+ int T_LONG = 11;
+
+ // opcodes // visit method (- = idem)
+
+ int NOP = 0; // visitInsn
+ int ACONST_NULL = 1; // -
+ int ICONST_M1 = 2; // -
+ int ICONST_0 = 3; // -
+ int ICONST_1 = 4; // -
+ int ICONST_2 = 5; // -
+ int ICONST_3 = 6; // -
+ int ICONST_4 = 7; // -
+ int ICONST_5 = 8; // -
+ int LCONST_0 = 9; // -
+ int LCONST_1 = 10; // -
+ int FCONST_0 = 11; // -
+ int FCONST_1 = 12; // -
+ int FCONST_2 = 13; // -
+ int DCONST_0 = 14; // -
+ int DCONST_1 = 15; // -
+ int BIPUSH = 16; // visitIntInsn
+ int SIPUSH = 17; // -
+ int LDC = 18; // visitLdcInsn
+ // int LDC_W = 19; // -
+ // int LDC2_W = 20; // -
+ int ILOAD = 21; // visitVarInsn
+ int LLOAD = 22; // -
+ int FLOAD = 23; // -
+ int DLOAD = 24; // -
+ int ALOAD = 25; // -
+ // int ILOAD_0 = 26; // -
+ // int ILOAD_1 = 27; // -
+ // int ILOAD_2 = 28; // -
+ // int ILOAD_3 = 29; // -
+ // int LLOAD_0 = 30; // -
+ // int LLOAD_1 = 31; // -
+ // int LLOAD_2 = 32; // -
+ // int LLOAD_3 = 33; // -
+ // int FLOAD_0 = 34; // -
+ // int FLOAD_1 = 35; // -
+ // int FLOAD_2 = 36; // -
+ // int FLOAD_3 = 37; // -
+ // int DLOAD_0 = 38; // -
+ // int DLOAD_1 = 39; // -
+ // int DLOAD_2 = 40; // -
+ // int DLOAD_3 = 41; // -
+ // int ALOAD_0 = 42; // -
+ // int ALOAD_1 = 43; // -
+ // int ALOAD_2 = 44; // -
+ // int ALOAD_3 = 45; // -
+ int IALOAD = 46; // visitInsn
+ int LALOAD = 47; // -
+ int FALOAD = 48; // -
+ int DALOAD = 49; // -
+ int AALOAD = 50; // -
+ int BALOAD = 51; // -
+ int CALOAD = 52; // -
+ int SALOAD = 53; // -
+ int ISTORE = 54; // visitVarInsn
+ int LSTORE = 55; // -
+ int FSTORE = 56; // -
+ int DSTORE = 57; // -
+ int ASTORE = 58; // -
+ // int ISTORE_0 = 59; // -
+ // int ISTORE_1 = 60; // -
+ // int ISTORE_2 = 61; // -
+ // int ISTORE_3 = 62; // -
+ // int LSTORE_0 = 63; // -
+ // int LSTORE_1 = 64; // -
+ // int LSTORE_2 = 65; // -
+ // int LSTORE_3 = 66; // -
+ // int FSTORE_0 = 67; // -
+ // int FSTORE_1 = 68; // -
+ // int FSTORE_2 = 69; // -
+ // int FSTORE_3 = 70; // -
+ // int DSTORE_0 = 71; // -
+ // int DSTORE_1 = 72; // -
+ // int DSTORE_2 = 73; // -
+ // int DSTORE_3 = 74; // -
+ // int ASTORE_0 = 75; // -
+ // int ASTORE_1 = 76; // -
+ // int ASTORE_2 = 77; // -
+ // int ASTORE_3 = 78; // -
+ int IASTORE = 79; // visitInsn
+ int LASTORE = 80; // -
+ int FASTORE = 81; // -
+ int DASTORE = 82; // -
+ int AASTORE = 83; // -
+ int BASTORE = 84; // -
+ int CASTORE = 85; // -
+ int SASTORE = 86; // -
+ int POP = 87; // -
+ int POP2 = 88; // -
+ int DUP = 89; // -
+ int DUP_X1 = 90; // -
+ int DUP_X2 = 91; // -
+ int DUP2 = 92; // -
+ int DUP2_X1 = 93; // -
+ int DUP2_X2 = 94; // -
+ int SWAP = 95; // -
+ int IADD = 96; // -
+ int LADD = 97; // -
+ int FADD = 98; // -
+ int DADD = 99; // -
+ int ISUB = 100; // -
+ int LSUB = 101; // -
+ int FSUB = 102; // -
+ int DSUB = 103; // -
+ int IMUL = 104; // -
+ int LMUL = 105; // -
+ int FMUL = 106; // -
+ int DMUL = 107; // -
+ int IDIV = 108; // -
+ int LDIV = 109; // -
+ int FDIV = 110; // -
+ int DDIV = 111; // -
+ int IREM = 112; // -
+ int LREM = 113; // -
+ int FREM = 114; // -
+ int DREM = 115; // -
+ int INEG = 116; // -
+ int LNEG = 117; // -
+ int FNEG = 118; // -
+ int DNEG = 119; // -
+ int ISHL = 120; // -
+ int LSHL = 121; // -
+ int ISHR = 122; // -
+ int LSHR = 123; // -
+ int IUSHR = 124; // -
+ int LUSHR = 125; // -
+ int IAND = 126; // -
+ int LAND = 127; // -
+ int IOR = 128; // -
+ int LOR = 129; // -
+ int IXOR = 130; // -
+ int LXOR = 131; // -
+ int IINC = 132; // visitIincInsn
+ int I2L = 133; // visitInsn
+ int I2F = 134; // -
+ int I2D = 135; // -
+ int L2I = 136; // -
+ int L2F = 137; // -
+ int L2D = 138; // -
+ int F2I = 139; // -
+ int F2L = 140; // -
+ int F2D = 141; // -
+ int D2I = 142; // -
+ int D2L = 143; // -
+ int D2F = 144; // -
+ int I2B = 145; // -
+ int I2C = 146; // -
+ int I2S = 147; // -
+ int LCMP = 148; // -
+ int FCMPL = 149; // -
+ int FCMPG = 150; // -
+ int DCMPL = 151; // -
+ int DCMPG = 152; // -
+ int IFEQ = 153; // visitJumpInsn
+ int IFNE = 154; // -
+ int IFLT = 155; // -
+ int IFGE = 156; // -
+ int IFGT = 157; // -
+ int IFLE = 158; // -
+ int IF_ICMPEQ = 159; // -
+ int IF_ICMPNE = 160; // -
+ int IF_ICMPLT = 161; // -
+ int IF_ICMPGE = 162; // -
+ int IF_ICMPGT = 163; // -
+ int IF_ICMPLE = 164; // -
+ int IF_ACMPEQ = 165; // -
+ int IF_ACMPNE = 166; // -
+ int GOTO = 167; // -
+ int JSR = 168; // -
+ int RET = 169; // visitVarInsn
+ int TABLESWITCH = 170; // visiTableSwitchInsn
+ int LOOKUPSWITCH = 171; // visitLookupSwitch
+ int IRETURN = 172; // visitInsn
+ int LRETURN = 173; // -
+ int FRETURN = 174; // -
+ int DRETURN = 175; // -
+ int ARETURN = 176; // -
+ int RETURN = 177; // -
+ int GETSTATIC = 178; // visitFieldInsn
+ int PUTSTATIC = 179; // -
+ int GETFIELD = 180; // -
+ int PUTFIELD = 181; // -
+ int INVOKEVIRTUAL = 182; // visitMethodInsn
+ int INVOKESPECIAL = 183; // -
+ int INVOKESTATIC = 184; // -
+ int INVOKEINTERFACE = 185; // -
+ // int UNUSED = 186; // NOT VISITED
+ int NEW = 187; // visitTypeInsn
+ int NEWARRAY = 188; // visitIntInsn
+ int ANEWARRAY = 189; // visitTypeInsn
+ int ARRAYLENGTH = 190; // visitInsn
+ int ATHROW = 191; // -
+ int CHECKCAST = 192; // visitTypeInsn
+ int INSTANCEOF = 193; // -
+ int MONITORENTER = 194; // visitInsn
+ int MONITOREXIT = 195; // -
+ // int WIDE = 196; // NOT VISITED
+ int MULTIANEWARRAY = 197; // visitMultiANewArrayInsn
+ int IFNULL = 198; // visitJumpInsn
+ int IFNONNULL = 199; // -
+ // int GOTO_W = 200; // -
+ // int JSR_W = 201; // -
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/Type.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/Type.java
new file mode 100644
index 000000000..ae314e8cd
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/Type.java
@@ -0,0 +1,760 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm;
+
+import java.lang.reflect.Method;
+
+/**
+ * A Java type. This class can be used to make it easier to manipulate type and
+ * method descriptors.
+ *
+ * @author Eric Bruneton
+ * @author Chris Nokleberg
+ */
+public class Type {
+
+ /**
+ * The sort of the <tt>void</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int VOID = 0;
+
+ /**
+ * The sort of the <tt>boolean</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int BOOLEAN = 1;
+
+ /**
+ * The sort of the <tt>char</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int CHAR = 2;
+
+ /**
+ * The sort of the <tt>byte</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int BYTE = 3;
+
+ /**
+ * The sort of the <tt>short</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int SHORT = 4;
+
+ /**
+ * The sort of the <tt>int</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int INT = 5;
+
+ /**
+ * The sort of the <tt>float</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int FLOAT = 6;
+
+ /**
+ * The sort of the <tt>long</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int LONG = 7;
+
+ /**
+ * The sort of the <tt>double</tt> type. See {@link #getSort getSort}.
+ */
+ public final static int DOUBLE = 8;
+
+ /**
+ * The sort of array reference types. See {@link #getSort getSort}.
+ */
+ public final static int ARRAY = 9;
+
+ /**
+ * The sort of object reference type. See {@link #getSort getSort}.
+ */
+ public final static int OBJECT = 10;
+
+ /**
+ * The <tt>void</tt> type.
+ */
+ public final static Type VOID_TYPE = new Type(VOID);
+
+ /**
+ * The <tt>boolean</tt> type.
+ */
+ public final static Type BOOLEAN_TYPE = new Type(BOOLEAN);
+
+ /**
+ * The <tt>char</tt> type.
+ */
+ public final static Type CHAR_TYPE = new Type(CHAR);
+
+ /**
+ * The <tt>byte</tt> type.
+ */
+ public final static Type BYTE_TYPE = new Type(BYTE);
+
+ /**
+ * The <tt>short</tt> type.
+ */
+ public final static Type SHORT_TYPE = new Type(SHORT);
+
+ /**
+ * The <tt>int</tt> type.
+ */
+ public final static Type INT_TYPE = new Type(INT);
+
+ /**
+ * The <tt>float</tt> type.
+ */
+ public final static Type FLOAT_TYPE = new Type(FLOAT);
+
+ /**
+ * The <tt>long</tt> type.
+ */
+ public final static Type LONG_TYPE = new Type(LONG);
+
+ /**
+ * The <tt>double</tt> type.
+ */
+ public final static Type DOUBLE_TYPE = new Type(DOUBLE);
+
+ // ------------------------------------------------------------------------
+ // Fields
+ // ------------------------------------------------------------------------
+
+ /**
+ * The sort of this Java type.
+ */
+ private final int sort;
+
+ /**
+ * A buffer containing the descriptor of this Java type. This field is only
+ * used for reference types.
+ */
+ private char[] buf;
+
+ /**
+ * The offset of the descriptor of this Java type in {@link #buf buf}. This
+ * field is only used for reference types.
+ */
+ private int off;
+
+ /**
+ * The length of the descriptor of this Java type.
+ */
+ private int len;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs a primitive type.
+ *
+ * @param sort the sort of the primitive type to be constructed.
+ */
+ private Type(final int sort) {
+ this.sort = sort;
+ this.len = 1;
+ }
+
+ /**
+ * Constructs a reference type.
+ *
+ * @param sort the sort of the reference type to be constructed.
+ * @param buf a buffer containing the descriptor of the previous type.
+ * @param off the offset of this descriptor in the previous buffer.
+ * @param len the length of this descriptor.
+ */
+ private Type(final int sort, final char[] buf, final int off, final int len)
+ {
+ this.sort = sort;
+ this.buf = buf;
+ this.off = off;
+ this.len = len;
+ }
+
+ /**
+ * Returns the Java type corresponding to the given type descriptor.
+ *
+ * @param typeDescriptor a type descriptor.
+ * @return the Java type corresponding to the given type descriptor.
+ */
+ public static Type getType(final String typeDescriptor) {
+ return getType(typeDescriptor.toCharArray(), 0);
+ }
+
+ /**
+ * Returns the Java type corresponding to the given class.
+ *
+ * @param c a class.
+ * @return the Java type corresponding to the given class.
+ */
+ public static Type getType(final Class c) {
+ if (c.isPrimitive()) {
+ if (c == Integer.TYPE) {
+ return INT_TYPE;
+ } else if (c == Void.TYPE) {
+ return VOID_TYPE;
+ } else if (c == Boolean.TYPE) {
+ return BOOLEAN_TYPE;
+ } else if (c == Byte.TYPE) {
+ return BYTE_TYPE;
+ } else if (c == Character.TYPE) {
+ return CHAR_TYPE;
+ } else if (c == Short.TYPE) {
+ return SHORT_TYPE;
+ } else if (c == Double.TYPE) {
+ return DOUBLE_TYPE;
+ } else if (c == Float.TYPE) {
+ return FLOAT_TYPE;
+ } else /* if (c == Long.TYPE) */{
+ return LONG_TYPE;
+ }
+ } else {
+ return getType(getDescriptor(c));
+ }
+ }
+
+ /**
+ * Returns the Java types corresponding to the argument types of the given
+ * method descriptor.
+ *
+ * @param methodDescriptor a method descriptor.
+ * @return the Java types corresponding to the argument types of the given
+ * method descriptor.
+ */
+ public static Type[] getArgumentTypes(final String methodDescriptor) {
+ char[] buf = methodDescriptor.toCharArray();
+ int off = 1;
+ int size = 0;
+ while (true) {
+ char car = buf[off++];
+ if (car == ')') {
+ break;
+ } else if (car == 'L') {
+ while (buf[off++] != ';') {
+ }
+ ++size;
+ } else if (car != '[') {
+ ++size;
+ }
+ }
+ Type[] args = new Type[size];
+ off = 1;
+ size = 0;
+ while (buf[off] != ')') {
+ args[size] = getType(buf, off);
+ off += args[size].len;
+ size += 1;
+ }
+ return args;
+ }
+
+ /**
+ * Returns the Java types corresponding to the argument types of the given
+ * method.
+ *
+ * @param method a method.
+ * @return the Java types corresponding to the argument types of the given
+ * method.
+ */
+ public static Type[] getArgumentTypes(final Method method) {
+ Class[] classes = method.getParameterTypes();
+ Type[] types = new Type[classes.length];
+ for (int i = classes.length - 1; i >= 0; --i) {
+ types[i] = getType(classes[i]);
+ }
+ return types;
+ }
+
+ /**
+ * Returns the Java type corresponding to the return type of the given
+ * method descriptor.
+ *
+ * @param methodDescriptor a method descriptor.
+ * @return the Java type corresponding to the return type of the given
+ * method descriptor.
+ */
+ public static Type getReturnType(final String methodDescriptor) {
+ char[] buf = methodDescriptor.toCharArray();
+ return getType(buf, methodDescriptor.indexOf(')') + 1);
+ }
+
+ /**
+ * Returns the Java type corresponding to the return type of the given
+ * method.
+ *
+ * @param method a method.
+ * @return the Java type corresponding to the return type of the given
+ * method.
+ */
+ public static Type getReturnType(final Method method) {
+ return getType(method.getReturnType());
+ }
+
+ /**
+ * Returns the Java type corresponding to the given type descriptor.
+ *
+ * @param buf a buffer containing a type descriptor.
+ * @param off the offset of this descriptor in the previous buffer.
+ * @return the Java type corresponding to the given type descriptor.
+ */
+ private static Type getType(final char[] buf, final int off) {
+ int len;
+ switch (buf[off]) {
+ case 'V':
+ return VOID_TYPE;
+ case 'Z':
+ return BOOLEAN_TYPE;
+ case 'C':
+ return CHAR_TYPE;
+ case 'B':
+ return BYTE_TYPE;
+ case 'S':
+ return SHORT_TYPE;
+ case 'I':
+ return INT_TYPE;
+ case 'F':
+ return FLOAT_TYPE;
+ case 'J':
+ return LONG_TYPE;
+ case 'D':
+ return DOUBLE_TYPE;
+ case '[':
+ len = 1;
+ while (buf[off + len] == '[') {
+ ++len;
+ }
+ if (buf[off + len] == 'L') {
+ ++len;
+ while (buf[off + len] != ';') {
+ ++len;
+ }
+ }
+ return new Type(ARRAY, buf, off, len + 1);
+ // case 'L':
+ default:
+ len = 1;
+ while (buf[off + len] != ';') {
+ ++len;
+ }
+ return new Type(OBJECT, buf, off, len + 1);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the sort of this Java type.
+ *
+ * @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN},
+ * {@link #CHAR CHAR}, {@link #BYTE BYTE}, {@link #SHORT SHORT},
+ * {@link #INT INT}, {@link #FLOAT FLOAT}, {@link #LONG LONG},
+ * {@link #DOUBLE DOUBLE}, {@link #ARRAY ARRAY} or
+ * {@link #OBJECT OBJECT}.
+ */
+ public int getSort() {
+ return sort;
+ }
+
+ /**
+ * Returns the number of dimensions of this array type. This method should
+ * only be used for an array type.
+ *
+ * @return the number of dimensions of this array type.
+ */
+ public int getDimensions() {
+ int i = 1;
+ while (buf[off + i] == '[') {
+ ++i;
+ }
+ return i;
+ }
+
+ /**
+ * Returns the type of the elements of this array type. This method should
+ * only be used for an array type.
+ *
+ * @return Returns the type of the elements of this array type.
+ */
+ public Type getElementType() {
+ return getType(buf, off + getDimensions());
+ }
+
+ /**
+ * Returns the name of the class corresponding to this type.
+ *
+ * @return the fully qualified name of the class corresponding to this type.
+ */
+ public String getClassName() {
+ switch (sort) {
+ case VOID:
+ return "void";
+ case BOOLEAN:
+ return "boolean";
+ case CHAR:
+ return "char";
+ case BYTE:
+ return "byte";
+ case SHORT:
+ return "short";
+ case INT:
+ return "int";
+ case FLOAT:
+ return "float";
+ case LONG:
+ return "long";
+ case DOUBLE:
+ return "double";
+ case ARRAY:
+ StringBuffer b = new StringBuffer(getElementType().getClassName());
+ for (int i = getDimensions(); i > 0; --i) {
+ b.append("[]");
+ }
+ return b.toString();
+ // case OBJECT:
+ default:
+ return new String(buf, off + 1, len - 2).replace('/', '.');
+ }
+ }
+
+ /**
+ * Returns the internal name of the class corresponding to this object type.
+ * The internal name of a class is its fully qualified name, where '.' are
+ * replaced by '/'. This method should only be used for an object type.
+ *
+ * @return the internal name of the class corresponding to this object type.
+ */
+ public String getInternalName() {
+ return new String(buf, off + 1, len - 2);
+ }
+
+ // ------------------------------------------------------------------------
+ // Conversion to type descriptors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the descriptor corresponding to this Java type.
+ *
+ * @return the descriptor corresponding to this Java type.
+ */
+ public String getDescriptor() {
+ StringBuffer buf = new StringBuffer();
+ getDescriptor(buf);
+ return buf.toString();
+ }
+
+ /**
+ * Returns the descriptor corresponding to the given argument and return
+ * types.
+ *
+ * @param returnType the return type of the method.
+ * @param argumentTypes the argument types of the method.
+ * @return the descriptor corresponding to the given argument and return
+ * types.
+ */
+ public static String getMethodDescriptor(
+ final Type returnType,
+ final Type[] argumentTypes)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append('(');
+ for (int i = 0; i < argumentTypes.length; ++i) {
+ argumentTypes[i].getDescriptor(buf);
+ }
+ buf.append(')');
+ returnType.getDescriptor(buf);
+ return buf.toString();
+ }
+
+ /**
+ * Appends the descriptor corresponding to this Java type to the given
+ * string buffer.
+ *
+ * @param buf the string buffer to which the descriptor must be appended.
+ */
+ private void getDescriptor(final StringBuffer buf) {
+ switch (sort) {
+ case VOID:
+ buf.append('V');
+ return;
+ case BOOLEAN:
+ buf.append('Z');
+ return;
+ case CHAR:
+ buf.append('C');
+ return;
+ case BYTE:
+ buf.append('B');
+ return;
+ case SHORT:
+ buf.append('S');
+ return;
+ case INT:
+ buf.append('I');
+ return;
+ case FLOAT:
+ buf.append('F');
+ return;
+ case LONG:
+ buf.append('J');
+ return;
+ case DOUBLE:
+ buf.append('D');
+ return;
+ // case ARRAY:
+ // case OBJECT:
+ default:
+ buf.append(this.buf, off, len);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Direct conversion from classes to type descriptors,
+ // without intermediate Type objects
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the internal name of the given class. The internal name of a
+ * class is its fully qualified name, where '.' are replaced by '/'.
+ *
+ * @param c an object class.
+ * @return the internal name of the given class.
+ */
+ public static String getInternalName(final Class c) {
+ return c.getName().replace('.', '/');
+ }
+
+ /**
+ * Returns the descriptor corresponding to the given Java type.
+ *
+ * @param c an object class, a primitive class or an array class.
+ * @return the descriptor corresponding to the given class.
+ */
+ public static String getDescriptor(final Class c) {
+ StringBuffer buf = new StringBuffer();
+ getDescriptor(buf, c);
+ return buf.toString();
+ }
+
+ /**
+ * Returns the descriptor corresponding to the given method.
+ *
+ * @param m a {@link Method Method} object.
+ * @return the descriptor of the given method.
+ */
+ public static String getMethodDescriptor(final Method m) {
+ Class[] parameters = m.getParameterTypes();
+ StringBuffer buf = new StringBuffer();
+ buf.append('(');
+ for (int i = 0; i < parameters.length; ++i) {
+ getDescriptor(buf, parameters[i]);
+ }
+ buf.append(')');
+ getDescriptor(buf, m.getReturnType());
+ return buf.toString();
+ }
+
+ /**
+ * Appends the descriptor of the given class to the given string buffer.
+ *
+ * @param buf the string buffer to which the descriptor must be appended.
+ * @param c the class whose descriptor must be computed.
+ */
+ private static void getDescriptor(final StringBuffer buf, final Class c) {
+ Class d = c;
+ while (true) {
+ if (d.isPrimitive()) {
+ char car;
+ if (d == Integer.TYPE) {
+ car = 'I';
+ } else if (d == Void.TYPE) {
+ car = 'V';
+ } else if (d == Boolean.TYPE) {
+ car = 'Z';
+ } else if (d == Byte.TYPE) {
+ car = 'B';
+ } else if (d == Character.TYPE) {
+ car = 'C';
+ } else if (d == Short.TYPE) {
+ car = 'S';
+ } else if (d == Double.TYPE) {
+ car = 'D';
+ } else if (d == Float.TYPE) {
+ car = 'F';
+ } else /* if (d == Long.TYPE) */{
+ car = 'J';
+ }
+ buf.append(car);
+ return;
+ } else if (d.isArray()) {
+ buf.append('[');
+ d = d.getComponentType();
+ } else {
+ buf.append('L');
+ String name = d.getName();
+ int len = name.length();
+ for (int i = 0; i < len; ++i) {
+ char car = name.charAt(i);
+ buf.append(car == '.' ? '/' : car);
+ }
+ buf.append(';');
+ return;
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Corresponding size and opcodes
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the size of values of this type.
+ *
+ * @return the size of values of this type, i.e., 2 for <tt>long</tt> and
+ * <tt>double</tt>, and 1 otherwise.
+ */
+ public int getSize() {
+ return (sort == LONG || sort == DOUBLE ? 2 : 1);
+ }
+
+ /**
+ * Returns a JVM instruction opcode adapted to this Java type.
+ *
+ * @param opcode a JVM instruction opcode. This opcode must be one of ILOAD,
+ * ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG, ISHL,
+ * ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.
+ * @return an opcode that is similar to the given opcode, but adapted to
+ * this Java type. For example, if this type is <tt>float</tt> and
+ * <tt>opcode</tt> is IRETURN, this method returns FRETURN.
+ */
+ public int getOpcode(final int opcode) {
+ if (opcode == Opcodes.IALOAD || opcode == Opcodes.IASTORE) {
+ switch (sort) {
+ case BOOLEAN:
+ case BYTE:
+ return opcode + 5;
+ case CHAR:
+ return opcode + 6;
+ case SHORT:
+ return opcode + 7;
+ case INT:
+ return opcode;
+ case FLOAT:
+ return opcode + 2;
+ case LONG:
+ return opcode + 1;
+ case DOUBLE:
+ return opcode + 3;
+ // case ARRAY:
+ // case OBJECT:
+ default:
+ return opcode + 4;
+ }
+ } else {
+ switch (sort) {
+ case VOID:
+ return opcode + 5;
+ case BOOLEAN:
+ case CHAR:
+ case BYTE:
+ case SHORT:
+ case INT:
+ return opcode;
+ case FLOAT:
+ return opcode + 2;
+ case LONG:
+ return opcode + 1;
+ case DOUBLE:
+ return opcode + 3;
+ // case ARRAY:
+ // case OBJECT:
+ default:
+ return opcode + 4;
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Equals, hashCode and toString
+ // ------------------------------------------------------------------------
+
+ /**
+ * Tests if the given object is equal to this type.
+ *
+ * @param o the object to be compared to this type.
+ * @return <tt>true</tt> if the given object is equal to this type.
+ */
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || !(o instanceof Type)) {
+ return false;
+ }
+ Type t = (Type) o;
+ if (sort != t.sort) {
+ return false;
+ }
+ if (sort == Type.OBJECT || sort == Type.ARRAY) {
+ if (len != t.len) {
+ return false;
+ }
+ for (int i = off, j = t.off, end = i + len; i < end; i++, j++) {
+ if (buf[i] != t.buf[j]) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns a hash code value for this type.
+ *
+ * @return a hash code value for this type.
+ */
+ public int hashCode() {
+ int hc = 13 * sort;
+ if (sort == Type.OBJECT || sort == Type.ARRAY) {
+ for (int i = off, end = i + len; i < end; i++) {
+ hc = 17 * (hc + buf[i]);
+ }
+ }
+ return hc;
+ }
+
+ /**
+ * Returns a string representation of this type.
+ *
+ * @return the descriptor of this type.
+ */
+ public String toString() {
+ return getDescriptor();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapAttribute.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapAttribute.java
new file mode 100644
index 000000000..f35947485
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapAttribute.java
@@ -0,0 +1,378 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.attrs;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ByteVector;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Label;
+
+/**
+ * StackMapAttribute is used by CDLC preverifier. Definition is given in
+ * appendix "CLDC Byte Code Typechecker Specification" from CDLC 1.1
+ * specification. <p> <i>Note that this implementation does not calculate
+ * StackMapFrame structures from the method bytecode. If method code is changed
+ * or generated from scratch, then developer is responsible to prepare a correct
+ * StackMapFrame structures.</i> <p> The format of the stack map in the class
+ * file is given below. In the following, <ul> <li>if the length of the
+ * method's byte code1 is 65535 or less, then <tt>uoffset</tt> represents the
+ * type u2; otherwise <tt>uoffset</tt> represents the type u4.</li> <li>If
+ * the maximum number of local variables for the method is 65535 or less, then
+ * <tt>ulocalvar</tt> represents the type u2; otherwise <tt>ulocalvar</tt>
+ * represents the type u4.</li> <li>If the maximum size of the operand stack
+ * is 65535 or less, then <tt>ustack</tt> represents the type u2; otherwise
+ * ustack represents the type u4.</li> </ul>
+ *
+ * <pre>
+ * stack_map { // attribute StackMap
+ * u2 attribute_name_index;
+ * u4 attribute_length
+ * uoffset number_of_entries;
+ * stack_map_frame entries[number_of_entries];
+ * }
+ * </pre>
+ *
+ * Each stack map frame has the following format:
+ *
+ * <pre>
+ * stack_map_frame {
+ * uoffset offset;
+ * ulocalvar number_of_locals;
+ * verification_type_info locals[number_of_locals];
+ * ustack number_of_stack_items;
+ * verification_type_info stack[number_of_stack_items];
+ * }
+ * </pre>
+ *
+ * The <tt>verification_type_info</tt> structure consists of a one-byte tag
+ * followed by zero or more bytes, giving more information about the tag. Each
+ * <tt>verification_type_info</tt> structure specifies the verification type
+ * of one or two locations.
+ *
+ * <pre>
+ * union verification_type_info {
+ * Top_variable_info;
+ * Integer_variable_info;
+ * Float_variable_info;
+ * Long_variable_info;
+ * Double_variable_info;
+ * Null_variable_info;
+ * UninitializedThis_variable_info;
+ * Object_variable_info;
+ * Uninitialized_variable_info;
+ * }
+ *
+ * Top_variable_info {
+ * u1 tag = ITEM_Top; // 0
+ * }
+ *
+ * Integer_variable_info {
+ * u1 tag = ITEM_Integer; // 1
+ * }
+ *
+ * Float_variable_info {
+ * u1 tag = ITEM_Float; // 2
+ * }
+ *
+ * Long_variable_info {
+ * u1 tag = ITEM_Long; // 4
+ * }
+ *
+ * Double_variable_info {
+ * u1 tag = ITEM_Double; // 3
+ * }
+ *
+ * Null_variable_info {
+ * u1 tag = ITEM_Null; // 5
+ * }
+ *
+ * UninitializedThis_variable_info {
+ * u1 tag = ITEM_UninitializedThis; // 6
+ * }
+ *
+ * Object_variable_info {
+ * u1 tag = ITEM_Object; // 7
+ * u2 cpool_index;
+ * }
+ *
+ * Uninitialized_variable_info {
+ * u1 tag = ITEM_Uninitialized // 8
+ * uoffset offset;
+ * }
+ * </pre>
+ *
+ * @see <a href="http://www.jcp.org/en/jsr/detail?id=139">JSR 139 : Connected
+ * Limited Device Configuration 1.1</a>
+ *
+ * @author Eugene Kuleshov
+ */
+public class StackMapAttribute extends Attribute {
+
+ static final int MAX_SIZE = 65535;
+
+ /**
+ * A List of <code>StackMapFrame</code> instances.
+ */
+ public List frames = new ArrayList();
+
+ public StackMapAttribute() {
+ super("StackMap");
+ }
+
+ public StackMapAttribute(List frames) {
+ this();
+ this.frames = frames;
+ }
+
+ public List getFrames() {
+ return frames;
+ }
+
+ public StackMapFrame getFrame(Label label) {
+ for (int i = 0; i < frames.size(); i++) {
+ StackMapFrame frame = (StackMapFrame) frames.get(i);
+ if (frame.label == label) {
+ return frame;
+ }
+ }
+ return null;
+ }
+
+ public boolean isUnknown() {
+ return false;
+ }
+
+ public boolean isCodeAttribute() {
+ return true;
+ }
+
+ protected Attribute read(
+ ClassReader cr,
+ int off,
+ int len,
+ char[] buf,
+ int codeOff,
+ Label[] labels)
+ {
+ StackMapAttribute attr = new StackMapAttribute();
+ // note that this is not the size of Code attribute
+ boolean isExtCodeSize = cr.readInt(codeOff + 4) > MAX_SIZE;
+ boolean isExtLocals = cr.readUnsignedShort(codeOff + 2) > MAX_SIZE;
+ boolean isExtStack = cr.readUnsignedShort(codeOff) > MAX_SIZE;
+
+ int size = 0;
+ if (isExtCodeSize) {
+ size = cr.readInt(off);
+ off += 4;
+ } else {
+ size = cr.readUnsignedShort(off);
+ off += 2;
+ }
+ for (int i = 0; i < size; i++) {
+ int offset;
+ if (isExtCodeSize) {
+ offset = cr.readInt(off);
+ off += 4;
+ } else {
+ offset = cr.readUnsignedShort(off);
+ off += 2;
+ }
+
+ Label label = getLabel(offset, labels);
+ List locals = new ArrayList();
+ List stack = new ArrayList();
+
+ off = readTypeInfo(cr,
+ off,
+ locals,
+ labels,
+ buf,
+ isExtLocals,
+ isExtCodeSize);
+ off = readTypeInfo(cr,
+ off,
+ stack,
+ labels,
+ buf,
+ isExtStack,
+ isExtCodeSize);
+
+ attr.frames.add(new StackMapFrame(label, locals, stack));
+ }
+ return attr;
+ }
+
+ private int readTypeInfo(
+ ClassReader cr,
+ int off,
+ List info,
+ Label[] labels,
+ char[] buf,
+ boolean isExt,
+ boolean isExtCode)
+ {
+ int n = 0;
+ if (isExt) {
+ n = cr.readInt(off);
+ off += 4;
+ } else {
+ n = cr.readUnsignedShort(off);
+ off += 2;
+ }
+ for (int j = 0; j < n; j++) {
+ int itemType = cr.readByte(off++);
+ StackMapType typeInfo = StackMapType.getTypeInfo(itemType);
+ info.add(typeInfo);
+ switch (itemType) {
+ case StackMapType.ITEM_Object: //
+ typeInfo.setObject(cr.readClass(off, buf));
+ off += 2;
+ break;
+ case StackMapType.ITEM_Uninitialized: //
+ int offset;
+ if (isExtCode) {
+ offset = cr.readInt(off);
+ off += 4;
+ } else {
+ offset = cr.readUnsignedShort(off);
+ off += 2;
+ }
+ typeInfo.setLabel(getLabel(offset, labels));
+ break;
+ }
+ }
+ return off;
+ }
+
+ private void writeTypeInfo(ByteVector bv, ClassWriter cw, List info, int max)
+ {
+ if (max > StackMapAttribute.MAX_SIZE) {
+ bv.putInt(info.size());
+ } else {
+ bv.putShort(info.size());
+ }
+ for (int j = 0; j < info.size(); j++) {
+ StackMapType typeInfo = (StackMapType) info.get(j);
+ bv.putByte(typeInfo.getType());
+ switch (typeInfo.getType()) {
+ case StackMapType.ITEM_Object: //
+ bv.putShort(cw.newClass(typeInfo.getObject()));
+ break;
+
+ case StackMapType.ITEM_Uninitialized: //
+ bv.putShort(typeInfo.getLabel().getOffset());
+ break;
+
+ }
+ }
+ }
+
+ private Label getLabel(int offset, Label[] labels) {
+ Label l = labels[offset];
+ if (l != null) {
+ return l;
+ }
+ return labels[offset] = new Label();
+ }
+
+ protected ByteVector write(
+ ClassWriter cw,
+ byte[] code,
+ int len,
+ int maxStack,
+ int maxLocals)
+ {
+ ByteVector bv = new ByteVector();
+ if (code != null && code.length > MAX_SIZE) { // TODO verify value
+ bv.putInt(frames.size());
+ } else {
+ bv.putShort(frames.size());
+ }
+ for (int i = 0; i < frames.size(); i++) {
+ writeFrame((StackMapFrame) frames.get(i),
+ cw,
+ maxStack,
+ maxLocals,
+ bv);
+ }
+ return bv;
+ }
+
+ protected Label[] getLabels() {
+ HashSet labels = new HashSet();
+ for (int i = 0; i < frames.size(); i++) {
+ getFrameLabels((StackMapFrame) frames.get(i), labels);
+ }
+ return (Label[]) labels.toArray(new Label[labels.size()]);
+ }
+
+ private void writeFrame(
+ StackMapFrame frame,
+ ClassWriter cw,
+ int maxStack,
+ int maxLocals,
+ ByteVector bv)
+ {
+ bv.putShort(frame.label.getOffset());
+ writeTypeInfo(bv, cw, frame.locals, maxLocals);
+ writeTypeInfo(bv, cw, frame.stack, maxStack);
+ }
+
+ private void getFrameLabels(StackMapFrame frame, Set labels) {
+ labels.add(frame.label);
+ getTypeInfoLabels(labels, frame.locals);
+ getTypeInfoLabels(labels, frame.stack);
+ }
+
+ private void getTypeInfoLabels(Set labels, List info) {
+ for (Iterator it = info.iterator(); it.hasNext();) {
+ StackMapType typeInfo = (StackMapType) it.next();
+ if (typeInfo.getType() == StackMapType.ITEM_Uninitialized) {
+ labels.add(typeInfo.getLabel());
+ }
+ }
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("StackMap[");
+ for (int i = 0; i < frames.size(); i++) {
+ sb.append('\n').append('[').append(frames.get(i)).append(']');
+ }
+ sb.append("\n]");
+ return sb.toString();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapFrame.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapFrame.java
new file mode 100644
index 000000000..d91d8e707
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapFrame.java
@@ -0,0 +1,82 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.attrs;
+
+import java.util.List;
+
+import org.objectweb.asm.Label;
+
+/**
+ * Holds the state of the stack and local variables for a single execution
+ * branch.
+ *
+ * <i>Note that Long and Double types are represented by two entries in locals
+ * and stack. Second entry should be always of type Top.</i>
+ *
+ * @see <a href="http://www.jcp.org/en/jsr/detail?id=139">JSR 139 : Connected
+ * Limited Device Configuration 1.1</a>
+ *
+ * @see "ClassFileFormat-Java6.fm Page 138 Friday, April 15, 2005 3:22 PM"
+ *
+ * @author Eugene Kuleshov
+ */
+public class StackMapFrame {
+
+ /**
+ * A <code>Label</code> for frame offset within method bytecode.
+ */
+ public Label label;
+
+ /**
+ * A List of <code>StackMapType</code> instances that represent locals for
+ * this frame.
+ */
+ public List locals;
+
+ /**
+ * A List of <code>StackMapType</code> instances that represent stack for
+ * this frame.
+ */
+ public List stack;
+
+ public StackMapFrame(Label label, List locals, List stack) {
+ this.label = label;
+ this.locals = locals;
+ this.stack = stack;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("Frame:L");
+ sb.append(System.identityHashCode(label));
+ sb.append(" locals").append(locals);
+ sb.append(" stack").append(stack);
+ return sb.toString();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapTableAttribute.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapTableAttribute.java
new file mode 100644
index 000000000..032adf62b
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapTableAttribute.java
@@ -0,0 +1,927 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.attrs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ByteVector;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * The stack map attribute is used during the process of verification by
+ * typechecking (§4.11.1). <br> <br> A stack map attribute consists of zero or
+ * more stack map frames. Each stack map frame specifies (either explicitly or
+ * implicitly) a bytecode offset, the verification types (§4.11.1) for the local
+ * variables, and the verification types for the operand stack. <br> <br> The
+ * type checker deals with and manipulates the expected types of a method's
+ * local variables and operand stack. Throughout this section, a location refers
+ * to either a single local variable or to a single operand stack entry. <br>
+ * <br> We will use the terms stack frame map and type state interchangeably to
+ * describe a mapping from locations in the operand stack and local variables of
+ * a method to verification types. We will usually use the term stack frame map
+ * when such a mapping is provided in the class file, and the term type state
+ * when the mapping is inferred by the type checker. <br> <br> If a method's
+ * Code attribute does not have a StackMapTable attribute, it has an implicit
+ * stack map attribute. This implicit stack map attribute is equivalent to a
+ * StackMapTable attribute with number_of_entries equal to zero. A method's Code
+ * attribute may have at most one StackMapTable attribute, otherwise a
+ * java.lang.ClassFormatError is thrown. <br> <br> The format of the stack map
+ * in the class file is given below. In the following, if the length of the
+ * method's byte code is 65535 or less, then uoffset represents the type u2;
+ * otherwise uoffset represents the type u4. If the maximum number of local
+ * variables for the method is 65535 or less, then <code>ulocalvar</code>
+ * represents the type u2; otherwise ulocalvar represents the type u4. If the
+ * maximum size of the operand stack is 65535 or less, then <code>ustack</code>
+ * represents the type u2; otherwise ustack represents the type u4.
+ *
+ * <pre>
+ * stack_map { // attribute StackMapTable
+ * u2 attribute_name_index;
+ * u4 attribute_length
+ * uoffset number_of_entries;
+ * stack_map_frame entries[number_of_entries];
+ * }
+ * </pre>
+ *
+ * Each stack_map_frame structure specifies the type state at a particular byte
+ * code offset. Each frame type specifies (explicitly or implicitly) a value,
+ * offset_delta, that is used to calulate the actual byte code offset at which
+ * it applies. The byte code offset at which the frame applies is given by
+ * adding <code>1 + offset_delta</code> to the <code>offset</code> of the
+ * previous frame, unless the previous frame is the initial frame of the method,
+ * in which case the byte code offset is <code>offset_delta</code>. <br> <br>
+ * <i>Note that the length of the byte codes is not the same as the length of
+ * the Code attribute. The byte codes are embedded in the Code attribute, along
+ * with other information.</i> <br> <br> By using an offset delta rather than
+ * the actual byte code offset we ensure, by definition, that stack map frames
+ * are in the correctly sorted order. Furthermore, by consistently using the
+ * formula <code>offset_delta + 1</code> for all explicit frames, we guarantee
+ * the absence of duplicates. <br> <br> All frame types, even full_frame, rely
+ * on the previous frame for some of their semantics. This raises the question
+ * of what is the very first frame? The initial frame is implicit, and computed
+ * from the method descriptor. See the Prolog code for methodInitialStacFrame.
+ * <br> <br> The stack_map_frame structure consists of a one-byte tag followed
+ * by zero or more bytes, giving more information, depending upon the tag. <br>
+ * <br> A stack map frame may belong to one of several frame types
+ *
+ * <pre>
+ * union stack_map_frame {
+ * same_frame;
+ * same_locals_1_stack_item_frame;
+ * chop_frame;
+ * same_frame_extended;
+ * append_frame;
+ * full_frame;
+ * }
+ * </pre>
+ *
+ * The frame type same_frame is represented by tags in the range [0-63]. If the
+ * frame type is same_frame, it means the frame has exactly the same locals as
+ * the previous stack map frame and that the number of stack items is zero. The
+ * offset_delta value for the frame is the value of the tag field, frame_type.
+ * The form of such a frame is then:
+ *
+ * <pre>
+ * same_frame {
+ * u1 frame_type = SAME; // 0-63
+ * }
+ * </pre>
+ *
+ * The frame type same_locals_1_stack_item_frame is represented by tags in the
+ * range [64, 127]. If the frame_type is same_locals_1_stack_item_frame, it
+ * means the frame has exactly the same locals as the previous stack map frame
+ * and that the number of stack items is 1. The offset_delta value for the frame
+ * is the value (frame_type - 64). There is a verification_type_info following
+ * the frame_type for the one stack item. The form of such a frame is then:
+ *
+ * <pre>
+ * same_locals_1_stack_item_frame {
+ * u1 frame_type = SAME_LOCALS_1_STACK_ITEM; // 64-127
+ * verification_type_info stack[1];
+ * }
+ * </pre>
+ *
+ * Tags in the range [128-247] are reserved for future use. <br> <br> The frame
+ * type chop_frame is represented by tags in the range [248-250]. If the
+ * frame_type is chop_frame, it means that the current locals are the same as
+ * the locals in the previous frame, except that the k last locals are absent.
+ * The value of k is given by the formula 251-frame_type. <br> <br> The form of
+ * such a frame is then:
+ *
+ * <pre>
+ * chop_frame {
+ * u1 frame_type=CHOP; // 248-250
+ * uoffset offset_delta;
+ * }
+ * </pre>
+ *
+ * The frame type same_frame_extended is represented by the tag value 251. If
+ * the frame type is same_frame_extended, it means the frame has exactly the
+ * same locals as the previous stack map frame and that the number of stack
+ * items is zero. The form of such a frame is then:
+ *
+ * <pre>
+ * same_frame_extended {
+ * u1 frame_type = SAME_FRAME_EXTENDED; // 251
+ * uoffset offset_delta;
+ * }
+ * </pre>
+ *
+ * The frame type append_frame is represented by tags in the range [252-254]. If
+ * the frame_type is append_frame, it means that the current locals are the same
+ * as the locals in the previous frame, except that k additional locals are
+ * defined. The value of k is given by the formula frame_type-251. <br> <br> The
+ * form of such a frame is then:
+ *
+ * <pre>
+ * append_frame {
+ * u1 frame_type =APPEND; // 252-254
+ * uoffset offset_delta;
+ * verification_type_info locals[frame_type -251];
+ * }
+ * </pre>
+ *
+ * The 0th entry in locals represents the type of the first additional local
+ * variable. If locals[M] represents local variable N, then locals[M+1]
+ * represents local variable N+1 if locals[M] is one of Top_variable_info,
+ * Integer_variable_info, Float_variable_info, Null_variable_info,
+ * UninitializedThis_variable_info, Object_variable_info, or
+ * Uninitialized_variable_info, otherwise locals[M+1] represents local variable
+ * N+2. It is an error if, for any index i, locals[i] represents a local
+ * variable whose index is greater than the maximum number of local variables
+ * for the method. <br> <br> The frame type full_frame is represented by the tag
+ * value 255. The form of such a frame is then:
+ *
+ * <pre>
+ * full_frame {
+ * u1 frame_type = FULL_FRAME; // 255
+ * uoffset offset_delta;
+ * ulocalvar number_of_locals;
+ * verification_type_info locals[number_of_locals];
+ * ustack number_of_stack_items;
+ * verification_type_info stack[number_of_stack_items];
+ * }
+ * </pre>
+ *
+ * The 0th entry in locals represents the type of local variable 0. If locals[M]
+ * represents local variable N, then locals[M+1] represents local variable N+1
+ * if locals[M] is one of Top_variable_info, Integer_variable_info,
+ * Float_variable_info, Null_variable_info, UninitializedThis_variable_info,
+ * Object_variable_info, or Uninitialized_variable_info, otherwise locals[M+1]
+ * represents local variable N+2. It is an error if, for any index i, locals[i]
+ * represents a local variable whose index is greater than the maximum number of
+ * local variables for the method. <br> <br> The 0th entry in stack represents
+ * the type of the bottom of the stack, and subsequent entries represent types
+ * of stack elements closer to the top of the operand stack. We shall refer to
+ * the bottom element of the stack as stack element 0, and to subsequent
+ * elements as stack element 1, 2 etc. If stack[M] represents stack element N,
+ * then stack[M+1] represents stack element N+1 if stack[M] is one of
+ * Top_variable_info, Integer_variable_info, Float_variable_info,
+ * Null_variable_info, UninitializedThis_variable_info, Object_variable_info, or
+ * Uninitialized_variable_info, otherwise stack[M+1] represents stack element
+ * N+2. It is an error if, for any index i, stack[i] represents a stack entry
+ * whose index is greater than the maximum operand stack size for the method.
+ * <br> <br> We say that an instruction in the byte code has a corresponding
+ * stack map frame if the offset in the offset field of the stack map frame is
+ * the same as the offset of the instruction in the byte codes. <br> <br> The
+ * verification_type_info structure consists of a one-byte tag followed by zero
+ * or more bytes, giving more information about the tag. Each
+ * verification_type_info structure specifies the verification type of one or
+ * two locations.
+ *
+ * <pre>
+ * union verification_type_info {
+ * Top_variable_info;
+ * Integer_variable_info;
+ * Float_variable_info;
+ * Long_variable_info;
+ * Double_variable_info;
+ * Null_variable_info;
+ * UninitializedThis_variable_info;
+ * Object_variable_info;
+ * Uninitialized_variable_info;
+ * }
+ * </pre>
+ *
+ * The Top_variable_info type indicates that the local variable has the
+ * verification type top (T.)
+ *
+ * <pre>
+ * Top_variable_info {
+ * u1 tag = ITEM_Top; // 0
+ * }
+ * </pre>
+ *
+ * The Integer_variable_info type indicates that the location contains the
+ * verification type int.
+ *
+ * <pre>
+ * Integer_variable_info {
+ * u1 tag = ITEM_Integer; // 1
+ * }
+ * </pre>
+ *
+ * The Float_variable_info type indicates that the location contains the
+ * verification type float.
+ *
+ * <pre>
+ * Float_variable_info {
+ * u1 tag = ITEM_Float; // 2
+ * }
+ * </pre>
+ *
+ * The Long_variable_info type indicates that the location contains the
+ * verification type long. If the location is a local variable, then:
+ *
+ * <ul> <li>It must not be the local variable with the highest index.</li>
+ * <li>The next higher numbered local variable contains the verification type
+ * T.</li> </ul>
+ *
+ * If the location is an operand stack entry, then:
+ *
+ * <ul> <li>The current location must not be the topmost location of the
+ * operand stack.</li> <li>the next location closer to the top of the operand
+ * stack contains the verification type T.</li> </ul>
+ *
+ * This structure gives the contents of two locations in the operand stack or in
+ * the local variables.
+ *
+ * <pre>
+ * Long_variable_info {
+ * u1 tag = ITEM_Long; // 4
+ * }
+ * </pre>
+ *
+ * The Double_variable_info type indicates that the location contains the
+ * verification type double. If the location is a local variable, then:
+ *
+ * <ul> <li>It must not be the local variable with the highest index.</li>
+ * <li>The next higher numbered local variable contains the verification type
+ * T. <li> </ul>
+ *
+ * If the location is an operand stack entry, then:
+ *
+ * <ul> <li>The current location must not be the topmost location of the
+ * operand stack.</li> <li>the next location closer to the top of the operand
+ * stack contains the verification type T.</li> </ul>
+ *
+ * This structure gives the contents of two locations in in the operand stack or
+ * in the local variables.
+ *
+ * <pre>
+ * Double_variable_info {
+ * u1 tag = ITEM_Double; // 3
+ * }
+ * </pre>
+ *
+ * The Null_variable_info type indicates that location contains the verification
+ * type null.
+ *
+ * <pre>
+ * Null_variable_info {
+ * u1 tag = ITEM_Null; // 5
+ * }
+ * </pre>
+ *
+ * The UninitializedThis_variable_info type indicates that the location contains
+ * the verification type uninitializedThis.
+ *
+ * <pre>
+ * UninitializedThis_variable_info {
+ * u1 tag = ITEM_UninitializedThis; // 6
+ * }
+ * </pre>
+ *
+ * The Object_variable_info type indicates that the location contains an
+ * instance of the class referenced by the constant pool entry.
+ *
+ * <pre>
+ * Object_variable_info {
+ * u1 tag = ITEM_Object; // 7
+ * u2 cpool_index;
+ * }
+ * </pre>
+ *
+ * The Uninitialized_variable_info indicates that the location contains the
+ * verification type uninitialized(offset). The offset item indicates the offset
+ * of the new instruction that created the object being stored in the location.
+ *
+ * <pre>
+ * Uninitialized_variable_info {
+ * u1 tag = ITEM_Uninitialized // 8
+ * uoffset offset;
+ * }
+ * </pre>
+ *
+ * @see "ClassFileFormat-Java6.fm Page 138 Friday, April 15, 2005 3:22 PM"
+ *
+ * @author Eugene Kuleshov
+ */
+public class StackMapTableAttribute extends Attribute {
+ /**
+ * Frame has exactly the same locals as the previous stack map frame and
+ * number of stack items is zero.
+ */
+ public static final int SAME_FRAME = 0; // to 63 (0-3f)
+
+ /**
+ * Frame has exactly the same locals as the previous stack map frame and
+ * number of stack items is 1
+ */
+ public static final int SAME_LOCALS_1_STACK_ITEM_FRAME = 64; // to 127
+
+ // (40-7f)
+
+ /**
+ * Reserved for future use
+ */
+ public static final int RESERVED = 128;
+
+ /**
+ * Frame has exactly the same locals as the previous stack map frame and
+ * number of stack items is 1. Offset is bigger then 63;
+ */
+ public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED = 247; // f7
+
+ /**
+ * Frame where current locals are the same as the locals in the previous
+ * frame, except that the k last locals are absent. The value of k is given
+ * by the formula 251-frame_type.
+ */
+ public static final int CHOP_FRAME = 248; // to 250 (f8-fA)
+
+ /**
+ * Frame has exactly the same locals as the previous stack map frame and
+ * number of stack items is zero. Offset is bigger then 63;
+ */
+ public static final int SAME_FRAME_EXTENDED = 251; // fb
+
+ /**
+ * Frame where current locals are the same as the locals in the previous
+ * frame, except that k additional locals are defined. The value of k is
+ * given by the formula frame_type-251.
+ */
+ public static final int APPEND_FRAME = 252; // to 254 // fc-fe
+
+ /**
+ * Full frame
+ */
+ public static final int FULL_FRAME = 255; // ff
+
+ private static final int MAX_SHORT = 65535;
+
+ /**
+ * A <code>List</code> of <code>StackMapFrame</code> instances.
+ */
+ private List frames;
+
+ public StackMapTableAttribute() {
+ super("StackMapTable");
+ }
+
+ public StackMapTableAttribute(List frames) {
+ this();
+ this.frames = frames;
+ }
+
+ public List getFrames() {
+ return frames;
+ }
+
+ public StackMapFrame getFrame(Label label) {
+ for (int i = 0; i < frames.size(); i++) {
+ StackMapFrame frame = (StackMapFrame) frames.get(i);
+ if (frame.label == label) {
+ return frame;
+ }
+ }
+ return null;
+ }
+
+ public boolean isUnknown() {
+ return false;
+ }
+
+ public boolean isCodeAttribute() {
+ return true;
+ }
+
+ protected Attribute read(
+ ClassReader cr,
+ int off,
+ int len,
+ char[] buf,
+ int codeOff,
+ Label[] labels)
+ {
+
+ ArrayList frames = new ArrayList();
+
+ // note that this is not the size of Code attribute
+ boolean isExtCodeSize = cr.readInt(codeOff + 4) > MAX_SHORT;
+ boolean isExtLocals = cr.readUnsignedShort(codeOff + 2) > MAX_SHORT;
+ boolean isExtStack = cr.readUnsignedShort(codeOff) > MAX_SHORT;
+
+ int offset = 0;
+
+ int methodOff = getMethodOff(cr, codeOff, buf);
+ StackMapFrame frame = new StackMapFrame(getLabel(offset, labels),
+ calculateLocals(cr.readClass(cr.header + 2, buf), // owner
+ cr.readUnsignedShort(methodOff), // method access
+ cr.readUTF8(methodOff + 2, buf), // method name
+ cr.readUTF8(methodOff + 4, buf)), // method desc
+ Collections.EMPTY_LIST);
+ frames.add(frame);
+
+ // System.err.println( cr.readUTF8( methodOff + 2, buf));
+ // System.err.println( offset +" delta:" + 0 +" : "+ frame);
+
+ int size;
+ if (isExtCodeSize) {
+ size = cr.readInt(off);
+ off += 4;
+ } else {
+ size = cr.readUnsignedShort(off);
+ off += 2;
+ }
+
+ for (; size > 0; size--) {
+ int tag = cr.readByte(off); // & 0xff;
+ off++;
+
+ List stack;
+ List locals;
+
+ int offsetDelta;
+ if (tag < SAME_LOCALS_1_STACK_ITEM_FRAME) { // SAME_FRAME
+ offsetDelta = tag;
+
+ locals = new ArrayList(frame.locals);
+ stack = Collections.EMPTY_LIST;
+
+ } else if (tag < RESERVED) { // SAME_LOCALS_1_STACK_ITEM_FRAME
+ offsetDelta = tag - SAME_LOCALS_1_STACK_ITEM_FRAME;
+
+ locals = new ArrayList(frame.locals);
+ stack = new ArrayList();
+ // read verification_type_info stack[1];
+ off = readType(stack, isExtCodeSize, cr, off, labels, buf);
+
+ } else {
+ if (isExtCodeSize) {
+ offsetDelta = cr.readInt(off);
+ off += 4;
+ } else {
+ offsetDelta = cr.readUnsignedShort(off);
+ off += 2;
+ }
+
+ if (tag == SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED
+ locals = new ArrayList(frame.locals);
+ stack = new ArrayList();
+ // read verification_type_info stack[1];
+ off = readType(stack, isExtCodeSize, cr, off, labels, buf);
+
+ } else if (tag >= CHOP_FRAME && tag < SAME_FRAME_EXTENDED) { // CHOP_FRAME
+ stack = Collections.EMPTY_LIST;
+
+ int k = SAME_FRAME_EXTENDED - tag;
+ // copy locals from prev frame and chop last k
+ locals = new ArrayList(frame.locals.subList(0,
+ frame.locals.size() - k));
+
+ } else if (tag == SAME_FRAME_EXTENDED) { // SAME_FRAME_EXTENDED
+ stack = Collections.EMPTY_LIST;
+ locals = new ArrayList(frame.locals);
+
+ } else if ( /* tag>=APPEND && */tag < FULL_FRAME) { // APPEND_FRAME
+ stack = Collections.EMPTY_LIST;
+
+ // copy locals from prev frame and append new k
+ locals = new ArrayList(frame.locals);
+ for (int k = tag - SAME_FRAME_EXTENDED; k > 0; k--) {
+ off = readType(locals,
+ isExtCodeSize,
+ cr,
+ off,
+ labels,
+ buf);
+ }
+
+ } else if (tag == FULL_FRAME) { // FULL_FRAME
+ // read verification_type_info locals[number_of_locals];
+ locals = new ArrayList();
+ off = readTypes(locals,
+ isExtLocals,
+ isExtCodeSize,
+ cr,
+ off,
+ labels,
+ buf);
+
+ // read verification_type_info stack[number_of_stack_items];
+ stack = new ArrayList();
+ off = readTypes(stack,
+ isExtStack,
+ isExtCodeSize,
+ cr,
+ off,
+ labels,
+ buf);
+
+ } else {
+ throw new RuntimeException("Unknown frame type " + tag
+ + " after offset " + offset);
+
+ }
+ }
+
+ offset += offsetDelta;
+
+ Label offsetLabel = getLabel(offset, labels);
+
+ frame = new StackMapFrame(offsetLabel, locals, stack);
+ frames.add(frame);
+ // System.err.println( tag +" " + offset +" delta:" + offsetDelta +
+ // " frameType:"+ frameType+" : "+ frame);
+
+ offset++;
+ }
+
+ return new StackMapTableAttribute(frames);
+ }
+
+ protected ByteVector write(
+ ClassWriter cw,
+ byte[] code,
+ int len,
+ int maxStack,
+ int maxLocals)
+ {
+ ByteVector bv = new ByteVector();
+ // TODO verify this value (MAX_SHORT)
+ boolean isExtCodeSize = code != null && code.length > MAX_SHORT;
+ writeSize(frames.size() - 1, bv, isExtCodeSize);
+
+ if (frames.size() < 2) {
+ return bv;
+ }
+
+ boolean isExtLocals = maxLocals > MAX_SHORT;
+ boolean isExtStack = maxStack > MAX_SHORT;
+
+ // skip the first frame
+ StackMapFrame frame = (StackMapFrame) frames.get(0);
+ List locals = frame.locals;
+ int offset = frame.label.getOffset();
+
+ for (int i = 1; i < frames.size(); i++) {
+ frame = (StackMapFrame) frames.get(i);
+
+ List clocals = frame.locals;
+ List cstack = frame.stack;
+ int coffset = frame.label.getOffset();
+
+ int clocalsSize = clocals.size();
+ int cstackSize = cstack.size();
+
+ int localsSize = locals.size();
+
+ int delta = coffset - offset;
+
+ int type = FULL_FRAME;
+ int k = 0;
+ if (cstackSize == 0) {
+ k = clocalsSize - localsSize;
+ switch (k) {
+ case -3:
+ case -2:
+ case -1:
+ type = CHOP_FRAME; // CHOP or FULL
+ localsSize = clocalsSize; // for full_frame check
+ break;
+
+ case 0:
+ // SAME, SAME_EXTENDED or FULL
+ type = delta < 64 ? SAME_FRAME : SAME_FRAME_EXTENDED;
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+ type = APPEND_FRAME; // APPEND or FULL
+ break;
+ }
+ } else if (localsSize == clocalsSize && cstackSize == 1) {
+ // SAME_LOCAL_1_STACK or FULL
+ type = delta < 63
+ ? SAME_LOCALS_1_STACK_ITEM_FRAME
+ : SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED;
+ }
+
+ if (type != FULL_FRAME) {
+ // verify if stack and locals are the same
+ for (int j = 0; j < localsSize && type != FULL_FRAME; j++) {
+ if (!locals.get(j).equals(clocals.get(j)))
+ type = FULL_FRAME;
+ }
+ }
+
+ switch (type) {
+ case SAME_FRAME:
+ bv.putByte(delta);
+ break;
+
+ case SAME_LOCALS_1_STACK_ITEM_FRAME:
+ bv.putByte(SAME_LOCALS_1_STACK_ITEM_FRAME + delta);
+ writeTypeInfos(bv, cw, cstack, 0, 1);
+ break;
+
+ case SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED:
+ bv.putByte(SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED);
+ writeSize(delta, bv, isExtCodeSize);
+ writeTypeInfos(bv, cw, cstack, 0, 1);
+ break;
+
+ case SAME_FRAME_EXTENDED:
+ bv.putByte(SAME_FRAME_EXTENDED);
+ writeSize(delta, bv, isExtCodeSize);
+ break;
+
+ case CHOP_FRAME:
+ bv.putByte(SAME_FRAME_EXTENDED + k); // negative k
+ writeSize(delta, bv, isExtCodeSize);
+ break;
+
+ case APPEND_FRAME:
+ bv.putByte(SAME_FRAME_EXTENDED + k); // positive k
+ writeSize(delta, bv, isExtCodeSize);
+ writeTypeInfos(bv,
+ cw,
+ clocals,
+ clocalsSize - 1,
+ clocalsSize);
+ break;
+
+ case FULL_FRAME:
+ bv.putByte(FULL_FRAME);
+ writeSize(delta, bv, isExtCodeSize);
+ writeSize(clocalsSize, bv, isExtLocals);
+ writeTypeInfos(bv, cw, clocals, 0, clocalsSize);
+ writeSize(cstackSize, bv, isExtStack);
+ writeTypeInfos(bv, cw, cstack, 0, cstackSize);
+ break;
+
+ default:
+ throw new RuntimeException();
+ }
+ offset = coffset + 1; // compensating non first offset
+ locals = clocals;
+ }
+ return bv;
+ }
+
+ private void writeSize(int delta, ByteVector bv, boolean isExt) {
+ if (isExt) {
+ bv.putInt(delta);
+ } else {
+ bv.putShort(delta);
+ }
+ }
+
+ private void writeTypeInfos(
+ ByteVector bv,
+ ClassWriter cw,
+ List info,
+ int start,
+ int end)
+ {
+ for (int j = start; j < end; j++) {
+ StackMapType typeInfo = (StackMapType) info.get(j);
+ bv.putByte(typeInfo.getType());
+
+ switch (typeInfo.getType()) {
+ case StackMapType.ITEM_Object: //
+ bv.putShort(cw.newClass(typeInfo.getObject()));
+ break;
+
+ case StackMapType.ITEM_Uninitialized: //
+ bv.putShort(typeInfo.getLabel().getOffset());
+ break;
+
+ }
+ }
+ }
+
+ public static int getMethodOff(ClassReader cr, int codeOff, char[] buf) {
+ int off = cr.header + 6;
+
+ int interfacesCount = cr.readUnsignedShort(off);
+ off += 2 + interfacesCount * 2;
+
+ int fieldsCount = cr.readUnsignedShort(off);
+ off += 2;
+ for (; fieldsCount > 0; --fieldsCount) {
+ int attrCount = cr.readUnsignedShort(off + 6); // field attributes
+ off += 8;
+ for (; attrCount > 0; --attrCount) {
+ off += 6 + cr.readInt(off + 2);
+ }
+ }
+
+ int methodsCount = cr.readUnsignedShort(off);
+ off += 2;
+ for (; methodsCount > 0; --methodsCount) {
+ int methodOff = off;
+ int attrCount = cr.readUnsignedShort(off + 6); // method attributes
+ off += 8;
+ for (; attrCount > 0; --attrCount) {
+ String attrName = cr.readUTF8(off, buf);
+ off += 6;
+ if (attrName.equals("Code")) {
+ if (codeOff == off) {
+ return methodOff;
+ }
+ }
+ off += cr.readInt(off - 4);
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Use method signature and access flags to resolve initial locals state.
+ *
+ * @param className name of the method's owner class.
+ * @param access access flags of the method.
+ * @param methodName name of the method.
+ * @param methodDesc descriptor of the method.
+ * @return list of <code>StackMapType</code> instances representing locals
+ * for an initial frame.
+ */
+ public static List calculateLocals(
+ String className,
+ int access,
+ String methodName,
+ String methodDesc)
+ {
+ List locals = new ArrayList();
+
+ // TODO
+ if ("<init>".equals(methodName)
+ && !className.equals("java/lang/Object"))
+ {
+ StackMapType typeInfo = StackMapType.getTypeInfo(StackMapType.ITEM_UninitializedThis);
+ typeInfo.setObject(className); // this
+ locals.add(typeInfo);
+ } else if ((access & Opcodes.ACC_STATIC) == 0) {
+ StackMapType typeInfo = StackMapType.getTypeInfo(StackMapType.ITEM_Object);
+ typeInfo.setObject(className); // this
+ locals.add(typeInfo);
+ }
+
+ Type[] types = Type.getArgumentTypes(methodDesc);
+ for (int i = 0; i < types.length; i++) {
+ Type t = types[i];
+ StackMapType smt;
+ switch (t.getSort()) {
+ case Type.LONG:
+ smt = StackMapType.getTypeInfo(StackMapType.ITEM_Long);
+ break;
+ case Type.DOUBLE:
+ smt = StackMapType.getTypeInfo(StackMapType.ITEM_Double);
+ break;
+
+ case Type.FLOAT:
+ smt = StackMapType.getTypeInfo(StackMapType.ITEM_Float);
+ break;
+
+ case Type.ARRAY:
+ case Type.OBJECT:
+ smt = StackMapType.getTypeInfo(StackMapType.ITEM_Object);
+ smt.setObject(t.getDescriptor()); // TODO verify name
+ break;
+
+ default:
+ smt = StackMapType.getTypeInfo(StackMapType.ITEM_Integer);
+ break;
+ }
+ }
+
+ return locals;
+ }
+
+ private int readTypes(
+ List info,
+ boolean isExt,
+ boolean isExtCodeSize,
+ ClassReader cr,
+ int off,
+ Label[] labels,
+ char[] buf)
+ {
+ int n = 0;
+ if (isExt) {
+ n = cr.readInt(off);
+ off += 4;
+ } else {
+ n = cr.readUnsignedShort(off);
+ off += 2;
+ }
+
+ for (; n > 0; n--) {
+ off = readType(info, isExtCodeSize, cr, off, labels, buf);
+ }
+ return off;
+ }
+
+ private int readType(
+ List info,
+ boolean isExtCodeSize,
+ ClassReader cr,
+ int off,
+ Label[] labels,
+ char[] buf)
+ {
+ int itemType = cr.readByte(off++);
+ StackMapType typeInfo = StackMapType.getTypeInfo(itemType);
+ info.add(typeInfo);
+ switch (itemType) {
+ // case StackMapType.ITEM_Long: //
+ // case StackMapType.ITEM_Double: //
+ // info.add(StackMapType.getTypeInfo(StackMapType.ITEM_Top));
+ // break;
+
+ case StackMapType.ITEM_Object: //
+ typeInfo.setObject(cr.readClass(off, buf));
+ off += 2;
+ break;
+
+ case StackMapType.ITEM_Uninitialized: //
+ int offset;
+ if (isExtCodeSize) {
+ offset = cr.readInt(off);
+ off += 4;
+ } else {
+ offset = cr.readUnsignedShort(off);
+ off += 2;
+ }
+
+ typeInfo.setLabel(getLabel(offset, labels));
+ break;
+ }
+ return off;
+ }
+
+ private Label getLabel(int offset, Label[] labels) {
+ Label l = labels[offset];
+ if (l != null) {
+ return l;
+ }
+ return labels[offset] = new Label();
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("StackMapTable[");
+ for (int i = 0; i < frames.size(); i++) {
+ sb.append('\n').append('[').append(frames.get(i)).append(']');
+ }
+ sb.append("\n]");
+ return sb.toString();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapType.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapType.java
new file mode 100644
index 000000000..30cadf1fc
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapType.java
@@ -0,0 +1,114 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.objectweb.asm.attrs;
+
+import org.objectweb.asm.Label;
+
+/**
+ * Verification type info used by {@link StackMapAttribute}.
+ *
+ * @see <a href="http://www.jcp.org/en/jsr/detail?id=139">JSR 139 : Connected
+ * Limited Device Configuration 1.1</a>
+ *
+ * @see "ClassFileFormat-Java6.fm Page 138 Friday, April 15, 2005 3:22 PM"
+ *
+ * @author Eugene Kuleshov
+ */
+
+public class StackMapType {
+
+ public static final int ITEM_Top = 0;
+ public static final int ITEM_Integer = 1;
+ public static final int ITEM_Float = 2;
+ public static final int ITEM_Double = 3;
+ public static final int ITEM_Long = 4;
+ public static final int ITEM_Null = 5;
+ public static final int ITEM_UninitializedThis = 6;
+ public static final int ITEM_Object = 7;
+ public static final int ITEM_Uninitialized = 8;
+
+ public static final String[] ITEM_NAMES = {
+ "Top",
+ "Integer",
+ "Float",
+ "Double",
+ "Long",
+ "Null",
+ "UninitializedThis",
+ "Object",
+ "Uninitialized" };
+
+ private int type;
+ private Label offset;
+ private String object;
+
+ private StackMapType(int type) {
+ this.type = type;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public static StackMapType getTypeInfo(int itemType) {
+ if (itemType < ITEM_Top || itemType > ITEM_Uninitialized) {
+ throw new IllegalArgumentException("" + itemType);
+ }
+ return new StackMapType(itemType);
+ }
+
+ public void setLabel(Label offset) {
+ this.offset = offset;
+ }
+
+ public void setObject(String object) {
+ this.object = object;
+ }
+
+ public Label getLabel() {
+ return offset;
+ }
+
+ public String getObject() {
+ return object;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer(ITEM_NAMES[type]);
+ if (type == ITEM_Object) {
+ sb.append(":").append(object);
+ }
+ if (type == ITEM_Uninitialized) {
+ sb.append(":L").append(System.identityHashCode(offset));
+ }
+ return sb.toString();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/AdviceAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/AdviceAdapter.java
new file mode 100644
index 000000000..13fbaa68c
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/AdviceAdapter.java
@@ -0,0 +1,642 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * A <code>MethodAdapter</code> to dispatch method body instruction
+ * <p>
+ * The behavior is like this:
+ * <ol>
+ *
+ * <li>as long as the INVOKESPECIAL for the object initialization has not been
+ * reached, every bytecode instruction is dispatched in the ctor code visitor</li>
+ *
+ * <li>when this one is reached, it is only added in the ctor code visitor and
+ * a JP invoke is added</li>
+ * <li>after that, only the other code visitor receives the instructions</li>
+ *
+ * </ol>
+ *
+ * @author Eugene Kuleshov
+ * @author Eric Bruneton
+ */
+public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes {
+ private static final Object THIS = new Object();
+ private static final Object OTHER = new Object();
+
+ protected int methodAccess;
+ protected String methodDesc;
+
+ private boolean constructor;
+ private boolean superInitialized;
+ private ArrayList stackFrame;
+ private HashMap branches;
+
+
+ /**
+ * Creates a new {@link AdviceAdapter}.
+ *
+ * @param mv the method visitor to which this adapter delegates calls.
+ * @param access the method's access flags (see {@link Opcodes}).
+ * @param name the method's name.
+ * @param desc the method's descriptor (see {@link Type Type}).
+ */
+ public AdviceAdapter(MethodVisitor mv, int access, String name, String desc) {
+ super(mv, access, name, desc);
+ methodAccess = access;
+ methodDesc = desc;
+
+ constructor = "<init>".equals(name);
+ if (!constructor) {
+ superInitialized = true;
+ onMethodEnter();
+ } else {
+ stackFrame = new ArrayList();
+ branches = new HashMap();
+ }
+ }
+
+ public void visitLabel(Label label) {
+ mv.visitLabel(label);
+
+ if (constructor && branches != null) {
+ ArrayList frame = (ArrayList) branches.get(label);
+ if (frame != null) {
+ stackFrame = frame;
+ branches.remove(label);
+ }
+ }
+ }
+
+ public void visitInsn(int opcode) {
+ if (constructor) {
+ switch (opcode) {
+ case RETURN: // empty stack
+ onMethodExit(opcode);
+ break;
+
+ case IRETURN: // 1 before n/a after
+ case FRETURN: // 1 before n/a after
+ case ARETURN: // 1 before n/a after
+ case ATHROW: // 1 before n/a after
+ popValue();
+ popValue();
+ onMethodExit(opcode);
+ break;
+
+ case LRETURN: // 2 before n/a after
+ case DRETURN: // 2 before n/a after
+ popValue();
+ popValue();
+ onMethodExit(opcode);
+ break;
+
+ case NOP:
+ case LALOAD: // remove 2 add 2
+ case DALOAD: // remove 2 add 2
+ case LNEG:
+ case DNEG:
+ case FNEG:
+ case INEG:
+ case L2D:
+ case D2L:
+ case F2I:
+ case I2B:
+ case I2C:
+ case I2S:
+ case I2F:
+ case Opcodes.ARRAYLENGTH:
+ break;
+
+ case ACONST_NULL:
+ case ICONST_M1:
+ case ICONST_0:
+ case ICONST_1:
+ case ICONST_2:
+ case ICONST_3:
+ case ICONST_4:
+ case ICONST_5:
+ case FCONST_0:
+ case FCONST_1:
+ case FCONST_2:
+ case F2L: // 1 before 2 after
+ case F2D:
+ case I2L:
+ case I2D:
+ pushValue(OTHER);
+ break;
+
+ case LCONST_0:
+ case LCONST_1:
+ case DCONST_0:
+ case DCONST_1:
+ pushValue(OTHER);
+ pushValue(OTHER);
+ break;
+
+ case IALOAD: // remove 2 add 1
+ case FALOAD: // remove 2 add 1
+ case AALOAD: // remove 2 add 1
+ case BALOAD: // remove 2 add 1
+ case CALOAD: // remove 2 add 1
+ case SALOAD: // remove 2 add 1
+ case POP:
+ case IADD:
+ case FADD:
+ case ISUB:
+ case LSHL: // 3 before 2 after
+ case LSHR: // 3 before 2 after
+ case LUSHR: // 3 before 2 after
+ case L2I: // 2 before 1 after
+ case L2F: // 2 before 1 after
+ case D2I: // 2 before 1 after
+ case D2F: // 2 before 1 after
+ case FSUB:
+ case FMUL:
+ case FDIV:
+ case FREM:
+ case FCMPL: // 2 before 1 after
+ case FCMPG: // 2 before 1 after
+ case IMUL:
+ case IDIV:
+ case IREM:
+ case ISHL:
+ case ISHR:
+ case IUSHR:
+ case IAND:
+ case IOR:
+ case IXOR:
+ case MONITORENTER:
+ case MONITOREXIT:
+ popValue();
+ break;
+
+ case POP2:
+ case LSUB:
+ case LMUL:
+ case LDIV:
+ case LREM:
+ case LADD:
+ case LAND:
+ case LOR:
+ case LXOR:
+ case DADD:
+ case DMUL:
+ case DSUB:
+ case DDIV:
+ case DREM:
+ popValue();
+ popValue();
+ break;
+
+ case IASTORE:
+ case FASTORE:
+ case AASTORE:
+ case BASTORE:
+ case CASTORE:
+ case SASTORE:
+ case LCMP: // 4 before 1 after
+ case DCMPL:
+ case DCMPG:
+ popValue();
+ popValue();
+ popValue();
+ break;
+
+ case LASTORE:
+ case DASTORE:
+ popValue();
+ popValue();
+ popValue();
+ popValue();
+ break;
+
+ case DUP:
+ pushValue(peekValue());
+ break;
+
+ case DUP_X1:
+ // TODO optimize this
+ {
+ Object o1 = popValue();
+ Object o2 = popValue();
+ pushValue(o1);
+ pushValue(o2);
+ pushValue(o1);
+ }
+ break;
+
+ case DUP_X2:
+ // TODO optimize this
+ {
+ Object o1 = popValue();
+ Object o2 = popValue();
+ Object o3 = popValue();
+ pushValue(o1);
+ pushValue(o3);
+ pushValue(o2);
+ pushValue(o1);
+ }
+ break;
+
+ case DUP2:
+ // TODO optimize this
+ {
+ Object o1 = popValue();
+ Object o2 = popValue();
+ pushValue(o2);
+ pushValue(o1);
+ pushValue(o2);
+ pushValue(o1);
+ }
+ break;
+
+ case DUP2_X1:
+ // TODO optimize this
+ {
+ Object o1 = popValue();
+ Object o2 = popValue();
+ Object o3 = popValue();
+ pushValue(o2);
+ pushValue(o1);
+ pushValue(o3);
+ pushValue(o2);
+ pushValue(o1);
+ }
+ break;
+
+ case DUP2_X2:
+ // TODO optimize this
+ {
+ Object o1 = popValue();
+ Object o2 = popValue();
+ Object o3 = popValue();
+ Object o4 = popValue();
+ pushValue(o2);
+ pushValue(o1);
+ pushValue(o4);
+ pushValue(o3);
+ pushValue(o2);
+ pushValue(o1);
+ }
+ break;
+
+ case SWAP: {
+ Object o1 = popValue();
+ Object o2 = popValue();
+ pushValue(o1);
+ pushValue(o2);
+ }
+ break;
+ }
+ } else {
+ switch (opcode) {
+ case RETURN:
+ case IRETURN:
+ case FRETURN:
+ case ARETURN:
+ case LRETURN:
+ case DRETURN:
+ case ATHROW:
+ onMethodExit(opcode);
+ break;
+ }
+ }
+ mv.visitInsn(opcode);
+ }
+
+ public void visitVarInsn(int opcode, int var) {
+ super.visitVarInsn(opcode, var);
+
+ if (constructor) {
+ switch (opcode) {
+ case ILOAD:
+ case FLOAD:
+ pushValue(OTHER);
+ break;
+ case LLOAD:
+ case DLOAD:
+ pushValue(OTHER);
+ pushValue(OTHER);
+ break;
+ case ALOAD:
+ pushValue(var == 0 ? THIS : OTHER);
+ break;
+ case ASTORE:
+ case ISTORE:
+ case FSTORE:
+ popValue();
+ break;
+ case LSTORE:
+ case DSTORE:
+ popValue();
+ popValue();
+ break;
+ }
+ }
+ }
+
+ public void visitFieldInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ mv.visitFieldInsn(opcode, owner, name, desc);
+
+ if (constructor) {
+ char c = desc.charAt(0);
+ boolean longOrDouble = c == 'J' || c == 'D';
+ switch (opcode) {
+ case GETSTATIC:
+ pushValue(OTHER);
+ if (longOrDouble) {
+ pushValue(OTHER);
+ }
+ break;
+ case PUTSTATIC:
+ popValue();
+ if(longOrDouble) {
+ popValue();
+ }
+ break;
+ case PUTFIELD:
+ popValue();
+ if(longOrDouble) {
+ popValue();
+ popValue();
+ }
+ break;
+ // case GETFIELD:
+ default:
+ if (longOrDouble) {
+ pushValue(OTHER);
+ }
+ }
+ }
+ }
+
+ public void visitIntInsn(int opcode, int operand) {
+ mv.visitIntInsn(opcode, operand);
+
+ if (constructor) {
+ switch (opcode) {
+ case BIPUSH:
+ case SIPUSH:
+ pushValue(OTHER);
+ }
+ }
+ }
+
+ public void visitLdcInsn(Object cst) {
+ mv.visitLdcInsn(cst);
+
+ if (constructor) {
+ pushValue(OTHER);
+ if (cst instanceof Double || cst instanceof Long) {
+ pushValue(OTHER);
+ }
+ }
+ }
+
+ public void visitMultiANewArrayInsn(String desc, int dims) {
+ mv.visitMultiANewArrayInsn(desc, dims);
+
+ if (constructor) {
+ for (int i = 0; i < dims; i++) {
+ popValue();
+ }
+ pushValue(OTHER);
+ }
+ }
+
+ public void visitTypeInsn(int opcode, String name) {
+ mv.visitTypeInsn(opcode, name);
+
+ // ANEWARRAY, CHECKCAST or INSTANCEOF don't change stack
+ if (constructor && opcode == NEW) {
+ pushValue(OTHER);
+ }
+ }
+
+ public void visitMethodInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ mv.visitMethodInsn(opcode, owner, name, desc);
+
+ if (constructor) {
+ Type[] types = Type.getArgumentTypes(desc);
+ for (int i = 0; i < types.length; i++) {
+ popValue();
+ if (types[i].getSize() == 2) {
+ popValue();
+ }
+ }
+ switch (opcode) {
+ // case INVOKESTATIC:
+ // break;
+
+ case INVOKEINTERFACE:
+ case INVOKEVIRTUAL:
+ popValue(); // objectref
+ break;
+
+ case INVOKESPECIAL:
+ Object type = popValue(); // objectref
+ if (type == THIS && !superInitialized) {
+ onMethodEnter();
+ superInitialized = true;
+ // once super has been initialized it is no longer
+ // necessary to keep track of stack state
+ constructor = false;
+ }
+ break;
+ }
+
+ Type returnType = Type.getReturnType(desc);
+ if (returnType != Type.VOID_TYPE) {
+ pushValue(OTHER);
+ if (returnType.getSize() == 2) {
+ pushValue(OTHER);
+ }
+ }
+ }
+ }
+
+ public void visitJumpInsn(int opcode, Label label) {
+ mv.visitJumpInsn(opcode, label);
+
+ if (constructor) {
+ switch (opcode) {
+ case IFEQ:
+ case IFNE:
+ case IFLT:
+ case IFGE:
+ case IFGT:
+ case IFLE:
+ case IFNULL:
+ case IFNONNULL:
+ popValue();
+ break;
+
+ case IF_ICMPEQ:
+ case IF_ICMPNE:
+ case IF_ICMPLT:
+ case IF_ICMPGE:
+ case IF_ICMPGT:
+ case IF_ICMPLE:
+ case IF_ACMPEQ:
+ case IF_ACMPNE:
+ popValue();
+ popValue();
+ break;
+
+ case JSR:
+ pushValue(OTHER);
+ break;
+ }
+ addBranch(label);
+ }
+ }
+
+ public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
+ mv.visitLookupSwitchInsn(dflt, keys, labels);
+
+ if (constructor) {
+ popValue();
+ addBranches(dflt, labels);
+ }
+ }
+
+ public void visitTableSwitchInsn(
+ int min,
+ int max,
+ Label dflt,
+ Label[] labels)
+ {
+ mv.visitTableSwitchInsn(min, max, dflt, labels);
+
+ if (constructor) {
+ popValue();
+ addBranches(dflt, labels);
+ }
+ }
+
+ private void addBranches(Label dflt, Label[] labels) {
+ addBranch(dflt);
+ for (int i = 0; i < labels.length; i++) {
+ addBranch(labels[i]);
+ }
+ }
+
+ private void addBranch(Label label) {
+ if (branches.containsKey(label)) {
+ return;
+ }
+ ArrayList frame = new ArrayList();
+ frame.addAll(stackFrame);
+ branches.put(label, frame);
+ }
+
+ private Object popValue() {
+ return stackFrame.remove(stackFrame.size()-1);
+ }
+
+ private Object peekValue() {
+ return stackFrame.get(stackFrame.size()-1);
+ }
+
+ private void pushValue(Object o) {
+ stackFrame.add(o);
+ }
+
+ /**
+ * Called at the beginning of the method or after super
+ * class class call in the constructor.
+ * <br><br>
+ *
+ * <i>Custom code can use or change all the local variables,
+ * but should not change state of the stack.</i>
+ */
+ protected abstract void onMethodEnter();
+
+ /**
+ * Called before explicit exit from the method using either
+ * return or throw. Top element on the stack contains the
+ * return value or exception instance. For example:
+ *
+ * <pre>
+ * public void onMethodExit(int opcode) {
+ * if(opcode==RETURN) {
+ * visitInsn(ACONST_NULL);
+ * } else if(opcode==ARETURN || opcode==ATHROW) {
+ * dup();
+ * } else {
+ * if(opcode==LRETURN || opcode==DRETURN) {
+ * dup2();
+ * } else {
+ * dup();
+ * }
+ * box(Type.getReturnType(this.methodDesc));
+ * }
+ * visitIntInsn(SIPUSH, opcode);
+ * visitMethodInsn(INVOKESTATIC, owner, "onExit", "(Ljava/lang/Object;I)V");
+ * }
+ *
+ * // an actual call back method
+ * public static void onExit(int opcode, Object param) {
+ * ...
+ * </pre>
+ *
+ * <br><br>
+ *
+ * <i>Custom code can use or change all the local variables,
+ * but should not change state of the stack.</i>
+ *
+ * @param opcode one of the RETURN, IRETURN, FRETURN,
+ * ARETURN, LRETURN, DRETURN or ATHROW
+ *
+ */
+ protected abstract void onMethodExit(int opcode);
+
+ // TODO onException, onMethodCall
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/EmptyVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/EmptyVisitor.java
new file mode 100644
index 000000000..d979659bd
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/EmptyVisitor.java
@@ -0,0 +1,211 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * An empty implementation of the ASM visitor interfaces.
+ *
+ * @author Eric Bruneton
+ */
+public class EmptyVisitor implements
+ ClassVisitor,
+ FieldVisitor,
+ MethodVisitor,
+ AnnotationVisitor
+{
+
+ public void visit(
+ int version,
+ int access,
+ String name,
+ String signature,
+ String superName,
+ String[] interfaces)
+ {
+ }
+
+ public void visitSource(String source, String debug) {
+ }
+
+ public void visitOuterClass(String owner, String name, String desc) {
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return this;
+ }
+
+ public void visitAttribute(Attribute attr) {
+ }
+
+ public void visitInnerClass(
+ String name,
+ String outerName,
+ String innerName,
+ int access)
+ {
+ }
+
+ public FieldVisitor visitField(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ Object value)
+ {
+ return this;
+ }
+
+ public MethodVisitor visitMethod(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ String[] exceptions)
+ {
+ return this;
+ }
+
+ public void visitEnd() {
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ return this;
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ int parameter,
+ String desc,
+ boolean visible)
+ {
+ return this;
+ }
+
+ public void visitCode() {
+ }
+
+ public void visitInsn(int opcode) {
+ }
+
+ public void visitIntInsn(int opcode, int operand) {
+ }
+
+ public void visitVarInsn(int opcode, int var) {
+ }
+
+ public void visitTypeInsn(int opcode, String desc) {
+ }
+
+ public void visitFieldInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ }
+
+ public void visitMethodInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ }
+
+ public void visitJumpInsn(int opcode, Label label) {
+ }
+
+ public void visitLabel(Label label) {
+ }
+
+ public void visitLdcInsn(Object cst) {
+ }
+
+ public void visitIincInsn(int var, int increment) {
+ }
+
+ public void visitTableSwitchInsn(
+ int min,
+ int max,
+ Label dflt,
+ Label labels[])
+ {
+ }
+
+ public void visitLookupSwitchInsn(Label dflt, int keys[], Label labels[]) {
+ }
+
+ public void visitMultiANewArrayInsn(String desc, int dims) {
+ }
+
+ public void visitTryCatchBlock(
+ Label start,
+ Label end,
+ Label handler,
+ String type)
+ {
+ }
+
+ public void visitLocalVariable(
+ String name,
+ String desc,
+ String signature,
+ Label start,
+ Label end,
+ int index)
+ {
+ }
+
+ public void visitLineNumber(int line, Label start) {
+ }
+
+ public void visitMaxs(int maxStack, int maxLocals) {
+ }
+
+ public void visit(String name, Object value) {
+ }
+
+ public void visitEnum(String name, String desc, String value) {
+ }
+
+ public AnnotationVisitor visitAnnotation(String name, String desc) {
+ return this;
+ }
+
+ public AnnotationVisitor visitArray(String name) {
+ return this;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/GeneratorAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/GeneratorAdapter.java
new file mode 100644
index 000000000..aacb27cf5
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/GeneratorAdapter.java
@@ -0,0 +1,1454 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * A {@link org.objectweb.asm.MethodAdapter} with convenient methods to generate
+ * code. For example, using this adapter, the class below
+ *
+ * <pre>
+ * public class Example {
+ * public static void main(String[] args) {
+ * System.out.println(&quot;Hello world!&quot;);
+ * }
+ * }
+ * </pre>
+ *
+ * can be generated as follows:
+ *
+ * <pre>
+ * ClassWriter cw = new ClassWriter(true);
+ * cw.visit(V1_1, ACC_PUBLIC, &quot;Example&quot;, null, &quot;java/lang/Object&quot;, null);
+ *
+ * Method m = Method.getMethod(&quot;void &lt;init&gt; ()&quot;);
+ * GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw);
+ * mg.loadThis();
+ * mg.invokeConstructor(Type.getType(Object.class), m);
+ * mg.returnValue();
+ * mg.endMethod();
+ *
+ * m = Method.getMethod(&quot;void main (String[])&quot;);
+ * mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw);
+ * mg.getStatic(Type.getType(System.class), &quot;out&quot;, Type.getType(PrintStream.class));
+ * mg.push(&quot;Hello world!&quot;);
+ * mg.invokeVirtual(Type.getType(PrintStream.class), Method.getMethod(&quot;void println (String)&quot;));
+ * mg.returnValue();
+ * mg.endMethod();
+ *
+ * cw.visitEnd();
+ * </pre>
+ *
+ * @author Juozas Baliuka
+ * @author Chris Nokleberg
+ * @author Eric Bruneton
+ */
+public class GeneratorAdapter extends LocalVariablesSorter {
+
+ private final static Type BYTE_TYPE = Type.getType("Ljava/lang/Byte;");
+
+ private final static Type BOOLEAN_TYPE = Type.getType("Ljava/lang/Boolean;");
+
+ private final static Type SHORT_TYPE = Type.getType("Ljava/lang/Short;");
+
+ private final static Type CHARACTER_TYPE = Type.getType("Ljava/lang/Character;");
+
+ private final static Type INTEGER_TYPE = Type.getType("Ljava/lang/Integer;");
+
+ private final static Type FLOAT_TYPE = Type.getType("Ljava/lang/Float;");
+
+ private final static Type LONG_TYPE = Type.getType("Ljava/lang/Long;");
+
+ private final static Type DOUBLE_TYPE = Type.getType("Ljava/lang/Double;");
+
+ private final static Type NUMBER_TYPE = Type.getType("Ljava/lang/Number;");
+
+ private final static Type OBJECT_TYPE = Type.getType("Ljava/lang/Object;");
+
+ private final static Method BOOLEAN_VALUE = Method.getMethod("boolean booleanValue()");
+
+ private final static Method CHAR_VALUE = Method.getMethod("char charValue()");
+
+ private final static Method INT_VALUE = Method.getMethod("int intValue()");
+
+ private final static Method FLOAT_VALUE = Method.getMethod("float floatValue()");
+
+ private final static Method LONG_VALUE = Method.getMethod("long longValue()");
+
+ private final static Method DOUBLE_VALUE = Method.getMethod("double doubleValue()");
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int ADD = Opcodes.IADD;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int SUB = Opcodes.ISUB;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int MUL = Opcodes.IMUL;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int DIV = Opcodes.IDIV;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int REM = Opcodes.IREM;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int NEG = Opcodes.INEG;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int SHL = Opcodes.ISHL;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int SHR = Opcodes.ISHR;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int USHR = Opcodes.IUSHR;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int AND = Opcodes.IAND;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int OR = Opcodes.IOR;
+
+ /**
+ * Constant for the {@link #math math} method.
+ */
+ public final static int XOR = Opcodes.IXOR;
+
+ /**
+ * Constant for the {@link #ifCmp ifCmp} method.
+ */
+ public final static int EQ = Opcodes.IFEQ;
+
+ /**
+ * Constant for the {@link #ifCmp ifCmp} method.
+ */
+ public final static int NE = Opcodes.IFNE;
+
+ /**
+ * Constant for the {@link #ifCmp ifCmp} method.
+ */
+ public final static int LT = Opcodes.IFLT;
+
+ /**
+ * Constant for the {@link #ifCmp ifCmp} method.
+ */
+ public final static int GE = Opcodes.IFGE;
+
+ /**
+ * Constant for the {@link #ifCmp ifCmp} method.
+ */
+ public final static int GT = Opcodes.IFGT;
+
+ /**
+ * Constant for the {@link #ifCmp ifCmp} method.
+ */
+ public final static int LE = Opcodes.IFLE;
+
+ /**
+ * Access flags of the method visited by this adapter.
+ */
+ private final int access;
+
+ /**
+ * Return type of the method visited by this adapter.
+ */
+ private final Type returnType;
+
+ /**
+ * Argument types of the method visited by this adapter.
+ */
+ private final Type[] argumentTypes;
+
+ /**
+ * Types of the local variables of the method visited by this adapter.
+ */
+ private final List localTypes;
+
+ /**
+ * Creates a new {@link GeneratorAdapter}.
+ *
+ * @param mv the method visitor to which this adapter delegates calls.
+ * @param access the method's access flags (see {@link Opcodes}).
+ * @param name the method's name.
+ * @param desc the method's descriptor (see {@link Type Type}).
+ */
+ public GeneratorAdapter(
+ MethodVisitor mv,
+ int access,
+ String name,
+ String desc)
+ {
+ super(access, desc, mv);
+ this.access = access;
+ this.returnType = Type.getReturnType(desc);
+ this.argumentTypes = Type.getArgumentTypes(desc);
+ this.localTypes = new ArrayList();
+ }
+
+ /**
+ * Creates a new {@link GeneratorAdapter}.
+ *
+ * @param access access flags of the adapted method.
+ * @param method the adapted method.
+ * @param mv the method visitor to which this adapter delegates calls.
+ */
+ public GeneratorAdapter(
+ final int access,
+ final Method method,
+ final MethodVisitor mv)
+ {
+ super(access, method.getDescriptor(), mv);
+ this.access = access;
+ this.returnType = method.getReturnType();
+ this.argumentTypes = method.getArgumentTypes();
+ this.localTypes = new ArrayList();
+ }
+
+ /**
+ * Creates a new {@link GeneratorAdapter}.
+ *
+ * @param access access flags of the adapted method.
+ * @param method the adapted method.
+ * @param signature the signature of the adapted method (may be
+ * <tt>null</tt>).
+ * @param exceptions the exceptions thrown by the adapted method (may be
+ * <tt>null</tt>).
+ * @param cv the class visitor to which this adapter delegates calls.
+ */
+ public GeneratorAdapter(
+ final int access,
+ final Method method,
+ final String signature,
+ final Type[] exceptions,
+ final ClassVisitor cv)
+ {
+ this(access, method, cv.visitMethod(access,
+ method.getName(),
+ method.getDescriptor(),
+ signature,
+ getInternalNames(exceptions)));
+ }
+
+ /**
+ * Returns the internal names of the given types.
+ *
+ * @param types a set of types.
+ * @return the internal names of the given types.
+ */
+ private static String[] getInternalNames(final Type[] types) {
+ if (types == null) {
+ return null;
+ }
+ String[] names = new String[types.length];
+ for (int i = 0; i < names.length; ++i) {
+ names[i] = types[i].getInternalName();
+ }
+ return names;
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to push constants on the stack
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates the instruction to push the given value on the stack.
+ *
+ * @param value the value to be pushed on the stack.
+ */
+ public void push(final boolean value) {
+ push(value ? 1 : 0);
+ }
+
+ /**
+ * Generates the instruction to push the given value on the stack.
+ *
+ * @param value the value to be pushed on the stack.
+ */
+ public void push(final int value) {
+ if (value >= -1 && value <= 5) {
+ mv.visitInsn(Opcodes.ICONST_0 + value);
+ } else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) {
+ mv.visitIntInsn(Opcodes.BIPUSH, value);
+ } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) {
+ mv.visitIntInsn(Opcodes.SIPUSH, value);
+ } else {
+ mv.visitLdcInsn(new Integer(value));
+ }
+ }
+
+ /**
+ * Generates the instruction to push the given value on the stack.
+ *
+ * @param value the value to be pushed on the stack.
+ */
+ public void push(final long value) {
+ if (value == 0L || value == 1L) {
+ mv.visitInsn(Opcodes.LCONST_0 + (int) value);
+ } else {
+ mv.visitLdcInsn(new Long(value));
+ }
+ }
+
+ /**
+ * Generates the instruction to push the given value on the stack.
+ *
+ * @param value the value to be pushed on the stack.
+ */
+ public void push(final float value) {
+ int bits = Float.floatToIntBits(value);
+ if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2
+ mv.visitInsn(Opcodes.FCONST_0 + (int) value);
+ } else {
+ mv.visitLdcInsn(new Float(value));
+ }
+ }
+
+ /**
+ * Generates the instruction to push the given value on the stack.
+ *
+ * @param value the value to be pushed on the stack.
+ */
+ public void push(final double value) {
+ long bits = Double.doubleToLongBits(value);
+ if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d
+ mv.visitInsn(Opcodes.DCONST_0 + (int) value);
+ } else {
+ mv.visitLdcInsn(new Double(value));
+ }
+ }
+
+ /**
+ * Generates the instruction to push the given value on the stack.
+ *
+ * @param value the value to be pushed on the stack. May be <tt>null</tt>.
+ */
+ public void push(final String value) {
+ if (value == null) {
+ mv.visitInsn(Opcodes.ACONST_NULL);
+ } else {
+ mv.visitLdcInsn(value);
+ }
+ }
+
+ /**
+ * Generates the instruction to push the given value on the stack.
+ *
+ * @param value the value to be pushed on the stack.
+ */
+ public void push(final Type value) {
+ if (value == null) {
+ mv.visitInsn(Opcodes.ACONST_NULL);
+ } else {
+ mv.visitLdcInsn(value);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to load and store method arguments
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the index of the given method argument in the frame's local
+ * variables array.
+ *
+ * @param arg the index of a method argument.
+ * @return the index of the given method argument in the frame's local
+ * variables array.
+ */
+ private int getArgIndex(final int arg) {
+ int index = ((access & Opcodes.ACC_STATIC) == 0 ? 1 : 0);
+ for (int i = 0; i < arg; i++) {
+ index += argumentTypes[i].getSize();
+ }
+ return index;
+ }
+
+ /**
+ * Generates the instruction to push a local variable on the stack.
+ *
+ * @param type the type of the local variable to be loaded.
+ * @param index an index in the frame's local variables array.
+ */
+ private void loadInsn(final Type type, final int index) {
+ mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), index);
+ }
+
+ /**
+ * Generates the instruction to store the top stack value in a local
+ * variable.
+ *
+ * @param type the type of the local variable to be stored.
+ * @param index an index in the frame's local variables array.
+ */
+ private void storeInsn(final Type type, final int index) {
+ mv.visitVarInsn(type.getOpcode(Opcodes.ISTORE), index);
+ }
+
+ /**
+ * Generates the instruction to load 'this' on the stack.
+ */
+ public void loadThis() {
+ if ((access & Opcodes.ACC_STATIC) != 0) {
+ throw new IllegalStateException("no 'this' pointer within static method");
+ }
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ }
+
+ /**
+ * Generates the instruction to load the given method argument on the stack.
+ *
+ * @param arg the index of a method argument.
+ */
+ public void loadArg(final int arg) {
+ loadInsn(argumentTypes[arg], getArgIndex(arg));
+ }
+
+ /**
+ * Generates the instructions to load the given method arguments on the
+ * stack.
+ *
+ * @param arg the index of the first method argument to be loaded.
+ * @param count the number of method arguments to be loaded.
+ */
+ public void loadArgs(final int arg, final int count) {
+ int index = getArgIndex(arg);
+ for (int i = 0; i < count; ++i) {
+ Type t = argumentTypes[arg + i];
+ loadInsn(t, index);
+ index += t.getSize();
+ }
+ }
+
+ /**
+ * Generates the instructions to load all the method arguments on the stack.
+ */
+ public void loadArgs() {
+ loadArgs(0, argumentTypes.length);
+ }
+
+ /**
+ * Generates the instructions to load all the method arguments on the stack,
+ * as a single object array.
+ */
+ public void loadArgArray() {
+ push(argumentTypes.length);
+ newArray(OBJECT_TYPE);
+ for (int i = 0; i < argumentTypes.length; i++) {
+ dup();
+ push(i);
+ loadArg(i);
+ box(argumentTypes[i]);
+ arrayStore(OBJECT_TYPE);
+ }
+ }
+
+ /**
+ * Generates the instruction to store the top stack value in the given
+ * method argument.
+ *
+ * @param arg the index of a method argument.
+ */
+ public void storeArg(final int arg) {
+ storeInsn(argumentTypes[arg], getArgIndex(arg));
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to load and store local variables
+ // ------------------------------------------------------------------------
+
+ /**
+ * Creates a new local variable of the given type.
+ *
+ * @param type the type of the local variable to be created.
+ * @return the identifier of the newly created local variable.
+ */
+ public int newLocal(final Type type) {
+ int local = super.newLocal(type.getSize());
+ setLocalType(local, type);
+ return local;
+ }
+
+ /**
+ * Returns the type of the given local variable.
+ *
+ * @param local a local variable identifier, as returned by {@link #newLocal
+ * newLocal}.
+ * @return the type of the given local variable.
+ */
+ public Type getLocalType(final int local) {
+ return (Type) localTypes.get(local - firstLocal);
+ }
+
+ /**
+ * Sets the current type of the given local variable.
+ *
+ * @param local a local variable identifier, as returned by {@link #newLocal
+ * newLocal}.
+ * @param type the type of the value being stored in the local variable
+ */
+ private void setLocalType(final int local, final Type type) {
+ int index = local - firstLocal;
+ while (localTypes.size() < index + 1)
+ localTypes.add(null);
+ localTypes.set(index, type);
+ }
+
+ /**
+ * Generates the instruction to load the given local variable on the stack.
+ *
+ * @param local a local variable identifier, as returned by {@link #newLocal
+ * newLocal}.
+ */
+ public void loadLocal(final int local) {
+ loadInsn(getLocalType(local), local);
+ }
+
+ /**
+ * Generates the instruction to load the given local variable on the stack.
+ *
+ * @param local a local variable identifier, as returned by {@link #newLocal
+ * newLocal}.
+ * @param type the type of this local variable.
+ */
+ public void loadLocal(final int local, final Type type) {
+ setLocalType(local, type);
+ loadInsn(type, local);
+ }
+
+ /**
+ * Generates the instruction to store the top stack value in the given local
+ * variable.
+ *
+ * @param local a local variable identifier, as returned by {@link #newLocal
+ * newLocal}.
+ */
+ public void storeLocal(final int local) {
+ storeInsn(getLocalType(local), local);
+ }
+
+ /**
+ * Generates the instruction to store the top stack value in the given local
+ * variable.
+ *
+ * @param local a local variable identifier, as returned by {@link #newLocal
+ * newLocal}.
+ * @param type the type of this local variable.
+ */
+ public void storeLocal(final int local, final Type type) {
+ setLocalType(local, type);
+ storeInsn(type, local);
+ }
+
+ /**
+ * Generates the instruction to load an element from an array.
+ *
+ * @param type the type of the array element to be loaded.
+ */
+ public void arrayLoad(final Type type) {
+ mv.visitInsn(type.getOpcode(Opcodes.IALOAD));
+ }
+
+ /**
+ * Generates the instruction to store an element in an array.
+ *
+ * @param type the type of the array element to be stored.
+ */
+ public void arrayStore(final Type type) {
+ mv.visitInsn(type.getOpcode(Opcodes.IASTORE));
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to manage the stack
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates a POP instruction.
+ */
+ public void pop() {
+ mv.visitInsn(Opcodes.POP);
+ }
+
+ /**
+ * Generates a POP2 instruction.
+ */
+ public void pop2() {
+ mv.visitInsn(Opcodes.POP2);
+ }
+
+ /**
+ * Generates a DUP instruction.
+ */
+ public void dup() {
+ mv.visitInsn(Opcodes.DUP);
+ }
+
+ /**
+ * Generates a DUP2 instruction.
+ */
+ public void dup2() {
+ mv.visitInsn(Opcodes.DUP2);
+ }
+
+ /**
+ * Generates a DUP_X1 instruction.
+ */
+ public void dupX1() {
+ mv.visitInsn(Opcodes.DUP_X1);
+ }
+
+ /**
+ * Generates a DUP_X2 instruction.
+ */
+ public void dupX2() {
+ mv.visitInsn(Opcodes.DUP_X2);
+ }
+
+ /**
+ * Generates a DUP2_X1 instruction.
+ */
+ public void dup2X1() {
+ mv.visitInsn(Opcodes.DUP2_X1);
+ }
+
+ /**
+ * Generates a DUP2_X2 instruction.
+ */
+ public void dup2X2() {
+ mv.visitInsn(Opcodes.DUP2_X2);
+ }
+
+ /**
+ * Generates a SWAP instruction.
+ */
+ public void swap() {
+ mv.visitInsn(Opcodes.SWAP);
+ }
+
+ /**
+ * Generates the instructions to swap the top two stack values.
+ *
+ * @param prev type of the top - 1 stack value.
+ * @param type type of the top stack value.
+ */
+ public void swap(final Type prev, final Type type) {
+ if (type.getSize() == 1) {
+ if (prev.getSize() == 1) {
+ swap(); // same as dupX1(), pop();
+ } else {
+ dupX2();
+ pop();
+ }
+ } else {
+ if (prev.getSize() == 1) {
+ dup2X1();
+ pop2();
+ } else {
+ dup2X2();
+ pop2();
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to do mathematical and logical operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates the instruction to do the specified mathematical or logical
+ * operation.
+ *
+ * @param op a mathematical or logical operation. Must be one of ADD, SUB,
+ * MUL, DIV, REM, NEG, SHL, SHR, USHR, AND, OR, XOR.
+ * @param type the type of the operand(s) for this operation.
+ */
+ public void math(final int op, final Type type) {
+ mv.visitInsn(type.getOpcode(op));
+ }
+
+ /**
+ * Generates the instructions to compute the bitwise negation of the top
+ * stack value.
+ */
+ public void not() {
+ mv.visitInsn(Opcodes.ICONST_1);
+ mv.visitInsn(Opcodes.IXOR);
+ }
+
+ /**
+ * Generates the instruction to increment the given local variable.
+ *
+ * @param local the local variable to be incremented.
+ * @param amount the amount by which the local variable must be incremented.
+ */
+ public void iinc(final int local, final int amount) {
+ mv.visitIincInsn(local, amount);
+ }
+
+ /**
+ * Generates the instructions to cast a numerical value from one type to
+ * another.
+ *
+ * @param from the type of the top stack value
+ * @param to the type into which this value must be cast.
+ */
+ public void cast(final Type from, final Type to) {
+ if (from != to) {
+ if (from == Type.DOUBLE_TYPE) {
+ if (to == Type.FLOAT_TYPE) {
+ mv.visitInsn(Opcodes.D2F);
+ } else if (to == Type.LONG_TYPE) {
+ mv.visitInsn(Opcodes.D2L);
+ } else {
+ mv.visitInsn(Opcodes.D2I);
+ cast(Type.INT_TYPE, to);
+ }
+ } else if (from == Type.FLOAT_TYPE) {
+ if (to == Type.DOUBLE_TYPE) {
+ mv.visitInsn(Opcodes.F2D);
+ } else if (to == Type.LONG_TYPE) {
+ mv.visitInsn(Opcodes.F2L);
+ } else {
+ mv.visitInsn(Opcodes.F2I);
+ cast(Type.INT_TYPE, to);
+ }
+ } else if (from == Type.LONG_TYPE) {
+ if (to == Type.DOUBLE_TYPE) {
+ mv.visitInsn(Opcodes.L2D);
+ } else if (to == Type.FLOAT_TYPE) {
+ mv.visitInsn(Opcodes.L2F);
+ } else {
+ mv.visitInsn(Opcodes.L2I);
+ cast(Type.INT_TYPE, to);
+ }
+ } else {
+ if (to == Type.BYTE_TYPE) {
+ mv.visitInsn(Opcodes.I2B);
+ } else if (to == Type.CHAR_TYPE) {
+ mv.visitInsn(Opcodes.I2C);
+ } else if (to == Type.DOUBLE_TYPE) {
+ mv.visitInsn(Opcodes.I2D);
+ } else if (to == Type.FLOAT_TYPE) {
+ mv.visitInsn(Opcodes.I2F);
+ } else if (to == Type.LONG_TYPE) {
+ mv.visitInsn(Opcodes.I2L);
+ } else if (to == Type.SHORT_TYPE) {
+ mv.visitInsn(Opcodes.I2S);
+ }
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to do boxing and unboxing operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates the instructions to box the top stack value. This value is
+ * replaced by its boxed equivalent on top of the stack.
+ *
+ * @param type the type of the top stack value.
+ */
+ public void box(final Type type) {
+ if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
+ return;
+ }
+ if (type == Type.VOID_TYPE) {
+ push((String) null);
+ } else {
+ Type boxed = type;
+ switch (type.getSort()) {
+ case Type.BYTE:
+ boxed = BYTE_TYPE;
+ break;
+ case Type.BOOLEAN:
+ boxed = BOOLEAN_TYPE;
+ break;
+ case Type.SHORT:
+ boxed = SHORT_TYPE;
+ break;
+ case Type.CHAR:
+ boxed = CHARACTER_TYPE;
+ break;
+ case Type.INT:
+ boxed = INTEGER_TYPE;
+ break;
+ case Type.FLOAT:
+ boxed = FLOAT_TYPE;
+ break;
+ case Type.LONG:
+ boxed = LONG_TYPE;
+ break;
+ case Type.DOUBLE:
+ boxed = DOUBLE_TYPE;
+ break;
+ }
+ newInstance(boxed);
+ if (type.getSize() == 2) {
+ // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
+ dupX2();
+ dupX2();
+ pop();
+ } else {
+ // p -> po -> opo -> oop -> o
+ dupX1();
+ swap();
+ }
+ invokeConstructor(boxed, new Method("<init>",
+ Type.VOID_TYPE,
+ new Type[] { type }));
+ }
+ }
+
+ /**
+ * Generates the instructions to unbox the top stack value. This value is
+ * replaced by its unboxed equivalent on top of the stack.
+ *
+ * @param type the type of the top stack value.
+ */
+ public void unbox(final Type type) {
+ Type t = NUMBER_TYPE;
+ Method sig = null;
+ switch (type.getSort()) {
+ case Type.VOID:
+ return;
+ case Type.CHAR:
+ t = CHARACTER_TYPE;
+ sig = CHAR_VALUE;
+ break;
+ case Type.BOOLEAN:
+ t = BOOLEAN_TYPE;
+ sig = BOOLEAN_VALUE;
+ break;
+ case Type.DOUBLE:
+ sig = DOUBLE_VALUE;
+ break;
+ case Type.FLOAT:
+ sig = FLOAT_VALUE;
+ break;
+ case Type.LONG:
+ sig = LONG_VALUE;
+ break;
+ case Type.INT:
+ case Type.SHORT:
+ case Type.BYTE:
+ sig = INT_VALUE;
+ }
+ if (sig == null) {
+ checkCast(type);
+ } else {
+ checkCast(t);
+ invokeVirtual(t, sig);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to jump to other instructions
+ // ------------------------------------------------------------------------
+
+ /**
+ * Creates a new {@link Label}.
+ *
+ * @return a new {@link Label}.
+ */
+ public Label newLabel() {
+ return new Label();
+ }
+
+ /**
+ * Marks the current code position with the given label.
+ *
+ * @param label a label.
+ */
+ public void mark(final Label label) {
+ mv.visitLabel(label);
+ }
+
+ /**
+ * Marks the current code position with a new label.
+ *
+ * @return the label that was created to mark the current code position.
+ */
+ public Label mark() {
+ Label label = new Label();
+ mv.visitLabel(label);
+ return label;
+ }
+
+ /**
+ * Generates the instructions to jump to a label based on the comparison of
+ * the top two stack values.
+ *
+ * @param type the type of the top two stack values.
+ * @param mode how these values must be compared. One of EQ, NE, LT, GE, GT,
+ * LE.
+ * @param label where to jump if the comparison result is <tt>true</tt>.
+ */
+ public void ifCmp(final Type type, final int mode, final Label label) {
+ int intOp = -1;
+ int jumpMode = mode;
+ switch (mode) {
+ case GE:
+ jumpMode = LT;
+ break;
+ case LE:
+ jumpMode = GT;
+ break;
+ }
+ switch (type.getSort()) {
+ case Type.LONG:
+ mv.visitInsn(Opcodes.LCMP);
+ break;
+ case Type.DOUBLE:
+ mv.visitInsn(Opcodes.DCMPG);
+ break;
+ case Type.FLOAT:
+ mv.visitInsn(Opcodes.FCMPG);
+ break;
+ case Type.ARRAY:
+ case Type.OBJECT:
+ switch (mode) {
+ case EQ:
+ mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);
+ return;
+ case NE:
+ mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);
+ return;
+ }
+ throw new IllegalArgumentException("Bad comparison for type "
+ + type);
+ default:
+ switch (mode) {
+ case EQ:
+ intOp = Opcodes.IF_ICMPEQ;
+ break;
+ case NE:
+ intOp = Opcodes.IF_ICMPNE;
+ break;
+ case GE:
+ intOp = Opcodes.IF_ICMPGE;
+ break;
+ case LT:
+ intOp = Opcodes.IF_ICMPLT;
+ break;
+ case LE:
+ intOp = Opcodes.IF_ICMPLE;
+ break;
+ case GT:
+ intOp = Opcodes.IF_ICMPGT;
+ break;
+ }
+ mv.visitJumpInsn(intOp, label);
+ return;
+ }
+ mv.visitJumpInsn(jumpMode, label);
+ }
+
+ /**
+ * Generates the instructions to jump to a label based on the comparison of
+ * the top two integer stack values.
+ *
+ * @param mode how these values must be compared. One of EQ, NE, LT, GE, GT,
+ * LE.
+ * @param label where to jump if the comparison result is <tt>true</tt>.
+ */
+ public void ifICmp(final int mode, final Label label) {
+ ifCmp(Type.INT_TYPE, mode, label);
+ }
+
+ /**
+ * Generates the instructions to jump to a label based on the comparison of
+ * the top integer stack value with zero.
+ *
+ * @param mode how these values must be compared. One of EQ, NE, LT, GE, GT,
+ * LE.
+ * @param label where to jump if the comparison result is <tt>true</tt>.
+ */
+ public void ifZCmp(final int mode, final Label label) {
+ mv.visitJumpInsn(mode, label);
+ }
+
+ /**
+ * Generates the instruction to jump to the given label if the top stack
+ * value is null.
+ *
+ * @param label where to jump if the condition is <tt>true</tt>.
+ */
+ public void ifNull(final Label label) {
+ mv.visitJumpInsn(Opcodes.IFNULL, label);
+ }
+
+ /**
+ * Generates the instruction to jump to the given label if the top stack
+ * value is not null.
+ *
+ * @param label where to jump if the condition is <tt>true</tt>.
+ */
+ public void ifNonNull(final Label label) {
+ mv.visitJumpInsn(Opcodes.IFNONNULL, label);
+ }
+
+ /**
+ * Generates the instruction to jump to the given label.
+ *
+ * @param label where to jump if the condition is <tt>true</tt>.
+ */
+ public void goTo(final Label label) {
+ mv.visitJumpInsn(Opcodes.GOTO, label);
+ }
+
+ /**
+ * Generates a RET instruction.
+ *
+ * @param local a local variable identifier, as returned by {@link #newLocal
+ * newLocal}.
+ */
+ public void ret(final int local) {
+ mv.visitVarInsn(Opcodes.RET, local);
+ }
+
+ /**
+ * Generates the instructions for a switch statement.
+ *
+ * @param keys the switch case keys.
+ * @param generator a generator to generate the code for the switch cases.
+ */
+ public void tableSwitch(
+ final int[] keys,
+ final TableSwitchGenerator generator)
+ {
+ float density;
+ if (keys.length == 0) {
+ density = 0;
+ } else {
+ density = (float) keys.length
+ / (keys[keys.length - 1] - keys[0] + 1);
+ }
+ tableSwitch(keys, generator, density >= 0.5f);
+ }
+
+ /**
+ * Generates the instructions for a switch statement.
+ *
+ * @param keys the switch case keys.
+ * @param generator a generator to generate the code for the switch cases.
+ * @param useTable <tt>true</tt> to use a TABLESWITCH instruction, or
+ * <tt>false</tt> to use a LOOKUPSWITCH instruction.
+ */
+ public void tableSwitch(
+ final int[] keys,
+ final TableSwitchGenerator generator,
+ final boolean useTable)
+ {
+ for (int i = 1; i < keys.length; ++i) {
+ if (keys[i] < keys[i - 1]) {
+ throw new IllegalArgumentException("keys must be sorted ascending");
+ }
+ }
+ Label def = newLabel();
+ Label end = newLabel();
+ if (keys.length > 0) {
+ int len = keys.length;
+ int min = keys[0];
+ int max = keys[len - 1];
+ int range = max - min + 1;
+ if (useTable) {
+ Label[] labels = new Label[range];
+ Arrays.fill(labels, def);
+ for (int i = 0; i < len; ++i) {
+ labels[keys[i] - min] = newLabel();
+ }
+ mv.visitTableSwitchInsn(min, max, def, labels);
+ for (int i = 0; i < range; ++i) {
+ Label label = labels[i];
+ if (label != def) {
+ mark(label);
+ generator.generateCase(i + min, end);
+ }
+ }
+ } else {
+ Label[] labels = new Label[len];
+ for (int i = 0; i < len; ++i) {
+ labels[i] = newLabel();
+ }
+ mv.visitLookupSwitchInsn(def, keys, labels);
+ for (int i = 0; i < len; ++i) {
+ mark(labels[i]);
+ generator.generateCase(keys[i], end);
+ }
+ }
+ }
+ mark(def);
+ generator.generateDefault();
+ mark(end);
+ }
+
+ /**
+ * Generates the instruction to return the top stack value to the caller.
+ */
+ public void returnValue() {
+ mv.visitInsn(returnType.getOpcode(Opcodes.IRETURN));
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to load and store fields
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates a get field or set field instruction.
+ *
+ * @param opcode the instruction's opcode.
+ * @param ownerType the class in which the field is defined.
+ * @param name the name of the field.
+ * @param fieldType the type of the field.
+ */
+ private void fieldInsn(
+ final int opcode,
+ final Type ownerType,
+ final String name,
+ final Type fieldType)
+ {
+ mv.visitFieldInsn(opcode,
+ ownerType.getInternalName(),
+ name,
+ fieldType.getDescriptor());
+ }
+
+ /**
+ * Generates the instruction to push the value of a static field on the
+ * stack.
+ *
+ * @param owner the class in which the field is defined.
+ * @param name the name of the field.
+ * @param type the type of the field.
+ */
+ public void getStatic(final Type owner, final String name, final Type type)
+ {
+ fieldInsn(Opcodes.GETSTATIC, owner, name, type);
+ }
+
+ /**
+ * Generates the instruction to store the top stack value in a static field.
+ *
+ * @param owner the class in which the field is defined.
+ * @param name the name of the field.
+ * @param type the type of the field.
+ */
+ public void putStatic(final Type owner, final String name, final Type type)
+ {
+ fieldInsn(Opcodes.PUTSTATIC, owner, name, type);
+ }
+
+ /**
+ * Generates the instruction to push the value of a non static field on the
+ * stack.
+ *
+ * @param owner the class in which the field is defined.
+ * @param name the name of the field.
+ * @param type the type of the field.
+ */
+ public void getField(final Type owner, final String name, final Type type) {
+ fieldInsn(Opcodes.GETFIELD, owner, name, type);
+ }
+
+ /**
+ * Generates the instruction to store the top stack value in a non static
+ * field.
+ *
+ * @param owner the class in which the field is defined.
+ * @param name the name of the field.
+ * @param type the type of the field.
+ */
+ public void putField(final Type owner, final String name, final Type type) {
+ fieldInsn(Opcodes.PUTFIELD, owner, name, type);
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to invoke methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates an invoke method instruction.
+ *
+ * @param opcode the instruction's opcode.
+ * @param type the class in which the method is defined.
+ * @param method the method to be invoked.
+ */
+ private void invokeInsn(
+ final int opcode,
+ final Type type,
+ final Method method)
+ {
+ String owner = type.getSort() == Type.ARRAY
+ ? type.getDescriptor()
+ : type.getInternalName();
+ mv.visitMethodInsn(opcode,
+ owner,
+ method.getName(),
+ method.getDescriptor());
+ }
+
+ /**
+ * Generates the instruction to invoke a normal method.
+ *
+ * @param owner the class in which the method is defined.
+ * @param method the method to be invoked.
+ */
+ public void invokeVirtual(final Type owner, final Method method) {
+ invokeInsn(Opcodes.INVOKEVIRTUAL, owner, method);
+ }
+
+ /**
+ * Generates the instruction to invoke a constructor.
+ *
+ * @param type the class in which the constructor is defined.
+ * @param method the constructor to be invoked.
+ */
+ public void invokeConstructor(final Type type, final Method method) {
+ invokeInsn(Opcodes.INVOKESPECIAL, type, method);
+ }
+
+ /**
+ * Generates the instruction to invoke a static method.
+ *
+ * @param owner the class in which the method is defined.
+ * @param method the method to be invoked.
+ */
+ public void invokeStatic(final Type owner, final Method method) {
+ invokeInsn(Opcodes.INVOKESTATIC, owner, method);
+ }
+
+ /**
+ * Generates the instruction to invoke an interface method.
+ *
+ * @param owner the class in which the method is defined.
+ * @param method the method to be invoked.
+ */
+ public void invokeInterface(final Type owner, final Method method) {
+ invokeInsn(Opcodes.INVOKEINTERFACE, owner, method);
+ }
+
+ // ------------------------------------------------------------------------
+ // Instructions to create objects and arrays
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates a type dependent instruction.
+ *
+ * @param opcode the instruction's opcode.
+ * @param type the instruction's operand.
+ */
+ private void typeInsn(final int opcode, final Type type) {
+ String desc;
+ if (type.getSort() == Type.ARRAY) {
+ desc = type.getDescriptor();
+ } else {
+ desc = type.getInternalName();
+ }
+ mv.visitTypeInsn(opcode, desc);
+ }
+
+ /**
+ * Generates the instruction to create a new object.
+ *
+ * @param type the class of the object to be created.
+ */
+ public void newInstance(final Type type) {
+ typeInsn(Opcodes.NEW, type);
+ }
+
+ /**
+ * Generates the instruction to create a new array.
+ *
+ * @param type the type of the array elements.
+ */
+ public void newArray(final Type type) {
+ int typ;
+ switch (type.getSort()) {
+ case Type.BOOLEAN:
+ typ = Opcodes.T_BOOLEAN;
+ break;
+ case Type.CHAR:
+ typ = Opcodes.T_CHAR;
+ break;
+ case Type.BYTE:
+ typ = Opcodes.T_BYTE;
+ break;
+ case Type.SHORT:
+ typ = Opcodes.T_SHORT;
+ break;
+ case Type.INT:
+ typ = Opcodes.T_INT;
+ break;
+ case Type.FLOAT:
+ typ = Opcodes.T_FLOAT;
+ break;
+ case Type.LONG:
+ typ = Opcodes.T_LONG;
+ break;
+ case Type.DOUBLE:
+ typ = Opcodes.T_DOUBLE;
+ break;
+ default:
+ typeInsn(Opcodes.ANEWARRAY, type);
+ return;
+ }
+ mv.visitIntInsn(Opcodes.NEWARRAY, typ);
+ }
+
+ // ------------------------------------------------------------------------
+ // Miscelaneous instructions
+ // ------------------------------------------------------------------------
+
+ /**
+ * Generates the instruction to compute the length of an array.
+ */
+ public void arrayLength() {
+ mv.visitInsn(Opcodes.ARRAYLENGTH);
+ }
+
+ /**
+ * Generates the instruction to throw an exception.
+ */
+ public void throwException() {
+ mv.visitInsn(Opcodes.ATHROW);
+ }
+
+ /**
+ * Generates the instructions to create and throw an exception. The
+ * exception class must have a constructor with a single String argument.
+ *
+ * @param type the class of the exception to be thrown.
+ * @param msg the detailed message of the exception.
+ */
+ public void throwException(final Type type, final String msg) {
+ newInstance(type);
+ dup();
+ push(msg);
+ invokeConstructor(type, Method.getMethod("void <init> (String)"));
+ throwException();
+ }
+
+ /**
+ * Generates the instruction to check that the top stack value is of the
+ * given type.
+ *
+ * @param type a class or interface type.
+ */
+ public void checkCast(final Type type) {
+ if (!type.equals(OBJECT_TYPE)) {
+ typeInsn(Opcodes.CHECKCAST, type);
+ }
+ }
+
+ /**
+ * Generates the instruction to test if the top stack value is of the given
+ * type.
+ *
+ * @param type a class or interface type.
+ */
+ public void instanceOf(final Type type) {
+ typeInsn(Opcodes.INSTANCEOF, type);
+ }
+
+ /**
+ * Generates the instruction to get the monitor of the top stack value.
+ */
+ public void monitorEnter() {
+ mv.visitInsn(Opcodes.MONITORENTER);
+ }
+
+ /**
+ * Generates the instruction to release the monitor of the top stack value.
+ */
+ public void monitorExit() {
+ mv.visitInsn(Opcodes.MONITOREXIT);
+ }
+
+ // ------------------------------------------------------------------------
+ // Non instructions
+ // ------------------------------------------------------------------------
+
+ /**
+ * Marks the end of the visited method.
+ */
+ public void endMethod() {
+ if ((access & Opcodes.ACC_ABSTRACT) == 0) {
+ mv.visitMaxs(0, 0);
+ }
+ }
+
+ /**
+ * Marks the start of an exception handler.
+ *
+ * @param start beginning of the exception handler's scope (inclusive).
+ * @param end end of the exception handler's scope (exclusive).
+ * @param exception internal name of the type of exceptions handled by the
+ * handler.
+ */
+ public void catchException(
+ final Label start,
+ final Label end,
+ final Type exception)
+ {
+ mv.visitTryCatchBlock(start, end, mark(), exception.getInternalName());
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/LocalVariablesSorter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/LocalVariablesSorter.java
new file mode 100644
index 000000000..bfc873247
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/LocalVariablesSorter.java
@@ -0,0 +1,136 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodAdapter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * A {@link MethodAdapter} that renumbers local variables in their order of
+ * appearance. This adapter allows one to easily add new local variables to a
+ * method.
+ *
+ * @author Chris Nokleberg
+ * @author Eric Bruneton
+ */
+public class LocalVariablesSorter extends MethodAdapter {
+
+ /**
+ * Mapping from old to new local variable indexes. A local variable at index
+ * i of size 1 is remapped to 'mapping[2*i]', while a local variable at
+ * index i of size 2 is remapped to 'mapping[2*i+1]'.
+ */
+ private int[] mapping = new int[40];
+
+ protected final int firstLocal;
+
+ private int nextLocal;
+
+ public LocalVariablesSorter(
+ final int access,
+ final String desc,
+ final MethodVisitor mv)
+ {
+ super(mv);
+ Type[] args = Type.getArgumentTypes(desc);
+ nextLocal = ((Opcodes.ACC_STATIC & access) != 0) ? 0 : 1;
+ for (int i = 0; i < args.length; i++) {
+ nextLocal += args[i].getSize();
+ }
+ firstLocal = nextLocal;
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ int size;
+ switch (opcode) {
+ case Opcodes.LLOAD:
+ case Opcodes.LSTORE:
+ case Opcodes.DLOAD:
+ case Opcodes.DSTORE:
+ size = 2;
+ break;
+ default:
+ size = 1;
+ }
+ mv.visitVarInsn(opcode, remap(var, size));
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ mv.visitIincInsn(remap(var, 1), increment);
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ mv.visitMaxs(maxStack, nextLocal);
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ int size = "J".equals(desc) || "D".equals(desc) ? 2 : 1;
+ mv.visitLocalVariable(name, desc, signature, start, end, remap(index, size));
+ }
+
+ // -------------
+
+ protected int newLocal(final int size) {
+ int var = nextLocal;
+ nextLocal += size;
+ return var;
+ }
+
+ private int remap(final int var, final int size) {
+ if (var < firstLocal) {
+ return var;
+ }
+ int key = 2 * var + size - 1;
+ int length = mapping.length;
+ if (key >= length) {
+ int[] newMapping = new int[Math.max(2 * length, key + 1)];
+ System.arraycopy(mapping, 0, newMapping, 0, length);
+ mapping = newMapping;
+ }
+ int value = mapping[key];
+ if (value == 0) {
+ value = nextLocal + 1;
+ mapping[key] = value;
+ nextLocal += size;
+ }
+ return value - 1;
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/Method.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/Method.java
new file mode 100644
index 000000000..c5ce31407
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/Method.java
@@ -0,0 +1,220 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.objectweb.asm.Type;
+
+/**
+ * A named method descriptor.
+ *
+ * @author Juozas Baliuka
+ * @author Chris Nokleberg
+ * @author Eric Bruneton
+ */
+public class Method {
+
+ /**
+ * The method name.
+ */
+ private final String name;
+
+ /**
+ * The method descriptor.
+ */
+ private final String desc;
+
+ /**
+ * Maps primitive Java type names to their descriptors.
+ */
+ private final static Map DESCRIPTORS;
+
+ static {
+ DESCRIPTORS = new HashMap();
+ DESCRIPTORS.put("void", "V");
+ DESCRIPTORS.put("byte", "B");
+ DESCRIPTORS.put("char", "C");
+ DESCRIPTORS.put("double", "D");
+ DESCRIPTORS.put("float", "F");
+ DESCRIPTORS.put("int", "I");
+ DESCRIPTORS.put("long", "J");
+ DESCRIPTORS.put("short", "S");
+ DESCRIPTORS.put("boolean", "Z");
+ }
+
+ /**
+ * Creates a new {@link Method}.
+ *
+ * @param name the method's name.
+ * @param desc the method's descriptor.
+ */
+ public Method(final String name, final String desc) {
+ this.name = name;
+ this.desc = desc;
+ }
+
+ /**
+ * Creates a new {@link Method}.
+ *
+ * @param name the method's name.
+ * @param returnType the method's return type.
+ * @param argumentTypes the method's argument types.
+ */
+ public Method(
+ final String name,
+ final Type returnType,
+ final Type[] argumentTypes)
+ {
+ this(name, Type.getMethodDescriptor(returnType, argumentTypes));
+ }
+
+ /**
+ * Returns a {@link Method} corresponding to the given Java method
+ * declaration.
+ *
+ * @param method a Java method declaration, without argument names, of the
+ * form "returnType name (argumentType1, ... argumentTypeN)", where
+ * the types are in plain Java (e.g. "int", "float",
+ * "java.util.List", ...).
+ * @return a {@link Method} corresponding to the given Java method
+ * declaration.
+ * @throws IllegalArgumentException if <code>method</code> could not get
+ * parsed.
+ */
+ public static Method getMethod(final String method)
+ throws IllegalArgumentException
+ {
+ int space = method.indexOf(' ');
+ int start = method.indexOf('(', space) + 1;
+ int end = method.indexOf(')', start);
+ if (space == -1 || start == -1 || end == -1) {
+ throw new IllegalArgumentException();
+ }
+ // TODO: Check validity of returnType, methodName and arguments.
+ String returnType = method.substring(0, space);
+ String methodName = method.substring(space + 1, start - 1).trim();
+ StringBuffer sb = new StringBuffer();
+ sb.append('(');
+ int p;
+ do {
+ p = method.indexOf(',', start);
+ if (p == -1) {
+ sb.append(map(method.substring(start, end).trim()));
+ } else {
+ sb.append(map(method.substring(start, p).trim()));
+ start = p + 1;
+ }
+ } while (p != -1);
+ sb.append(')');
+ sb.append(map(returnType));
+ return new Method(methodName, sb.toString());
+ }
+
+ private static String map(final String type) {
+ if (type.equals("")) {
+ return type;
+ }
+
+ StringBuffer sb = new StringBuffer();
+ int index = 0;
+ while ((index = type.indexOf("[]", index) + 1) > 0) {
+ sb.append('[');
+ }
+
+ String t = type.substring(0, type.length() - sb.length() * 2);
+ String desc = (String) DESCRIPTORS.get(t);
+ if (desc != null) {
+ sb.append(desc);
+ } else {
+ sb.append('L');
+ if (t.indexOf('.') < 0) {
+ sb.append("java/lang/" + t);
+ } else {
+ sb.append(t.replace('.', '/'));
+ }
+ sb.append(';');
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Returns the name of the method described by this object.
+ *
+ * @return the name of the method described by this object.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the descriptor of the method described by this object.
+ *
+ * @return the descriptor of the method described by this object.
+ */
+ public String getDescriptor() {
+ return desc;
+ }
+
+ /**
+ * Returns the return type of the method described by this object.
+ *
+ * @return the return type of the method described by this object.
+ */
+ public Type getReturnType() {
+ return Type.getReturnType(desc);
+ }
+
+ /**
+ * Returns the argument types of the method described by this object.
+ *
+ * @return the argument types of the method described by this object.
+ */
+ public Type[] getArgumentTypes() {
+ return Type.getArgumentTypes(desc);
+ }
+
+ public String toString() {
+ return name + desc;
+ }
+
+ public boolean equals(final Object o) {
+ if (!(o instanceof Method)) {
+ return false;
+ }
+ Method other = (Method) o;
+ return name.equals(other.name) && desc.equals(other.desc);
+ }
+
+ public int hashCode() {
+ return name.hashCode() ^ desc.hashCode();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.java
new file mode 100644
index 000000000..3932a01ad
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.java
@@ -0,0 +1,490 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * A {@link ClassAdapter} that adds a serial version unique identifier to a
+ * class if missing. Here is typical usage of this class:
+ *
+ * <pre>
+ * ClassWriter cw = new ClassWriter(...);
+ * ClassVisitor sv = new SerialVersionUIDAdder(cw);
+ * ClassVisitor ca = new MyClassAdapter(sv);
+ * new ClassReader(orginalClass).accept(ca, false);
+ * </pre>
+ *
+ * The SVUID algorithm can be found <a href=
+ * "http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/class.html"
+ * >http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/class.html</a>:
+ *
+ * <pre>
+ * The serialVersionUID is computed using the signature of a stream of bytes
+ * that reflect the class definition. The National Institute of Standards and
+ * Technology (NIST) Secure Hash Algorithm (SHA-1) is used to compute a
+ * signature for the stream. The first two 32-bit quantities are used to form a
+ * 64-bit hash. A java.lang.DataOutputStream is used to convert primitive data
+ * types to a sequence of bytes. The values input to the stream are defined by
+ * the Java Virtual Machine (VM) specification for classes.
+ *
+ * The sequence of items in the stream is as follows:
+ *
+ * 1. The class name written using UTF encoding.
+ * 2. The class modifiers written as a 32-bit integer.
+ * 3. The name of each interface sorted by name written using UTF encoding.
+ * 4. For each field of the class sorted by field name (except private static
+ * and private transient fields):
+ * 1. The name of the field in UTF encoding.
+ * 2. The modifiers of the field written as a 32-bit integer.
+ * 3. The descriptor of the field in UTF encoding
+ * 5. If a class initializer exists, write out the following:
+ * 1. The name of the method, &lt;clinit&gt;, in UTF encoding.
+ * 2. The modifier of the method, java.lang.reflect.Modifier.STATIC,
+ * written as a 32-bit integer.
+ * 3. The descriptor of the method, ()V, in UTF encoding.
+ * 6. For each non-private constructor sorted by method name and signature:
+ * 1. The name of the method, &lt;init&gt;, in UTF encoding.
+ * 2. The modifiers of the method written as a 32-bit integer.
+ * 3. The descriptor of the method in UTF encoding.
+ * 7. For each non-private method sorted by method name and signature:
+ * 1. The name of the method in UTF encoding.
+ * 2. The modifiers of the method written as a 32-bit integer.
+ * 3. The descriptor of the method in UTF encoding.
+ * 8. The SHA-1 algorithm is executed on the stream of bytes produced by
+ * DataOutputStream and produces five 32-bit values sha[0..4].
+ *
+ * 9. The hash value is assembled from the first and second 32-bit values of
+ * the SHA-1 message digest. If the result of the message digest, the five
+ * 32-bit words H0 H1 H2 H3 H4, is in an array of five int values named
+ * sha, the hash value would be computed as follows:
+ *
+ * long hash = ((sha[0] &gt;&gt;&gt; 24) &amp; 0xFF) |
+ * ((sha[0] &gt;&gt;&gt; 16) &amp; 0xFF) &lt;&lt; 8 |
+ * ((sha[0] &gt;&gt;&gt; 8) &amp; 0xFF) &lt;&lt; 16 |
+ * ((sha[0] &gt;&gt;&gt; 0) &amp; 0xFF) &lt;&lt; 24 |
+ * ((sha[1] &gt;&gt;&gt; 24) &amp; 0xFF) &lt;&lt; 32 |
+ * ((sha[1] &gt;&gt;&gt; 16) &amp; 0xFF) &lt;&lt; 40 |
+ * ((sha[1] &gt;&gt;&gt; 8) &amp; 0xFF) &lt;&lt; 48 |
+ * ((sha[1] &gt;&gt;&gt; 0) &amp; 0xFF) &lt;&lt; 56;
+ * </pre>
+ *
+ * @author Rajendra Inamdar, Vishal Vishnoi
+ */
+public class SerialVersionUIDAdder extends ClassAdapter {
+
+ /**
+ * Flag that indicates if we need to compute SVUID.
+ */
+ protected boolean computeSVUID;
+
+ /**
+ * Set to true if the class already has SVUID.
+ */
+ protected boolean hasSVUID;
+
+ /**
+ * Classes access flags.
+ */
+ protected int access;
+
+ /**
+ * Internal name of the class
+ */
+ protected String name;
+
+ /**
+ * Interfaces implemented by the class.
+ */
+ protected String[] interfaces;
+
+ /**
+ * Collection of fields. (except private static and private transient
+ * fields)
+ */
+ protected Collection svuidFields;
+
+ /**
+ * Set to true if the class has static initializer.
+ */
+ protected boolean hasStaticInitializer;
+
+ /**
+ * Collection of non-private constructors.
+ */
+ protected Collection svuidConstructors;
+
+ /**
+ * Collection of non-private methods.
+ */
+ protected Collection svuidMethods;
+
+ /**
+ * Creates a new {@link SerialVersionUIDAdder}.
+ *
+ * @param cv a {@link ClassVisitor} to which this visitor will delegate
+ * calls.
+ */
+ public SerialVersionUIDAdder(final ClassVisitor cv) {
+ super(cv);
+ svuidFields = new ArrayList();
+ svuidConstructors = new ArrayList();
+ svuidMethods = new ArrayList();
+ }
+
+ // ------------------------------------------------------------------------
+ // Overriden methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * Visit class header and get class name, access , and intefraces
+ * informatoin (step 1,2, and 3) for SVUID computation.
+ */
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0;
+
+ if (computeSVUID) {
+ this.name = name;
+ this.access = access;
+ this.interfaces = interfaces;
+ }
+
+ super.visit(version, access, name, signature, superName, interfaces);
+ }
+
+ /*
+ * Visit the methods and get constructor and method information (step 5 and
+ * 7). Also determince if there is a class initializer (step 6).
+ */
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ if (computeSVUID) {
+ if (name.equals("<clinit>")) {
+ hasStaticInitializer = true;
+ }
+ /*
+ * Remembers non private constructors and methods for SVUID
+ * computation For constructor and method modifiers, only the
+ * ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
+ * ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and ACC_STRICT flags
+ * are used.
+ */
+ int mods = access
+ & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE
+ | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
+ | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED
+ | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT);
+
+ // all non private methods
+ if ((access & Opcodes.ACC_PRIVATE) == 0) {
+ if (name.equals("<init>")) {
+ svuidConstructors.add(new Item(name, mods, desc));
+ } else if (!name.equals("<clinit>")) {
+ svuidMethods.add(new Item(name, mods, desc));
+ }
+ }
+ }
+
+ return cv.visitMethod(access, name, desc, signature, exceptions);
+ }
+
+ /*
+ * Gets class field information for step 4 of the alogrithm. Also determines
+ * if the class already has a SVUID.
+ */
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ if (computeSVUID) {
+ if (name.equals("serialVersionUID")) {
+ // since the class already has SVUID, we won't be computing it.
+ computeSVUID = false;
+ hasSVUID = true;
+ }
+ /*
+ * Remember field for SVUID computation For field modifiers, only
+ * the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC,
+ * ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when
+ * computing serialVersionUID values.
+ */
+ int mods = access
+ & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE
+ | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
+ | Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT);
+
+ if (((access & Opcodes.ACC_PRIVATE) == 0)
+ || ((access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0))
+ {
+ svuidFields.add(new Item(name, mods, desc));
+ }
+ }
+
+ return super.visitField(access, name, desc, signature, value);
+ }
+
+ /*
+ * Add the SVUID if class doesn't have one
+ */
+ public void visitEnd() {
+ // compute SVUID and add it to the class
+ if (computeSVUID && !hasSVUID) {
+ try {
+ cv.visitField(Opcodes.ACC_FINAL + Opcodes.ACC_STATIC,
+ "serialVersionUID",
+ "J",
+ null,
+ new Long(computeSVUID()));
+ } catch (Throwable e) {
+ throw new RuntimeException("Error while computing SVUID for "
+ + name, e);
+ }
+ }
+
+ super.visitEnd();
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the value of SVUID if the class doesn't have one already. Please
+ * note that 0 is returned if the class already has SVUID, thus use
+ * <code>isHasSVUID</code> to determine if the class already had an SVUID.
+ *
+ * @return Returns the serial version UID
+ * @throws IOException
+ */
+ protected long computeSVUID() throws IOException {
+ if (hasSVUID) {
+ return 0;
+ }
+
+ ByteArrayOutputStream bos = null;
+ DataOutputStream dos = null;
+ long svuid = 0;
+
+ try {
+ bos = new ByteArrayOutputStream();
+ dos = new DataOutputStream(bos);
+
+ /*
+ * 1. The class name written using UTF encoding.
+ */
+ dos.writeUTF(name.replace('/', '.'));
+
+ /*
+ * 2. The class modifiers written as a 32-bit integer.
+ */
+ dos.writeInt(access
+ & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL
+ | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT));
+
+ /*
+ * 3. The name of each interface sorted by name written using UTF
+ * encoding.
+ */
+ Arrays.sort(interfaces);
+ for (int i = 0; i < interfaces.length; i++) {
+ dos.writeUTF(interfaces[i].replace('/', '.'));
+ }
+
+ /*
+ * 4. For each field of the class sorted by field name (except
+ * private static and private transient fields):
+ *
+ * 1. The name of the field in UTF encoding. 2. The modifiers of the
+ * field written as a 32-bit integer. 3. The descriptor of the field
+ * in UTF encoding
+ *
+ * Note that field signatutes are not dot separated. Method and
+ * constructor signatures are dot separated. Go figure...
+ */
+ writeItems(svuidFields, dos, false);
+
+ /*
+ * 5. If a class initializer exists, write out the following: 1. The
+ * name of the method, <clinit>, in UTF encoding. 2. The modifier of
+ * the method, java.lang.reflect.Modifier.STATIC, written as a
+ * 32-bit integer. 3. The descriptor of the method, ()V, in UTF
+ * encoding.
+ */
+ if (hasStaticInitializer) {
+ dos.writeUTF("<clinit>");
+ dos.writeInt(Opcodes.ACC_STATIC);
+ dos.writeUTF("()V");
+ } // if..
+
+ /*
+ * 6. For each non-private constructor sorted by method name and
+ * signature: 1. The name of the method, <init>, in UTF encoding. 2.
+ * The modifiers of the method written as a 32-bit integer. 3. The
+ * descriptor of the method in UTF encoding.
+ */
+ writeItems(svuidConstructors, dos, true);
+
+ /*
+ * 7. For each non-private method sorted by method name and
+ * signature: 1. The name of the method in UTF encoding. 2. The
+ * modifiers of the method written as a 32-bit integer. 3. The
+ * descriptor of the method in UTF encoding.
+ */
+ writeItems(svuidMethods, dos, true);
+
+ dos.flush();
+
+ /*
+ * 8. The SHA-1 algorithm is executed on the stream of bytes
+ * produced by DataOutputStream and produces five 32-bit values
+ * sha[0..4].
+ */
+ byte[] hashBytes = computeSHAdigest(bos.toByteArray());
+
+ /*
+ * 9. The hash value is assembled from the first and second 32-bit
+ * values of the SHA-1 message digest. If the result of the message
+ * digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of
+ * five int values named sha, the hash value would be computed as
+ * follows:
+ *
+ * long hash = ((sha[0] >>> 24) & 0xFF) | ((sha[0] >>> 16) & 0xFF) <<
+ * 8 | ((sha[0] >>> 8) & 0xFF) << 16 | ((sha[0] >>> 0) & 0xFF) <<
+ * 24 | ((sha[1] >>> 24) & 0xFF) << 32 | ((sha[1] >>> 16) & 0xFF) <<
+ * 40 | ((sha[1] >>> 8) & 0xFF) << 48 | ((sha[1] >>> 0) & 0xFF) <<
+ * 56;
+ */
+ for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) {
+ svuid = (svuid << 8) | (hashBytes[i] & 0xFF);
+ }
+ } finally {
+ // close the stream (if open)
+ if (dos != null) {
+ dos.close();
+ }
+ }
+
+ return svuid;
+ }
+
+ /**
+ * Returns the SHA-1 message digest of the given value.
+ *
+ * @param value the value whose SHA message digest must be computed.
+ * @return the SHA-1 message digest of the given value.
+ */
+ protected byte[] computeSHAdigest(byte[] value) {
+ try {
+ return MessageDigest.getInstance("SHA").digest(value);
+ } catch (Exception e) {
+ throw new UnsupportedOperationException(e);
+ }
+ }
+
+ /**
+ * Sorts the items in the collection and writes it to the data output stream
+ *
+ * @param itemCollection collection of items
+ * @param dos a <code>DataOutputStream</code> value
+ * @param dotted a <code>boolean</code> value
+ * @exception IOException if an error occurs
+ */
+ private void writeItems(
+ final Collection itemCollection,
+ final DataOutputStream dos,
+ final boolean dotted) throws IOException
+ {
+ int size = itemCollection.size();
+ Item items[] = (Item[]) itemCollection.toArray(new Item[size]);
+ Arrays.sort(items);
+ for (int i = 0; i < size; i++) {
+ dos.writeUTF(items[i].name);
+ dos.writeInt(items[i].access);
+ dos.writeUTF(dotted
+ ? items[i].desc.replace('/', '.')
+ : items[i].desc);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Inner classes
+ // ------------------------------------------------------------------------
+
+ static class Item implements Comparable {
+
+ String name;
+
+ int access;
+
+ String desc;
+
+ Item(final String name, final int access, final String desc) {
+ this.name = name;
+ this.access = access;
+ this.desc = desc;
+ }
+
+ public int compareTo(final Object o) {
+ Item other = (Item) o;
+ int retVal = name.compareTo(other.name);
+ if (retVal == 0) {
+ retVal = desc.compareTo(other.desc);
+ }
+ return retVal;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/StaticInitMerger.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/StaticInitMerger.java
new file mode 100644
index 000000000..2af409e87
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/StaticInitMerger.java
@@ -0,0 +1,99 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * A {@link ClassAdapter} that merges clinit methods into a single one.
+ *
+ * @author Eric Bruneton
+ */
+public class StaticInitMerger extends ClassAdapter {
+
+ private String name;
+
+ private MethodVisitor clinit;
+
+ private String prefix;
+
+ private int counter;
+
+ public StaticInitMerger(final String prefix, final ClassVisitor cv) {
+ super(cv);
+ this.prefix = prefix;
+ }
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ cv.visit(version, access, name, signature, superName, interfaces);
+ this.name = name;
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ MethodVisitor mv;
+ if (name.equals("<clinit>")) {
+ int a = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC;
+ String n = prefix + counter++;
+ mv = cv.visitMethod(a, n, desc, signature, exceptions);
+
+ if (clinit == null) {
+ clinit = cv.visitMethod(a, name, desc, null, null);
+ }
+ clinit.visitMethodInsn(Opcodes.INVOKESTATIC, this.name, n, desc);
+ } else {
+ mv = cv.visitMethod(access, name, desc, signature, exceptions);
+ }
+ return mv;
+ }
+
+ public void visitEnd() {
+ if (clinit != null) {
+ clinit.visitInsn(Opcodes.RETURN);
+ clinit.visitMaxs(0, 0);
+ }
+ cv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/TableSwitchGenerator.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/TableSwitchGenerator.java
new file mode 100644
index 000000000..c90a9cabf
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/commons/TableSwitchGenerator.java
@@ -0,0 +1,55 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.commons;
+
+import org.objectweb.asm.Label;
+
+/**
+ * A code generator for switch statements.
+ *
+ * @author Juozas Baliuka
+ * @author Chris Nokleberg
+ * @author Eric Bruneton
+ */
+public interface TableSwitchGenerator {
+
+ /**
+ * Generates the code for a switch case.
+ *
+ * @param key the switch case key.
+ * @param end a label that corresponds to the end of the switch statement.
+ */
+ void generateCase(int key, Label end);
+
+ /**
+ * Generates the code for the default switch case.
+ */
+ void generateDefault();
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.java
new file mode 100644
index 000000000..5bceca157
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.java
@@ -0,0 +1,150 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Type;
+
+/**
+ * An {@link AnnotationVisitor} that collects the {@link Constant}s of the
+ * annotations it visits.
+ *
+ * @author Eric Bruneton
+ */
+public class AnnotationConstantsCollector implements AnnotationVisitor {
+
+ private AnnotationVisitor av;
+
+ private ConstantPool cp;
+
+ public AnnotationConstantsCollector(
+ final AnnotationVisitor av,
+ final ConstantPool cp)
+ {
+ this.av = av;
+ this.cp = cp;
+ }
+
+ public void visit(final String name, final Object value) {
+ if (name != null) {
+ cp.newUTF8(name);
+ }
+ if (value instanceof Byte) {
+ cp.newInteger(((Byte) value).byteValue());
+ } else if (value instanceof Boolean) {
+ cp.newInteger(((Boolean) value).booleanValue() ? 1 : 0);
+ } else if (value instanceof Character) {
+ cp.newInteger(((Character) value).charValue());
+ } else if (value instanceof Short) {
+ cp.newInteger(((Short) value).shortValue());
+ } else if (value instanceof Type) {
+ cp.newUTF8(((Type) value).getDescriptor());
+ } else if (value instanceof byte[]) {
+ byte[] v = (byte[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newInteger(v[i]);
+ }
+ } else if (value instanceof boolean[]) {
+ boolean[] v = (boolean[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newInteger(v[i] ? 1 : 0);
+ }
+ } else if (value instanceof short[]) {
+ short[] v = (short[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newInteger(v[i]);
+ }
+ } else if (value instanceof char[]) {
+ char[] v = (char[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newInteger(v[i]);
+ }
+ } else if (value instanceof int[]) {
+ int[] v = (int[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newInteger(v[i]);
+ }
+ } else if (value instanceof long[]) {
+ long[] v = (long[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newLong(v[i]);
+ }
+ } else if (value instanceof float[]) {
+ float[] v = (float[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newFloat(v[i]);
+ }
+ } else if (value instanceof double[]) {
+ double[] v = (double[]) value;
+ for (int i = 0; i < v.length; i++) {
+ cp.newDouble(v[i]);
+ }
+ } else {
+ cp.newConst(value);
+ }
+ av.visit(name, value);
+ }
+
+ public void visitEnum(
+ final String name,
+ final String desc,
+ final String value)
+ {
+ if (name != null) {
+ cp.newUTF8(name);
+ }
+ cp.newUTF8(desc);
+ cp.newUTF8(value);
+ av.visitEnum(name, desc, value);
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String name,
+ final String desc)
+ {
+ if (name != null) {
+ cp.newUTF8(name);
+ }
+ cp.newUTF8(desc);
+ return new AnnotationConstantsCollector(av.visitAnnotation(name, desc),
+ cp);
+ }
+
+ public AnnotationVisitor visitArray(final String name) {
+ if (name != null) {
+ cp.newUTF8(name);
+ }
+ return new AnnotationConstantsCollector(av.visitArray(name), cp);
+ }
+
+ public void visitEnd() {
+ av.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.java
new file mode 100644
index 000000000..4a6efe5d0
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.java
@@ -0,0 +1,212 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * A {@link ClassVisitor} that collects the {@link Constant}s of the classes it
+ * visits.
+ *
+ * @author Eric Bruneton
+ */
+public class ClassConstantsCollector extends ClassAdapter {
+
+ private ConstantPool cp;
+
+ public ClassConstantsCollector(final ClassVisitor cv, final ConstantPool cp)
+ {
+ super(cv);
+ this.cp = cp;
+ }
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ cp.newUTF8("Deprecated");
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
+ cp.newUTF8("Synthetic");
+ }
+ cp.newClass(name);
+ if (signature != null) {
+ cp.newUTF8("Signature");
+ cp.newUTF8(signature);
+ }
+ if (superName != null) {
+ cp.newClass(superName);
+ }
+ if (interfaces != null) {
+ for (int i = 0; i < interfaces.length; ++i) {
+ cp.newClass(interfaces[i]);
+ }
+ }
+ cv.visit(version, access, name, signature, superName, interfaces);
+ }
+
+ public void visitSource(final String source, final String debug) {
+ if (source != null) {
+ cp.newUTF8("SourceFile");
+ cp.newUTF8(source);
+ }
+ if (debug != null) {
+ cp.newUTF8("SourceDebugExtension");
+ }
+ cv.visitSource(source, debug);
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ cp.newUTF8("EnclosingMethod");
+ cp.newClass(owner);
+ if (name != null && desc != null) {
+ cp.newNameType(name, desc);
+ }
+ cv.visitOuterClass(owner, name, desc);
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ cp.newUTF8(desc);
+ if (visible) {
+ cp.newUTF8("RuntimeVisibleAnnotations");
+ } else {
+ cp.newUTF8("RuntimeInvisibleAnnotations");
+ }
+ return new AnnotationConstantsCollector(cv.visitAnnotation(desc,
+ visible), cp);
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ // can do nothing
+ cv.visitAttribute(attr);
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ cp.newUTF8("InnerClasses");
+ if (name != null) {
+ cp.newClass(name);
+ }
+ if (outerName != null) {
+ cp.newClass(outerName);
+ }
+ if (innerName != null) {
+ cp.newClass(innerName);
+ }
+ cv.visitInnerClass(name, outerName, innerName, access);
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
+ cp.newUTF8("Synthetic");
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ cp.newUTF8("Deprecated");
+ }
+ cp.newUTF8(name);
+ cp.newUTF8(desc);
+ if (signature != null) {
+ cp.newUTF8("Signature");
+ cp.newUTF8(signature);
+ }
+ if (value != null) {
+ cp.newConst(value);
+ }
+ return new FieldConstantsCollector(cv.visitField(access,
+ name,
+ desc,
+ signature,
+ value), cp);
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
+ cp.newUTF8("Synthetic");
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ cp.newUTF8("Deprecated");
+ }
+ cp.newUTF8(name);
+ cp.newUTF8(desc);
+ if (signature != null) {
+ cp.newUTF8("Signature");
+ cp.newUTF8(signature);
+ }
+ if (exceptions != null) {
+ cp.newUTF8("Exceptions");
+ for (int i = 0; i < exceptions.length; ++i) {
+ cp.newClass(exceptions[i]);
+ }
+ }
+ return new MethodConstantsCollector(cv.visitMethod(access,
+ name,
+ desc,
+ signature,
+ exceptions), cp);
+ }
+
+ public void visitEnd() {
+ cv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassOptimizer.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassOptimizer.java
new file mode 100644
index 000000000..b9a1a421c
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassOptimizer.java
@@ -0,0 +1,182 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * A {@link ClassAdapter} that renames fields and methods, and removes debug
+ * info.
+ *
+ * @author Eric Bruneton
+ */
+public class ClassOptimizer extends ClassAdapter {
+
+ private NameMapping mapping;
+
+ private String className;
+
+ private String pkgName;
+
+ public ClassOptimizer(final ClassVisitor cv, final NameMapping mapping) {
+ super(cv);
+ this.mapping = mapping;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overriden methods
+ // ------------------------------------------------------------------------
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ className = name;
+ pkgName = name.substring(0, name.lastIndexOf('/'));
+ cv.visit(version,
+ access,
+ mapping.map(name),
+ null,
+ mapping.map(superName),
+ interfaces);
+ }
+
+ public void visitSource(final String source, final String debug) {
+ // remove debug info
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ // remove debug info
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ // remove non standard attribute
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ // remove debug info
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ String s = className + "." + name;
+ if ((access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0) {
+ if ((access & Opcodes.ACC_FINAL) != 0
+ && (access & Opcodes.ACC_STATIC) != 0 && desc.equals("I"))
+ {
+ return null;
+ }
+ if (pkgName.equals("org/objectweb/asm")
+ && mapping.map(s).equals(name))
+ {
+ System.out.println("INFO: " + s + " could be renamed");
+ }
+ cv.visitField(access,
+ mapping.map(s),
+ mapping.fix(desc),
+ null,
+ value);
+ } else {
+ if (!mapping.map(s).equals(name)) {
+ throw new RuntimeException("The public or protected field " + s
+ + " must not be renamed.");
+ }
+ cv.visitField(access, name, desc, null, value);
+ }
+ return null; // remove debug info
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ String s = className + "." + name + desc;
+ if ((access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0) {
+ if (pkgName.equals("org/objectweb/asm") && !name.startsWith("<")
+ && mapping.map(s).equals(name))
+ {
+ System.out.println("INFO: " + s + " could be renamed");
+ }
+ return new MethodOptimizer(cv.visitMethod(access,
+ mapping.map(s),
+ mapping.fix(desc),
+ null,
+ exceptions), mapping);
+ } else {
+ if (!mapping.map(s).equals(name)) {
+ throw new RuntimeException("The public or protected method "
+ + s + " must not be renamed.");
+ }
+ return new MethodOptimizer(cv.visitMethod(access,
+ name,
+ desc,
+ null,
+ exceptions), mapping);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Constant.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Constant.java
new file mode 100644
index 000000000..c07599dea
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Constant.java
@@ -0,0 +1,265 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import org.objectweb.asm.ClassWriter;
+
+/**
+ * A constant pool item.
+ *
+ * @author Eric Bruneton
+ */
+class Constant {
+
+ /**
+ * Type of this constant pool item. A single class is used to represent all
+ * constant pool item types, in order to minimize the bytecode size of this
+ * package. The value of this field is I, J, F, D, S, s, C, T, G, M, or N
+ * (for Constant Integer, Long, Float, Double, STR, UTF8, Class, NameType,
+ * Fieldref, Methodref, or InterfaceMethodref constant pool items
+ * respectively).
+ */
+ char type;
+
+ /**
+ * Value of this item, for an integer item.
+ */
+ int intVal;
+
+ /**
+ * Value of this item, for a long item.
+ */
+ long longVal;
+
+ /**
+ * Value of this item, for a float item.
+ */
+ float floatVal;
+
+ /**
+ * Value of this item, for a double item.
+ */
+ double doubleVal;
+
+ /**
+ * First part of the value of this item, for items that do not hold a
+ * primitive value.
+ */
+ String strVal1;
+
+ /**
+ * Second part of the value of this item, for items that do not hold a
+ * primitive value.
+ */
+ String strVal2;
+
+ /**
+ * Third part of the value of this item, for items that do not hold a
+ * primitive value.
+ */
+ String strVal3;
+
+ /**
+ * The hash code value of this constant pool item.
+ */
+ int hashCode;
+
+ public Constant() {
+ }
+
+ public Constant(final Constant i) {
+ type = i.type;
+ intVal = i.intVal;
+ longVal = i.longVal;
+ floatVal = i.floatVal;
+ doubleVal = i.doubleVal;
+ strVal1 = i.strVal1;
+ strVal2 = i.strVal2;
+ strVal3 = i.strVal3;
+ hashCode = i.hashCode;
+ }
+
+ /**
+ * Sets this item to an integer item.
+ *
+ * @param intVal the value of this item.
+ */
+ void set(final int intVal) {
+ this.type = 'I';
+ this.intVal = intVal;
+ this.hashCode = 0x7FFFFFFF & (type + intVal);
+ }
+
+ /**
+ * Sets this item to a long item.
+ *
+ * @param longVal the value of this item.
+ */
+ void set(final long longVal) {
+ this.type = 'J';
+ this.longVal = longVal;
+ this.hashCode = 0x7FFFFFFF & (type + (int) longVal);
+ }
+
+ /**
+ * Sets this item to a float item.
+ *
+ * @param floatVal the value of this item.
+ */
+ void set(final float floatVal) {
+ this.type = 'F';
+ this.floatVal = floatVal;
+ this.hashCode = 0x7FFFFFFF & (type + (int) floatVal);
+ }
+
+ /**
+ * Sets this item to a double item.
+ *
+ * @param doubleVal the value of this item.
+ */
+ void set(final double doubleVal) {
+ this.type = 'D';
+ this.doubleVal = doubleVal;
+ this.hashCode = 0x7FFFFFFF & (type + (int) doubleVal);
+ }
+
+ /**
+ * Sets this item to an item that do not hold a primitive value.
+ *
+ * @param type the type of this item.
+ * @param strVal1 first part of the value of this item.
+ * @param strVal2 second part of the value of this item.
+ * @param strVal3 third part of the value of this item.
+ */
+ void set(
+ final char type,
+ final String strVal1,
+ final String strVal2,
+ final String strVal3)
+ {
+ this.type = type;
+ this.strVal1 = strVal1;
+ this.strVal2 = strVal2;
+ this.strVal3 = strVal3;
+ switch (type) {
+ case 's':
+ case 'S':
+ case 'C':
+ hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());
+ return;
+ case 'T':
+ hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()
+ * strVal2.hashCode());
+ return;
+ // case 'G':
+ // case 'M':
+ // case 'N':
+ default:
+ hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()
+ * strVal2.hashCode() * strVal3.hashCode());
+ }
+ }
+
+ void write(final ClassWriter cw) {
+ switch (type) {
+ case 'I':
+ cw.newConst(new Integer(intVal));
+ break;
+ case 'J':
+ cw.newConst(new Long(longVal));
+ break;
+ case 'F':
+ cw.newConst(new Float(floatVal));
+ break;
+ case 'D':
+ cw.newConst(new Double(doubleVal));
+ break;
+ case 'S':
+ cw.newConst(strVal1);
+ break;
+ case 's':
+ cw.newUTF8(strVal1);
+ break;
+ case 'C':
+ cw.newClass(strVal1);
+ break;
+ case 'T':
+ cw.newNameType(strVal1, strVal2);
+ break;
+ case 'G':
+ cw.newField(strVal1, strVal2, strVal3);
+ break;
+ case 'M':
+ cw.newMethod(strVal1, strVal2, strVal3, false);
+ break;
+ case 'N':
+ cw.newMethod(strVal1, strVal2, strVal3, true);
+ break;
+ }
+ }
+
+ public boolean equals(final Object o) {
+ if (!(o instanceof Constant)) {
+ return false;
+ }
+ Constant c = (Constant) o;
+ if (c.type == type) {
+ switch (type) {
+ case 'I':
+ return c.intVal == intVal;
+ case 'J':
+ return c.longVal == longVal;
+ case 'F':
+ return c.floatVal == floatVal;
+ case 'D':
+ return c.doubleVal == doubleVal;
+ case 's':
+ case 'S':
+ case 'C':
+ return c.strVal1.equals(strVal1);
+ case 'T':
+ return c.strVal1.equals(strVal1)
+ && c.strVal2.equals(strVal2);
+ // case 'G':
+ // case 'M':
+ // case 'N':
+ default:
+ return c.strVal1.equals(strVal1)
+ && c.strVal2.equals(strVal2)
+ && c.strVal3.equals(strVal3);
+ }
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ConstantPool.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ConstantPool.java
new file mode 100644
index 000000000..dff17dec6
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ConstantPool.java
@@ -0,0 +1,198 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import java.util.HashMap;
+
+import org.objectweb.asm.Type;
+
+/**
+ * A constant pool.
+ *
+ * @author Eric Bruneton
+ */
+public class ConstantPool extends HashMap {
+
+ private Constant key1 = new Constant();
+
+ private Constant key2 = new Constant();
+
+ private Constant key3 = new Constant();
+
+ public Constant newInteger(final int value) {
+ key1.set(value);
+ Constant result = get(key1);
+ if (result == null) {
+ result = new Constant(key1);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newFloat(final float value) {
+ key1.set(value);
+ Constant result = get(key1);
+ if (result == null) {
+ result = new Constant(key1);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newLong(final long value) {
+ key1.set(value);
+ Constant result = get(key1);
+ if (result == null) {
+ result = new Constant(key1);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newDouble(final double value) {
+ key1.set(value);
+ Constant result = get(key1);
+ if (result == null) {
+ result = new Constant(key1);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newUTF8(final String value) {
+ key1.set('s', value, null, null);
+ Constant result = get(key1);
+ if (result == null) {
+ result = new Constant(key1);
+ put(result);
+ }
+ return result;
+ }
+
+ private Constant newString(final String value) {
+ key2.set('S', value, null, null);
+ Constant result = get(key2);
+ if (result == null) {
+ newUTF8(value);
+ result = new Constant(key2);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newClass(final String value) {
+ key2.set('C', value, null, null);
+ Constant result = get(key2);
+ if (result == null) {
+ newUTF8(value);
+ result = new Constant(key2);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newConst(final Object cst) {
+ if (cst instanceof Integer) {
+ int val = ((Integer) cst).intValue();
+ return newInteger(val);
+ } else if (cst instanceof Float) {
+ float val = ((Float) cst).floatValue();
+ return newFloat(val);
+ } else if (cst instanceof Long) {
+ long val = ((Long) cst).longValue();
+ return newLong(val);
+ } else if (cst instanceof Double) {
+ double val = ((Double) cst).doubleValue();
+ return newDouble(val);
+ } else if (cst instanceof String) {
+ return newString((String) cst);
+ } else if (cst instanceof Type) {
+ Type t = (Type) cst;
+ return newClass(t.getSort() == Type.OBJECT
+ ? t.getInternalName()
+ : t.getDescriptor());
+ } else {
+ throw new IllegalArgumentException("value " + cst);
+ }
+ }
+
+ public Constant newField(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ key3.set('G', owner, name, desc);
+ Constant result = get(key3);
+ if (result == null) {
+ newClass(owner);
+ newNameType(name, desc);
+ result = new Constant(key3);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newMethod(
+ final String owner,
+ final String name,
+ final String desc,
+ final boolean itf)
+ {
+ key3.set(itf ? 'N' : 'M', owner, name, desc);
+ Constant result = get(key3);
+ if (result == null) {
+ newClass(owner);
+ newNameType(name, desc);
+ result = new Constant(key3);
+ put(result);
+ }
+ return result;
+ }
+
+ public Constant newNameType(final String name, final String desc) {
+ key2.set('T', name, desc, null);
+ Constant result = get(key2);
+ if (result == null) {
+ newUTF8(name);
+ newUTF8(desc);
+ result = new Constant(key2);
+ put(result);
+ }
+ return result;
+ }
+
+ private Constant get(final Constant key) {
+ return (Constant) get((Object) key);
+ }
+
+ private void put(final Constant cst) {
+ put(cst, cst);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.java
new file mode 100644
index 000000000..ac5d0d317
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.java
@@ -0,0 +1,76 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.FieldVisitor;
+
+/**
+ * A {@link FieldVisitor} that collects the {@link Constant}s of the fields it
+ * visits.
+ *
+ * @author Eric Bruneton
+ */
+public class FieldConstantsCollector implements FieldVisitor {
+
+ private FieldVisitor fv;
+
+ private ConstantPool cp;
+
+ public FieldConstantsCollector(final FieldVisitor fv, final ConstantPool cp)
+ {
+ this.fv = fv;
+ this.cp = cp;
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ cp.newUTF8(desc);
+ if (visible) {
+ cp.newUTF8("RuntimeVisibleAnnotations");
+ } else {
+ cp.newUTF8("RuntimeInvisibleAnnotations");
+ }
+ return new AnnotationConstantsCollector(fv.visitAnnotation(desc,
+ visible), cp);
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ // can do nothing
+ fv.visitAttribute(attr);
+ }
+
+ public void visitEnd() {
+ fv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/JarOptimizer.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/JarOptimizer.java
new file mode 100644
index 000000000..994b4584e
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/JarOptimizer.java
@@ -0,0 +1,87 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * A Jar file optimizer.
+ *
+ * @author Eric Bruneton
+ */
+public class JarOptimizer {
+
+ public static void main(final String[] args) throws IOException {
+ File f = new File(args[0]);
+ optimize(f);
+ }
+
+ static void optimize(final File f) throws IOException {
+ if (f.isDirectory()) {
+ File[] files = f.listFiles();
+ for (int i = 0; i < files.length; ++i) {
+ optimize(files[i]);
+ }
+ } else if (f.getName().endsWith(".jar")) {
+ File g = new File(f.getParentFile(), f.getName() + ".new");
+ ZipFile zf = new ZipFile(f);
+ ZipOutputStream out = new ZipOutputStream(new FileOutputStream(g));
+ Enumeration e = zf.entries();
+ byte[] buf = new byte[10000];
+ while (e.hasMoreElements()) {
+ ZipEntry ze = (ZipEntry) e.nextElement();
+ if (ze.isDirectory()) {
+ continue;
+ }
+ out.putNextEntry(ze);
+ InputStream is = zf.getInputStream(ze);
+ int n;
+ do {
+ n = is.read(buf, 0, buf.length);
+ if (n != -1) {
+ out.write(buf, 0, n);
+ }
+ } while (n != -1);
+ out.closeEntry();
+ }
+ out.close();
+ zf.close();
+ f.delete();
+ g.renameTo(f);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.java
new file mode 100644
index 000000000..33d82e952
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.java
@@ -0,0 +1,168 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodAdapter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * An {@link MethodVisitor} that collects the {@link Constant}s of the methods
+ * it visits.
+ *
+ * @author Eric Bruneton
+ */
+public class MethodConstantsCollector extends MethodAdapter {
+
+ private ConstantPool cp;
+
+ public MethodConstantsCollector(
+ final MethodVisitor mv,
+ final ConstantPool cp)
+ {
+ super(mv);
+ this.cp = cp;
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ cp.newUTF8("AnnotationDefault");
+ return new AnnotationConstantsCollector(mv.visitAnnotationDefault(), cp);
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ cp.newUTF8(desc);
+ if (visible) {
+ cp.newUTF8("RuntimeVisibleAnnotations");
+ } else {
+ cp.newUTF8("RuntimeInvisibleAnnotations");
+ }
+ return new AnnotationConstantsCollector(mv.visitAnnotation(desc,
+ visible), cp);
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ cp.newUTF8(desc);
+ if (visible) {
+ cp.newUTF8("RuntimeVisibleParameterAnnotations");
+ } else {
+ cp.newUTF8("RuntimeInvisibleParameterAnnotations");
+ }
+ return new AnnotationConstantsCollector(mv.visitParameterAnnotation(parameter,
+ desc,
+ visible),
+ cp);
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ cp.newClass(desc);
+ mv.visitTypeInsn(opcode, desc);
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ cp.newField(owner, name, desc);
+ mv.visitFieldInsn(opcode, owner, name, desc);
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ boolean itf = opcode == Opcodes.INVOKEINTERFACE;
+ cp.newMethod(owner, name, desc, itf);
+ mv.visitMethodInsn(opcode, owner, name, desc);
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ cp.newConst(cst);
+ mv.visitLdcInsn(cst);
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ cp.newClass(desc);
+ mv.visitMultiANewArrayInsn(desc, dims);
+ }
+
+ public void visitTryCatchBlock(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ if (type != null) {
+ cp.newClass(type);
+ }
+ mv.visitTryCatchBlock(start, end, handler, type);
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ if (signature != null) {
+ cp.newUTF8("LocalVariableTypeTable");
+ cp.newUTF8(name);
+ cp.newUTF8(signature);
+ }
+ cp.newUTF8("LocalVariableTable");
+ cp.newUTF8(name);
+ cp.newUTF8(desc);
+ mv.visitLocalVariable(name, desc, signature, start, end, index);
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ cp.newUTF8("LineNumberTable");
+ mv.visitLineNumber(line, start);
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ cp.newUTF8("Code");
+ mv.visitMaxs(maxStack, maxLocals);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodOptimizer.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodOptimizer.java
new file mode 100644
index 000000000..ea2927498
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodOptimizer.java
@@ -0,0 +1,108 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodAdapter;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A {@link MethodAdapter} that renames fields and methods, and removes debug
+ * info.
+ *
+ * @author Eric Bruneton
+ */
+public class MethodOptimizer extends MethodAdapter {
+
+ private NameMapping mapping;
+
+ public MethodOptimizer(final MethodVisitor mv, final NameMapping mapping) {
+ super(mv);
+ this.mapping = mapping;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overriden methods
+ // ------------------------------------------------------------------------
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ throw new UnsupportedOperationException();
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ mv.visitTypeInsn(opcode, desc.startsWith("[")
+ ? mapping.fix(desc)
+ : mapping.map(desc));
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ mv.visitFieldInsn(opcode, mapping.map(owner), mapping.map(owner + "."
+ + name), mapping.fix(desc));
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ mv.visitMethodInsn(opcode, mapping.map(owner), mapping.map(owner + "."
+ + name + desc), mapping.fix(desc));
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ // remove debug info
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ // remove debug info
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/NameMapping.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/NameMapping.java
new file mode 100644
index 000000000..77a856b46
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/NameMapping.java
@@ -0,0 +1,101 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.objectweb.asm.Type;
+
+/**
+ * A mapping from names to names, used to rename classes, fields and methods.
+ *
+ * @author Eric Bruneton
+ */
+public class NameMapping extends Properties {
+
+ public final Set unused;
+
+ public NameMapping(final String file) throws IOException {
+ load(new FileInputStream(file));
+ unused = new HashSet(keySet());
+ }
+
+ public String map(final String name) {
+ String s = (String) get(name);
+ if (s == null) {
+ int p = name.indexOf('.');
+ if (p != -1) {
+ int q = name.indexOf('(');
+ if (q != -1) {
+ s = name.substring(p + 1, q);
+ } else {
+ s = name.substring(p + 1);
+ }
+ } else {
+ s = name;
+ }
+ } else {
+ unused.remove(name);
+ }
+ return s;
+ }
+
+ public String fix(final String desc) {
+ if (desc.startsWith("(")) {
+ Type[] arguments = Type.getArgumentTypes(desc);
+ Type result = Type.getReturnType(desc);
+ for (int i = 0; i < arguments.length; ++i) {
+ arguments[i] = fix(arguments[i]);
+ }
+ result = fix(result);
+ return Type.getMethodDescriptor(result, arguments);
+ } else {
+ return fix(Type.getType(desc)).getDescriptor();
+ }
+ }
+
+ private Type fix(final Type t) {
+ if (t.getSort() == Type.OBJECT) {
+ return Type.getType("L" + map(t.getInternalName()) + ";");
+ } else if (t.getSort() == Type.ARRAY) {
+ String s = fix(t.getElementType()).getDescriptor();
+ for (int i = 0; i < t.getDimensions(); ++i) {
+ s = "[" + s;
+ }
+ return Type.getType(s);
+ } else {
+ return t;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Shrinker.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Shrinker.java
new file mode 100644
index 000000000..86da30779
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Shrinker.java
@@ -0,0 +1,168 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.optimizer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+
+/**
+ * A class file shrinker utility.
+ *
+ * @author Eric Bruneton
+ */
+public class Shrinker {
+
+ public static void main(final String[] args) throws IOException {
+ NameMapping mapping = new NameMapping(args[0]);
+ File f = new File(args[1]);
+ File d = new File(args[2]);
+ optimize(f, d, mapping);
+ Iterator i = mapping.unused.iterator();
+ while (i.hasNext()) {
+ System.out.println("INFO: unused mapping " + i.next());
+ }
+ }
+
+ static void optimize(final File f, final File d, final NameMapping mapping)
+ throws IOException
+ {
+ if (f.isDirectory()) {
+ File[] files = f.listFiles();
+ for (int i = 0; i < files.length; ++i) {
+ optimize(files[i], d, mapping);
+ }
+ } else if (f.getName().endsWith(".class")) {
+ ConstantPool cp = new ConstantPool();
+ ClassReader cr = new ClassReader(new FileInputStream(f));
+ ClassWriter cw = new ClassWriter(false);
+ ClassConstantsCollector ccc = new ClassConstantsCollector(cw, cp);
+ ClassOptimizer co = new ClassOptimizer(ccc, mapping);
+ cr.accept(co, true);
+
+ Set constants = new TreeSet(new ConstantComparator());
+ constants.addAll(cp.values());
+
+ cr = new ClassReader(cw.toByteArray());
+ cw = new ClassWriter(false);
+ Iterator i = constants.iterator();
+ while (i.hasNext()) {
+ Constant c = (Constant) i.next();
+ c.write(cw);
+ }
+ cr.accept(cw, true);
+
+ String n = mapping.map(co.getClassName());
+ File g = new File(d, n + ".class");
+ if (!g.exists() || g.lastModified() < f.lastModified()) {
+ g.getParentFile().mkdirs();
+ OutputStream os = new FileOutputStream(g);
+ os.write(cw.toByteArray());
+ os.close();
+ }
+ }
+ }
+
+ static class ConstantComparator implements Comparator {
+
+ public int compare(final Object o1, final Object o2) {
+ Constant c1 = (Constant) o1;
+ Constant c2 = (Constant) o2;
+ int d = getSort(c1) - getSort(c2);
+ if (d == 0) {
+ switch (c1.type) {
+ case 'I':
+ return new Integer(c1.intVal).compareTo(new Integer(c2.intVal));
+ case 'J':
+ return new Long(c1.longVal).compareTo(new Long(c2.longVal));
+ case 'F':
+ return new Float(c1.floatVal).compareTo(new Float(c2.floatVal));
+ case 'D':
+ return new Double(c1.doubleVal).compareTo(new Double(c2.doubleVal));
+ case 's':
+ case 'S':
+ case 'C':
+ return c1.strVal1.compareTo(c2.strVal1);
+ case 'T':
+ d = c1.strVal1.compareTo(c2.strVal1);
+ if (d == 0) {
+ d = c1.strVal2.compareTo(c2.strVal2);
+ }
+ break;
+ default:
+ d = c1.strVal1.compareTo(c2.strVal1);
+ if (d == 0) {
+ d = c1.strVal2.compareTo(c2.strVal2);
+ if (d == 0) {
+ d = c1.strVal3.compareTo(c2.strVal3);
+ }
+ }
+ }
+ }
+ return d;
+ }
+
+ private int getSort(Constant c) {
+ switch (c.type) {
+ case 'I':
+ return 0;
+ case 'J':
+ return 1;
+ case 'F':
+ return 2;
+ case 'D':
+ return 3;
+ case 's':
+ return 4;
+ case 'S':
+ return 5;
+ case 'C':
+ return 6;
+ case 'T':
+ return 7;
+ case 'G':
+ return 8;
+ case 'M':
+ return 9;
+ default:
+ return 10;
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/shrink.properties b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/shrink.properties
new file mode 100644
index 000000000..868780bdd
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/shrink.properties
@@ -0,0 +1,225 @@
+# class mappings
+
+#org/objectweb/asm/Edge=org/objectweb/asm/a
+#org/objectweb/asm/Item=org/objectweb/asm/b
+#org/objectweb/asm/FieldWriter=org/objectweb/asm/c
+#org/objectweb/asm/MethodWriter=org/objectweb/asm/d
+#org/objectweb/asm/AnnotationWriter=org/objectweb/asm/e
+
+# field mappings
+
+org/objectweb/asm/AnnotationWriter.cw=a
+org/objectweb/asm/AnnotationWriter.size=b
+org/objectweb/asm/AnnotationWriter.named=c
+org/objectweb/asm/AnnotationWriter.bv=d
+org/objectweb/asm/AnnotationWriter.parent=e
+org/objectweb/asm/AnnotationWriter.offset=f
+org/objectweb/asm/AnnotationWriter.next=g
+org/objectweb/asm/AnnotationWriter.prev=h
+
+org/objectweb/asm/Attribute.next=a
+org/objectweb/asm/Attribute.value=b
+
+org/objectweb/asm/ByteVector.data=a
+org/objectweb/asm/ByteVector.length=b
+
+org/objectweb/asm/ClassReader.items=a
+org/objectweb/asm/ClassReader.strings=c
+org/objectweb/asm/ClassReader.maxStringLength=d
+#org/objectweb/asm/ClassReader.header=e
+
+org/objectweb/asm/ClassWriter.TYPE=a
+org/objectweb/asm/ClassWriter.version=b
+org/objectweb/asm/ClassWriter.index=c
+org/objectweb/asm/ClassWriter.pool=d
+org/objectweb/asm/ClassWriter.items=e
+org/objectweb/asm/ClassWriter.threshold=f
+org/objectweb/asm/ClassWriter.key=g
+org/objectweb/asm/ClassWriter.key2=h
+org/objectweb/asm/ClassWriter.key3=i
+org/objectweb/asm/ClassWriter.access=j
+org/objectweb/asm/ClassWriter.name=k
+org/objectweb/asm/ClassWriter.signature=l
+org/objectweb/asm/ClassWriter.superName=m
+org/objectweb/asm/ClassWriter.interfaceCount=n
+org/objectweb/asm/ClassWriter.interfaces=o
+org/objectweb/asm/ClassWriter.sourceFile=p
+org/objectweb/asm/ClassWriter.sourceDebug=q
+org/objectweb/asm/ClassWriter.enclosingMethodOwner=r
+org/objectweb/asm/ClassWriter.enclosingMethod=s
+org/objectweb/asm/ClassWriter.anns=t
+org/objectweb/asm/ClassWriter.ianns=u
+org/objectweb/asm/ClassWriter.attrs=v
+org/objectweb/asm/ClassWriter.innerClassesCount=w
+org/objectweb/asm/ClassWriter.innerClasses=x
+org/objectweb/asm/ClassWriter.firstField=y
+org/objectweb/asm/ClassWriter.lastField=z
+org/objectweb/asm/ClassWriter.firstMethod=A
+org/objectweb/asm/ClassWriter.lastMethod=B
+org/objectweb/asm/ClassWriter.computeMaxs=C
+org/objectweb/asm/ClassWriter.cr=D
+
+org/objectweb/asm/Edge.stackSize=a
+org/objectweb/asm/Edge.successor=b
+org/objectweb/asm/Edge.next=c
+
+org/objectweb/asm/Handler.start=a
+org/objectweb/asm/Handler.end=b
+org/objectweb/asm/Handler.handler=c
+org/objectweb/asm/Handler.desc=d
+org/objectweb/asm/Handler.type=e
+org/objectweb/asm/Handler.next=f
+
+org/objectweb/asm/FieldWriter.next=a
+org/objectweb/asm/FieldWriter.cw=b
+org/objectweb/asm/FieldWriter.access=c
+org/objectweb/asm/FieldWriter.name=d
+org/objectweb/asm/FieldWriter.desc=e
+org/objectweb/asm/FieldWriter.signature=f
+org/objectweb/asm/FieldWriter.value=g
+org/objectweb/asm/FieldWriter.anns=h
+org/objectweb/asm/FieldWriter.ianns=i
+org/objectweb/asm/FieldWriter.attrs=j
+
+org/objectweb/asm/Item.index=a
+org/objectweb/asm/Item.type=b
+org/objectweb/asm/Item.intVal=c
+org/objectweb/asm/Item.longVal=d
+org/objectweb/asm/Item.floatVal=e
+org/objectweb/asm/Item.doubleVal=f
+org/objectweb/asm/Item.strVal1=g
+org/objectweb/asm/Item.strVal2=h
+org/objectweb/asm/Item.strVal3=i
+org/objectweb/asm/Item.hashCode=j
+org/objectweb/asm/Item.next=k
+
+org/objectweb/asm/Label.resolved=a
+org/objectweb/asm/Label.position=b
+org/objectweb/asm/Label.resized=c
+org/objectweb/asm/Label.referenceCount=d
+org/objectweb/asm/Label.srcAndRefPositions=e
+org/objectweb/asm/Label.beginStackSize=f
+org/objectweb/asm/Label.maxStackSize=g
+org/objectweb/asm/Label.successors=h
+org/objectweb/asm/Label.next=i
+org/objectweb/asm/Label.pushed=j
+org/objectweb/asm/Label.line=k
+
+org/objectweb/asm/MethodWriter.next=a
+org/objectweb/asm/MethodWriter.cw=b
+org/objectweb/asm/MethodWriter.access=c
+org/objectweb/asm/MethodWriter.name=d
+org/objectweb/asm/MethodWriter.desc=e
+org/objectweb/asm/MethodWriter.descriptor=f
+org/objectweb/asm/MethodWriter.signature=g
+org/objectweb/asm/MethodWriter.exceptionCount=h
+org/objectweb/asm/MethodWriter.exceptions=i
+org/objectweb/asm/MethodWriter.annd=j
+org/objectweb/asm/MethodWriter.anns=k
+org/objectweb/asm/MethodWriter.ianns=l
+org/objectweb/asm/MethodWriter.panns=m
+org/objectweb/asm/MethodWriter.ipanns=n
+org/objectweb/asm/MethodWriter.attrs=o
+org/objectweb/asm/MethodWriter.code=p
+org/objectweb/asm/MethodWriter.maxStack=q
+org/objectweb/asm/MethodWriter.maxLocals=r
+org/objectweb/asm/MethodWriter.catchCount=s
+org/objectweb/asm/MethodWriter.catchTable=t
+org/objectweb/asm/MethodWriter.localVarCount=u
+org/objectweb/asm/MethodWriter.localVar=v
+org/objectweb/asm/MethodWriter.localVarTypeCount=w
+org/objectweb/asm/MethodWriter.localVarType=x
+org/objectweb/asm/MethodWriter.lineNumberCount=y
+org/objectweb/asm/MethodWriter.lineNumber=z
+org/objectweb/asm/MethodWriter.cattrs=A
+org/objectweb/asm/MethodWriter.resize=B
+org/objectweb/asm/MethodWriter.computeMaxs=C
+org/objectweb/asm/MethodWriter.stackSize=D
+org/objectweb/asm/MethodWriter.maxStackSize=E
+org/objectweb/asm/MethodWriter.currentBlock=F
+org/objectweb/asm/MethodWriter.blockStack=G
+org/objectweb/asm/MethodWriter.SIZE=H
+org/objectweb/asm/MethodWriter.classReaderOffset=I
+org/objectweb/asm/MethodWriter.classReaderLength=J
+org/objectweb/asm/MethodWriter.lastHandler=K
+
+org/objectweb/asm/Type.sort=a
+org/objectweb/asm/Type.buf=b
+org/objectweb/asm/Type.off=c
+org/objectweb/asm/Type.len=d
+
+org/objectweb/asm/signature/SignatureReader.signature=a
+
+org/objectweb/asm/signature/SignatureWriter.buf=a
+org/objectweb/asm/signature/SignatureWriter.hasFormals=b
+org/objectweb/asm/signature/SignatureWriter.hasParameters=c
+org/objectweb/asm/signature/SignatureWriter.argumentStack=d
+
+# method mappings
+
+org/objectweb/asm/AnnotationWriter.getSize()I=a
+org/objectweb/asm/AnnotationWriter.put([Lorg/objectweb/asm/AnnotationWriter;Lorg/objectweb/asm/ByteVector;)V=a
+org/objectweb/asm/AnnotationWriter.put(Lorg/objectweb/asm/ByteVector;)V=a
+
+org/objectweb/asm/Attribute.getCount()I=a
+org/objectweb/asm/Attribute.getSize(Lorg/objectweb/asm/ClassWriter;[BIII)I=a
+org/objectweb/asm/Attribute.put(Lorg/objectweb/asm/ClassWriter;[BIIILorg/objectweb/asm/ByteVector;)V=a
+
+org/objectweb/asm/ByteVector.enlarge(I)V=a
+org/objectweb/asm/ByteVector.put11(II)Lorg/objectweb/asm/ByteVector;=a
+org/objectweb/asm/ByteVector.put12(II)Lorg/objectweb/asm/ByteVector;=b
+
+org/objectweb/asm/ClassReader.copyPool(Lorg/objectweb/asm/ClassWriter;)V=a
+org/objectweb/asm/ClassReader.readAnnotationValue(I[CLjava/lang/String;Lorg/objectweb/asm/AnnotationVisitor;)I=a
+org/objectweb/asm/ClassReader.readAnnotationValues(I[CLorg/objectweb/asm/AnnotationVisitor;)I=a
+org/objectweb/asm/ClassReader.readAttribute([Lorg/objectweb/asm/Attribute;Ljava/lang/String;II[CI[Lorg/objectweb/asm/Label;)Lorg/objectweb/asm/Attribute;=a
+org/objectweb/asm/ClassReader.readClass(Ljava/io/InputStream;)[B=a
+org/objectweb/asm/ClassReader.readParameterAnnotations(I[CZLorg/objectweb/asm/MethodVisitor;)V=a
+org/objectweb/asm/ClassReader.readUTF(II[C)Ljava/lang/String;=a
+
+org/objectweb/asm/ClassWriter.get(Lorg/objectweb/asm/Item;)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newClassItem(Ljava/lang/String;)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newConstItem(Ljava/lang/Object;)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newDouble(D)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newFloat(F)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newInteger(I)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newLong(J)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newMethodItem(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Lorg/objectweb/asm/Item;=a
+org/objectweb/asm/ClassWriter.newString(Ljava/lang/String;)Lorg/objectweb/asm/Item;=b
+org/objectweb/asm/ClassWriter.put122(III)V=a
+org/objectweb/asm/ClassWriter.put(Lorg/objectweb/asm/Item;)V=b
+
+org/objectweb/asm/FieldWriter.getSize()I=a
+org/objectweb/asm/FieldWriter.put(Lorg/objectweb/asm/ByteVector;)V=a
+
+org/objectweb/asm/Item.isEqualTo(Lorg/objectweb/asm/Item;)Z=a
+org/objectweb/asm/Item.set(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V=a
+org/objectweb/asm/Item.set(D)V=a
+org/objectweb/asm/Item.set(F)V=a
+org/objectweb/asm/Item.set(I)V=a
+org/objectweb/asm/Item.set(J)V=a
+
+org/objectweb/asm/Label.addReference(II)V=a
+org/objectweb/asm/Label.put(Lorg/objectweb/asm/MethodWriter;Lorg/objectweb/asm/ByteVector;IZ)V=a
+org/objectweb/asm/Label.resolve(Lorg/objectweb/asm/MethodWriter;I[B)Z=a
+
+org/objectweb/asm/MethodWriter.addSuccessor(ILorg/objectweb/asm/Label;)V=a
+org/objectweb/asm/MethodWriter.getArgumentsAndReturnSizes(Ljava/lang/String;)I=a
+org/objectweb/asm/MethodWriter.getNewOffset([I[III)I=a
+org/objectweb/asm/MethodWriter.getSize()I=a
+org/objectweb/asm/MethodWriter.put(Lorg/objectweb/asm/ByteVector;)V=a
+org/objectweb/asm/MethodWriter.readInt([BI)I=a
+org/objectweb/asm/MethodWriter.readShort([BI)S=b
+org/objectweb/asm/MethodWriter.readUnsignedShort([BI)I=c
+org/objectweb/asm/MethodWriter.resizeInstructions([I[II)[I=a
+org/objectweb/asm/MethodWriter.writeShort([BII)V=a
+org/objectweb/asm/MethodWriter.getNewOffset([I[ILorg/objectweb/asm/Label;)V=a
+
+org/objectweb/asm/Type.getType([CI)Lorg/objectweb/asm/Type;=a
+org/objectweb/asm/Type.getDescriptor(Ljava/lang/StringBuffer;)V=a
+org/objectweb/asm/Type.getDescriptor(Ljava/lang/StringBuffer;Ljava/lang/Class;)V=a
+
+org/objectweb/asm/signature/SignatureReader.parseType(Ljava/lang/String;ILorg/objectweb/asm/signature/SignatureVisitor;)I=a
+
+org/objectweb/asm/signature/SignatureWriter.endFormals()V=a
+org/objectweb/asm/signature/SignatureWriter.endArguments()V=b
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureReader.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureReader.java
new file mode 100644
index 000000000..a2f31f39e
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureReader.java
@@ -0,0 +1,233 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.signature;
+
+/**
+ * A type signature parser to make a signature visitor visit an existing
+ * signature.
+ *
+ * @author Thomas Hallgren
+ * @author Eric Bruneton
+ */
+public class SignatureReader {
+
+ /**
+ * The signature to be read.
+ */
+ private final String signature;
+
+ /**
+ * Constructs a {@link SignatureReader} for the given signature.
+ *
+ * @param signature A <i>ClassSignature</i>, <i>MethodTypeSignature</i>,
+ * or <i>FieldTypeSignature</i>.
+ */
+ public SignatureReader(final String signature) {
+ this.signature = signature;
+ }
+
+ /**
+ * Makes the given visitor visit the signature of this
+ * {@link SignatureReader}. This signature is the one specified in the
+ * constructor (see {@link #SignatureReader(String) SignatureReader}). This
+ * method is intended to be called on a {@link SignatureReader} that was
+ * created using a <i>ClassSignature</i> (such as the
+ * <code>signature</code> parameter of the
+ * {@link org.objectweb.asm.ClassVisitor#visit ClassVisitor.visit} method)
+ * or a <i>MethodTypeSignature</i> (such as the <code>signature</code>
+ * parameter of the
+ * {@link org.objectweb.asm.ClassVisitor#visitMethod ClassVisitor.visitMethod}
+ * method).
+ *
+ * @param v the visitor that must visit this signature.
+ */
+ public void accept(final SignatureVisitor v) {
+ String signature = this.signature;
+ int len = signature.length();
+ int pos;
+ char c;
+
+ if (signature.charAt(0) == '<') {
+ pos = 2;
+ do {
+ int end = signature.indexOf(':', pos);
+ v.visitFormalTypeParameter(signature.substring(pos - 1, end));
+ pos = end + 1;
+
+ c = signature.charAt(pos);
+ if (c == 'L' || c == '[' || c == 'T') {
+ pos = parseType(signature, pos, v.visitClassBound());
+ }
+
+ for (;;) {
+ if ((c = signature.charAt(pos++)) == ':') {
+ pos = parseType(signature, pos, v.visitInterfaceBound());
+ } else {
+ break;
+ }
+ }
+ } while (c != '>');
+ } else {
+ pos = 0;
+ }
+
+ if (signature.charAt(pos) == '(') {
+ pos = pos + 1;
+ while (signature.charAt(pos) != ')') {
+ pos = parseType(signature, pos, v.visitParameterType());
+ }
+ pos = parseType(signature, pos + 1, v.visitReturnType());
+ while (pos < len) {
+ pos = parseType(signature, pos + 1, v.visitExceptionType());
+ }
+ } else {
+ pos = parseType(signature, pos, v.visitSuperclass());
+ while (pos < len) {
+ pos = parseType(signature, pos, v.visitInterface());
+ }
+ }
+ }
+
+ /**
+ * Makes the given visitor visit the signature of this
+ * {@link SignatureReader}. This signature is the one specified in the
+ * constructor (see {@link #SignatureReader(String) SignatureReader}). This
+ * method is intended to be called on a {@link SignatureReader} that was
+ * created using a <i>FieldTypeSignature</i>, such as the
+ * <code>signature</code> parameter of the
+ * {@link org.objectweb.asm.ClassVisitor#visitField
+ * ClassVisitor.visitField} or {@link
+ * org.objectweb.asm.MethodVisitor#visitLocalVariable
+ * MethodVisitor.visitLocalVariable} methods.
+ *
+ * @param v the visitor that must visit this signature.
+ */
+ public void acceptType(final SignatureVisitor v) {
+ parseType(this.signature, 0, v);
+ }
+
+ /**
+ * Parses a field type signature and makes the given visitor visit it.
+ *
+ * @param signature a string containing the signature that must be parsed.
+ * @param pos index of the first character of the signature to parsed.
+ * @param v the visitor that must visit this signature.
+ * @return the index of the first character after the parsed signature.
+ */
+ private static int parseType(
+ final String signature,
+ int pos,
+ final SignatureVisitor v)
+ {
+ char c;
+ int start, end;
+ boolean visited, inner;
+ String name;
+
+ switch (c = signature.charAt(pos++)) {
+ case 'Z':
+ case 'C':
+ case 'B':
+ case 'S':
+ case 'I':
+ case 'F':
+ case 'J':
+ case 'D':
+ case 'V':
+ v.visitBaseType(c);
+ return pos;
+
+ case '[':
+ return parseType(signature, pos, v.visitArrayType());
+
+ case 'T':
+ end = signature.indexOf(';', pos);
+ v.visitTypeVariable(signature.substring(pos, end));
+ return end + 1;
+
+ default: // case 'L':
+ start = pos;
+ visited = false;
+ inner = false;
+ for (;;) {
+ switch (c = signature.charAt(pos++)) {
+ case '.':
+ case ';':
+ if (!visited) {
+ name = signature.substring(start, pos - 1);
+ if (inner) {
+ v.visitInnerClassType(name);
+ } else {
+ v.visitClassType(name);
+ }
+ }
+ if (c == ';') {
+ v.visitEnd();
+ return pos;
+ }
+ start = pos;
+ visited = false;
+ inner = true;
+ break;
+
+ case '<':
+ name = signature.substring(start, pos - 1);
+ if (inner) {
+ v.visitInnerClassType(name);
+ } else {
+ v.visitClassType(name);
+ }
+ visited = true;
+ top: for (;;) {
+ switch (c = signature.charAt(pos)) {
+ case '>':
+ break top;
+ case '*':
+ ++pos;
+ v.visitTypeArgument();
+ break;
+ case '+':
+ case '-':
+ pos = parseType(signature,
+ pos + 1,
+ v.visitTypeArgument(c));
+ break;
+ default:
+ pos = parseType(signature,
+ pos,
+ v.visitTypeArgument('='));
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureVisitor.java
new file mode 100644
index 000000000..46df8c939
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureVisitor.java
@@ -0,0 +1,185 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.signature;
+
+/**
+ * A visitor to visit a generic signature. The methods of this interface must be
+ * called in one of the three following orders (the last one is the only valid
+ * order for a {@link SignatureVisitor} that is returned by a method of this
+ * interface): <ul> <li><i>ClassSignature</i> = (
+ * <tt>visitFormalTypeParameter</tt>
+ * <tt>visitClassBound</tt>?
+ * <tt>visitInterfaceBound</tt>* )* ( <tt>visitSuperClass</tt>
+ * <tt>visitInterface</tt>* )</li>
+ * <li><i>MethodSignature</i> = ( <tt>visitFormalTypeParameter</tt>
+ * <tt>visitClassBound</tt>?
+ * <tt>visitInterfaceBound</tt>* )* ( <tt>visitParameterType</tt>*
+ * <tt>visitReturnType</tt>
+ * <tt>visitExceptionType</tt>* )</li> <li><i>TypeSignature</i> =
+ * <tt>visitBaseType</tt> | <tt>visitTypeVariable</tt> |
+ * <tt>visitArrayType</tt> | (
+ * <tt>visitClassType</tt> <tt>visitTypeArgument</tt>* (
+ * <tt>visitInnerClassType</tt> <tt>visitTypeArgument</tt>* )*
+ * <tt>visitEnd</tt> ) )</li> </ul>
+ *
+ * @author Thomas Hallgren
+ * @author Eric Bruneton
+ */
+public interface SignatureVisitor {
+
+ /**
+ * Wildcard for an "extends" type argument.
+ */
+ char EXTENDS = '+';
+
+ /**
+ * Wildcard for a "super" type argument.
+ */
+ char SUPER = '-';
+
+ /**
+ * Wildcard for a normal type argument.
+ */
+ char INSTANCEOF = '=';
+
+ /**
+ * Visits a formal type parameter.
+ *
+ * @param name the name of the formal parameter.
+ */
+ void visitFormalTypeParameter(String name);
+
+ /**
+ * Visits the class bound of the last visited formal type parameter.
+ *
+ * @return a non null visitor to visit the signature of the class bound.
+ */
+ SignatureVisitor visitClassBound();
+
+ /**
+ * Visits an interface bound of the last visited formal type parameter.
+ *
+ * @return a non null visitor to visit the signature of the interface bound.
+ */
+ SignatureVisitor visitInterfaceBound();
+
+ /**
+ * Visits the type of the super class.
+ *
+ * @return a non null visitor to visit the signature of the super class
+ * type.
+ */
+ SignatureVisitor visitSuperclass();
+
+ /**
+ * Visits the type of an interface implemented by the class.
+ *
+ * @return a non null visitor to visit the signature of the interface type.
+ */
+ SignatureVisitor visitInterface();
+
+ /**
+ * Visits the type of a method parameter.
+ *
+ * @return a non null visitor to visit the signature of the parameter type.
+ */
+ SignatureVisitor visitParameterType();
+
+ /**
+ * Visits the return type of the method.
+ *
+ * @return a non null visitor to visit the signature of the return type.
+ */
+ SignatureVisitor visitReturnType();
+
+ /**
+ * Visits the type of a method exception.
+ *
+ * @return a non null visitor to visit the signature of the exception type.
+ */
+ SignatureVisitor visitExceptionType();
+
+ /**
+ * Visits a signature corresponding to a primitive type.
+ *
+ * @param descriptor the descriptor of the primitive type, or 'V' for
+ * <tt>void</tt>.
+ */
+ void visitBaseType(char descriptor);
+
+ /**
+ * Visits a signature corresponding to a type variable.
+ *
+ * @param name the name of the type variable.
+ */
+ void visitTypeVariable(String name);
+
+ /**
+ * Visits a signature corresponding to an array type.
+ *
+ * @return a non null visitor to visit the signature of the array element
+ * type.
+ */
+ SignatureVisitor visitArrayType();
+
+ /**
+ * Starts the visit of a signature corresponding to a class or interface
+ * type.
+ *
+ * @param name the internal name of the class or interface.
+ */
+ void visitClassType(String name);
+
+ /**
+ * Visits an inner class.
+ *
+ * @param name the local name of the inner class in its enclosing class.
+ */
+ void visitInnerClassType(String name);
+
+ /**
+ * Visits an unbounded type argument of the last visited class or inner
+ * class type.
+ */
+ void visitTypeArgument();
+
+ /**
+ * Visits a type argument of the last visited class or inner class type.
+ *
+ * @param wildcard '+', '-' or '='.
+ * @return a non null visitor to visit the signature of the type argument.
+ */
+ SignatureVisitor visitTypeArgument(char wildcard);
+
+ /**
+ * Ends the visit of a signature corresponding to a class or interface type.
+ */
+ void visitEnd();
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureWriter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureWriter.java
new file mode 100644
index 000000000..833d688b8
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureWriter.java
@@ -0,0 +1,207 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.signature;
+
+/**
+ * A signature visitor that generates signatures in string format.
+ *
+ * @author Thomas Hallgren
+ * @author Eric Bruneton
+ */
+public class SignatureWriter implements SignatureVisitor {
+
+ /**
+ * Buffer used to construct the signature.
+ */
+ private final StringBuffer buf = new StringBuffer();
+
+ /**
+ * Indicates if the signature contains formal type parameters.
+ */
+ private boolean hasFormals;
+
+ /**
+ * Indicates if the signature contains method parameter types.
+ */
+ private boolean hasParameters;
+
+ /**
+ * Stack used to keep track of class types that have arguments. Each element
+ * of this stack is a boolean encoded in one bit. The top of the stack is
+ * the lowest order bit. Pushing false = *2, pushing true = *2+1, popping =
+ * /2.
+ */
+ private int argumentStack;
+
+ /**
+ * Constructs a new {@link SignatureWriter} object.
+ */
+ public SignatureWriter() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the SignatureVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visitFormalTypeParameter(String name) {
+ if (!hasFormals) {
+ hasFormals = true;
+ buf.append('<');
+ }
+ buf.append(name);
+ buf.append(':');
+ }
+
+ public SignatureVisitor visitClassBound() {
+ return this;
+ }
+
+ public SignatureVisitor visitInterfaceBound() {
+ buf.append(':');
+ return this;
+ }
+
+ public SignatureVisitor visitSuperclass() {
+ endFormals();
+ return this;
+ }
+
+ public SignatureVisitor visitInterface() {
+ return this;
+ }
+
+ public SignatureVisitor visitParameterType() {
+ endFormals();
+ if (!hasParameters) {
+ hasParameters = true;
+ buf.append('(');
+ }
+ return this;
+ }
+
+ public SignatureVisitor visitReturnType() {
+ endFormals();
+ if (!hasParameters) {
+ buf.append('(');
+ }
+ buf.append(')');
+ return this;
+ }
+
+ public SignatureVisitor visitExceptionType() {
+ buf.append('^');
+ return this;
+ }
+
+ public void visitBaseType(char descriptor) {
+ buf.append(descriptor);
+ }
+
+ public void visitTypeVariable(String name) {
+ buf.append('T');
+ buf.append(name);
+ buf.append(';');
+ }
+
+ public SignatureVisitor visitArrayType() {
+ buf.append('[');
+ return this;
+ }
+
+ public void visitClassType(String name) {
+ buf.append('L');
+ buf.append(name);
+ argumentStack *= 2;
+ }
+
+ public void visitInnerClassType(String name) {
+ endArguments();
+ buf.append('.');
+ buf.append(name);
+ argumentStack *= 2;
+ }
+
+ public void visitTypeArgument() {
+ if (argumentStack % 2 == 0) {
+ ++argumentStack;
+ buf.append('<');
+ }
+ buf.append('*');
+ }
+
+ public SignatureVisitor visitTypeArgument(char wildcard) {
+ if (argumentStack % 2 == 0) {
+ ++argumentStack;
+ buf.append('<');
+ }
+ if (wildcard != '=') {
+ buf.append(wildcard);
+ }
+ return this;
+ }
+
+ public void visitEnd() {
+ endArguments();
+ buf.append(';');
+ }
+
+ /**
+ * Returns the signature that was built by this signature writer.
+ *
+ * @return the signature that was built by this signature writer.
+ */
+ public String toString() {
+ return buf.toString();
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Ends the formal type parameters section of the signature.
+ */
+ private void endFormals() {
+ if (hasFormals) {
+ hasFormals = false;
+ buf.append('>');
+ }
+ }
+
+ /**
+ * Ends the type arguments of a class or inner class type.
+ */
+ private void endArguments() {
+ if (argumentStack % 2 == 1) {
+ buf.append('>');
+ }
+ argumentStack /= 2;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AbstractInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AbstractInsnNode.java
new file mode 100644
index 000000000..e0009da98
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AbstractInsnNode.java
@@ -0,0 +1,143 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a bytecode instruction.
+ *
+ * @author Eric Bruneton
+ */
+public abstract class AbstractInsnNode {
+
+ /**
+ * The type of {@link InsnNode} instructions.
+ */
+ public final static int INSN = 0;
+
+ /**
+ * The type of {@link IntInsnNode} instructions.
+ */
+ public final static int INT_INSN = 1;
+
+ /**
+ * The type of {@link VarInsnNode} instructions.
+ */
+ public final static int VAR_INSN = 2;
+
+ /**
+ * The type of {@link TypeInsnNode} instructions.
+ */
+ public final static int TYPE_INSN = 3;
+
+ /**
+ * The type of {@link FieldInsnNode} instructions.
+ */
+ public final static int FIELD_INSN = 4;
+
+ /**
+ * The type of {@link MethodInsnNode} instructions.
+ */
+ public final static int METHOD_INSN = 5;
+
+ /**
+ * The type of {@link JumpInsnNode} instructions.
+ */
+ public final static int JUMP_INSN = 6;
+
+ /**
+ * The type of {@link LabelNode} "instructions".
+ */
+ public final static int LABEL = 7;
+
+ /**
+ * The type of {@link LdcInsnNode} instructions.
+ */
+ public final static int LDC_INSN = 8;
+
+ /**
+ * The type of {@link IincInsnNode} instructions.
+ */
+ public final static int IINC_INSN = 9;
+
+ /**
+ * The type of {@link TableSwitchInsnNode} instructions.
+ */
+ public final static int TABLESWITCH_INSN = 10;
+
+ /**
+ * The type of {@link LookupSwitchInsnNode} instructions.
+ */
+ public final static int LOOKUPSWITCH_INSN = 11;
+
+ /**
+ * The type of {@link MultiANewArrayInsnNode} instructions.
+ */
+ public final static int MULTIANEWARRAY_INSN = 12;
+
+ /**
+ * The opcode of this instruction.
+ */
+ protected int opcode;
+
+ /**
+ * Constructs a new {@link AbstractInsnNode}.
+ *
+ * @param opcode the opcode of the instruction to be constructed.
+ */
+ protected AbstractInsnNode(final int opcode) {
+ this.opcode = opcode;
+ }
+
+ /**
+ * Returns the opcode of this instruction.
+ *
+ * @return the opcode of this instruction.
+ */
+ public int getOpcode() {
+ return opcode;
+ }
+
+ /**
+ * Returns the type of this instruction.
+ *
+ * @return the type of this instruction, i.e. one the constants defined in
+ * this class.
+ */
+ public abstract int getType();
+
+ /**
+ * Makes the given code visitor visit this instruction.
+ *
+ * @param cv a code visitor.
+ */
+ public abstract void accept(final MethodVisitor cv);
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AnnotationNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AnnotationNode.java
new file mode 100644
index 000000000..c9c1cb98f
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AnnotationNode.java
@@ -0,0 +1,187 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.asm.AnnotationVisitor;
+
+/**
+ * A node that represents an annotationn.
+ *
+ * @author Eric Bruneton
+ */
+public class AnnotationNode implements AnnotationVisitor {
+
+ /**
+ * The class descriptor of the annotation class.
+ */
+ public String desc;
+
+ /**
+ * The name value pairs of this annotation. Each name value pair is stored
+ * as two consecutive elements in the list. The name is a {@link String},
+ * and the value may be a {@link Byte}, {@link Boolean}, {@link Character},
+ * {@link Short}, {@link Integer}, {@link Long}, {@link Float},
+ * {@link Double}, {@link String} or {@link org.objectweb.asm.Type}, or an
+ * two elements String array (for enumeration values), a
+ * {@link AnnotationNode}, or a {@link List} of values of one of the
+ * preceding types. The list may be <tt>null</tt> if there is no name
+ * value pair.
+ */
+ public List values;
+
+ /**
+ * Constructs a new {@link AnnotationNode}.
+ *
+ * @param desc the class descriptor of the annotation class.
+ */
+ public AnnotationNode(final String desc) {
+ this.desc = desc;
+ }
+
+ /**
+ * Constructs a new {@link AnnotationNode} to visit an array value.
+ *
+ * @param values where the visited values must be stored.
+ */
+ AnnotationNode(final List values) {
+ this.values = values;
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the AnnotationVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(final String name, final Object value) {
+ if (values == null) {
+ values = new ArrayList(this.desc != null ? 2 : 1);
+ }
+ if (this.desc != null) {
+ values.add(name);
+ }
+ values.add(value);
+ }
+
+ public void visitEnum(
+ final String name,
+ final String desc,
+ final String value)
+ {
+ if (values == null) {
+ values = new ArrayList(this.desc != null ? 2 : 1);
+ }
+ if (this.desc != null) {
+ values.add(name);
+ }
+ values.add(new String[] { desc, value });
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String name,
+ final String desc)
+ {
+ if (values == null) {
+ values = new ArrayList(this.desc != null ? 2 : 1);
+ }
+ if (this.desc != null) {
+ values.add(name);
+ }
+ AnnotationNode annotation = new AnnotationNode(desc);
+ values.add(annotation);
+ return annotation;
+ }
+
+ public AnnotationVisitor visitArray(final String name) {
+ if (values == null) {
+ values = new ArrayList(this.desc != null ? 2 : 1);
+ }
+ if (this.desc != null) {
+ values.add(name);
+ }
+ List array = new ArrayList();
+ values.add(array);
+ return new AnnotationNode(array);
+ }
+
+ public void visitEnd() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Accept methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Makes the given visitor visit this annotation.
+ *
+ * @param av an annotation visitor.
+ */
+ public void accept(final AnnotationVisitor av) {
+ if (values != null) {
+ for (int i = 0; i < values.size(); i += 2) {
+ String name = (String) values.get(i);
+ Object value = values.get(i + 1);
+ accept(av, name, value);
+ }
+ }
+ av.visitEnd();
+ }
+
+ /**
+ * Makes the given visitor visit a given annotation value.
+ *
+ * @param av an annotation visitor.
+ * @param name the value name.
+ * @param value the actual value.
+ */
+ static void accept(
+ final AnnotationVisitor av,
+ final String name,
+ final Object value)
+ {
+ if (value instanceof String[]) {
+ String[] typeconst = (String[]) value;
+ av.visitEnum(name, typeconst[0], typeconst[1]);
+ } else if (value instanceof AnnotationNode) {
+ AnnotationNode an = (AnnotationNode) value;
+ an.accept(av.visitAnnotation(name, an.desc));
+ } else if (value instanceof List) {
+ AnnotationVisitor v = av.visitArray(name);
+ List array = (List) value;
+ for (int j = 0; j < array.size(); ++j) {
+ accept(v, null, array.get(j));
+ }
+ v.visitEnd();
+ } else {
+ av.visit(name, value);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/ClassNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/ClassNode.java
new file mode 100644
index 000000000..85134e3a5
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/ClassNode.java
@@ -0,0 +1,283 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.FieldVisitor;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * A node that represents a class.
+ *
+ * @author Eric Bruneton
+ */
+public class ClassNode extends MemberNode implements ClassVisitor {
+
+ /**
+ * The class version.
+ */
+ public int version;
+
+ /**
+ * The class's access flags (see {@link org.objectweb.asm.Opcodes}). This
+ * field also indicates if the class is deprecated.
+ */
+ public int access;
+
+ /**
+ * The internal name of the class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ */
+ public String name;
+
+ /**
+ * The signature of the class. Mayt be <tt>null</tt>.
+ */
+ public String signature;
+
+ /**
+ * The internal of name of the super class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). For
+ * interfaces, the super class is {@link Object}. May be <tt>null</tt>,
+ * but only for the {@link Object} class.
+ */
+ public String superName;
+
+ /**
+ * The internal names of the class's interfaces (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). This
+ * list is a list of {@link String} objects.
+ */
+ public List interfaces;
+
+ /**
+ * The name of the source file from which this class was compiled. May be
+ * <tt>null</tt>.
+ */
+ public String sourceFile;
+
+ /**
+ * Debug information to compute the correspondance between source and
+ * compiled elements of the class. May be <tt>null</tt>.
+ */
+ public String sourceDebug;
+
+ /**
+ * The internal name of the enclosing class of the class. May be
+ * <tt>null</tt>.
+ */
+ public String outerClass;
+
+ /**
+ * The name of the method that contains the class, or <tt>null</tt> if the
+ * class is not enclosed in a method.
+ */
+ public String outerMethod;
+
+ /**
+ * The descriptor of the method that contains the class, or <tt>null</tt>
+ * if the class is not enclosed in a method.
+ */
+ public String outerMethodDesc;
+
+ /**
+ * Informations about the inner classes of this class. This list is a list
+ * of {@link InnerClassNode} objects.
+ *
+ * @associates org.objectweb.asm.tree.InnerClassNode
+ */
+ public List innerClasses;
+
+ /**
+ * The fields of this class. This list is a list of {@link FieldNode}
+ * objects.
+ *
+ * @associates org.objectweb.asm.tree.FieldNode
+ */
+ public List fields;
+
+ /**
+ * The methods of this class. This list is a list of {@link MethodNode}
+ * objects.
+ *
+ * @associates org.objectweb.asm.tree.MethodNode
+ */
+ public List methods;
+
+ /**
+ * Constructs a new {@link ClassNode}.
+ */
+ public ClassNode() {
+ this.interfaces = new ArrayList();
+ this.innerClasses = new ArrayList();
+ this.fields = new ArrayList();
+ this.methods = new ArrayList();
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the ClassVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ this.version = version;
+ this.access = access;
+ this.name = name;
+ this.signature = signature;
+ this.superName = superName;
+ if (interfaces != null) {
+ this.interfaces.addAll(Arrays.asList(interfaces));
+ }
+ }
+
+ public void visitSource(final String file, final String debug) {
+ sourceFile = file;
+ sourceDebug = debug;
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ outerClass = owner;
+ outerMethod = name;
+ outerMethodDesc = desc;
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ InnerClassNode icn = new InnerClassNode(name,
+ outerName,
+ innerName,
+ access);
+ innerClasses.add(icn);
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ FieldNode fn = new FieldNode(access, name, desc, signature, value);
+ fields.add(fn);
+ return fn;
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ MethodNode mn = new MethodNode(access,
+ name,
+ desc,
+ signature,
+ exceptions);
+ methods.add(mn);
+ return mn;
+ }
+
+ public void visitEnd() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Accept method
+ // ------------------------------------------------------------------------
+
+ /**
+ * Makes the given class visitor visit this class.
+ *
+ * @param cv a class visitor.
+ */
+ public void accept(final ClassVisitor cv) {
+ // visits header
+ String[] interfaces = new String[this.interfaces.size()];
+ this.interfaces.toArray(interfaces);
+ cv.visit(version, access, name, signature, superName, interfaces);
+ // visits source
+ if (sourceFile != null || sourceDebug != null) {
+ cv.visitSource(sourceFile, sourceDebug);
+ }
+ // visits outer class
+ if (outerClass != null) {
+ cv.visitOuterClass(outerClass, outerMethod, outerMethodDesc);
+ }
+ // visits attributes
+ int i, n;
+ n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ AnnotationNode an = (AnnotationNode) visibleAnnotations.get(i);
+ an.accept(cv.visitAnnotation(an.desc, true));
+ }
+ n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ AnnotationNode an = (AnnotationNode) invisibleAnnotations.get(i);
+ an.accept(cv.visitAnnotation(an.desc, false));
+ }
+ n = attrs == null ? 0 : attrs.size();
+ for (i = 0; i < n; ++i) {
+ cv.visitAttribute((Attribute) attrs.get(i));
+ }
+ // visits inner classes
+ for (i = 0; i < innerClasses.size(); ++i) {
+ ((InnerClassNode) innerClasses.get(i)).accept(cv);
+ }
+ // visits fields
+ for (i = 0; i < fields.size(); ++i) {
+ ((FieldNode) fields.get(i)).accept(cv);
+ }
+ // visits methods
+ for (i = 0; i < methods.size(); ++i) {
+ ((MethodNode) methods.get(i)).accept(cv);
+ }
+ // visits end
+ cv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldInsnNode.java
new file mode 100644
index 000000000..2ae5388b1
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldInsnNode.java
@@ -0,0 +1,97 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a field instruction. A field instruction is an
+ * instruction that loads or stores the value of a field of an object.
+ *
+ * @author Eric Bruneton
+ */
+public class FieldInsnNode extends AbstractInsnNode {
+
+ /**
+ * The internal name of the field's owner class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ */
+ public String owner;
+
+ /**
+ * The field's name.
+ */
+ public String name;
+
+ /**
+ * The field's descriptor (see {@link org.objectweb.asm.Type}).
+ */
+ public String desc;
+
+ /**
+ * Constructs a new {@link FieldInsnNode}.
+ *
+ * @param opcode the opcode of the type instruction to be constructed. This
+ * opcode must be GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
+ * @param owner the internal name of the field's owner class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * @param name the field's name.
+ * @param desc the field's descriptor (see {@link org.objectweb.asm.Type}).
+ */
+ public FieldInsnNode(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ super(opcode);
+ this.owner = owner;
+ this.name = name;
+ this.desc = desc;
+ }
+
+ /**
+ * Sets the opcode of this instruction.
+ *
+ * @param opcode the new instruction opcode. This opcode must be GETSTATIC,
+ * PUTSTATIC, GETFIELD or PUTFIELD.
+ */
+ public void setOpcode(final int opcode) {
+ this.opcode = opcode;
+ }
+
+ public void accept(final MethodVisitor cv) {
+ cv.visitFieldInsn(opcode, owner, name, desc);
+ }
+
+ public int getType() {
+ return FIELD_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldNode.java
new file mode 100644
index 000000000..8a97b1cbc
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldNode.java
@@ -0,0 +1,123 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+
+/**
+ * A node that represents a field.
+ *
+ * @author Eric Bruneton
+ */
+public class FieldNode extends MemberNode implements FieldVisitor {
+
+ /**
+ * The field's access flags (see {@link org.objectweb.asm.Opcodes}). This
+ * field also indicates if the field is synthetic and/or deprecated.
+ */
+ public int access;
+
+ /**
+ * The field's name.
+ */
+ public String name;
+
+ /**
+ * The field's descriptor (see {@link org.objectweb.asm.Type}).
+ */
+ public String desc;
+
+ /**
+ * The field's signature. May be <tt>null</tt>.
+ */
+ public String signature;
+
+ /**
+ * The field's initial value. This field, which may be <tt>null</tt> if
+ * the field does not have an initial value, must be an {@link Integer}, a
+ * {@link Float}, a {@link Long}, a {@link Double} or a {@link String}.
+ */
+ public Object value;
+
+ /**
+ * Constructs a new {@link FieldNode}.
+ *
+ * @param access the field's access flags (see
+ * {@link org.objectweb.asm.Opcodes}). This parameter also indicates
+ * if the field is synthetic and/or deprecated.
+ * @param name the field's name.
+ * @param desc the field's descriptor (see {@link org.objectweb.asm.Type}).
+ * @param signature the field's signature.
+ * @param value the field's initial value. This parameter, which may be
+ * <tt>null</tt> if the field does not have an initial value, must
+ * be an {@link Integer}, a {@link Float}, a {@link Long}, a
+ * {@link Double} or a {@link String}.
+ */
+ public FieldNode(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ this.access = access;
+ this.name = name;
+ this.desc = desc;
+ this.signature = signature;
+ this.value = value;
+ }
+
+ /**
+ * Makes the given class visitor visit this field.
+ *
+ * @param cv a class visitor.
+ */
+ public void accept(final ClassVisitor cv) {
+ FieldVisitor fv = cv.visitField(access, name, desc, signature, value);
+ int i, n;
+ n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ AnnotationNode an = (AnnotationNode) visibleAnnotations.get(i);
+ an.accept(fv.visitAnnotation(an.desc, true));
+ }
+ n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ AnnotationNode an = (AnnotationNode) invisibleAnnotations.get(i);
+ an.accept(fv.visitAnnotation(an.desc, false));
+ }
+ n = attrs == null ? 0 : attrs.size();
+ for (i = 0; i < n; ++i) {
+ fv.visitAttribute((Attribute) attrs.get(i));
+ }
+ fv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IincInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IincInsnNode.java
new file mode 100644
index 000000000..b5399b07d
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IincInsnNode.java
@@ -0,0 +1,71 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * A node that represents an IINC instruction.
+ *
+ * @author Eric Bruneton
+ */
+public class IincInsnNode extends AbstractInsnNode {
+
+ /**
+ * Index of the local variable to be incremented.
+ */
+ public int var;
+
+ /**
+ * Amount to increment the local variable by.
+ */
+ public int incr;
+
+ /**
+ * Constructs a new {@link IincInsnNode}.
+ *
+ * @param var index of the local variable to be incremented.
+ * @param incr increment amount to increment the local variable by.
+ */
+ public IincInsnNode(final int var, final int incr) {
+ super(Opcodes.IINC);
+ this.var = var;
+ this.incr = incr;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitIincInsn(var, incr);
+ }
+
+ public int getType() {
+ return IINC_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InnerClassNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InnerClassNode.java
new file mode 100644
index 000000000..6af060ee8
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InnerClassNode.java
@@ -0,0 +1,101 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.ClassVisitor;
+
+/**
+ * A node that represents an inner class.
+ *
+ * @author Eric Bruneton
+ */
+public class InnerClassNode {
+
+ /**
+ * The internal name of an inner class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ */
+ public String name;
+
+ /**
+ * The internal name of the class to which the inner class belongs (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). May
+ * be <tt>null</tt>.
+ */
+ public String outerName;
+
+ /**
+ * The (simple) name of the inner class inside its enclosing class. May be
+ * <tt>null</tt> for anonymous inner classes.
+ */
+ public String innerName;
+
+ /**
+ * The access flags of the inner class as originally declared in the
+ * enclosing class.
+ */
+ public int access;
+
+ /**
+ * Constructs a new {@link InnerClassNode}.
+ *
+ * @param name the internal name of an inner class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * @param outerName the internal name of the class to which the inner class
+ * belongs (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * May be <tt>null</tt>.
+ * @param innerName the (simple) name of the inner class inside its
+ * enclosing class. May be <tt>null</tt> for anonymous inner
+ * classes.
+ * @param access the access flags of the inner class as originally declared
+ * in the enclosing class.
+ */
+ public InnerClassNode(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ this.name = name;
+ this.outerName = outerName;
+ this.innerName = innerName;
+ this.access = access;
+ }
+
+ /**
+ * Makes the given class visitor visit this inner class.
+ *
+ * @param cv a class visitor.
+ */
+ public void accept(final ClassVisitor cv) {
+ cv.visitInnerClass(name, outerName, innerName, access);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InsnNode.java
new file mode 100644
index 000000000..718272600
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InsnNode.java
@@ -0,0 +1,96 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a zero operand instruction.
+ *
+ * @author Eric Bruneton
+ */
+public class InsnNode extends AbstractInsnNode {
+
+ private final static InsnNode[] INSNS;
+
+ static {
+ INSNS = new InsnNode[255];
+ for (int i = 0; i < INSNS.length; ++i) {
+ INSNS[i] = new InsnNode(i);
+ }
+ }
+
+ /**
+ * Returns the {@link InsnNode} corresponding to the given opcode.
+ *
+ * @deprecated uses the constructor instead.
+ *
+ * @param opcode an instruction opcode.
+ * @return the {@link InsnNode} corresponding to the given opcode.
+ */
+ public final static InsnNode getByOpcode(final int opcode) {
+ return INSNS[opcode];
+ }
+
+ /**
+ * Constructs a new {@link InsnNode}.
+ *
+ * @param opcode the opcode of the instruction to be constructed. This
+ * opcode must be 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, IALOAD, LALOAD,
+ * FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, 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, I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F,
+ * I2B, I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN,
+ * FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW,
+ * MONITORENTER, or MONITOREXIT.
+ */
+ public InsnNode(final int opcode) {
+ super(opcode);
+ }
+
+ /**
+ * Makes the given visitor visit this instruction.
+ *
+ * @param mv a method visitor.
+ */
+ public void accept(final MethodVisitor mv) {
+ mv.visitInsn(opcode);
+ }
+
+ public int getType() {
+ return INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IntInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IntInsnNode.java
new file mode 100644
index 000000000..b9b02e382
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IntInsnNode.java
@@ -0,0 +1,75 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents an instruction with a single int operand.
+ *
+ * @author Eric Bruneton
+ */
+public class IntInsnNode extends AbstractInsnNode {
+
+ /**
+ * The operand of this instruction.
+ */
+ public int operand;
+
+ /**
+ * Constructs a new {@link IntInsnNode}.
+ *
+ * @param opcode the opcode of the instruction to be constructed. This
+ * opcode must be BIPUSH, SIPUSH or NEWARRAY.
+ * @param operand the operand of the instruction to be constructed.
+ */
+ public IntInsnNode(final int opcode, final int operand) {
+ super(opcode);
+ this.operand = operand;
+ }
+
+ /**
+ * Sets the opcode of this instruction.
+ *
+ * @param opcode the new instruction opcode. This opcode must be BIPUSH,
+ * SIPUSH or NEWARRAY.
+ */
+ public void setOpcode(final int opcode) {
+ this.opcode = opcode;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitIntInsn(opcode, operand);
+ }
+
+ public int getType() {
+ return INT_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/JumpInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/JumpInsnNode.java
new file mode 100644
index 000000000..7dccf32be
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/JumpInsnNode.java
@@ -0,0 +1,84 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a jump instruction. A jump instruction is an
+ * instruction that may jump to another instruction.
+ *
+ * @author Eric Bruneton
+ */
+public class JumpInsnNode extends AbstractInsnNode {
+
+ /**
+ * The operand of this instruction. This operand is a label that designates
+ * the instruction to which this instruction may jump.
+ */
+ public Label label;
+
+ /**
+ * Constructs a new {@link JumpInsnNode}.
+ *
+ * @param opcode the opcode of the type instruction to be constructed. This
+ * opcode must be IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
+ * IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ,
+ * IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
+ * @param label the operand of the instruction to be constructed. This
+ * operand is a label that designates the instruction to which the
+ * jump instruction may jump.
+ */
+ public JumpInsnNode(final int opcode, final Label label) {
+ super(opcode);
+ this.label = label;
+ }
+
+ /**
+ * Sets the opcode of this instruction.
+ *
+ * @param opcode the new instruction opcode. This opcode must be IFEQ, IFNE,
+ * IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT,
+ * IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR,
+ * IFNULL or IFNONNULL.
+ */
+ public void setOpcode(final int opcode) {
+ this.opcode = opcode;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitJumpInsn(opcode, label);
+ }
+
+ public int getType() {
+ return JUMP_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LabelNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LabelNode.java
new file mode 100644
index 000000000..0f8c93351
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LabelNode.java
@@ -0,0 +1,54 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * An {@link AbstractInsnNode} that encapsulates a {@link Label}.
+ */
+public class LabelNode extends AbstractInsnNode {
+
+ public Label label;
+
+ public LabelNode(final Label label) {
+ super(-1);
+ this.label = label;
+ }
+
+ public void accept(final MethodVisitor cv) {
+ cv.visitLabel(label);
+ }
+
+ public int getType() {
+ return LABEL;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LdcInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LdcInsnNode.java
new file mode 100644
index 000000000..234b41fe3
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LdcInsnNode.java
@@ -0,0 +1,68 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * A node that represents an LDC instruction.
+ *
+ * @author Eric Bruneton
+ */
+public class LdcInsnNode extends AbstractInsnNode {
+
+ /**
+ * The constant to be loaded on the stack. This parameter must be a non null
+ * {@link Integer}, a {@link Float}, a {@link Long}, a {@link Double}, a
+ * {@link String} or a {@link org.objectweb.asm.Type}.
+ */
+ public Object cst;
+
+ /**
+ * Constructs a new {@link LdcInsnNode}.
+ *
+ * @param cst the constant to be loaded on the stack. This parameter must be
+ * a non null {@link Integer}, a {@link Float}, a {@link Long}, a
+ * {@link Double} or a {@link String}.
+ */
+ public LdcInsnNode(final Object cst) {
+ super(Opcodes.LDC);
+ this.cst = cst;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitLdcInsn(cst);
+ }
+
+ public int getType() {
+ return LDC_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LineNumberNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LineNumberNode.java
new file mode 100644
index 000000000..2a3498844
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LineNumberNode.java
@@ -0,0 +1,73 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a line number declaration.
+ *
+ * @author Eric Bruneton
+ */
+public class LineNumberNode {
+
+ /**
+ * A line number. This number refers to the source file from which the class
+ * was compiled.
+ */
+ public int line;
+
+ /**
+ * The first instruction corresponding to this line number.
+ */
+ public Label start;
+
+ /**
+ * Constructs a new {@link LineNumberNode}.
+ *
+ * @param line a line number. This number refers to the source file from
+ * which the class was compiled.
+ * @param start the first instruction corresponding to this line number.
+ */
+ public LineNumberNode(final int line, final Label start) {
+ this.line = line;
+ this.start = start;
+ }
+
+ /**
+ * Makes the given visitor visit this line number declaration.
+ *
+ * @param mv a method visitor.
+ */
+ public void accept(final MethodVisitor mv) {
+ mv.visitLineNumber(line, start);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LocalVariableNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LocalVariableNode.java
new file mode 100644
index 000000000..511dcf964
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LocalVariableNode.java
@@ -0,0 +1,111 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Label;
+
+/**
+ * A node that represents a local variable declaration.
+ *
+ * @author Eric Bruneton
+ */
+public class LocalVariableNode {
+
+ /**
+ * The name of a local variable.
+ */
+ public String name;
+
+ /**
+ * The type descriptor of this local variable.
+ */
+ public String desc;
+
+ /**
+ * The signature of this local variable. May be <tt>null</tt>.
+ */
+ public String signature;
+
+ /**
+ * The first instruction corresponding to the scope of this local variable
+ * (inclusive).
+ */
+ public Label start;
+
+ /**
+ * The last instruction corresponding to the scope of this local variable
+ * (exclusive).
+ */
+ public Label end;
+
+ /**
+ * The local variable's index.
+ */
+ public int index;
+
+ /**
+ * Constructs a new {@link LocalVariableNode}.
+ *
+ * @param name the name of a local variable.
+ * @param desc the type descriptor of this local variable.
+ * @param signature the signature of this local variable. May be
+ * <tt>null</tt>.
+ * @param start the first instruction corresponding to the scope of this
+ * local variable (inclusive).
+ * @param end the last instruction corresponding to the scope of this local
+ * variable (exclusive).
+ * @param index the local variable's index.
+ */
+ public LocalVariableNode(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ this.name = name;
+ this.desc = desc;
+ this.signature = signature;
+ this.start = start;
+ this.end = end;
+ this.index = index;
+ }
+
+ /**
+ * Makes the given visitor visit this local variable declaration.
+ *
+ * @param mv a method visitor.
+ */
+ public void accept(final MethodVisitor mv) {
+ mv.visitLocalVariable(name, desc, signature, start, end, index);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.java
new file mode 100644
index 000000000..31eb234e8
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.java
@@ -0,0 +1,103 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.MethodVisitor;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * A node that represents a LOOKUPSWITCH instruction.
+ *
+ * @author Eric Bruneton
+ */
+public class LookupSwitchInsnNode extends AbstractInsnNode {
+
+ /**
+ * Beginning of the default handler block.
+ */
+ public Label dflt;
+
+ /**
+ * The values of the keys. This list is a list of {@link Integer} objects.
+ */
+ public List keys;
+
+ /**
+ * Beginnings of the handler blocks. This list is a list of {@link Label}
+ * objects.
+ */
+ public List labels;
+
+ /**
+ * Constructs a new {@link LookupSwitchInsnNode}.
+ *
+ * @param dflt beginning of the default handler block.
+ * @param keys the values of the keys.
+ * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
+ * the beginning of the handler block for the <tt>keys[i]</tt> key.
+ */
+ public LookupSwitchInsnNode(
+ final Label dflt,
+ final int[] keys,
+ final Label[] labels)
+ {
+ super(Opcodes.LOOKUPSWITCH);
+ this.dflt = dflt;
+ this.keys = new ArrayList(keys == null ? 0 : keys.length);
+ this.labels = new ArrayList(labels == null ? 0 : labels.length);
+ if (keys != null) {
+ for (int i = 0; i < keys.length; ++i) {
+ this.keys.add(new Integer(keys[i]));
+ }
+ }
+ if (labels != null) {
+ this.labels.addAll(Arrays.asList(labels));
+ }
+ }
+
+ public void accept(final MethodVisitor mv) {
+ int[] keys = new int[this.keys.size()];
+ for (int i = 0; i < keys.length; ++i) {
+ keys[i] = ((Integer) this.keys.get(i)).intValue();
+ }
+ Label[] labels = new Label[this.labels.size()];
+ this.labels.toArray(labels);
+ mv.visitLookupSwitchInsn(dflt, keys, labels);
+ }
+
+ public int getType() {
+ return LOOKUPSWITCH_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MemberNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MemberNode.java
new file mode 100644
index 000000000..11dfad862
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MemberNode.java
@@ -0,0 +1,120 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+
+/**
+ * An abstract class, field or method node.
+ *
+ * @author Eric Bruneton
+ */
+public abstract class MemberNode {
+
+ /**
+ * The runtime visible annotations of this class, field or method. This list
+ * is a list of {@link AnnotationNode} objects. May be <tt>null</tt>.
+ *
+ * @associates org.objectweb.asm.tree.AnnotationNode
+ * @label visible
+ */
+ public List visibleAnnotations;
+
+ /**
+ * The runtime invisible annotations of this class, field or method. This
+ * list is a list of {@link AnnotationNode} objects. May be <tt>null</tt>.
+ *
+ * @associates org.objectweb.asm.tree.AnnotationNode
+ * @label invisible
+ */
+ public List invisibleAnnotations;
+
+ /**
+ * The non standard attributes of this class, field or method. This list is
+ * a list of {@link Attribute} objects. May be <tt>null</tt>.
+ *
+ * @associates org.objectweb.asm.Attribute
+ */
+ public List attrs;
+
+ /**
+ * Constructs a new {@link MemberNode}.
+ */
+ public MemberNode() {
+ }
+
+ /**
+ * Visits an annotation of this class, field or method.
+ *
+ * @param desc the class descriptor of the annotation class.
+ * @param visible <tt>true</tt> if the annotation is visible at runtime.
+ * @return a visitor to visit the annotation values.
+ */
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ AnnotationNode an = new AnnotationNode(desc);
+ if (visible) {
+ if (visibleAnnotations == null) {
+ visibleAnnotations = new ArrayList(1);
+ }
+ visibleAnnotations.add(an);
+ } else {
+ if (invisibleAnnotations == null) {
+ invisibleAnnotations = new ArrayList(1);
+ }
+ invisibleAnnotations.add(an);
+ }
+ return an;
+ }
+
+ /**
+ * Visits a non standard attribute of this class, field or method.
+ *
+ * @param attr an attribute.
+ */
+ public void visitAttribute(final Attribute attr) {
+ if (attrs == null) {
+ attrs = new ArrayList(1);
+ }
+ attrs.add(attr);
+ }
+
+ /**
+ * Visits the end of this class, field or method.
+ */
+ public void visitEnd() {
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodInsnNode.java
new file mode 100644
index 000000000..f22744706
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodInsnNode.java
@@ -0,0 +1,98 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a method instruction. A method instruction is an
+ * instruction that invokes a method.
+ *
+ * @author Eric Bruneton
+ */
+public class MethodInsnNode extends AbstractInsnNode {
+
+ /**
+ * The internal name of the method's owner class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ */
+ public String owner;
+
+ /**
+ * The method's name.
+ */
+ public String name;
+
+ /**
+ * The method's descriptor (see {@link org.objectweb.asm.Type}).
+ */
+ public String desc;
+
+ /**
+ * Constructs a new {@link MethodInsnNode}.
+ *
+ * @param opcode the opcode of the type instruction to be constructed. This
+ * opcode must be INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
+ * INVOKEINTERFACE.
+ * @param owner the internal name of the method's owner class (see
+ * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * @param name the method's name.
+ * @param desc the method's descriptor (see {@link org.objectweb.asm.Type}).
+ */
+ public MethodInsnNode(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ super(opcode);
+ this.owner = owner;
+ this.name = name;
+ this.desc = desc;
+ }
+
+ /**
+ * Sets the opcode of this instruction.
+ *
+ * @param opcode the new instruction opcode. This opcode must be
+ * INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
+ */
+ public void setOpcode(final int opcode) {
+ this.opcode = opcode;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitMethodInsn(opcode, owner, name, desc);
+ }
+
+ public int getType() {
+ return METHOD_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodNode.java
new file mode 100644
index 000000000..9d0b2e9cf
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodNode.java
@@ -0,0 +1,439 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * A node that represents a method.
+ *
+ * @author Eric Bruneton
+ */
+public class MethodNode extends MemberNode implements MethodVisitor {
+
+ /**
+ * The method's access flags (see {@link Opcodes}). This field also
+ * indicates if the method is synthetic and/or deprecated.
+ */
+ public int access;
+
+ /**
+ * The method's name.
+ */
+ public String name;
+
+ /**
+ * The method's descriptor (see {@link Type}).
+ */
+ public String desc;
+
+ /**
+ * The method's signature. May be <tt>null</tt>.
+ */
+ public String signature;
+
+ /**
+ * The internal names of the method's exception classes (see
+ * {@link Type#getInternalName() getInternalName}). This list is a list of
+ * {@link String} objects.
+ */
+ public List exceptions;
+
+ /**
+ * The default value of this annotation interface method. This field must be
+ * a {@link Byte}, {@link Boolean}, {@link Character}, {@link Short},
+ * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
+ * {@link String} or {@link Type}, or an two elements String array (for
+ * enumeration values), a {@link AnnotationNode}, or a {@link List} of
+ * values of one of the preceding types. May be <tt>null</tt>.
+ */
+ public Object annotationDefault;
+
+ /**
+ * The runtime visible parameter annotations of this method. These lists are
+ * lists of {@link AnnotationNode} objects. May be <tt>null</tt>.
+ *
+ * @associates org.objectweb.asm.tree.AnnotationNode
+ * @label invisible parameters
+ */
+ public List[] visibleParameterAnnotations;
+
+ /**
+ * The runtime invisible parameter annotations of this method. These lists
+ * are lists of {@link AnnotationNode} objects. May be <tt>null</tt>.
+ *
+ * @associates org.objectweb.asm.tree.AnnotationNode
+ * @label visible parameters
+ */
+ public List[] invisibleParameterAnnotations;
+
+ /**
+ * The instructions of this method. This list is a list of
+ * {@link AbstractInsnNode} objects.
+ *
+ * @associates org.objectweb.asm.tree.AbstractInsnNode
+ * @label instructions
+ */
+ public List instructions;
+
+ /**
+ * The try catch blocks of this method. This list is a list of
+ * {@link TryCatchBlockNode} objects.
+ *
+ * @associates org.objectweb.asm.tree.TryCatchBlockNode
+ */
+ public List tryCatchBlocks;
+
+ /**
+ * The maximum stack size of this method.
+ */
+ public int maxStack;
+
+ /**
+ * The maximum number of local variables of this method.
+ */
+ public int maxLocals;
+
+ /**
+ * The local variables of this method. This list is a list of
+ * {@link LocalVariableNode} objects. May be <tt>null</tt>
+ *
+ * @associates org.objectweb.asm.tree.LocalVariableNode
+ */
+ public List localVariables;
+
+ /**
+ * The line numbers of this method. This list is a list of
+ * {@link LineNumberNode} objects. May be <tt>null</tt>
+ *
+ * @associates org.objectweb.asm.tree.LineNumberNode
+ */
+ public List lineNumbers;
+
+ /**
+ * Constructs a new {@link MethodNode}.
+ *
+ * @param access the method's access flags (see {@link Opcodes}). This
+ * parameter also indicates if the method is synthetic and/or
+ * deprecated.
+ * @param name the method's name.
+ * @param desc the method's descriptor (see {@link Type}).
+ * @param signature the method's signature. May be <tt>null</tt>.
+ * @param exceptions the internal names of the method's exception classes
+ * (see {@link Type#getInternalName() getInternalName}). May be
+ * <tt>null</tt>.
+ */
+ public MethodNode(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ this.access = access;
+ this.name = name;
+ this.desc = desc;
+ this.signature = signature;
+ this.exceptions = new ArrayList(exceptions == null
+ ? 0
+ : exceptions.length);
+ boolean isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0;
+ this.instructions = new ArrayList(isAbstract ? 0 : 24);
+ if (!isAbstract) {
+ this.localVariables = new ArrayList(5);
+ this.lineNumbers = new ArrayList(5);
+ }
+ this.tryCatchBlocks = new ArrayList();
+ if (exceptions != null) {
+ this.exceptions.addAll(Arrays.asList(exceptions));
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the MethodVisitor interface
+ // ------------------------------------------------------------------------
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ return new AnnotationNode(new ArrayList(0) {
+ public boolean add(Object o) {
+ annotationDefault = o;
+ return super.add(o);
+ }
+ });
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ AnnotationNode an = new AnnotationNode(desc);
+ if (visible) {
+ if (visibleParameterAnnotations == null) {
+ int params = Type.getArgumentTypes(this.desc).length;
+ visibleParameterAnnotations = new List[params];
+ }
+ if (visibleParameterAnnotations[parameter] == null) {
+ visibleParameterAnnotations[parameter] = new ArrayList(1);
+ }
+ visibleParameterAnnotations[parameter].add(an);
+ } else {
+ if (invisibleParameterAnnotations == null) {
+ int params = Type.getArgumentTypes(this.desc).length;
+ invisibleParameterAnnotations = new List[params];
+ }
+ if (invisibleParameterAnnotations[parameter] == null) {
+ invisibleParameterAnnotations[parameter] = new ArrayList(1);
+ }
+ invisibleParameterAnnotations[parameter].add(an);
+ }
+ return an;
+ }
+
+ public void visitCode() {
+ }
+
+ public void visitInsn(final int opcode) {
+ instructions.add(new InsnNode(opcode));
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ instructions.add(new IntInsnNode(opcode, operand));
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ instructions.add(new VarInsnNode(opcode, var));
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ instructions.add(new TypeInsnNode(opcode, desc));
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ instructions.add(new FieldInsnNode(opcode, owner, name, desc));
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ instructions.add(new MethodInsnNode(opcode, owner, name, desc));
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ instructions.add(new JumpInsnNode(opcode, label));
+ }
+
+ public void visitLabel(final Label label) {
+ instructions.add(new LabelNode(label));
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ instructions.add(new LdcInsnNode(cst));
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ instructions.add(new IincInsnNode(var, increment));
+ }
+
+ public void visitTableSwitchInsn(
+ final int min,
+ final int max,
+ final Label dflt,
+ final Label[] labels)
+ {
+ instructions.add(new TableSwitchInsnNode(min, max, dflt, labels));
+ }
+
+ public void visitLookupSwitchInsn(
+ final Label dflt,
+ final int[] keys,
+ final Label[] labels)
+ {
+ instructions.add(new LookupSwitchInsnNode(dflt, keys, labels));
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ instructions.add(new MultiANewArrayInsnNode(desc, dims));
+ }
+
+ public void visitTryCatchBlock(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ tryCatchBlocks.add(new TryCatchBlockNode(start, end, handler, type));
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ localVariables.add(new LocalVariableNode(name,
+ desc,
+ signature,
+ start,
+ end,
+ index));
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ lineNumbers.add(new LineNumberNode(line, start));
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ this.maxStack = maxStack;
+ this.maxLocals = maxLocals;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accept method
+ // ------------------------------------------------------------------------
+
+ /**
+ * Makes the given class visitor visit this method.
+ *
+ * @param cv a class visitor.
+ */
+ public void accept(final ClassVisitor cv) {
+ String[] exceptions = new String[this.exceptions.size()];
+ this.exceptions.toArray(exceptions);
+ MethodVisitor mv = cv.visitMethod(access,
+ name,
+ desc,
+ signature,
+ exceptions);
+ if (mv != null) {
+ accept(mv);
+ }
+ }
+
+ /**
+ * Makes the given method visitor visit this method.
+ *
+ * @param mv a method visitor.
+ */
+ public void accept(final MethodVisitor mv) {
+ // visits the method attributes
+ int i, j, n;
+ if (annotationDefault != null) {
+ AnnotationVisitor av = mv.visitAnnotationDefault();
+ AnnotationNode.accept(av, null, annotationDefault);
+ av.visitEnd();
+ }
+ n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ AnnotationNode an = (AnnotationNode) visibleAnnotations.get(i);
+ an.accept(mv.visitAnnotation(an.desc, true));
+ }
+ n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ AnnotationNode an = (AnnotationNode) invisibleAnnotations.get(i);
+ an.accept(mv.visitAnnotation(an.desc, false));
+ }
+ n = visibleParameterAnnotations == null
+ ? 0
+ : visibleParameterAnnotations.length;
+ for (i = 0; i < n; ++i) {
+ List l = visibleParameterAnnotations[i];
+ if (l == null) {
+ continue;
+ }
+ for (j = 0; j < l.size(); ++j) {
+ AnnotationNode an = (AnnotationNode) l.get(j);
+ an.accept(mv.visitParameterAnnotation(i, an.desc, true));
+ }
+ }
+ n = invisibleParameterAnnotations == null
+ ? 0
+ : invisibleParameterAnnotations.length;
+ for (i = 0; i < n; ++i) {
+ List l = invisibleParameterAnnotations[i];
+ if (l == null) {
+ continue;
+ }
+ for (j = 0; j < l.size(); ++j) {
+ AnnotationNode an = (AnnotationNode) l.get(j);
+ an.accept(mv.visitParameterAnnotation(i, an.desc, false));
+ }
+ }
+ n = attrs == null ? 0 : attrs.size();
+ for (i = 0; i < n; ++i) {
+ mv.visitAttribute((Attribute) attrs.get(i));
+ }
+ // visits the method's code
+ if (instructions.size() > 0) {
+ mv.visitCode();
+ // visits try catch blocks
+ for (i = 0; i < tryCatchBlocks.size(); ++i) {
+ ((TryCatchBlockNode) tryCatchBlocks.get(i)).accept(mv);
+ }
+ // visits instructions
+ for (i = 0; i < instructions.size(); ++i) {
+ ((AbstractInsnNode) instructions.get(i)).accept(mv);
+ }
+ // visits local variables
+ n = localVariables == null ? 0 : localVariables.size();
+ for (i = 0; i < n; ++i) {
+ ((LocalVariableNode) localVariables.get(i)).accept(mv);
+ }
+ // visits line numbers
+ n = lineNumbers == null ? 0 : lineNumbers.size();
+ for (i = 0; i < n; ++i) {
+ ((LineNumberNode) lineNumbers.get(i)).accept(mv);
+ }
+ // visits maxs
+ mv.visitMaxs(maxStack, maxLocals);
+ }
+ mv.visitEnd();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.java
new file mode 100644
index 000000000..ed81347dc
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.java
@@ -0,0 +1,71 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a MULTIANEWARRAY instruction.
+ *
+ * @author Eric Bruneton
+ */
+public class MultiANewArrayInsnNode extends AbstractInsnNode {
+
+ /**
+ * An array type descriptor (see {@link org.objectweb.asm.Type}).
+ */
+ public String desc;
+
+ /**
+ * Number of dimensions of the array to allocate.
+ */
+ public int dims;
+
+ /**
+ * Constructs a new {@link MultiANewArrayInsnNode}.
+ *
+ * @param desc an array type descriptor (see {@link org.objectweb.asm.Type}).
+ * @param dims number of dimensions of the array to allocate.
+ */
+ public MultiANewArrayInsnNode(final String desc, final int dims) {
+ super(Opcodes.MULTIANEWARRAY);
+ this.desc = desc;
+ this.dims = dims;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitMultiANewArrayInsn(desc, dims);
+ }
+
+ public int getType() {
+ return MULTIANEWARRAY_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TableSwitchInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TableSwitchInsnNode.java
new file mode 100644
index 000000000..840309dd6
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TableSwitchInsnNode.java
@@ -0,0 +1,102 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.MethodVisitor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A node that represents a TABLESWITCH instruction.
+ *
+ * @author Eric Bruneton
+ */
+public class TableSwitchInsnNode extends AbstractInsnNode {
+
+ /**
+ * The minimum key value.
+ */
+ public int min;
+
+ /**
+ * The maximum key value.
+ */
+ public int max;
+
+ /**
+ * Beginning of the default handler block.
+ */
+ public Label dflt;
+
+ /**
+ * Beginnings of the handler blocks. This list is a list of {@link Label}
+ * objects.
+ */
+ public List labels;
+
+ /**
+ * Constructs a new {@link TableSwitchInsnNode}.
+ *
+ * @param min the minimum key value.
+ * @param max the maximum key value.
+ * @param dflt beginning of the default handler block.
+ * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
+ * the beginning of the handler block for the <tt>min + i</tt> key.
+ */
+ public TableSwitchInsnNode(
+ final int min,
+ final int max,
+ final Label dflt,
+ final Label[] labels)
+ {
+ super(Opcodes.TABLESWITCH);
+ this.min = min;
+ this.max = max;
+ this.dflt = dflt;
+ this.labels = new ArrayList();
+ if (labels != null) {
+ this.labels.addAll(Arrays.asList(labels));
+ }
+ }
+
+ public void accept(final MethodVisitor mv) {
+ Label[] labels = new Label[this.labels.size()];
+ this.labels.toArray(labels);
+ mv.visitTableSwitchInsn(min, max, dflt, labels);
+ }
+
+ public int getType() {
+ return TABLESWITCH_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TryCatchBlockNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TryCatchBlockNode.java
new file mode 100644
index 000000000..56b146574
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TryCatchBlockNode.java
@@ -0,0 +1,93 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a try catch block.
+ *
+ * @author Eric Bruneton
+ */
+public class TryCatchBlockNode {
+
+ /**
+ * Beginning of the exception handler's scope (inclusive).
+ */
+ public Label start;
+
+ /**
+ * End of the exception handler's scope (exclusive).
+ */
+ public Label end;
+
+ /**
+ * Beginning of the exception handler's code.
+ */
+ public Label handler;
+
+ /**
+ * Internal name of the type of exceptions handled by the handler. May be
+ * <tt>null</tt> to catch any exceptions (for "finally" blocks).
+ */
+ public String type;
+
+ /**
+ * Constructs a new {@link TryCatchBlockNode}.
+ *
+ * @param start beginning of the exception handler's scope (inclusive).
+ * @param end end of the exception handler's scope (exclusive).
+ * @param handler beginning of the exception handler's code.
+ * @param type internal name of the type of exceptions handled by the
+ * handler, or <tt>null</tt> to catch any exceptions (for "finally"
+ * blocks).
+ */
+ public TryCatchBlockNode(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ this.start = start;
+ this.end = end;
+ this.handler = handler;
+ this.type = type;
+ }
+
+ /**
+ * Makes the given visitor visit this try catch block.
+ *
+ * @param mv a method visitor.
+ */
+ public void accept(final MethodVisitor mv) {
+ mv.visitTryCatchBlock(start, end, handler, type);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TypeInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TypeInsnNode.java
new file mode 100644
index 000000000..9f830b4dd
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TypeInsnNode.java
@@ -0,0 +1,78 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a type instruction. A type instruction is an
+ * instruction that takes a type descriptor as parameter.
+ *
+ * @author Eric Bruneton
+ */
+public class TypeInsnNode extends AbstractInsnNode {
+
+ /**
+ * The operand of this instruction. This operand is a type descriptor (see
+ * {@link org.objectweb.asm.Type}).
+ */
+ public String desc;
+
+ /**
+ * Constructs a new {@link TypeInsnNode}.
+ *
+ * @param opcode the opcode of the type instruction to be constructed. This
+ * opcode must be NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
+ * @param desc the operand of the instruction to be constructed. This
+ * operand is a type descriptor (see {@link org.objectweb.asm.Type}).
+ */
+ public TypeInsnNode(final int opcode, final String desc) {
+ super(opcode);
+ this.desc = desc;
+ }
+
+ /**
+ * Sets the opcode of this instruction.
+ *
+ * @param opcode the new instruction opcode. This opcode must be NEW,
+ * ANEWARRAY, CHECKCAST or INSTANCEOF.
+ */
+ public void setOpcode(final int opcode) {
+ this.opcode = opcode;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitTypeInsn(opcode, desc);
+ }
+
+ public int getType() {
+ return TYPE_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/VarInsnNode.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/VarInsnNode.java
new file mode 100644
index 000000000..92e28ded0
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/VarInsnNode.java
@@ -0,0 +1,81 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree;
+
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * A node that represents a local variable instruction. A local variable
+ * instruction is an instruction that loads or stores the value of a local
+ * variable.
+ *
+ * @author Eric Bruneton
+ */
+public class VarInsnNode extends AbstractInsnNode {
+
+ /**
+ * The operand of this instruction. This operand is the index of a local
+ * variable.
+ */
+ public int var;
+
+ /**
+ * Constructs a new {@link VarInsnNode}.
+ *
+ * @param opcode the opcode of the local variable instruction to be
+ * constructed. This opcode must be ILOAD, LLOAD, FLOAD, DLOAD,
+ * ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
+ * @param var the operand of the instruction to be constructed. This operand
+ * is the index of a local variable.
+ */
+ public VarInsnNode(final int opcode, final int var) {
+ super(opcode);
+ this.var = var;
+ }
+
+ /**
+ * Sets the opcode of this instruction.
+ *
+ * @param opcode the new instruction opcode. This opcode must be ILOAD,
+ * LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE
+ * or RET.
+ */
+ public void setOpcode(final int opcode) {
+ this.opcode = opcode;
+ }
+
+ public void accept(final MethodVisitor mv) {
+ mv.visitVarInsn(opcode, var);
+ }
+
+ public int getType() {
+ return VAR_INSN;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Analyzer.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Analyzer.java
new file mode 100644
index 000000000..cfd48149c
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Analyzer.java
@@ -0,0 +1,416 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.IincInsnNode;
+import org.objectweb.asm.tree.JumpInsnNode;
+import org.objectweb.asm.tree.LabelNode;
+import org.objectweb.asm.tree.LookupSwitchInsnNode;
+import org.objectweb.asm.tree.MethodNode;
+import org.objectweb.asm.tree.TableSwitchInsnNode;
+import org.objectweb.asm.tree.TryCatchBlockNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/**
+ * A semantic bytecode analyzer.
+ *
+ * @author Eric Bruneton
+ */
+public class Analyzer implements Opcodes {
+
+ private Interpreter interpreter;
+
+ private int n;
+
+ private IntMap indexes;
+
+ private List[] handlers;
+
+ private Frame[] frames;
+
+ private Subroutine[] subroutines;
+
+ private boolean[] queued;
+
+ private int[] queue;
+
+ private int top;
+
+ private boolean jsr;
+
+ /**
+ * Constructs a new {@link Analyzer}.
+ *
+ * @param interpreter the interpreter to be used to symbolically interpret
+ * the bytecode instructions.
+ */
+ public Analyzer(final Interpreter interpreter) {
+ this.interpreter = interpreter;
+ }
+
+ /**
+ * Analyzes the given method.
+ *
+ * @param owner the internal name of the class to which the method belongs.
+ * @param m the method to be analyzed.
+ * @return the symbolic state of the execution stack frame at each bytecode
+ * instruction of the method. The size of the returned array is
+ * equal to the number of instructions (and labels) of the method. A
+ * given frame is <tt>null</tt> if and only if the corresponding
+ * instruction cannot be reached (dead code).
+ * @throws AnalyzerException if a problem occurs during the analysis.
+ */
+ public Frame[] analyze(final String owner, final MethodNode m)
+ throws AnalyzerException
+ {
+ n = m.instructions.size();
+ indexes = new IntMap(2 * n);
+ handlers = new List[n];
+ frames = new Frame[n];
+ subroutines = new Subroutine[n];
+ queued = new boolean[n];
+ queue = new int[n];
+ top = 0;
+
+ // computes instruction indexes
+ for (int i = 0; i < n; ++i) {
+ Object insn = m.instructions.get(i);
+ if (insn instanceof LabelNode) {
+ insn = ((LabelNode) insn).label;
+ }
+ indexes.put(insn, i);
+ }
+
+ // computes exception handlers for each instruction
+ for (int i = 0; i < m.tryCatchBlocks.size(); ++i) {
+ TryCatchBlockNode tcb = (TryCatchBlockNode) m.tryCatchBlocks.get(i);
+ int begin = indexes.get(tcb.start);
+ int end = indexes.get(tcb.end);
+ for (int j = begin; j < end; ++j) {
+ List insnHandlers = handlers[j];
+ if (insnHandlers == null) {
+ insnHandlers = new ArrayList();
+ handlers[j] = insnHandlers;
+ }
+ insnHandlers.add(tcb);
+ }
+ }
+
+ // initializes the data structures for the control flow analysis
+ // algorithm
+ Frame current = newFrame(m.maxLocals, m.maxStack);
+ Frame handler = newFrame(m.maxLocals, m.maxStack);
+ Type[] args = Type.getArgumentTypes(m.desc);
+ int local = 0;
+ if ((m.access & ACC_STATIC) == 0) {
+ Type ctype = Type.getType("L" + owner + ";");
+ current.setLocal(local++, interpreter.newValue(ctype));
+ }
+ for (int i = 0; i < args.length; ++i) {
+ current.setLocal(local++, interpreter.newValue(args[i]));
+ if (args[i].getSize() == 2) {
+ current.setLocal(local++, interpreter.newValue(null));
+ }
+ }
+ while (local < m.maxLocals) {
+ current.setLocal(local++, interpreter.newValue(null));
+ }
+ merge(0, current, null);
+
+ // control flow analysis
+ while (top > 0) {
+ int insn = queue[--top];
+ Frame f = frames[insn];
+ Subroutine subroutine = subroutines[insn];
+ queued[insn] = false;
+
+ try {
+ Object o = m.instructions.get(insn);
+ jsr = false;
+
+ if (o instanceof LabelNode) {
+ merge(insn + 1, f, subroutine);
+ } else {
+ AbstractInsnNode insnNode = (AbstractInsnNode) o;
+ int insnOpcode = insnNode.getOpcode();
+
+ current.init(f).execute(insnNode, interpreter);
+ subroutine = subroutine == null ? null : subroutine.copy();
+
+ if (insnNode instanceof JumpInsnNode) {
+ JumpInsnNode j = (JumpInsnNode) insnNode;
+ if (insnOpcode != GOTO && insnOpcode != JSR) {
+ merge(insn + 1, current, subroutine);
+ }
+ if (insnOpcode == JSR) {
+ jsr = true;
+ merge(indexes.get(j.label),
+ current,
+ new Subroutine(j.label, m.maxLocals, j));
+ } else {
+ merge(indexes.get(j.label), current, subroutine);
+ }
+ } else if (insnNode instanceof LookupSwitchInsnNode) {
+ LookupSwitchInsnNode lsi = (LookupSwitchInsnNode) insnNode;
+ merge(indexes.get(lsi.dflt), current, subroutine);
+ for (int j = 0; j < lsi.labels.size(); ++j) {
+ Label label = (Label) lsi.labels.get(j);
+ merge(indexes.get(label), current, subroutine);
+ }
+ } else if (insnNode instanceof TableSwitchInsnNode) {
+ TableSwitchInsnNode tsi = (TableSwitchInsnNode) insnNode;
+ merge(indexes.get(tsi.dflt), current, subroutine);
+ for (int j = 0; j < tsi.labels.size(); ++j) {
+ Label label = (Label) tsi.labels.get(j);
+ merge(indexes.get(label), current, subroutine);
+ }
+ } else if (insnOpcode == RET) {
+ if (subroutine == null) {
+ throw new AnalyzerException("RET instruction outside of a sub routine");
+ }
+ for (int i = 0; i < subroutine.callers.size(); ++i) {
+ int caller = indexes.get(subroutine.callers.get(i));
+ merge(caller + 1,
+ frames[caller],
+ current,
+ subroutines[caller],
+ subroutine.access);
+ }
+ } else if (insnOpcode != ATHROW
+ && (insnOpcode < IRETURN || insnOpcode > RETURN))
+ {
+ if (subroutine != null) {
+ if (insnNode instanceof VarInsnNode) {
+ int var = ((VarInsnNode) insnNode).var;
+ subroutine.access[var] = true;
+ if (insnOpcode == LLOAD || insnOpcode == DLOAD
+ || insnOpcode == LSTORE
+ || insnOpcode == DSTORE)
+ {
+ subroutine.access[var + 1] = true;
+ }
+ } else if (insnNode instanceof IincInsnNode) {
+ int var = ((IincInsnNode) insnNode).var;
+ subroutine.access[var] = true;
+ }
+ }
+ merge(insn + 1, current, subroutine);
+ }
+ }
+
+ List insnHandlers = handlers[insn];
+ if (insnHandlers != null) {
+ for (int i = 0; i < insnHandlers.size(); ++i) {
+ TryCatchBlockNode tcb = (TryCatchBlockNode) insnHandlers.get(i);
+ Type type;
+ if (tcb.type == null) {
+ type = Type.getType("Ljava/lang/Throwable;");
+ } else {
+ type = Type.getType("L" + tcb.type + ";");
+ }
+ handler.init(f);
+ handler.clearStack();
+ handler.push(interpreter.newValue(type));
+ merge(indexes.get(tcb.handler), handler, subroutine);
+ }
+ }
+ } catch (AnalyzerException e) {
+ throw new AnalyzerException("Error at instruction " + insn
+ + ": " + e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AnalyzerException("Error at instruction " + insn
+ + ": " + e.getMessage(), e);
+ }
+ }
+
+ return frames;
+ }
+
+ /**
+ * Returns the symbolic stack frame for each instruction of the last
+ * recently analyzed method.
+ *
+ * @return the symbolic state of the execution stack frame at each bytecode
+ * instruction of the method. The size of the returned array is
+ * equal to the number of instructions (and labels) of the method. A
+ * given frame is <tt>null</tt> if the corresponding instruction
+ * cannot be reached, or if an error occured during the analysis of
+ * the method.
+ */
+ public Frame[] getFrames() {
+ return frames;
+ }
+
+ /**
+ * Returns the index of the given instruction.
+ *
+ * @param insn a {@link Label} or {@link AbstractInsnNode} of the last
+ * recently analyzed method.
+ * @return the index of the given instruction of the last recently analyzed
+ * method.
+ */
+ public int getIndex(final Object insn) {
+ return indexes.get(insn);
+ }
+
+ /**
+ * Returns the exception handlers for the given instruction.
+ *
+ * @param insn the index of an instruction of the last recently analyzed
+ * method.
+ * @return a list of {@link TryCatchBlockNode} objects.
+ */
+ public List getHandlers(final int insn) {
+ return handlers[insn];
+ }
+
+ /**
+ * Constructs a new frame with the given size.
+ *
+ * @param nLocals the maximum number of local variables of the frame.
+ * @param nStack the maximum stack size of the frame.
+ * @return the created frame.
+ */
+ protected Frame newFrame(final int nLocals, final int nStack) {
+ return new Frame(nLocals, nStack);
+ }
+
+ /**
+ * Constructs a new frame that is identical to the given frame.
+ *
+ * @param src a frame.
+ * @return the created frame.
+ */
+ protected Frame newFrame(final Frame src) {
+ return new Frame(src);
+ }
+
+ /**
+ * Creates a control flow graph edge. The default implementation of this
+ * method does nothing. It can be overriden in order to construct the
+ * control flow graph of a method (this method is called by the
+ * {@link #analyze analyze} method during its visit of the method's code).
+ *
+ * @param frame the frame corresponding to an instruction.
+ * @param successor the frame corresponding to a successor instruction.
+ */
+ protected void newControlFlowEdge(final Frame frame, final Frame successor)
+ {
+ }
+
+ // -------------------------------------------------------------------------
+
+ private void merge(
+ final int insn,
+ final Frame frame,
+ final Subroutine subroutine) throws AnalyzerException
+ {
+ if (insn > n - 1) {
+ throw new AnalyzerException("Execution can fall off end of the code");
+ }
+
+ Frame oldFrame = frames[insn];
+ Subroutine oldSubroutine = subroutines[insn];
+ boolean changes = false;
+
+ if (oldFrame == null) {
+ frames[insn] = newFrame(frame);
+ changes = true;
+ } else {
+ changes |= oldFrame.merge(frame, interpreter);
+ }
+
+ newControlFlowEdge(frame, oldFrame);
+
+ if (oldSubroutine == null) {
+ if (subroutine != null) {
+ subroutines[insn] = subroutine.copy();
+ changes = true;
+ }
+ } else {
+ if (subroutine != null) {
+ changes |= oldSubroutine.merge(subroutine, !jsr);
+ }
+ }
+ if (changes && !queued[insn]) {
+ queued[insn] = true;
+ queue[top++] = insn;
+ }
+ }
+
+ private void merge(
+ final int insn,
+ final Frame beforeJSR,
+ final Frame afterRET,
+ final Subroutine subroutineBeforeJSR,
+ final boolean[] access) throws AnalyzerException
+ {
+ if (insn > n - 1) {
+ throw new AnalyzerException("Execution can fall off end of the code");
+ }
+
+ Frame oldFrame = frames[insn];
+ Subroutine oldSubroutine = subroutines[insn];
+ boolean changes = false;
+
+ afterRET.merge(beforeJSR, access);
+
+ if (oldFrame == null) {
+ frames[insn] = newFrame(afterRET);
+ changes = true;
+ } else {
+ changes |= oldFrame.merge(afterRET, access);
+ }
+
+ newControlFlowEdge(afterRET, oldFrame);
+
+ if (oldSubroutine == null) {
+ if (subroutineBeforeJSR != null) {
+ subroutines[insn] = subroutineBeforeJSR.copy();
+ changes = true;
+ }
+ } else {
+ if (subroutineBeforeJSR != null) {
+ changes |= oldSubroutine.merge(subroutineBeforeJSR, !jsr);
+ }
+ }
+ if (changes && !queued[insn]) {
+ queued[insn] = true;
+ queue[top++] = insn;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/AnalyzerException.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/AnalyzerException.java
new file mode 100644
index 000000000..c024fbade
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/AnalyzerException.java
@@ -0,0 +1,56 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+/**
+ * Thrown if a problem occurs during the analysis of a method.
+ *
+ * @author Bing Ran
+ * @author Eric Bruneton
+ */
+public class AnalyzerException extends Exception {
+
+ public AnalyzerException(final String msg) {
+ super(msg);
+ }
+
+ public AnalyzerException(final String msg, final Throwable exception) {
+ super(msg, exception);
+ }
+
+ public AnalyzerException(
+ final String msg,
+ final Object expected,
+ final Value encountered)
+ {
+ super((msg == null ? "Expected " : msg + ": expected ") + expected
+ + ", but found " + encountered);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.java
new file mode 100644
index 000000000..5e0c70277
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.java
@@ -0,0 +1,335 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.List;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.FieldInsnNode;
+import org.objectweb.asm.tree.IntInsnNode;
+import org.objectweb.asm.tree.LdcInsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+import org.objectweb.asm.tree.MultiANewArrayInsnNode;
+import org.objectweb.asm.tree.TypeInsnNode;
+
+/**
+ * An {@link Interpreter} for {@link BasicValue} values.
+ *
+ * @author Eric Bruneton
+ * @author Bing Ran
+ */
+public class BasicInterpreter implements Opcodes, Interpreter {
+
+ public Value newValue(final Type type) {
+ if (type == null) {
+ return BasicValue.UNINITIALIZED_VALUE;
+ }
+ switch (type.getSort()) {
+ case Type.VOID:
+ return null;
+ case Type.BOOLEAN:
+ case Type.CHAR:
+ case Type.BYTE:
+ case Type.SHORT:
+ case Type.INT:
+ return BasicValue.INT_VALUE;
+ case Type.FLOAT:
+ return BasicValue.FLOAT_VALUE;
+ case Type.LONG:
+ return BasicValue.LONG_VALUE;
+ case Type.DOUBLE:
+ return BasicValue.DOUBLE_VALUE;
+ case Type.ARRAY:
+ case Type.OBJECT:
+ return BasicValue.REFERENCE_VALUE;
+ default:
+ throw new RuntimeException("Internal error.");
+ }
+ }
+
+ public Value newOperation(final AbstractInsnNode insn) {
+ switch (insn.getOpcode()) {
+ case ACONST_NULL:
+ return newValue(Type.getType("Lnull;"));
+ case ICONST_M1:
+ case ICONST_0:
+ case ICONST_1:
+ case ICONST_2:
+ case ICONST_3:
+ case ICONST_4:
+ case ICONST_5:
+ return BasicValue.INT_VALUE;
+ case LCONST_0:
+ case LCONST_1:
+ return BasicValue.LONG_VALUE;
+ case FCONST_0:
+ case FCONST_1:
+ case FCONST_2:
+ return BasicValue.FLOAT_VALUE;
+ case DCONST_0:
+ case DCONST_1:
+ return BasicValue.DOUBLE_VALUE;
+ case BIPUSH:
+ case SIPUSH:
+ return BasicValue.INT_VALUE;
+ case LDC:
+ Object cst = ((LdcInsnNode) insn).cst;
+ if (cst instanceof Integer) {
+ return BasicValue.INT_VALUE;
+ } else if (cst instanceof Float) {
+ return BasicValue.FLOAT_VALUE;
+ } else if (cst instanceof Long) {
+ return BasicValue.LONG_VALUE;
+ } else if (cst instanceof Double) {
+ return BasicValue.DOUBLE_VALUE;
+ } else if (cst instanceof Type) {
+ return newValue(Type.getType("Ljava/lang/Class;"));
+ } else {
+ return newValue(Type.getType(cst.getClass()));
+ }
+ case JSR:
+ return BasicValue.RETURNADDRESS_VALUE;
+ case GETSTATIC:
+ return newValue(Type.getType(((FieldInsnNode) insn).desc));
+ case NEW:
+ return newValue(Type.getType("L" + ((TypeInsnNode) insn).desc
+ + ";"));
+ default:
+ throw new RuntimeException("Internal error.");
+ }
+ }
+
+ public Value copyOperation(final AbstractInsnNode insn, final Value value)
+ throws AnalyzerException
+ {
+ return value;
+ }
+
+ public Value unaryOperation(final AbstractInsnNode insn, final Value value)
+ throws AnalyzerException
+ {
+ switch (insn.getOpcode()) {
+ case INEG:
+ case IINC:
+ case L2I:
+ case F2I:
+ case D2I:
+ case I2B:
+ case I2C:
+ case I2S:
+ return BasicValue.INT_VALUE;
+ case FNEG:
+ case I2F:
+ case L2F:
+ case D2F:
+ return BasicValue.FLOAT_VALUE;
+ case LNEG:
+ case I2L:
+ case F2L:
+ case D2L:
+ return BasicValue.LONG_VALUE;
+ case DNEG:
+ case I2D:
+ case L2D:
+ case F2D:
+ return BasicValue.DOUBLE_VALUE;
+ case IFEQ:
+ case IFNE:
+ case IFLT:
+ case IFGE:
+ case IFGT:
+ case IFLE:
+ case TABLESWITCH:
+ case LOOKUPSWITCH:
+ case IRETURN:
+ case LRETURN:
+ case FRETURN:
+ case DRETURN:
+ case ARETURN:
+ case PUTSTATIC:
+ return null;
+ case GETFIELD:
+ return newValue(Type.getType(((FieldInsnNode) insn).desc));
+ case NEWARRAY:
+ switch (((IntInsnNode) insn).operand) {
+ case T_BOOLEAN:
+ return newValue(Type.getType("[Z"));
+ case T_CHAR:
+ return newValue(Type.getType("[C"));
+ case T_BYTE:
+ return newValue(Type.getType("[B"));
+ case T_SHORT:
+ return newValue(Type.getType("[S"));
+ case T_INT:
+ return newValue(Type.getType("[I"));
+ case T_FLOAT:
+ return newValue(Type.getType("[F"));
+ case T_DOUBLE:
+ return newValue(Type.getType("[D"));
+ case T_LONG:
+ return newValue(Type.getType("[J"));
+ default:
+ throw new AnalyzerException("Invalid array type");
+ }
+ case ANEWARRAY:
+ String desc = ((TypeInsnNode) insn).desc;
+ if (desc.charAt(0) == '[') {
+ return newValue(Type.getType("[" + desc));
+ } else {
+ return newValue(Type.getType("[L" + desc + ";"));
+ }
+ case ARRAYLENGTH:
+ return BasicValue.INT_VALUE;
+ case ATHROW:
+ return null;
+ case CHECKCAST:
+ desc = ((TypeInsnNode) insn).desc;
+ if (desc.charAt(0) == '[') {
+ return newValue(Type.getType(desc));
+ } else {
+ return newValue(Type.getType("L" + desc + ";"));
+ }
+ case INSTANCEOF:
+ return BasicValue.INT_VALUE;
+ case MONITORENTER:
+ case MONITOREXIT:
+ case IFNULL:
+ case IFNONNULL:
+ return null;
+ default:
+ throw new RuntimeException("Internal error.");
+ }
+ }
+
+ public Value binaryOperation(
+ final AbstractInsnNode insn,
+ final Value value1,
+ final Value value2) throws AnalyzerException
+ {
+ switch (insn.getOpcode()) {
+ case IALOAD:
+ case BALOAD:
+ case CALOAD:
+ case SALOAD:
+ case IADD:
+ case ISUB:
+ case IMUL:
+ case IDIV:
+ case IREM:
+ case ISHL:
+ case ISHR:
+ case IUSHR:
+ case IAND:
+ case IOR:
+ case IXOR:
+ return BasicValue.INT_VALUE;
+ case FALOAD:
+ case FADD:
+ case FSUB:
+ case FMUL:
+ case FDIV:
+ case FREM:
+ return BasicValue.FLOAT_VALUE;
+ case LALOAD:
+ case LADD:
+ case LSUB:
+ case LMUL:
+ case LDIV:
+ case LREM:
+ case LSHL:
+ case LSHR:
+ case LUSHR:
+ case LAND:
+ case LOR:
+ case LXOR:
+ return BasicValue.LONG_VALUE;
+ case DALOAD:
+ case DADD:
+ case DSUB:
+ case DMUL:
+ case DDIV:
+ case DREM:
+ return BasicValue.DOUBLE_VALUE;
+ case AALOAD:
+ Type t = ((BasicValue) value1).getType();
+ if (t != null && t.getSort() == Type.ARRAY) {
+ return newValue(t.getElementType());
+ } else {
+ return BasicValue.REFERENCE_VALUE;
+ }
+ case LCMP:
+ case FCMPL:
+ case FCMPG:
+ case DCMPL:
+ case DCMPG:
+ return BasicValue.INT_VALUE;
+ case IF_ICMPEQ:
+ case IF_ICMPNE:
+ case IF_ICMPLT:
+ case IF_ICMPGE:
+ case IF_ICMPGT:
+ case IF_ICMPLE:
+ case IF_ACMPEQ:
+ case IF_ACMPNE:
+ case PUTFIELD:
+ return null;
+ default:
+ throw new RuntimeException("Internal error.");
+ }
+ }
+
+ public Value ternaryOperation(
+ final AbstractInsnNode insn,
+ final Value value1,
+ final Value value2,
+ final Value value3) throws AnalyzerException
+ {
+ return null;
+ }
+
+ public Value naryOperation(final AbstractInsnNode insn, final List values)
+ throws AnalyzerException
+ {
+ if (insn.getOpcode() == MULTIANEWARRAY) {
+ return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
+ } else {
+ return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
+ }
+ }
+
+ public Value merge(final Value v, final Value w) {
+ if (!v.equals(w)) {
+ return BasicValue.UNINITIALIZED_VALUE;
+ }
+ return v;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicValue.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicValue.java
new file mode 100644
index 000000000..46b8cf49a
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicValue.java
@@ -0,0 +1,105 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import org.objectweb.asm.Type;
+
+/**
+ * A {@link Value} that is represented by its type in a seven types type sytem.
+ * This type system distinguishes the UNINITIALZED, INT, FLOAT, LONG, DOUBLE,
+ * REFERENCE and RETURNADDRESS types.
+ *
+ * @author Eric Bruneton
+ */
+public class BasicValue implements Value {
+
+ public final static Value UNINITIALIZED_VALUE = new BasicValue(null);
+
+ public final static Value INT_VALUE = new BasicValue(Type.INT_TYPE);
+
+ public final static Value FLOAT_VALUE = new BasicValue(Type.FLOAT_TYPE);
+
+ public final static Value LONG_VALUE = new BasicValue(Type.LONG_TYPE);
+
+ public final static Value DOUBLE_VALUE = new BasicValue(Type.DOUBLE_TYPE);
+
+ public final static Value REFERENCE_VALUE = new BasicValue(Type.getType("Ljava/lang/Object;"));
+
+ public final static Value RETURNADDRESS_VALUE = new BasicValue(null);
+
+ private Type type;
+
+ public BasicValue(final Type type) {
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public int getSize() {
+ return type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1;
+ }
+
+ public boolean isReference() {
+ return type != null
+ && (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY);
+ }
+
+ public boolean equals(final Object value) {
+ if (value == this) {
+ return true;
+ } else if (value instanceof BasicValue) {
+ if (type == null) {
+ return ((BasicValue) value).type == null;
+ } else {
+ return type.equals(((BasicValue) value).type);
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return type == null ? 0 : type.hashCode();
+ }
+
+ public String toString() {
+ if (this == UNINITIALIZED_VALUE) {
+ return ".";
+ } else if (this == RETURNADDRESS_VALUE) {
+ return "A";
+ } else if (this == REFERENCE_VALUE) {
+ return "R";
+ } else {
+ return type.getDescriptor();
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicVerifier.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicVerifier.java
new file mode 100644
index 000000000..f65b56d8e
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicVerifier.java
@@ -0,0 +1,428 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.List;
+
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.FieldInsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+
+/**
+ * An extended {@link BasicInterpreter} that checks that bytecode instructions
+ * are correctly used.
+ *
+ * @author Eric Bruneton
+ * @author Bing Ran
+ */
+public class BasicVerifier extends BasicInterpreter {
+
+ public Value copyOperation(final AbstractInsnNode insn, final Value value)
+ throws AnalyzerException
+ {
+ Value expected;
+ switch (insn.getOpcode()) {
+ case ILOAD:
+ case ISTORE:
+ expected = BasicValue.INT_VALUE;
+ break;
+ case FLOAD:
+ case FSTORE:
+ expected = BasicValue.FLOAT_VALUE;
+ break;
+ case LLOAD:
+ case LSTORE:
+ expected = BasicValue.LONG_VALUE;
+ break;
+ case DLOAD:
+ case DSTORE:
+ expected = BasicValue.DOUBLE_VALUE;
+ break;
+ case ALOAD:
+ if (!((BasicValue) value).isReference()) {
+ throw new AnalyzerException(null,
+ "an object reference",
+ value);
+ }
+ return value;
+ case ASTORE:
+ if (!((BasicValue) value).isReference()
+ && value != BasicValue.RETURNADDRESS_VALUE)
+ {
+ throw new AnalyzerException(null,
+ "an object reference or a return address",
+ value);
+ }
+ return value;
+ default:
+ return value;
+ }
+ // type is necessarily a primitive type here,
+ // so value must be == to expected value
+ if (value != expected) {
+ throw new AnalyzerException(null, expected, value);
+ }
+ return value;
+ }
+
+ public Value unaryOperation(final AbstractInsnNode insn, Value value)
+ throws AnalyzerException
+ {
+ Value expected;
+ switch (insn.getOpcode()) {
+ case INEG:
+ case IINC:
+ case I2F:
+ case I2L:
+ case I2D:
+ case I2B:
+ case I2C:
+ case I2S:
+ case IFEQ:
+ case IFNE:
+ case IFLT:
+ case IFGE:
+ case IFGT:
+ case IFLE:
+ case TABLESWITCH:
+ case LOOKUPSWITCH:
+ case IRETURN:
+ case NEWARRAY:
+ case ANEWARRAY:
+ expected = BasicValue.INT_VALUE;
+ break;
+ case FNEG:
+ case F2I:
+ case F2L:
+ case F2D:
+ case FRETURN:
+ expected = BasicValue.FLOAT_VALUE;
+ break;
+ case LNEG:
+ case L2I:
+ case L2F:
+ case L2D:
+ case LRETURN:
+ expected = BasicValue.LONG_VALUE;
+ break;
+ case DNEG:
+ case D2I:
+ case D2F:
+ case D2L:
+ case DRETURN:
+ expected = BasicValue.DOUBLE_VALUE;
+ break;
+ case GETFIELD:
+ expected = newValue(Type.getType("L"
+ + ((FieldInsnNode) insn).owner + ";"));
+ break;
+ case CHECKCAST:
+ if (!((BasicValue) value).isReference()) {
+ throw new AnalyzerException(null,
+ "an object reference",
+ value);
+ }
+ return super.unaryOperation(insn, value);
+ case ARRAYLENGTH:
+ if (!isArrayValue(value)) {
+ throw new AnalyzerException(null,
+ "an array reference",
+ value);
+ }
+ return super.unaryOperation(insn, value);
+ case ARETURN:
+ case ATHROW:
+ case INSTANCEOF:
+ case MONITORENTER:
+ case MONITOREXIT:
+ case IFNULL:
+ case IFNONNULL:
+ if (!((BasicValue) value).isReference()) {
+ throw new AnalyzerException(null,
+ "an object reference",
+ value);
+ }
+ return super.unaryOperation(insn, value);
+ case PUTSTATIC:
+ expected = newValue(Type.getType(((FieldInsnNode) insn).desc));
+ break;
+ default:
+ throw new RuntimeException("Internal error.");
+ }
+ if (!isSubTypeOf(value, expected)) {
+ throw new AnalyzerException(null, expected, value);
+ }
+ return super.unaryOperation(insn, value);
+ }
+
+ public Value binaryOperation(
+ final AbstractInsnNode insn,
+ final Value value1,
+ final Value value2) throws AnalyzerException
+ {
+ Value expected1;
+ Value expected2;
+ switch (insn.getOpcode()) {
+ case IALOAD:
+ expected1 = newValue(Type.getType("[I"));
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case BALOAD:
+ if (!isSubTypeOf(value1, newValue(Type.getType("[Z")))) {
+ expected1 = newValue(Type.getType("[B"));
+ } else {
+ expected1 = newValue(Type.getType("[Z"));
+ }
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case CALOAD:
+ expected1 = newValue(Type.getType("[C"));
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case SALOAD:
+ expected1 = newValue(Type.getType("[S"));
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case LALOAD:
+ expected1 = newValue(Type.getType("[J"));
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case FALOAD:
+ expected1 = newValue(Type.getType("[F"));
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case DALOAD:
+ expected1 = newValue(Type.getType("[D"));
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case AALOAD:
+ expected1 = newValue(Type.getType("[Ljava/lang/Object;"));
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case IADD:
+ case ISUB:
+ case IMUL:
+ case IDIV:
+ case IREM:
+ case ISHL:
+ case ISHR:
+ case IUSHR:
+ case IAND:
+ case IOR:
+ case IXOR:
+ case IF_ICMPEQ:
+ case IF_ICMPNE:
+ case IF_ICMPLT:
+ case IF_ICMPGE:
+ case IF_ICMPGT:
+ case IF_ICMPLE:
+ expected1 = BasicValue.INT_VALUE;
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case FADD:
+ case FSUB:
+ case FMUL:
+ case FDIV:
+ case FREM:
+ case FCMPL:
+ case FCMPG:
+ expected1 = BasicValue.FLOAT_VALUE;
+ expected2 = BasicValue.FLOAT_VALUE;
+ break;
+ case LADD:
+ case LSUB:
+ case LMUL:
+ case LDIV:
+ case LREM:
+ case LAND:
+ case LOR:
+ case LXOR:
+ case LCMP:
+ expected1 = BasicValue.LONG_VALUE;
+ expected2 = BasicValue.LONG_VALUE;
+ break;
+ case LSHL:
+ case LSHR:
+ case LUSHR:
+ expected1 = BasicValue.LONG_VALUE;
+ expected2 = BasicValue.INT_VALUE;
+ break;
+ case DADD:
+ case DSUB:
+ case DMUL:
+ case DDIV:
+ case DREM:
+ case DCMPL:
+ case DCMPG:
+ expected1 = BasicValue.DOUBLE_VALUE;
+ expected2 = BasicValue.DOUBLE_VALUE;
+ break;
+ case IF_ACMPEQ:
+ case IF_ACMPNE:
+ expected1 = BasicValue.REFERENCE_VALUE;
+ expected2 = BasicValue.REFERENCE_VALUE;
+ break;
+ case PUTFIELD:
+ FieldInsnNode fin = (FieldInsnNode) insn;
+ expected1 = newValue(Type.getType("L" + fin.owner + ";"));
+ expected2 = newValue(Type.getType(fin.desc));
+ break;
+ default:
+ throw new RuntimeException("Internal error.");
+ }
+ if (!isSubTypeOf(value1, expected1)) {
+ throw new AnalyzerException("First argument", expected1, value1);
+ } else if (!isSubTypeOf(value2, expected2)) {
+ throw new AnalyzerException("Second argument", expected2, value2);
+ }
+ if (insn.getOpcode() == AALOAD) {
+ return getElementValue(value1);
+ } else {
+ return super.binaryOperation(insn, value1, value2);
+ }
+ }
+
+ public Value ternaryOperation(
+ final AbstractInsnNode insn,
+ final Value value1,
+ final Value value2,
+ final Value value3) throws AnalyzerException
+ {
+ Value expected1;
+ Value expected3;
+ switch (insn.getOpcode()) {
+ case IASTORE:
+ expected1 = newValue(Type.getType("[I"));
+ expected3 = BasicValue.INT_VALUE;
+ break;
+ case BASTORE:
+ if (!isSubTypeOf(value1, newValue(Type.getType("[Z")))) {
+ expected1 = newValue(Type.getType("[B"));
+ } else {
+ expected1 = newValue(Type.getType("[Z"));
+ }
+ expected3 = BasicValue.INT_VALUE;
+ break;
+ case CASTORE:
+ expected1 = newValue(Type.getType("[C"));
+ expected3 = BasicValue.INT_VALUE;
+ break;
+ case SASTORE:
+ expected1 = newValue(Type.getType("[S"));
+ expected3 = BasicValue.INT_VALUE;
+ break;
+ case LASTORE:
+ expected1 = newValue(Type.getType("[J"));
+ expected3 = BasicValue.LONG_VALUE;
+ break;
+ case FASTORE:
+ expected1 = newValue(Type.getType("[F"));
+ expected3 = BasicValue.FLOAT_VALUE;
+ break;
+ case DASTORE:
+ expected1 = newValue(Type.getType("[D"));
+ expected3 = BasicValue.DOUBLE_VALUE;
+ break;
+ case AASTORE:
+ expected1 = value1;
+ expected3 = BasicValue.REFERENCE_VALUE;
+ break;
+ default:
+ throw new RuntimeException("Internal error.");
+ }
+ if (!isSubTypeOf(value1, expected1)) {
+ throw new AnalyzerException("First argument", "a " + expected1
+ + " array reference", value1);
+ } else if (value2 != BasicValue.INT_VALUE) {
+ throw new AnalyzerException("Second argument",
+ BasicValue.INT_VALUE,
+ value2);
+ } else if (!isSubTypeOf(value3, expected3)) {
+ throw new AnalyzerException("Third argument", expected3, value3);
+ }
+ return null;
+ }
+
+ public Value naryOperation(final AbstractInsnNode insn, final List values)
+ throws AnalyzerException
+ {
+ int opcode = insn.getOpcode();
+ if (opcode == MULTIANEWARRAY) {
+ for (int i = 0; i < values.size(); ++i) {
+ if (values.get(i) != BasicValue.INT_VALUE) {
+ throw new AnalyzerException(null,
+ BasicValue.INT_VALUE,
+ (Value) values.get(i));
+ }
+ }
+ } else {
+ int i = 0;
+ int j = 0;
+ if (opcode != INVOKESTATIC) {
+ String own = ((MethodInsnNode) insn).owner;
+ if (own.charAt(0) != '[') { // can happen with JDK1.5 clone()
+ own = "L" + own + ";";
+ }
+ Type owner = Type.getType(own);
+ if (!isSubTypeOf((Value) values.get(i++), newValue(owner))) {
+ throw new AnalyzerException("Method owner",
+ newValue(owner),
+ (Value) values.get(0));
+ }
+ }
+ Type[] args = Type.getArgumentTypes(((MethodInsnNode) insn).desc);
+ while (i < values.size()) {
+ Value expected = newValue(args[j++]);
+ Value encountered = (Value) values.get(i++);
+ if (!isSubTypeOf(encountered, expected)) {
+ throw new AnalyzerException("Argument " + j,
+ expected,
+ encountered);
+ }
+ }
+ }
+ return super.naryOperation(insn, values);
+ }
+
+ protected boolean isArrayValue(final Value value) {
+ return ((BasicValue) value).isReference();
+ }
+
+ protected Value getElementValue(final Value objectArrayValue)
+ throws AnalyzerException
+ {
+ return BasicValue.REFERENCE_VALUE;
+ }
+
+ protected boolean isSubTypeOf(final Value value, final Value expected) {
+ return value == expected;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.java
new file mode 100644
index 000000000..3847d4949
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.java
@@ -0,0 +1,174 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.FieldInsnNode;
+import org.objectweb.asm.tree.LdcInsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+
+/**
+ * An {@link Interpreter} for {@link DataflowValue} values.
+ *
+ * @author Eric Bruneton
+ */
+public class DataflowInterpreter implements Opcodes, Interpreter {
+
+ public Value newValue(final Type type) {
+ return new DataflowValue(type == null ? 1 : type.getSize());
+ }
+
+ public Value newOperation(final AbstractInsnNode insn) {
+ int size;
+ switch (insn.getOpcode()) {
+ case LCONST_0:
+ case LCONST_1:
+ case DCONST_0:
+ case DCONST_1:
+ size = 2;
+ break;
+ case LDC:
+ Object cst = ((LdcInsnNode) insn).cst;
+ size = cst instanceof Long || cst instanceof Double ? 2 : 1;
+ break;
+ case GETSTATIC:
+ size = Type.getType(((FieldInsnNode) insn).desc).getSize();
+ break;
+ default:
+ size = 1;
+ }
+ return new DataflowValue(size, insn);
+ }
+
+ public Value copyOperation(final AbstractInsnNode insn, final Value value) {
+ return new DataflowValue(value.getSize(), insn);
+ }
+
+ public Value unaryOperation(final AbstractInsnNode insn, final Value value)
+ {
+ int size;
+ switch (insn.getOpcode()) {
+ case LNEG:
+ case DNEG:
+ case I2L:
+ case I2D:
+ case L2D:
+ case F2L:
+ case F2D:
+ case D2L:
+ size = 2;
+ break;
+ case GETFIELD:
+ size = Type.getType(((FieldInsnNode) insn).desc).getSize();
+ break;
+ default:
+ size = 1;
+ }
+ return new DataflowValue(size, insn);
+ }
+
+ public Value binaryOperation(
+ final AbstractInsnNode insn,
+ final Value value1,
+ final Value value2)
+ {
+ int size;
+ switch (insn.getOpcode()) {
+ case LALOAD:
+ case DALOAD:
+ case LADD:
+ case DADD:
+ case LSUB:
+ case DSUB:
+ case LMUL:
+ case DMUL:
+ case LDIV:
+ case DDIV:
+ case LREM:
+ case DREM:
+ case LSHL:
+ case LSHR:
+ case LUSHR:
+ case LAND:
+ case LOR:
+ case LXOR:
+ size = 2;
+ break;
+ default:
+ size = 1;
+ }
+ return new DataflowValue(size, insn);
+ }
+
+ public Value ternaryOperation(
+ final AbstractInsnNode insn,
+ final Value value1,
+ final Value value2,
+ final Value value3)
+ {
+ return new DataflowValue(1, insn);
+ }
+
+ public Value naryOperation(final AbstractInsnNode insn, final List values) {
+ int size;
+ if (insn.getOpcode() == MULTIANEWARRAY) {
+ size = 1;
+ } else {
+ size = Type.getReturnType(((MethodInsnNode) insn).desc).getSize();
+ }
+ return new DataflowValue(size, insn);
+ }
+
+ public Value merge(final Value v, final Value w) {
+ DataflowValue dv = (DataflowValue) v;
+ DataflowValue dw = (DataflowValue) w;
+ if (dv.insns instanceof SmallSet && dw.insns instanceof SmallSet) {
+ Set s = ((SmallSet) dv.insns).union((SmallSet) dw.insns);
+ if (s == dv.insns && dv.size == dw.size) {
+ return v;
+ } else {
+ return new DataflowValue(Math.min(dv.size, dw.size), s);
+ }
+ }
+ if (dv.size != dw.size || !dv.insns.containsAll(dw.insns)) {
+ Set s = new HashSet();
+ s.addAll(dv.insns);
+ s.addAll(dw.insns);
+ return new DataflowValue(Math.min(dv.size, dw.size), s);
+ }
+ return v;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowValue.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowValue.java
new file mode 100644
index 000000000..7b7756f78
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowValue.java
@@ -0,0 +1,92 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.Set;
+
+import org.objectweb.asm.tree.AbstractInsnNode;
+
+/**
+ * A {@link Value} that is represented by its type in a two types type system.
+ * This type system distinguishes the ONEWORD and TWOWORDS types.
+ *
+ * @author Eric Bruneton
+ */
+public class DataflowValue implements Value {
+
+ /**
+ * The size of this value.
+ */
+ public final int size;
+
+ /**
+ * The instructions that can produce this value. For example, for the Java
+ * code below, the instructions that can produce the value of <tt>i</tt>
+ * at line 5 are the txo ISTORE instructions at line 1 and 3:
+ *
+ * <pre>
+ * 1: i = 0;
+ * 2: if (...) {
+ * 3: i = 1;
+ * 4: }
+ * 5: return i;
+ * </pre>
+ *
+ * This field is a set of {@link AbstractInsnNode} objects.
+ */
+ public final Set insns;
+
+ public DataflowValue(final int size) {
+ this(size, SmallSet.EMPTY_SET);
+ }
+
+ public DataflowValue(final int size, final AbstractInsnNode insn) {
+ this.size = size;
+ this.insns = new SmallSet(insn, null);
+ }
+
+ public DataflowValue(final int size, final Set insns) {
+ this.size = size;
+ this.insns = insns;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public boolean equals(final Object value) {
+ DataflowValue v = (DataflowValue) value;
+ return size == v.size && insns.equals(v.insns);
+ }
+
+ public int hashCode() {
+ return insns.hashCode();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Frame.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Frame.java
new file mode 100644
index 000000000..1edf40c3d
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Frame.java
@@ -0,0 +1,670 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.IincInsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+import org.objectweb.asm.tree.MultiANewArrayInsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/**
+ * A symbolic execution stack frame. A stack frame contains a set of local
+ * variable slots, and an operand stack. Warning: long and double values are
+ * represented by <i>two</i> slots in local variables, and by <i>one</i> slot
+ * in the operand stack.
+ *
+ * @author Eric Bruneton
+ */
+public class Frame {
+
+ /**
+ * The local variables and operand stack of this frame.
+ */
+ private Value[] values;
+
+ /**
+ * The number of local variables of this frame.
+ */
+ private int locals;
+
+ /**
+ * The number of elements in the operand stack.
+ */
+ private int top;
+
+ /**
+ * Constructs a new frame with the given size.
+ *
+ * @param nLocals the maximum number of local variables of the frame.
+ * @param nStack the maximum stack size of the frame.
+ */
+ public Frame(final int nLocals, final int nStack) {
+ this.values = new Value[nLocals + nStack];
+ this.locals = nLocals;
+ }
+
+ /**
+ * Constructs a new frame that is identical to the given frame.
+ *
+ * @param src a frame.
+ */
+ public Frame(final Frame src) {
+ this(src.locals, src.values.length - src.locals);
+ init(src);
+ }
+
+ /**
+ * Copies the state of the given frame into this frame.
+ *
+ * @param src a frame.
+ * @return this frame.
+ */
+ public Frame init(final Frame src) {
+ System.arraycopy(src.values, 0, values, 0, values.length);
+ top = src.top;
+ return this;
+ }
+
+ /**
+ * Returns the maximum number of local variables of this frame.
+ *
+ * @return the maximum number of local variables of this frame.
+ */
+ public int getLocals() {
+ return locals;
+ }
+
+ /**
+ * Returns the value of the given local variable.
+ *
+ * @param i a local variable index.
+ * @return the value of the given local variable.
+ * @throws IndexOutOfBoundsException if the variable does not exist.
+ */
+ public Value getLocal(final int i) throws IndexOutOfBoundsException {
+ if (i >= locals) {
+ throw new IndexOutOfBoundsException("Trying to access an inexistant local variable");
+ }
+ return values[i];
+ }
+
+ /**
+ * Sets the value of the given local variable.
+ *
+ * @param i a local variable index.
+ * @param value the new value of this local variable.
+ * @throws IndexOutOfBoundsException if the variable does not exist.
+ */
+ public void setLocal(final int i, final Value value)
+ throws IndexOutOfBoundsException
+ {
+ if (i >= locals) {
+ throw new IndexOutOfBoundsException("Trying to access an inexistant local variable");
+ }
+ values[i] = value;
+ }
+
+ /**
+ * Returns the number of values in the operand stack of this frame. Long and
+ * double values are treated as single values.
+ *
+ * @return the number of values in the operand stack of this frame.
+ */
+ public int getStackSize() {
+ return top;
+ }
+
+ /**
+ * Returns the value of the given operand stack slot.
+ *
+ * @param i the index of an operand stack slot.
+ * @return the value of the given operand stack slot.
+ * @throws IndexOutOfBoundsException if the operand stack slot does not
+ * exist.
+ */
+ public Value getStack(final int i) throws IndexOutOfBoundsException {
+ if (i >= top) {
+ throw new IndexOutOfBoundsException("Trying to access an inexistant stack element");
+ }
+ return values[i + locals];
+ }
+
+ /**
+ * Clears the operand stack of this frame.
+ */
+ public void clearStack() {
+ top = 0;
+ }
+
+ /**
+ * Pops a value from the operand stack of this frame.
+ *
+ * @return the value that has been popped from the stack.
+ * @throws IndexOutOfBoundsException if the operand stack is empty.
+ */
+ public Value pop() throws IndexOutOfBoundsException {
+ if (top == 0) {
+ throw new IndexOutOfBoundsException("Cannot pop operand off an empty stack.");
+ }
+ return values[--top + locals];
+ }
+
+ /**
+ * Pushes a value into the operand stack of this frame.
+ *
+ * @param value the value that must be pushed into the stack.
+ * @throws IndexOutOfBoundsException if the operand stack is full.
+ */
+ public void push(final Value value) throws IndexOutOfBoundsException {
+ if (top + locals >= values.length) {
+ throw new IndexOutOfBoundsException("Insufficient maximum stack size.");
+ }
+ values[top++ + locals] = value;
+ }
+
+ public void execute(
+ final AbstractInsnNode insn,
+ final Interpreter interpreter) throws AnalyzerException
+ {
+ Value value1, value2, value3, value4;
+ List values;
+ int var;
+
+ switch (insn.getOpcode()) {
+ case Opcodes.NOP:
+ break;
+ case Opcodes.ACONST_NULL:
+ case Opcodes.ICONST_M1:
+ case Opcodes.ICONST_0:
+ case Opcodes.ICONST_1:
+ case Opcodes.ICONST_2:
+ case Opcodes.ICONST_3:
+ case Opcodes.ICONST_4:
+ case Opcodes.ICONST_5:
+ case Opcodes.LCONST_0:
+ case Opcodes.LCONST_1:
+ case Opcodes.FCONST_0:
+ case Opcodes.FCONST_1:
+ case Opcodes.FCONST_2:
+ case Opcodes.DCONST_0:
+ case Opcodes.DCONST_1:
+ case Opcodes.BIPUSH:
+ case Opcodes.SIPUSH:
+ case Opcodes.LDC:
+ push(interpreter.newOperation(insn));
+ break;
+ case Opcodes.ILOAD:
+ case Opcodes.LLOAD:
+ case Opcodes.FLOAD:
+ case Opcodes.DLOAD:
+ case Opcodes.ALOAD:
+ push(interpreter.copyOperation(insn,
+ getLocal(((VarInsnNode) insn).var)));
+ break;
+ case Opcodes.IALOAD:
+ case Opcodes.LALOAD:
+ case Opcodes.FALOAD:
+ case Opcodes.DALOAD:
+ case Opcodes.AALOAD:
+ case Opcodes.BALOAD:
+ case Opcodes.CALOAD:
+ case Opcodes.SALOAD:
+ value2 = pop();
+ value1 = pop();
+ push(interpreter.binaryOperation(insn, value1, value2));
+ break;
+ case Opcodes.ISTORE:
+ case Opcodes.LSTORE:
+ case Opcodes.FSTORE:
+ case Opcodes.DSTORE:
+ case Opcodes.ASTORE:
+ value1 = interpreter.copyOperation(insn, pop());
+ var = ((VarInsnNode) insn).var;
+ setLocal(var, value1);
+ if (value1.getSize() == 2) {
+ setLocal(var + 1, interpreter.newValue(null));
+ }
+ if (var > 0) {
+ Value local = getLocal(var - 1);
+ if (local != null && local.getSize() == 2) {
+ setLocal(var + 1, interpreter.newValue(null));
+ }
+ }
+ break;
+ case Opcodes.IASTORE:
+ case Opcodes.LASTORE:
+ case Opcodes.FASTORE:
+ case Opcodes.DASTORE:
+ case Opcodes.AASTORE:
+ case Opcodes.BASTORE:
+ case Opcodes.CASTORE:
+ case Opcodes.SASTORE:
+ value3 = pop();
+ value2 = pop();
+ value1 = pop();
+ interpreter.ternaryOperation(insn, value1, value2, value3);
+ break;
+ case Opcodes.POP:
+ if (pop().getSize() == 2) {
+ throw new AnalyzerException("Illegal use of POP");
+ }
+ break;
+ case Opcodes.POP2:
+ if (pop().getSize() == 1) {
+ if (pop().getSize() != 1) {
+ throw new AnalyzerException("Illegal use of POP2");
+ }
+ }
+ break;
+ case Opcodes.DUP:
+ value1 = pop();
+ if (value1.getSize() != 1) {
+ throw new AnalyzerException("Illegal use of DUP");
+ }
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ case Opcodes.DUP_X1:
+ value1 = pop();
+ value2 = pop();
+ if (value1.getSize() != 1 || value2.getSize() != 1) {
+ throw new AnalyzerException("Illegal use of DUP_X1");
+ }
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ case Opcodes.DUP_X2:
+ value1 = pop();
+ if (value1.getSize() == 1) {
+ value2 = pop();
+ if (value2.getSize() == 1) {
+ value3 = pop();
+ if (value3.getSize() == 1) {
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value3));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ } else {
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ }
+ throw new AnalyzerException("Illegal use of DUP_X2");
+ case Opcodes.DUP2:
+ value1 = pop();
+ if (value1.getSize() == 1) {
+ value2 = pop();
+ if (value2.getSize() == 1) {
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ } else {
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ throw new AnalyzerException("Illegal use of DUP2");
+ case Opcodes.DUP2_X1:
+ value1 = pop();
+ if (value1.getSize() == 1) {
+ value2 = pop();
+ if (value2.getSize() == 1) {
+ value3 = pop();
+ if (value3.getSize() == 1) {
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value3));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ }
+ } else {
+ value2 = pop();
+ if (value2.getSize() == 1) {
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ }
+ throw new AnalyzerException("Illegal use of DUP2_X1");
+ case Opcodes.DUP2_X2:
+ value1 = pop();
+ if (value1.getSize() == 1) {
+ value2 = pop();
+ if (value2.getSize() == 1) {
+ value3 = pop();
+ if (value3.getSize() == 1) {
+ value4 = pop();
+ if (value4.getSize() == 1) {
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value4));
+ push(interpreter.copyOperation(insn, value3));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ } else {
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value3));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ }
+ } else {
+ value2 = pop();
+ if (value2.getSize() == 1) {
+ value3 = pop();
+ if (value3.getSize() == 1) {
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value3));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ } else {
+ push(interpreter.copyOperation(insn, value1));
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ }
+ }
+ throw new AnalyzerException("Illegal use of DUP2_X2");
+ case Opcodes.SWAP:
+ value2 = pop();
+ value1 = pop();
+ if (value1.getSize() != 1 || value2.getSize() != 1) {
+ throw new AnalyzerException("Illegal use of SWAP");
+ }
+ push(interpreter.copyOperation(insn, value2));
+ push(interpreter.copyOperation(insn, value1));
+ break;
+ case Opcodes.IADD:
+ case Opcodes.LADD:
+ case Opcodes.FADD:
+ case Opcodes.DADD:
+ case Opcodes.ISUB:
+ case Opcodes.LSUB:
+ case Opcodes.FSUB:
+ case Opcodes.DSUB:
+ case Opcodes.IMUL:
+ case Opcodes.LMUL:
+ case Opcodes.FMUL:
+ case Opcodes.DMUL:
+ case Opcodes.IDIV:
+ case Opcodes.LDIV:
+ case Opcodes.FDIV:
+ case Opcodes.DDIV:
+ case Opcodes.IREM:
+ case Opcodes.LREM:
+ case Opcodes.FREM:
+ case Opcodes.DREM:
+ value2 = pop();
+ value1 = pop();
+ push(interpreter.binaryOperation(insn, value1, value2));
+ break;
+ case Opcodes.INEG:
+ case Opcodes.LNEG:
+ case Opcodes.FNEG:
+ case Opcodes.DNEG:
+ push(interpreter.unaryOperation(insn, pop()));
+ break;
+ case Opcodes.ISHL:
+ case Opcodes.LSHL:
+ case Opcodes.ISHR:
+ case Opcodes.LSHR:
+ case Opcodes.IUSHR:
+ case Opcodes.LUSHR:
+ case Opcodes.IAND:
+ case Opcodes.LAND:
+ case Opcodes.IOR:
+ case Opcodes.LOR:
+ case Opcodes.IXOR:
+ case Opcodes.LXOR:
+ value2 = pop();
+ value1 = pop();
+ push(interpreter.binaryOperation(insn, value1, value2));
+ break;
+ case Opcodes.IINC:
+ var = ((IincInsnNode) insn).var;
+ setLocal(var, interpreter.unaryOperation(insn, getLocal(var)));
+ break;
+ case Opcodes.I2L:
+ case Opcodes.I2F:
+ case Opcodes.I2D:
+ case Opcodes.L2I:
+ case Opcodes.L2F:
+ case Opcodes.L2D:
+ case Opcodes.F2I:
+ case Opcodes.F2L:
+ case Opcodes.F2D:
+ case Opcodes.D2I:
+ case Opcodes.D2L:
+ case Opcodes.D2F:
+ case Opcodes.I2B:
+ case Opcodes.I2C:
+ case Opcodes.I2S:
+ push(interpreter.unaryOperation(insn, pop()));
+ break;
+ case Opcodes.LCMP:
+ case Opcodes.FCMPL:
+ case Opcodes.FCMPG:
+ case Opcodes.DCMPL:
+ case Opcodes.DCMPG:
+ value2 = pop();
+ value1 = pop();
+ push(interpreter.binaryOperation(insn, value1, value2));
+ break;
+ case Opcodes.IFEQ:
+ case Opcodes.IFNE:
+ case Opcodes.IFLT:
+ case Opcodes.IFGE:
+ case Opcodes.IFGT:
+ case Opcodes.IFLE:
+ interpreter.unaryOperation(insn, pop());
+ break;
+ case Opcodes.IF_ICMPEQ:
+ case Opcodes.IF_ICMPNE:
+ case Opcodes.IF_ICMPLT:
+ case Opcodes.IF_ICMPGE:
+ case Opcodes.IF_ICMPGT:
+ case Opcodes.IF_ICMPLE:
+ case Opcodes.IF_ACMPEQ:
+ case Opcodes.IF_ACMPNE:
+ value2 = pop();
+ value1 = pop();
+ interpreter.binaryOperation(insn, value1, value2);
+ break;
+ case Opcodes.GOTO:
+ break;
+ case Opcodes.JSR:
+ push(interpreter.newOperation(insn));
+ break;
+ case Opcodes.RET:
+ break;
+ case Opcodes.TABLESWITCH:
+ case Opcodes.LOOKUPSWITCH:
+ case Opcodes.IRETURN:
+ case Opcodes.LRETURN:
+ case Opcodes.FRETURN:
+ case Opcodes.DRETURN:
+ case Opcodes.ARETURN:
+ interpreter.unaryOperation(insn, pop());
+ break;
+ case Opcodes.RETURN:
+ break;
+ case Opcodes.GETSTATIC:
+ push(interpreter.newOperation(insn));
+ break;
+ case Opcodes.PUTSTATIC:
+ interpreter.unaryOperation(insn, pop());
+ break;
+ case Opcodes.GETFIELD:
+ push(interpreter.unaryOperation(insn, pop()));
+ break;
+ case Opcodes.PUTFIELD:
+ value2 = pop();
+ value1 = pop();
+ interpreter.binaryOperation(insn, value1, value2);
+ break;
+ case Opcodes.INVOKEVIRTUAL:
+ case Opcodes.INVOKESPECIAL:
+ case Opcodes.INVOKESTATIC:
+ case Opcodes.INVOKEINTERFACE:
+ values = new ArrayList();
+ String desc = ((MethodInsnNode) insn).desc;
+ for (int i = Type.getArgumentTypes(desc).length; i > 0; --i) {
+ values.add(0, pop());
+ }
+ if (insn.getOpcode() != Opcodes.INVOKESTATIC) {
+ values.add(0, pop());
+ }
+ if (Type.getReturnType(desc) == Type.VOID_TYPE) {
+ interpreter.naryOperation(insn, values);
+ } else {
+ push(interpreter.naryOperation(insn, values));
+ }
+ break;
+ case Opcodes.NEW:
+ push(interpreter.newOperation(insn));
+ break;
+ case Opcodes.NEWARRAY:
+ case Opcodes.ANEWARRAY:
+ case Opcodes.ARRAYLENGTH:
+ push(interpreter.unaryOperation(insn, pop()));
+ break;
+ case Opcodes.ATHROW:
+ interpreter.unaryOperation(insn, pop());
+ break;
+ case Opcodes.CHECKCAST:
+ case Opcodes.INSTANCEOF:
+ push(interpreter.unaryOperation(insn, pop()));
+ break;
+ case Opcodes.MONITORENTER:
+ case Opcodes.MONITOREXIT:
+ interpreter.unaryOperation(insn, pop());
+ break;
+ case Opcodes.MULTIANEWARRAY:
+ values = new ArrayList();
+ for (int i = ((MultiANewArrayInsnNode) insn).dims; i > 0; --i) {
+ values.add(0, pop());
+ }
+ push(interpreter.naryOperation(insn, values));
+ break;
+ case Opcodes.IFNULL:
+ case Opcodes.IFNONNULL:
+ interpreter.unaryOperation(insn, pop());
+ break;
+ default:
+ throw new RuntimeException("Illegal opcode");
+ }
+ }
+
+ /**
+ * Merges this frame with the given frame.
+ *
+ * @param frame a frame.
+ * @param interpreter the interpreter used to merge values.
+ * @return <tt>true</tt> if this frame has been changed as a result of the
+ * merge operation, or <tt>false</tt> otherwise.
+ * @throws AnalyzerException if the frames have incompatible sizes.
+ */
+ public boolean merge(final Frame frame, final Interpreter interpreter)
+ throws AnalyzerException
+ {
+ if (top != frame.top) {
+ throw new AnalyzerException("Incompatible stack heights");
+ }
+ boolean changes = false;
+ for (int i = 0; i < locals + top; ++i) {
+ Value v = interpreter.merge(values[i], frame.values[i]);
+ if (v != values[i]) {
+ values[i] = v;
+ changes |= true;
+ }
+ }
+ return changes;
+ }
+
+ /**
+ * Merges this frame with the given frame (case of a RET instruction).
+ *
+ * @param frame a frame
+ * @param access the local variables that have been accessed by the
+ * subroutine to which the RET instruction corresponds.
+ * @return <tt>true</tt> if this frame has been changed as a result of the
+ * merge operation, or <tt>false</tt> otherwise.
+ */
+ public boolean merge(final Frame frame, final boolean[] access) {
+ boolean changes = false;
+ for (int i = 0; i < locals; ++i) {
+ if (!access[i] && !values[i].equals(frame.values[i])) {
+ values[i] = frame.values[i];
+ changes = true;
+ }
+ }
+ return changes;
+ }
+
+ /**
+ * Returns a string representation of this frame.
+ *
+ * @return a string representation of this frame.
+ */
+ public String toString() {
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < locals; ++i) {
+ b.append(values[i]).append(' ');
+ }
+ b.append(' ');
+ for (int i = 0; i < top; ++i) {
+ b.append(values[i + locals].toString()).append(' ');
+ }
+ return b.toString();
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/IntMap.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/IntMap.java
new file mode 100644
index 000000000..cac091cb7
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/IntMap.java
@@ -0,0 +1,73 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+/**
+ * A fixed size map of integer values.
+ *
+ * @author Eric Bruneton
+ */
+class IntMap {
+
+ private int size;
+
+ private Object[] keys;
+
+ private int[] values;
+
+ public IntMap(final int size) {
+ this.size = size;
+ this.keys = new Object[size];
+ this.values = new int[size];
+ }
+
+ public int get(final Object key) {
+ int n = size;
+ int h = (key.hashCode() & 0x7FFFFFFF) % n;
+ int i = h;
+ while (keys[i] != key) {
+ i = (i + 1) % n;
+ if (i == h) {
+ throw new RuntimeException("Cannot find index of " + key);
+ }
+ }
+ return values[i];
+ }
+
+ public void put(final Object key, final int value) {
+ int n = size;
+ int i = (key.hashCode() & 0x7FFFFFFF) % n;
+ while (keys[i] != null) {
+ i = (i + 1) % n;
+ }
+ keys[i] = key;
+ values[i] = value;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Interpreter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Interpreter.java
new file mode 100644
index 000000000..f989f4baf
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Interpreter.java
@@ -0,0 +1,178 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.List;
+
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+
+/**
+ * A semantic bytecode interpreter. More precisely, this interpreter only
+ * manages the computation of values from other values: it does not manage the
+ * transfer of values to or from the stack, and to or from the local variables.
+ * This separation allows a generic bytecode {@link Analyzer} to work with
+ * various semantic interpreters, without needing to duplicate the code to
+ * simulate the transfer of values.
+ *
+ * @author Eric Bruneton
+ */
+public interface Interpreter {
+
+ /**
+ * Creates a new value that represents the given type.
+ *
+ * Called for method parameters (including <code>this</code>),
+ * exception handler variable and with <code>null</code> type
+ * for variables reserved by long and double types.
+ *
+ * @param type a primitive or reference type, or <tt>null</tt> to
+ * represent an uninitialized value.
+ * @return a value that represents the given type. The size of the returned
+ * value must be equal to the size of the given type.
+ */
+ Value newValue(Type type);
+
+ /**
+ * Interprets a bytecode instruction without arguments. This method is
+ * called for the following opcodes:
+ *
+ * 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, JSR, GETSTATIC, NEW
+ *
+ * @param insn the bytecode instruction to be interpreted.
+ * @return the result of the interpretation of the given instruction.
+ * @throws AnalyzerException if an error occured during the interpretation.
+ */
+ Value newOperation(AbstractInsnNode insn) throws AnalyzerException;
+
+ /**
+ * Interprets a bytecode instruction that moves a value on the stack or to
+ * or from local variables. This method is called for the following opcodes:
+ *
+ * ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE,
+ * ASTORE, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP
+ *
+ * @param insn the bytecode instruction to be interpreted.
+ * @param value the value that must be moved by the instruction.
+ * @return the result of the interpretation of the given instruction. The
+ * returned value must be <tt>equal</tt> to the given value.
+ * @throws AnalyzerException if an error occured during the interpretation.
+ */
+ Value copyOperation(AbstractInsnNode insn, Value value)
+ throws AnalyzerException;
+
+ /**
+ * Interprets a bytecode instruction with a single argument. This method is
+ * called for the following opcodes:
+ *
+ * INEG, LNEG, FNEG, DNEG, IINC, I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L,
+ * F2D, D2I, D2L, D2F, I2B, I2C, I2S, IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE,
+ * TABLESWITCH, LOOKUPSWITCH, IRETURN, LRETURN, FRETURN, DRETURN, ARETURN,
+ * PUTSTATIC, GETFIELD, NEWARRAY, ANEWARRAY, ARRAYLENGTH, ATHROW, CHECKCAST,
+ * INSTANCEOF, MONITORENTER, MONITOREXIT, IFNULL, IFNONNULL
+ *
+ * @param insn the bytecode instruction to be interpreted.
+ * @param value the argument of the instruction to be interpreted.
+ * @return the result of the interpretation of the given instruction.
+ * @throws AnalyzerException if an error occured during the interpretation.
+ */
+ Value unaryOperation(AbstractInsnNode insn, Value value)
+ throws AnalyzerException;
+
+ /**
+ * Interprets a bytecode instruction with two arguments. This method is
+ * called for the following opcodes:
+ *
+ * IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, IADD,
+ * LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV,
+ * LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, ISHL, LSHL, ISHR, LSHR, IUSHR,
+ * LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, LCMP, FCMPL, FCMPG, DCMPL,
+ * DCMPG, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE,
+ * IF_ACMPEQ, IF_ACMPNE, PUTFIELD
+ *
+ * @param insn the bytecode instruction to be interpreted.
+ * @param value1 the first argument of the instruction to be interpreted.
+ * @param value2 the second argument of the instruction to be interpreted.
+ * @return the result of the interpretation of the given instruction.
+ * @throws AnalyzerException if an error occured during the interpretation.
+ */
+ Value binaryOperation(AbstractInsnNode insn, Value value1, Value value2)
+ throws AnalyzerException;
+
+ /**
+ * Interprets a bytecode instruction with three arguments. This method is
+ * called for the following opcodes:
+ *
+ * IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, SASTORE
+ *
+ * @param insn the bytecode instruction to be interpreted.
+ * @param value1 the first argument of the instruction to be interpreted.
+ * @param value2 the second argument of the instruction to be interpreted.
+ * @param value3 the third argument of the instruction to be interpreted.
+ * @return the result of the interpretation of the given instruction.
+ * @throws AnalyzerException if an error occured during the interpretation.
+ */
+ Value ternaryOperation(
+ AbstractInsnNode insn,
+ Value value1,
+ Value value2,
+ Value value3) throws AnalyzerException;
+
+ /**
+ * Interprets a bytecode instruction with a variable number of arguments.
+ * This method is called for the following opcodes:
+ *
+ * INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC, INVOKEINTERFACE,
+ * MULTIANEWARRAY
+ *
+ * @param insn the bytecode instruction to be interpreted.
+ * @param values the arguments of the instruction to be interpreted.
+ * @return the result of the interpretation of the given instruction.
+ * @throws AnalyzerException if an error occured during the interpretation.
+ */
+ Value naryOperation(AbstractInsnNode insn, List values)
+ throws AnalyzerException;
+
+ /**
+ * Merges two values. The merge operation must return a value that
+ * represents both values (for instance, if the two values are two types,
+ * the merged value must be a common super type of the two types. If the two
+ * values are integer intervals, the merged value must be an interval that
+ * contains the previous ones. Likewise for other types of values).
+ *
+ * @param v a value.
+ * @param w another value.
+ * @return the merged value. If the merged value is equal to <tt>v</tt>,
+ * this method <i>must</i> return <tt>v</tt>.
+ */
+ Value merge(Value v, Value w);
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.java
new file mode 100644
index 000000000..1329f77b8
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.java
@@ -0,0 +1,266 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.List;
+
+import org.objectweb.asm.Type;
+
+/**
+ * An extended {@link BasicVerifier} that performs more precise verifications.
+ * This verifier computes exact class types, instead of using a single "object
+ * reference" type (as done in the {@link BasicVerifier}).
+ *
+ * @author Eric Bruneton
+ * @author Bing Ran
+ */
+public class SimpleVerifier extends BasicVerifier {
+
+ /**
+ * The class that is verified.
+ */
+ private final Type currentClass;
+
+ /**
+ * The super class of the class that is verified.
+ */
+ private final Type currentSuperClass;
+
+ /**
+ * The interfaces implemented by the class that is verified.
+ */
+ private final List currentClassInterfaces;
+
+ /**
+ * If the class that is verified is an interface.
+ */
+ private final boolean isInterface;
+
+ /**
+ * Constructs a new {@link SimpleVerifier}.
+ */
+ public SimpleVerifier() {
+ this(null, null, false);
+ }
+
+ /**
+ * Constructs a new {@link SimpleVerifier} to verify a specific class. This
+ * class will not be loaded into the JVM since it may be incorrect.
+ *
+ * @param currentClass the class that is verified.
+ * @param currentSuperClass the super class of the class that is verified.
+ * @param isInterface if the class that is verified is an interface.
+ */
+ public SimpleVerifier(
+ final Type currentClass,
+ final Type currentSuperClass,
+ final boolean isInterface)
+ {
+ this(currentClass, currentSuperClass, null, isInterface);
+ }
+
+ /**
+ * Constructs a new {@link SimpleVerifier} to verify a specific class. This
+ * class will not be loaded into the JVM since it may be incorrect.
+ *
+ * @param currentClass the class that is verified.
+ * @param currentSuperClass the super class of the class that is verified.
+ * @param currentClassInterfaces the interfaces implemented by the class
+ * that is verified.
+ * @param isInterface if the class that is verified is an interface.
+ */
+ public SimpleVerifier(
+ final Type currentClass,
+ final Type currentSuperClass,
+ final List currentClassInterfaces,
+ final boolean isInterface)
+ {
+ this.currentClass = currentClass;
+ this.currentSuperClass = currentSuperClass;
+ this.currentClassInterfaces = currentClassInterfaces;
+ this.isInterface = isInterface;
+ }
+
+ public Value newValue(final Type type) {
+ Value v = super.newValue(type);
+ if (v == BasicValue.REFERENCE_VALUE) {
+ v = new BasicValue(type);
+ }
+ return v;
+ }
+
+ protected boolean isArrayValue(final Value value) {
+ Type t = ((BasicValue) value).getType();
+ if (t != null) {
+ return t.getDescriptor().equals("Lnull;")
+ || t.getSort() == Type.ARRAY;
+ }
+ return false;
+ }
+
+ protected Value getElementValue(final Value objectArrayValue)
+ throws AnalyzerException
+ {
+ Type arrayType = ((BasicValue) objectArrayValue).getType();
+ if (arrayType != null) {
+ if (arrayType.getSort() == Type.ARRAY) {
+ return newValue(Type.getType(arrayType.getDescriptor()
+ .substring(1)));
+ } else if (arrayType.getDescriptor().equals("Lnull;")) {
+ return objectArrayValue;
+ }
+ }
+ throw new AnalyzerException("Not an array type");
+ }
+
+ protected boolean isSubTypeOf(final Value value, final Value expected) {
+ Type expectedType = ((BasicValue) expected).getType();
+ Type type = ((BasicValue) value).getType();
+ if (expectedType == null) {
+ return type == null;
+ }
+ switch (expectedType.getSort()) {
+ case Type.INT:
+ case Type.FLOAT:
+ case Type.LONG:
+ case Type.DOUBLE:
+ return type == expectedType;
+ case Type.ARRAY:
+ case Type.OBJECT:
+ if (expectedType.getDescriptor().equals("Lnull;")) {
+ return type.getSort() == Type.OBJECT
+ || type.getSort() == Type.ARRAY;
+ }
+ if (type.getDescriptor().equals("Lnull;")) {
+ return true;
+ } else if (type.getSort() == Type.OBJECT
+ || type.getSort() == Type.ARRAY)
+ {
+ return isAssignableFrom(expectedType, type);
+ } else {
+ return false;
+ }
+ default:
+ throw new RuntimeException("Internal error");
+ }
+ }
+
+ public Value merge(final Value v, final Value w) {
+ if (!v.equals(w)) {
+ Type t = ((BasicValue) v).getType();
+ Type u = ((BasicValue) w).getType();
+ if (t != null
+ && (t.getSort() == Type.OBJECT || t.getSort() == Type.ARRAY))
+ {
+ if (u != null
+ && (u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY))
+ {
+ if (t.getDescriptor().equals("Lnull;")) {
+ return w;
+ }
+ if (u.getDescriptor().equals("Lnull;")) {
+ return v;
+ }
+ if (isAssignableFrom(t, u)) {
+ return v;
+ }
+ if (isAssignableFrom(u, t)) {
+ return w;
+ }
+ // TODO case of array classes of the same dimension
+ // TODO should we look also for a common super interface?
+ // problem: there may be several possible common super
+ // interfaces
+ do {
+ if (t == null || isInterface(t)) {
+ return BasicValue.REFERENCE_VALUE;
+ }
+ t = getSuperClass(t);
+ if (isAssignableFrom(t, u)) {
+ return newValue(t);
+ }
+ } while (true);
+ }
+ }
+ return BasicValue.UNINITIALIZED_VALUE;
+ }
+ return v;
+ }
+
+ private boolean isInterface(final Type t) {
+ if (currentClass != null && t.equals(currentClass)) {
+ return isInterface;
+ }
+ return getClass(t).isInterface();
+ }
+
+ private Type getSuperClass(final Type t) {
+ if (currentClass != null && t.equals(currentClass)) {
+ return currentSuperClass;
+ }
+ Class c = getClass(t).getSuperclass();
+ return c == null ? null : Type.getType(c);
+ }
+
+ private boolean isAssignableFrom(final Type t, final Type u) {
+ if (t.equals(u)) {
+ return true;
+ }
+ if (currentClass != null && t.equals(currentClass)) {
+ return isAssignableFrom(t, getSuperClass(u));
+ }
+ if (currentClass != null && u.equals(currentClass)) {
+ if (isAssignableFrom(t, currentSuperClass)) {
+ return true;
+ }
+ if (currentClassInterfaces != null) {
+ for (int i = 0; i < currentClassInterfaces.size(); ++i) {
+ Type v = (Type) currentClassInterfaces.get(i);
+ if (isAssignableFrom(t, v)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ return getClass(t).isAssignableFrom(getClass(u));
+ }
+
+ protected Class getClass(final Type t) {
+ try {
+ if (t.getSort() == Type.ARRAY) {
+ return Class.forName(t.getDescriptor().replace('/', '.'));
+ }
+ return Class.forName(t.getClassName());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SmallSet.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SmallSet.java
new file mode 100644
index 000000000..3049d5a78
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SmallSet.java
@@ -0,0 +1,126 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.AbstractSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * A set of at most two elements.
+ *
+ * @author Eric Bruneton
+ */
+class SmallSet extends AbstractSet implements Iterator {
+
+ // if e1 is null, e2 must be null; otherwise e2 must be different from e1
+
+ Object e1, e2;
+
+ final static SmallSet EMPTY_SET = new SmallSet(null, null);
+
+ SmallSet(Object e1, Object e2) {
+ this.e1 = e1;
+ this.e2 = e2;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation of inherited abstract methods
+ // -------------------------------------------------------------------------
+
+ public Iterator iterator() {
+ return new SmallSet(e1, e2);
+ }
+
+ public int size() {
+ return e1 == null ? 0 : (e2 == null ? 1 : 2);
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation of the Iterator interface
+ // -------------------------------------------------------------------------
+
+ public boolean hasNext() {
+ return e1 != null;
+ }
+
+ public Object next() {
+ Object e = e1;
+ e1 = e2;
+ e2 = null;
+ return e;
+ }
+
+ public void remove() {
+ }
+
+ // -------------------------------------------------------------------------
+ // Utility methods
+ // -------------------------------------------------------------------------
+
+ Set union(SmallSet s) {
+ if ((s.e1 == e1 && s.e2 == e2) || (s.e1 == e2 && s.e2 == e1)) {
+ return this; // if the two sets are equal, return this
+ }
+ if (s.e1 == null) {
+ return this; // if s is empty, return this
+ }
+ if (e1 == null) {
+ return s; // if this is empty, return s
+ }
+ if (s.e2 == null) { // s contains exactly one element
+ if (e2 == null) {
+ return new SmallSet(e1, s.e1); // necessarily e1 != s.e1
+ } else if (s.e1 == e1 || s.e1 == e2) { // s is included in this
+ return this;
+ }
+ }
+ if (e2 == null) { // this contains exactly one element
+ // if (s.e2 == null) { // cannot happen
+ // return new SmallSet(e1, s.e1); // necessarily e1 != s.e1
+ // } else
+ if (e1 == s.e1 || e1 == s.e2) { // this in included in s
+ return s;
+ }
+ }
+ // here we know that there are at least 3 distinct elements
+ HashSet r = new HashSet(4);
+ r.add(e1);
+ if (e2 != null) {
+ r.add(e2);
+ }
+ r.add(s.e1);
+ if (s.e2 != null) {
+ r.add(s.e2);
+ }
+ return r;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Subroutine.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Subroutine.java
new file mode 100644
index 000000000..5ae010905
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Subroutine.java
@@ -0,0 +1,96 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.tree.JumpInsnNode;
+
+/**
+ * A method subroutine (corresponds to a JSR instruction).
+ *
+ * @author Eric Bruneton
+ */
+class Subroutine {
+
+ Label start;
+
+ boolean[] access;
+
+ List callers;
+
+ private Subroutine() {
+ }
+
+ public Subroutine(
+ final Label start,
+ final int maxLocals,
+ final JumpInsnNode caller)
+ {
+ this.start = start;
+ this.access = new boolean[maxLocals];
+ this.callers = new ArrayList();
+ callers.add(caller);
+ }
+
+ public Subroutine copy() {
+ Subroutine result = new Subroutine();
+ result.start = start;
+ result.access = new boolean[access.length];
+ System.arraycopy(access, 0, result.access, 0, access.length);
+ result.callers = new ArrayList(callers);
+ return result;
+ }
+
+ public boolean merge(final Subroutine subroutine, boolean checkOverlap)
+ throws AnalyzerException
+ {
+ if (checkOverlap && subroutine.start != start) {
+ throw new AnalyzerException("Overlapping sub routines");
+ }
+ boolean changes = false;
+ for (int i = 0; i < access.length; ++i) {
+ if (subroutine.access[i] && !access[i]) {
+ access[i] = true;
+ changes = true;
+ }
+ }
+ for (int i = 0; i < subroutine.callers.size(); ++i) {
+ Object caller = subroutine.callers.get(i);
+ if (!callers.contains(caller)) {
+ callers.add(caller);
+ changes = true;
+ }
+ }
+ return changes;
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Value.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Value.java
new file mode 100644
index 000000000..4baf1b4b3
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Value.java
@@ -0,0 +1,45 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.tree.analysis;
+
+/**
+ * An immutable symbolic value for semantic interpretation of bytecode.
+ *
+ * @author Eric Bruneton
+ */
+public interface Value {
+
+ /**
+ * Returns the size of this value in words.
+ *
+ * @return either 1 or 2.
+ */
+ int getSize();
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.java
new file mode 100644
index 000000000..940bc112c
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.java
@@ -0,0 +1,226 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import java.util.HashMap;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.util.attrs.ASMifiable;
+
+/**
+ * An abstract ASMifier visitor.
+ *
+ * @author Eric Bruneton
+ */
+public class ASMifierAbstractVisitor extends AbstractVisitor {
+
+ /**
+ * The name of the variable for this visitor in the produced code.
+ */
+ protected String name;
+
+ /**
+ * The label names. This map associates String values to Label keys. It is
+ * used only in ASMifierMethodVisitor.
+ */
+ HashMap labelNames;
+
+ /**
+ * Constructs a new {@link ASMifierAbstractVisitor}.
+ *
+ * @param name the name of the variable for this visitor in the produced
+ * code.
+ */
+ protected ASMifierAbstractVisitor(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Prints the ASM code that generates the given annotation.
+ *
+ * @param desc the class descriptor of the annotation class.
+ * @param visible <tt>true</tt> if the annotation is visible at runtime.
+ * @return a visitor to visit the annotation values.
+ */
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ buf.setLength(0);
+ buf.append("{\n")
+ .append("av0 = ")
+ .append(name)
+ .append(".visitAnnotation(");
+ appendConstant(desc);
+ buf.append(", ").append(visible).append(");\n");
+ text.add(buf.toString());
+ ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
+ text.add(av.getText());
+ text.add("}\n");
+ return av;
+ }
+
+ /**
+ * Prints the ASM code that generates the given attribute.
+ *
+ * @param attr an attribute.
+ */
+ public void visitAttribute(final Attribute attr) {
+ buf.setLength(0);
+ if (attr instanceof ASMifiable) {
+ buf.append("{\n");
+ buf.append("// ATTRIBUTE\n");
+ ((ASMifiable) attr).asmify(buf, "attr", labelNames);
+ buf.append(name).append(".visitAttribute(attr);\n");
+ buf.append("}\n");
+ } else {
+ buf.append("// WARNING! skipped a non standard attribute of type \"");
+ buf.append(attr.type).append("\"\n");
+ }
+ text.add(buf.toString());
+ }
+
+ /**
+ * Prints the ASM code to end the visit.
+ */
+ public void visitEnd() {
+ buf.setLength(0);
+ buf.append(name).append(".visitEnd();\n");
+ text.add(buf.toString());
+ }
+
+ /**
+ * Appends a string representation of the given constant to the given
+ * buffer.
+ *
+ * @param cst an {@link Integer}, {@link Float}, {@link Long},
+ * {@link Double} or {@link String} object. May be <tt>null</tt>.
+ */
+ void appendConstant(final Object cst) {
+ appendConstant(buf, cst);
+ }
+
+ /**
+ * Appends a string representation of the given constant to the given
+ * buffer.
+ *
+ * @param buf a string buffer.
+ * @param cst an {@link Integer}, {@link Float}, {@link Long},
+ * {@link Double} or {@link String} object. May be <tt>null</tt>.
+ */
+ static void appendConstant(final StringBuffer buf, final Object cst) {
+ if (cst == null) {
+ buf.append("null");
+ } else if (cst instanceof String) {
+ appendString(buf, (String) cst);
+ } else if (cst instanceof Type) {
+ buf.append("Type.getType(\"");
+ buf.append(((Type) cst).getDescriptor());
+ buf.append("\")");
+ } else if (cst instanceof Byte) {
+ buf.append("new Byte((byte)").append(cst).append(")");
+ } else if (cst instanceof Boolean) {
+ buf.append("new Boolean(").append(cst).append(")");
+ } else if (cst instanceof Short) {
+ buf.append("new Short((short)").append(cst).append(")");
+ } else if (cst instanceof Character) {
+ int c = ((Character) cst).charValue();
+ buf.append("new Character((char)").append(c).append(")");
+ } else if (cst instanceof Integer) {
+ buf.append("new Integer(").append(cst).append(")");
+ } else if (cst instanceof Float) {
+ buf.append("new Float(\"").append(cst).append("\")");
+ } else if (cst instanceof Long) {
+ buf.append("new Long(").append(cst).append("L)");
+ } else if (cst instanceof Double) {
+ buf.append("new Double(\"").append(cst).append("\")");
+ } else if (cst instanceof byte[]) {
+ byte[] v = (byte[]) cst;
+ buf.append("new byte[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",").append(v[i]);
+ }
+ buf.append("}");
+ } else if (cst instanceof boolean[]) {
+ boolean[] v = (boolean[]) cst;
+ buf.append("new boolean[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",").append(v[i]);
+ }
+ buf.append("}");
+ } else if (cst instanceof short[]) {
+ short[] v = (short[]) cst;
+ buf.append("new short[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",").append("(short)").append(v[i]);
+ }
+ buf.append("}");
+ } else if (cst instanceof char[]) {
+ char[] v = (char[]) cst;
+ buf.append("new char[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",")
+ .append("(char)")
+ .append((int) v[i]);
+ }
+ buf.append("}");
+ } else if (cst instanceof int[]) {
+ int[] v = (int[]) cst;
+ buf.append("new int[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",").append(v[i]);
+ }
+ buf.append("}");
+ } else if (cst instanceof long[]) {
+ long[] v = (long[]) cst;
+ buf.append("new long[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",").append(v[i]).append("L");
+ }
+ buf.append("}");
+ } else if (cst instanceof float[]) {
+ float[] v = (float[]) cst;
+ buf.append("new float[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",").append(v[i]).append("f");
+ }
+ buf.append("}");
+ } else if (cst instanceof double[]) {
+ double[] v = (double[]) cst;
+ buf.append("new double[] {");
+ for (int i = 0; i < v.length; i++) {
+ buf.append(i == 0 ? "" : ",").append(v[i]).append("d");
+ }
+ buf.append("}");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.java
new file mode 100644
index 000000000..0f766b32e
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.java
@@ -0,0 +1,127 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+
+/**
+ * An {@link AnnotationVisitor} that prints the ASM code that generates the
+ * annotations it visits.
+ *
+ * @author Eric Bruneton
+ */
+public class ASMifierAnnotationVisitor extends AbstractVisitor implements
+ AnnotationVisitor
+{
+
+ /**
+ * Identifier of the annotation visitor variable in the produced code.
+ */
+ protected final int id;
+
+ /**
+ * Constructs a new {@link ASMifierAnnotationVisitor}.
+ *
+ * @param id identifier of the annotation visitor variable in the produced
+ * code.
+ */
+ public ASMifierAnnotationVisitor(final int id) {
+ this.id = id;
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the AnnotationVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(final String name, final Object value) {
+ buf.setLength(0);
+ buf.append("av").append(id).append(".visit(");
+ ASMifierAbstractVisitor.appendConstant(buf, name);
+ buf.append(", ");
+ ASMifierAbstractVisitor.appendConstant(buf, value);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitEnum(
+ final String name,
+ final String desc,
+ final String value)
+ {
+ buf.setLength(0);
+ buf.append("av").append(id).append(".visitEnum(");
+ ASMifierAbstractVisitor.appendConstant(buf, name);
+ buf.append(", ");
+ ASMifierAbstractVisitor.appendConstant(buf, desc);
+ buf.append(", ");
+ ASMifierAbstractVisitor.appendConstant(buf, value);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ buf.append("{\n");
+ buf.append("AnnotationVisitor av").append(id + 1).append(" = av");
+ buf.append(id).append(".visitAnnotation(");
+ ASMifierAbstractVisitor.appendConstant(buf, name);
+ buf.append(", ");
+ ASMifierAbstractVisitor.appendConstant(buf, desc);
+ buf.append(");\n");
+ text.add(buf.toString());
+ ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(id + 1);
+ text.add(av.getText());
+ text.add("}\n");
+ return av;
+ }
+
+ public AnnotationVisitor visitArray(final String name) {
+ buf.setLength(0);
+ buf.append("{\n");
+ buf.append("AnnotationVisitor av").append(id + 1).append(" = av");
+ buf.append(id).append(".visitArray(");
+ ASMifierAbstractVisitor.appendConstant(buf, name);
+ buf.append(");\n");
+ text.add(buf.toString());
+ ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(id + 1);
+ text.add(av.getText());
+ text.add("}\n");
+ return av;
+ }
+
+ public void visitEnd() {
+ buf.setLength(0);
+ buf.append("av").append(id).append(".visitEnd();\n");
+ text.add(buf.toString());
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierClassVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierClassVisitor.java
new file mode 100644
index 000000000..d7b73fb75
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierClassVisitor.java
@@ -0,0 +1,607 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import java.io.FileInputStream;
+import java.io.PrintWriter;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * A {@link ClassVisitor} that prints the ASM code that generates the classes it
+ * visits. This class visitor can be used to quickly write ASM code to generate
+ * some given bytecode: <ul> <li>write the Java source code equivalent to the
+ * bytecode you want to generate;</li> <li>compile it with <tt>javac</tt>;</li>
+ * <li>make a {@link ASMifierClassVisitor} visit this compiled class (see the
+ * {@link #main main} method);</li> <li>edit the generated source code, if
+ * necessary.</li> </ul> The source code printed when visiting the
+ * <tt>Hello</tt> class is the following: <p> <blockquote>
+ *
+ * <pre>
+ * import org.objectweb.asm.*;
+ *
+ * public class HelloDump implements Opcodes {
+ *
+ * public static byte[] dump() throws Exception {
+ *
+ * ClassWriter cw = new ClassWriter(false);
+ * FieldVisitor fv;
+ * MethodVisitor mv;
+ * AnnotationVisitor av0;
+ *
+ * cw.visit(49,
+ * ACC_PUBLIC + ACC_SUPER,
+ * &quot;Hello&quot;,
+ * null,
+ * &quot;java/lang/Object&quot;,
+ * null);
+ *
+ * cw.visitSource(&quot;Hello.java&quot;, null);
+ *
+ * {
+ * mv = cw.visitMethod(ACC_PUBLIC, &quot;&lt;init&gt;&quot;, &quot;()V&quot;, null, null);
+ * mv.visitVarInsn(ALOAD, 0);
+ * mv.visitMethodInsn(INVOKESPECIAL,
+ * &quot;java/lang/Object&quot;,
+ * &quot;&lt;init&gt;&quot;,
+ * &quot;()V&quot;);
+ * mv.visitInsn(RETURN);
+ * mv.visitMaxs(1, 1);
+ * mv.visitEnd();
+ * }
+ * {
+ * mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC,
+ * &quot;main&quot;,
+ * &quot;([Ljava/lang/String;)V&quot;,
+ * null,
+ * null);
+ * mv.visitFieldInsn(GETSTATIC,
+ * &quot;java/lang/System&quot;,
+ * &quot;out&quot;,
+ * &quot;Ljava/io/PrintStream;&quot;);
+ * mv.visitLdcInsn(&quot;hello&quot;);
+ * mv.visitMethodInsn(INVOKEVIRTUAL,
+ * &quot;java/io/PrintStream&quot;,
+ * &quot;println&quot;,
+ * &quot;(Ljava/lang/String;)V&quot;);
+ * mv.visitInsn(RETURN);
+ * mv.visitMaxs(2, 1);
+ * mv.visitEnd();
+ * }
+ * cw.visitEnd();
+ *
+ * return cw.toByteArray();
+ * }
+ * }
+ *
+ * </pre>
+ *
+ * </blockquote> where <tt>Hello</tt> is defined by: <p> <blockquote>
+ *
+ * <pre>
+ * public class Hello {
+ *
+ * public static void main(String[] args) {
+ * System.out.println(&quot;hello&quot;);
+ * }
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+public class ASMifierClassVisitor extends ASMifierAbstractVisitor implements
+ ClassVisitor
+{
+
+ /**
+ * Pseudo access flag used to distinguish class access flags.
+ */
+ private final static int ACCESS_CLASS = 262144;
+
+ /**
+ * Pseudo access flag used to distinguish field access flags.
+ */
+ private final static int ACCESS_FIELD = 524288;
+
+ /**
+ * Pseudo access flag used to distinguish inner class flags.
+ */
+ private static final int ACCESS_INNER = 1048576;
+
+ /**
+ * The print writer to be used to print the class.
+ */
+ protected final PrintWriter pw;
+
+ /**
+ * Prints the ASM source code to generate the given class to the standard
+ * output. <p> Usage: ASMifierClassVisitor [-debug] &lt;fully qualified
+ * class name or class file name&gt;
+ *
+ * @param args the command line arguments.
+ *
+ * @throws Exception if the class cannot be found, or if an IO exception
+ * occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ int i = 0;
+ boolean skipDebug = true;
+
+ boolean ok = true;
+ if (args.length < 1 || args.length > 2) {
+ ok = false;
+ }
+ if (ok && args[0].equals("-debug")) {
+ i = 1;
+ skipDebug = false;
+ if (args.length != 2) {
+ ok = false;
+ }
+ }
+ if (!ok) {
+ System.err.println("Prints the ASM code to generate the given class.");
+ System.err.println("Usage: ASMifierClassVisitor [-debug] "
+ + "<fully qualified class name or class file name>");
+ return;
+ }
+ ClassReader cr;
+ if (args[i].endsWith(".class") || args[i].indexOf('\\') > -1
+ || args[i].indexOf('/') > -1) {
+ cr = new ClassReader(new FileInputStream(args[i]));
+ } else {
+ cr = new ClassReader(args[i]);
+ }
+ cr.accept(new ASMifierClassVisitor(new PrintWriter(System.out)),
+ getDefaultAttributes(),
+ skipDebug);
+ }
+
+ /**
+ * Constructs a new {@link ASMifierClassVisitor} object.
+ *
+ * @param pw the print writer to be used to print the class.
+ */
+ public ASMifierClassVisitor(final PrintWriter pw) {
+ super("cw");
+ this.pw = pw;
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the ClassVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ String simpleName;
+ int n = name.lastIndexOf('/');
+ if (n != -1) {
+ text.add("package asm." + name.substring(0, n).replace('/', '.')
+ + ";\n");
+ simpleName = name.substring(n + 1);
+ } else {
+ simpleName = name;
+ }
+ text.add("import java.util.*;\n");
+ text.add("import org.objectweb.asm.*;\n");
+ text.add("import org.objectweb.asm.attrs.*;\n");
+ text.add("public class " + simpleName + "Dump implements Opcodes {\n\n");
+ text.add("public static byte[] dump () throws Exception {\n\n");
+ text.add("ClassWriter cw = new ClassWriter(false);\n");
+ text.add("FieldVisitor fv;\n");
+ text.add("MethodVisitor mv;\n");
+ text.add("AnnotationVisitor av0;\n\n");
+
+ buf.setLength(0);
+ buf.append("cw.visit(");
+ switch (version) {
+ case Opcodes.V1_1:
+ buf.append("V1_1");
+ break;
+ case Opcodes.V1_2:
+ buf.append("V1_2");
+ break;
+ case Opcodes.V1_3:
+ buf.append("V1_3");
+ break;
+ case Opcodes.V1_4:
+ buf.append("V1_4");
+ break;
+ case Opcodes.V1_5:
+ buf.append("V1_5");
+ break;
+ case Opcodes.V1_6:
+ buf.append("V1_6");
+ break;
+ default:
+ buf.append(version);
+ break;
+ }
+ buf.append(", ");
+ appendAccess(access | ACCESS_CLASS);
+ buf.append(", ");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(signature);
+ buf.append(", ");
+ appendConstant(superName);
+ buf.append(", ");
+ if (interfaces != null && interfaces.length > 0) {
+ buf.append("new String[] {");
+ for (int i = 0; i < interfaces.length; ++i) {
+ buf.append(i == 0 ? " " : ", ");
+ appendConstant(interfaces[i]);
+ }
+ buf.append(" }");
+ } else {
+ buf.append("null");
+ }
+ buf.append(");\n\n");
+ text.add(buf.toString());
+ }
+
+ public void visitSource(final String file, final String debug) {
+ buf.setLength(0);
+ buf.append("cw.visitSource(");
+ appendConstant(file);
+ buf.append(", ");
+ appendConstant(debug);
+ buf.append(");\n\n");
+ text.add(buf.toString());
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ buf.append("cw.visitOuterClass(");
+ appendConstant(owner);
+ buf.append(", ");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(desc);
+ buf.append(");\n\n");
+ text.add(buf.toString());
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ buf.setLength(0);
+ buf.append("cw.visitInnerClass(");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(outerName);
+ buf.append(", ");
+ appendConstant(innerName);
+ buf.append(", ");
+ appendAccess(access | ACCESS_INNER);
+ buf.append(");\n\n");
+ text.add(buf.toString());
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ buf.setLength(0);
+ buf.append("{\n");
+ buf.append("fv = cw.visitField(");
+ appendAccess(access | ACCESS_FIELD);
+ buf.append(", ");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(desc);
+ buf.append(", ");
+ appendConstant(signature);
+ buf.append(", ");
+ appendConstant(value);
+ buf.append(");\n");
+ text.add(buf.toString());
+ ASMifierFieldVisitor aav = new ASMifierFieldVisitor();
+ text.add(aav.getText());
+ text.add("}\n");
+ return aav;
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ buf.setLength(0);
+ buf.append("{\n");
+ buf.append("mv = cw.visitMethod(");
+ appendAccess(access);
+ buf.append(", ");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(desc);
+ buf.append(", ");
+ appendConstant(signature);
+ buf.append(", ");
+ if (exceptions != null && exceptions.length > 0) {
+ buf.append("new String[] {");
+ for (int i = 0; i < exceptions.length; ++i) {
+ buf.append(i == 0 ? " " : ", ");
+ appendConstant(exceptions[i]);
+ }
+ buf.append(" }");
+ } else {
+ buf.append("null");
+ }
+ buf.append(");\n");
+ text.add(buf.toString());
+ ASMifierMethodVisitor acv = new ASMifierMethodVisitor();
+ text.add(acv.getText());
+ text.add("}\n");
+ return acv;
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ buf.setLength(0);
+ buf.append("{\n");
+ buf.append("av0 = cw.visitAnnotation(");
+ appendConstant(desc);
+ buf.append(", ");
+ buf.append(visible);
+ buf.append(");\n");
+ text.add(buf.toString());
+ ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
+ text.add(av.getText());
+ text.add("}\n");
+ return av;
+ }
+
+ public void visitEnd() {
+ text.add("cw.visitEnd();\n\n");
+ text.add("return cw.toByteArray();\n");
+ text.add("}\n");
+ text.add("}\n");
+ printList(pw, text);
+ pw.flush();
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Appends a string representation of the given access modifiers to {@link
+ * #buf buf}.
+ *
+ * @param access some access modifiers.
+ */
+ void appendAccess(final int access) {
+ boolean first = true;
+ if ((access & Opcodes.ACC_PUBLIC) != 0) {
+ buf.append("ACC_PUBLIC");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_PRIVATE) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_PRIVATE");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_PROTECTED) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_PROTECTED");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_FINAL) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_FINAL");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_STATIC) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_STATIC");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ if ((access & ACCESS_CLASS) != 0) {
+ buf.append("ACC_SUPER");
+ } else {
+ buf.append("ACC_SYNCHRONIZED");
+ }
+ first = false;
+ }
+ if ((access & Opcodes.ACC_VOLATILE) != 0
+ && (access & ACCESS_FIELD) != 0)
+ {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_VOLATILE");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_BRIDGE) != 0 && (access & ACCESS_CLASS) == 0
+ && (access & ACCESS_FIELD) == 0)
+ {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_BRIDGE");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_VARARGS) != 0 && (access & ACCESS_CLASS) == 0
+ && (access & ACCESS_FIELD) == 0)
+ {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_VARARGS");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_TRANSIENT) != 0
+ && (access & ACCESS_FIELD) != 0)
+ {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_TRANSIENT");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_NATIVE) != 0 && (access & ACCESS_CLASS) == 0
+ && (access & ACCESS_FIELD) == 0)
+ {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_NATIVE");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_ENUM) != 0
+ && ((access & ACCESS_CLASS) != 0
+ || (access & ACCESS_FIELD) != 0 || (access & ACCESS_INNER) != 0))
+ {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_ENUM");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_ANNOTATION) != 0
+ && ((access & ACCESS_CLASS) != 0))
+ {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_ANNOTATION");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_ABSTRACT) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_ABSTRACT");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_INTERFACE) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_INTERFACE");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_STRICT) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_STRICT");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_SYNTHETIC");
+ first = false;
+ }
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ if (!first) {
+ buf.append(" + ");
+ }
+ buf.append("ACC_DEPRECATED");
+ first = false;
+ }
+ if (first) {
+ buf.append("0");
+ }
+ }
+
+ /**
+ * Appends a string representation of the given constant to the given
+ * buffer.
+ *
+ * @param buf a string buffer.
+ * @param cst an {@link java.lang.Integer Integer}, {@link java.lang.Float
+ * Float}, {@link java.lang.Long Long},
+ * {@link java.lang.Double Double} or {@link String String} object.
+ * May be <tt>null</tt>.
+ */
+ static void appendConstant(final StringBuffer buf, final Object cst) {
+ if (cst == null) {
+ buf.append("null");
+ } else if (cst instanceof String) {
+ AbstractVisitor.appendString(buf, (String) cst);
+ } else if (cst instanceof Type) {
+ buf.append("Type.getType(\"")
+ .append(((Type) cst).getDescriptor())
+ .append("\")");
+ } else if (cst instanceof Integer) {
+ buf.append("new Integer(").append(cst).append(")");
+ } else if (cst instanceof Float) {
+ buf.append("new Float(\"").append(cst).append("\")");
+ } else if (cst instanceof Long) {
+ buf.append("new Long(").append(cst).append("L)");
+ } else if (cst instanceof Double) {
+ buf.append("new Double(\"").append(cst).append("\")");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierFieldVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierFieldVisitor.java
new file mode 100644
index 000000000..673217909
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierFieldVisitor.java
@@ -0,0 +1,50 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.FieldVisitor;
+
+/**
+ * A {@link FieldVisitor} that prints the ASM code that generates the fields it
+ * visits.
+ *
+ * @author Eric Bruneton
+ */
+public class ASMifierFieldVisitor extends ASMifierAbstractVisitor implements
+ FieldVisitor
+{
+
+ /**
+ * Constructs a new {@link ASMifierFieldVisitor}.
+ */
+ public ASMifierFieldVisitor() {
+ super("fv");
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierMethodVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierMethodVisitor.java
new file mode 100644
index 000000000..57c55ee21
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierMethodVisitor.java
@@ -0,0 +1,347 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+
+import java.util.HashMap;
+
+/**
+ * A {@link MethodVisitor} that prints the ASM code that generates the methods
+ * it visits.
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+public class ASMifierMethodVisitor extends ASMifierAbstractVisitor implements
+ MethodVisitor
+{
+
+ /**
+ * Constructs a new {@link ASMifierMethodVisitor} object.
+ */
+ public ASMifierMethodVisitor() {
+ super("mv");
+ this.labelNames = new HashMap();
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ buf.setLength(0);
+ buf.append("{\n").append("av0 = mv.visitAnnotationDefault();\n");
+ text.add(buf.toString());
+ ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
+ text.add(av.getText());
+ text.add("}\n");
+ return av;
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ buf.setLength(0);
+ buf.append("{\n")
+ .append("av0 = mv.visitParameterAnnotation(")
+ .append(parameter)
+ .append(", ");
+ appendConstant(desc);
+ buf.append(", ").append(visible).append(");\n");
+ text.add(buf.toString());
+ ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
+ text.add(av.getText());
+ text.add("}\n");
+ return av;
+ }
+
+ public void visitCode() {
+ text.add("mv.visitCode();\n");
+ }
+
+ public void visitInsn(final int opcode) {
+ buf.setLength(0);
+ buf.append("mv.visitInsn(").append(OPCODES[opcode]).append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ buf.setLength(0);
+ buf.append("mv.visitIntInsn(")
+ .append(OPCODES[opcode])
+ .append(", ")
+ .append(opcode == Opcodes.NEWARRAY
+ ? TYPES[operand]
+ : Integer.toString(operand))
+ .append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ buf.setLength(0);
+ buf.append("mv.visitVarInsn(")
+ .append(OPCODES[opcode])
+ .append(", ")
+ .append(var)
+ .append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ buf.setLength(0);
+ buf.append("mv.visitTypeInsn(").append(OPCODES[opcode]).append(", ");
+ appendConstant(desc);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ buf.append("mv.visitFieldInsn(").append(OPCODES[opcode]).append(", ");
+ appendConstant(owner);
+ buf.append(", ");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(desc);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ buf.append("mv.visitMethodInsn(").append(OPCODES[opcode]).append(", ");
+ appendConstant(owner);
+ buf.append(", ");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(desc);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ buf.setLength(0);
+ declareLabel(label);
+ buf.append("mv.visitJumpInsn(").append(OPCODES[opcode]).append(", ");
+ appendLabel(label);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitLabel(final Label label) {
+ buf.setLength(0);
+ declareLabel(label);
+ buf.append("mv.visitLabel(");
+ appendLabel(label);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ buf.setLength(0);
+ buf.append("mv.visitLdcInsn(");
+ appendConstant(cst);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ buf.setLength(0);
+ buf.append("mv.visitIincInsn(")
+ .append(var)
+ .append(", ")
+ .append(increment)
+ .append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitTableSwitchInsn(
+ final int min,
+ final int max,
+ final Label dflt,
+ final Label labels[])
+ {
+ buf.setLength(0);
+ for (int i = 0; i < labels.length; ++i) {
+ declareLabel(labels[i]);
+ }
+ declareLabel(dflt);
+
+ buf.append("mv.visitTableSwitchInsn(")
+ .append(min)
+ .append(", ")
+ .append(max)
+ .append(", ");
+ appendLabel(dflt);
+ buf.append(", new Label[] {");
+ for (int i = 0; i < labels.length; ++i) {
+ buf.append(i == 0 ? " " : ", ");
+ appendLabel(labels[i]);
+ }
+ buf.append(" });\n");
+ text.add(buf.toString());
+ }
+
+ public void visitLookupSwitchInsn(
+ final Label dflt,
+ final int keys[],
+ final Label labels[])
+ {
+ buf.setLength(0);
+ for (int i = 0; i < labels.length; ++i) {
+ declareLabel(labels[i]);
+ }
+ declareLabel(dflt);
+
+ buf.append("mv.visitLookupSwitchInsn(");
+ appendLabel(dflt);
+ buf.append(", new int[] {");
+ for (int i = 0; i < keys.length; ++i) {
+ buf.append(i == 0 ? " " : ", ").append(keys[i]);
+ }
+ buf.append(" }, new Label[] {");
+ for (int i = 0; i < labels.length; ++i) {
+ buf.append(i == 0 ? " " : ", ");
+ appendLabel(labels[i]);
+ }
+ buf.append(" });\n");
+ text.add(buf.toString());
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ buf.setLength(0);
+ buf.append("mv.visitMultiANewArrayInsn(");
+ appendConstant(desc);
+ buf.append(", ").append(dims).append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitTryCatchBlock(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ buf.setLength(0);
+ declareLabel(start);
+ declareLabel(end);
+ declareLabel(handler);
+ buf.append("mv.visitTryCatchBlock(");
+ appendLabel(start);
+ buf.append(", ");
+ appendLabel(end);
+ buf.append(", ");
+ appendLabel(handler);
+ buf.append(", ");
+ appendConstant(type);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ buf.setLength(0);
+ buf.append("mv.visitLocalVariable(");
+ appendConstant(name);
+ buf.append(", ");
+ appendConstant(desc);
+ buf.append(", ");
+ appendConstant(signature);
+ buf.append(", ");
+ appendLabel(start);
+ buf.append(", ");
+ appendLabel(end);
+ buf.append(", ").append(index).append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ buf.setLength(0);
+ buf.append("mv.visitLineNumber(").append(line).append(", ");
+ appendLabel(start);
+ buf.append(");\n");
+ text.add(buf.toString());
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ buf.setLength(0);
+ buf.append("mv.visitMaxs(")
+ .append(maxStack)
+ .append(", ")
+ .append(maxLocals)
+ .append(");\n");
+ text.add(buf.toString());
+ }
+
+ /**
+ * Appends a declaration of the given label to {@link #buf buf}. This
+ * declaration is of the form "Label lXXX = new Label();". Does nothing if
+ * the given label has already been declared.
+ *
+ * @param l a label.
+ */
+ private void declareLabel(final Label l) {
+ String name = (String) labelNames.get(l);
+ if (name == null) {
+ name = "l" + labelNames.size();
+ labelNames.put(l, name);
+ buf.append("Label ").append(name).append(" = new Label();\n");
+ }
+ }
+
+ /**
+ * Appends the name of the given label to {@link #buf buf}. The given label
+ * <i>must</i> already have a name. One way to ensure this is to always
+ * call {@link #declareLabel declared} before calling this method.
+ *
+ * @param l a label.
+ */
+ private void appendLabel(final Label l) {
+ buf.append((String) labelNames.get(l));
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/AbstractVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/AbstractVisitor.java
new file mode 100644
index 000000000..557d5c82f
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/AbstractVisitor.java
@@ -0,0 +1,201 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.util.attrs.ASMStackMapAttribute;
+import org.objectweb.asm.util.attrs.ASMStackMapTableAttribute;
+
+/**
+ * An abstract visitor.
+ *
+ * @author Eric Bruneton
+ */
+public abstract class AbstractVisitor {
+
+ /**
+ * The names of the Java Virtual Machine opcodes.
+ */
+ public final static String[] OPCODES;
+ /**
+ * Types for <code>operand</code> parameter of the
+ * {@link org.objectweb.asm.MethodVisitor#visitIntInsn} method when
+ * <code>opcode</code> is <code>NEWARRAY</code>.
+ */
+ public final static String[] TYPES;
+
+ static {
+ String s = "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,,,"
+ + "ILOAD,LLOAD,FLOAD,DLOAD,ALOAD,,,,,,,,,,,,,,,,,,,,,IALOAD,"
+ + "LALOAD,FALOAD,DALOAD,AALOAD,BALOAD,CALOAD,SALOAD,ISTORE,"
+ + "LSTORE,FSTORE,DSTORE,ASTORE,,,,,,,,,,,,,,,,,,,,,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,,NEW,NEWARRAY,ANEWARRAY,"
+ + "ARRAYLENGTH,ATHROW,CHECKCAST,INSTANCEOF,MONITORENTER,"
+ + "MONITOREXIT,,MULTIANEWARRAY,IFNULL,IFNONNULL,";
+ OPCODES = new String[200];
+ int i = 0;
+ int j = 0;
+ int l;
+ while ((l = s.indexOf(',', j)) > 0) {
+ OPCODES[i++] = j + 1 == l ? null : s.substring(j, l);
+ j = l + 1;
+ }
+
+ s = "T_BOOLEAN,T_CHAR,T_FLOAT,T_DOUBLE,T_BYTE,T_SHORT,T_INT,T_LONG,";
+ TYPES = new String[12];
+ j = 0;
+ i = 4;
+ while ((l = s.indexOf(',', j)) > 0) {
+ TYPES[i++] = s.substring(j, l);
+ j = l + 1;
+ }
+ }
+
+ /**
+ * The text to be printed. Since the code of methods is not necessarily
+ * visited in sequential order, one method after the other, but can be
+ * interlaced (some instructions from method one, then some instructions
+ * from method two, then some instructions from method one again...), it is
+ * not possible to print the visited instructions directly to a sequential
+ * stream. A class is therefore printed in a two steps process: a string
+ * tree is constructed during the visit, and printed to a sequential stream
+ * at the end of the visit. This string tree is stored in this field, as a
+ * string list that can contain other string lists, which can themselves
+ * contain other string lists, and so on.
+ */
+ public final List text;
+
+ /**
+ * A buffer that can be used to create strings.
+ */
+ protected final StringBuffer buf;
+
+ /**
+ * Constructs a new {@link AbstractVisitor}.
+ */
+ protected AbstractVisitor() {
+ this.text = new ArrayList();
+ this.buf = new StringBuffer();
+ }
+
+ /**
+ * Returns the text printed by this visitor.
+ *
+ * @return the text printed by this visitor.
+ */
+ public List getText() {
+ return text;
+ }
+
+ /**
+ * Appends a quoted string to a given buffer.
+ *
+ * @param buf the buffer where the string must be added.
+ * @param s the string to be added.
+ */
+ public static void appendString(final StringBuffer buf, final String s) {
+ buf.append("\"");
+ for (int i = 0; i < s.length(); ++i) {
+ char c = s.charAt(i);
+ if (c == '\n') {
+ buf.append("\\n");
+ } else if (c == '\r') {
+ buf.append("\\r");
+ } else if (c == '\\') {
+ buf.append("\\\\");
+ } else if (c == '"') {
+ buf.append("\\\"");
+ } else if (c < 0x20 || c > 0x7f) {
+ buf.append("\\u");
+ if (c < 0x10) {
+ buf.append("000");
+ } else if (c < 0x100) {
+ buf.append("00");
+ } else if (c < 0x1000) {
+ buf.append("0");
+ }
+ buf.append(Integer.toString(c, 16));
+ } else {
+ buf.append(c);
+ }
+ }
+ buf.append("\"");
+ }
+
+ /**
+ * Prints the given string tree.
+ *
+ * @param pw the writer to be used to print the tree.
+ * @param l a string tree, i.e., a string list that can contain other string
+ * lists, and so on recursively.
+ */
+ void printList(final PrintWriter pw, final List l) {
+ for (int i = 0; i < l.size(); ++i) {
+ Object o = l.get(i);
+ if (o instanceof List) {
+ printList(pw, (List) o);
+ } else {
+ pw.print(o.toString());
+ }
+ }
+ }
+
+ /**
+ * Returns the default {@link ASMifiable} prototypes.
+ *
+ * @return the default {@link ASMifiable} prototypes.
+ */
+ public static Attribute[] getDefaultAttributes() {
+ try {
+ return new Attribute[] {
+ new ASMStackMapAttribute(),
+ new ASMStackMapTableAttribute() };
+ } catch (Exception e) {
+ return new Attribute[0];
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckAnnotationAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckAnnotationAdapter.java
new file mode 100644
index 000000000..228ff04ca
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckAnnotationAdapter.java
@@ -0,0 +1,125 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Type;
+
+/**
+ * An {@link AnnotationVisitor} that checks that its methods are properly used.
+ *
+ * @author Eric Bruneton
+ */
+public class CheckAnnotationAdapter implements AnnotationVisitor {
+
+ private AnnotationVisitor av;
+
+ private boolean named;
+
+ private boolean end;
+
+ public CheckAnnotationAdapter(final AnnotationVisitor av) {
+ this(av, true);
+ }
+
+ CheckAnnotationAdapter(
+ final AnnotationVisitor av,
+ final boolean named)
+ {
+ this.av = av;
+ this.named = named;
+ }
+
+ public void visit(final String name, final Object value) {
+ checkEnd();
+ checkName(name);
+ if (!(value instanceof Byte || value instanceof Boolean
+ || value instanceof Character || value instanceof Short
+ || value instanceof Integer || value instanceof Long
+ || value instanceof Float || value instanceof Double
+ || value instanceof String || value instanceof Type
+ || value instanceof byte[] || value instanceof boolean[]
+ || value instanceof char[] || value instanceof short[]
+ || value instanceof int[] || value instanceof long[]
+ || value instanceof float[] || value instanceof double[]))
+ {
+ throw new IllegalArgumentException("Invalid annotation value");
+ }
+ av.visit(name, value);
+ }
+
+ public void visitEnum(
+ final String name,
+ final String desc,
+ final String value)
+ {
+ checkEnd();
+ checkName(name);
+ CheckMethodAdapter.checkDesc(desc, false);
+ if (value == null) {
+ throw new IllegalArgumentException("Invalid enum value");
+ }
+ av.visitEnum(name, desc, value);
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String name,
+ final String desc)
+ {
+ checkEnd();
+ checkName(name);
+ CheckMethodAdapter.checkDesc(desc, false);
+ return new CheckAnnotationAdapter(av.visitAnnotation(name, desc));
+ }
+
+ public AnnotationVisitor visitArray(final String name) {
+ checkEnd();
+ checkName(name);
+ return new CheckAnnotationAdapter(av.visitArray(name), false);
+ }
+
+ public void visitEnd() {
+ checkEnd();
+ end = true;
+ av.visitEnd();
+ }
+
+ private void checkEnd() {
+ if (end) {
+ throw new IllegalStateException("Cannot call a visit method after visitEnd has been called");
+ }
+ }
+
+ private void checkName(final String name) {
+ if (named && name == null) {
+ throw new IllegalArgumentException("Annotation value name must not be null");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckClassAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckClassAdapter.java
new file mode 100644
index 000000000..1ca97ad6e
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckClassAdapter.java
@@ -0,0 +1,416 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import java.io.FileInputStream;
+import java.io.PrintWriter;
+import java.util.List;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.MethodNode;
+import org.objectweb.asm.tree.ClassNode;
+import org.objectweb.asm.tree.TryCatchBlockNode;
+import org.objectweb.asm.tree.analysis.Analyzer;
+import org.objectweb.asm.tree.analysis.SimpleVerifier;
+import org.objectweb.asm.tree.analysis.Frame;
+
+/**
+ * A {@link ClassAdapter} that checks that its methods are properly used. More
+ * precisely this class adapter checks each method call individually, based
+ * <i>only</i> on its arguments, but does <i>not</i> check the <i>sequence</i>
+ * of method calls. For example, the invalid sequence
+ * <tt>visitField(ACC_PUBLIC, "i", "I", null)</tt> <tt>visitField(ACC_PUBLIC,
+ * "i", "D", null)</tt>
+ * will <i>not</i> be detected by this class adapter.
+ *
+ * @author Eric Bruneton
+ */
+public class CheckClassAdapter extends ClassAdapter {
+
+ /**
+ * <tt>true</tt> if the visit method has been called.
+ */
+ private boolean start;
+
+ /**
+ * <tt>true</tt> if the visitSource method has been called.
+ */
+ private boolean source;
+
+ /**
+ * <tt>true</tt> if the visitOuterClass method has been called.
+ */
+ private boolean outer;
+
+ /**
+ * <tt>true</tt> if the visitEnd method has been called.
+ */
+ private boolean end;
+
+ /**
+ * Checks a given class. <p> Usage: CheckClassAdapter &lt;fully qualified
+ * class name or class file name&gt;
+ *
+ * @param args the command line arguments.
+ *
+ * @throws Exception if the class cannot be found, or if an IO exception
+ * occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ if (args.length != 1) {
+ System.err.println("Verifies the given class.");
+ System.err.println("Usage: CheckClassAdapter "
+ + "<fully qualified class name or class file name>");
+ return;
+ }
+ ClassReader cr;
+ if (args[0].endsWith(".class")) {
+ cr = new ClassReader(new FileInputStream(args[0]));
+ } else {
+ cr = new ClassReader(args[0]);
+ }
+
+ verify(cr, false, new PrintWriter(System.err));
+ }
+
+ /**
+ * Checks a given class
+ *
+ * @param cr a <code>ClassReader</code> that contains bytecode for the analysis.
+ * @param dump true if bytecode should be printed out not only when errors are found.
+ * @param pw write where results going to be printed
+ */
+ public static void verify(ClassReader cr, boolean dump, PrintWriter pw) {
+ ClassNode cn = new ClassNode();
+ cr.accept(new CheckClassAdapter(cn), true);
+
+ List methods = cn.methods;
+ for (int i = 0; i < methods.size(); ++i) {
+ MethodNode method = (MethodNode) methods.get(i);
+ if (method.instructions.size() > 0) {
+ Analyzer a = new Analyzer(new SimpleVerifier(Type.getType("L"
+ + cn.name + ";"),
+ Type.getType("L" + cn.superName + ";"),
+ (cn.access & Opcodes.ACC_INTERFACE) != 0));
+ try {
+ a.analyze(cn.name, method);
+ if (!dump) {
+ continue;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Frame[] frames = a.getFrames();
+
+ TraceMethodVisitor mv = new TraceMethodVisitor();
+
+ pw.println(method.name + method.desc);
+ for (int j = 0; j < method.instructions.size(); ++j) {
+ ((AbstractInsnNode) method.instructions.get(j)).accept(mv);
+
+ StringBuffer s = new StringBuffer();
+ Frame f = frames[j];
+ if (f == null) {
+ s.append('?');
+ } else {
+ for (int k = 0; k < f.getLocals(); ++k) {
+ s.append(getShortName(f.getLocal(k).toString()))
+ .append(' ');
+ }
+ s.append(" : ");
+ for (int k = 0; k < f.getStackSize(); ++k) {
+ s.append(getShortName(f.getStack(k).toString()))
+ .append(' ');
+ }
+ }
+ while (s.length() < method.maxStack + method.maxLocals + 1)
+ {
+ s.append(' ');
+ }
+ pw.print(Integer.toString(j + 100000).substring(1));
+ pw.print(" " + s + " : " + mv.buf); // mv.text.get(j));
+ }
+ for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
+ ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
+ pw.print(" " + mv.buf);
+ }
+ pw.println();
+ }
+ }
+ }
+
+ private static String getShortName(String name) {
+ int n = name.lastIndexOf('/');
+ int k = name.length();
+ if(name.charAt(k-1)==';') k--;
+ return n==-1 ? name : name.substring(n+1, k);
+ }
+
+ /**
+ * Constructs a new {@link CheckClassAdapter}.
+ *
+ * @param cv the class visitor to which this adapter must delegate calls.
+ */
+ public CheckClassAdapter(final ClassVisitor cv) {
+ super(cv);
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the ClassVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ if (start) {
+ throw new IllegalStateException("visit must be called only once");
+ } else {
+ start = true;
+ }
+ checkState();
+ checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL
+ + Opcodes.ACC_SUPER + Opcodes.ACC_INTERFACE
+ + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC
+ + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM
+ + Opcodes.ACC_DEPRECATED);
+ CheckMethodAdapter.checkInternalName(name, "class name");
+ if ("java/lang/Object".equals(name)) {
+ if (superName != null) {
+ throw new IllegalArgumentException("The super class name of the Object class must be 'null'");
+ }
+ } else {
+ CheckMethodAdapter.checkInternalName(superName, "super class name");
+ }
+ if (signature != null) {
+ // TODO
+ }
+ if ((access & Opcodes.ACC_INTERFACE) != 0) {
+ if (!"java/lang/Object".equals(superName)) {
+ throw new IllegalArgumentException("The super class name of interfaces must be 'java/lang/Object'");
+ }
+ }
+ if (interfaces != null) {
+ for (int i = 0; i < interfaces.length; ++i) {
+ CheckMethodAdapter.checkInternalName(interfaces[i],
+ "interface name at index " + i);
+ }
+ }
+ cv.visit(version, access, name, signature, superName, interfaces);
+ }
+
+ public void visitSource(final String file, final String debug) {
+ checkState();
+ if (source) {
+ throw new IllegalStateException("visitSource can be called only once.");
+ }
+ source = true;
+ cv.visitSource(file, debug);
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ checkState();
+ if (outer) {
+ throw new IllegalStateException("visitSource can be called only once.");
+ }
+ outer = true;
+ if (owner == null) {
+ throw new IllegalArgumentException("Illegal outer class owner");
+ }
+ if (desc != null) {
+ CheckMethodAdapter.checkMethodDesc(desc);
+ }
+ cv.visitOuterClass(owner, name, desc);
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ checkState();
+ CheckMethodAdapter.checkInternalName(name, "class name");
+ if (outerName != null) {
+ CheckMethodAdapter.checkInternalName(outerName, "outer class name");
+ }
+ if (innerName != null) {
+ CheckMethodAdapter.checkIdentifier(innerName, "inner class name");
+ }
+ checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
+ + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
+ + Opcodes.ACC_FINAL + Opcodes.ACC_INTERFACE
+ + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC
+ + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM);
+ cv.visitInnerClass(name, outerName, innerName, access);
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ checkState();
+ checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
+ + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
+ + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE
+ + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC
+ + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED);
+ CheckMethodAdapter.checkIdentifier(name, "field name");
+ CheckMethodAdapter.checkDesc(desc, false);
+ if (signature != null) {
+ // TODO
+ }
+ if (value != null) {
+ CheckMethodAdapter.checkConstant(value);
+ }
+ FieldVisitor av = cv.visitField(access, name, desc, signature, value);
+ return new CheckFieldAdapter(av);
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ checkState();
+ checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
+ + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
+ + Opcodes.ACC_FINAL + Opcodes.ACC_SYNCHRONIZED
+ + Opcodes.ACC_BRIDGE + Opcodes.ACC_VARARGS + Opcodes.ACC_NATIVE
+ + Opcodes.ACC_ABSTRACT + Opcodes.ACC_STRICT
+ + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_DEPRECATED);
+ CheckMethodAdapter.checkMethodIdentifier(name, "method name");
+ CheckMethodAdapter.checkMethodDesc(desc);
+ if (signature != null) {
+ // TODO
+ }
+ if (exceptions != null) {
+ for (int i = 0; i < exceptions.length; ++i) {
+ CheckMethodAdapter.checkInternalName(exceptions[i],
+ "exception name at index " + i);
+ }
+ }
+ return new CheckMethodAdapter(cv.visitMethod(access,
+ name,
+ desc,
+ signature,
+ exceptions));
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ checkState();
+ CheckMethodAdapter.checkDesc(desc, false);
+ return new CheckAnnotationAdapter(cv.visitAnnotation(desc, visible));
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ checkState();
+ if (attr == null) {
+ throw new IllegalArgumentException("Invalid attribute (must not be null)");
+ }
+ cv.visitAttribute(attr);
+ }
+
+ public void visitEnd() {
+ checkState();
+ end = true;
+ cv.visitEnd();
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Checks that the visit method has been called and that visitEnd has not
+ * been called.
+ */
+ private void checkState() {
+ if (!start) {
+ throw new IllegalStateException("Cannot visit member before visit has been called.");
+ }
+ if (end) {
+ throw new IllegalStateException("Cannot visit member after visitEnd has been called.");
+ }
+ }
+
+ /**
+ * Checks that the given access flags do not contain invalid flags. This
+ * method also checks that mutually incompatible flags are not set
+ * simultaneously.
+ *
+ * @param access the access flags to be checked
+ * @param possibleAccess the valid access flags.
+ */
+ static void checkAccess(final int access, final int possibleAccess) {
+ if ((access & ~possibleAccess) != 0) {
+ throw new IllegalArgumentException("Invalid access flags: "
+ + access);
+ }
+ int pub = ((access & Opcodes.ACC_PUBLIC) != 0 ? 1 : 0);
+ int pri = ((access & Opcodes.ACC_PRIVATE) != 0 ? 1 : 0);
+ int pro = ((access & Opcodes.ACC_PROTECTED) != 0 ? 1 : 0);
+ if (pub + pri + pro > 1) {
+ throw new IllegalArgumentException("public private and protected are mutually exclusive: "
+ + access);
+ }
+ int fin = ((access & Opcodes.ACC_FINAL) != 0 ? 1 : 0);
+ int abs = ((access & Opcodes.ACC_ABSTRACT) != 0 ? 1 : 0);
+ if (fin + abs > 1) {
+ throw new IllegalArgumentException("final and abstract are mutually exclusive: "
+ + access);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckFieldAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckFieldAdapter.java
new file mode 100644
index 000000000..3e7c113b8
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckFieldAdapter.java
@@ -0,0 +1,75 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.FieldVisitor;
+
+/**
+ * A {@link FieldVisitor} that checks that its methods are properly used.
+ */
+public class CheckFieldAdapter implements FieldVisitor {
+
+ private FieldVisitor fv;
+
+ private boolean end;
+
+ public CheckFieldAdapter(final FieldVisitor fv) {
+ this.fv = fv;
+ }
+
+ public AnnotationVisitor visitAnnotation(final String desc, boolean visible)
+ {
+ checkEnd();
+ CheckMethodAdapter.checkDesc(desc, false);
+ return new CheckAnnotationAdapter(fv.visitAnnotation(desc, visible));
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ checkEnd();
+ if (attr == null) {
+ throw new IllegalArgumentException("Invalid attribute (must not be null)");
+ }
+ fv.visitAttribute(attr);
+ }
+
+ public void visitEnd() {
+ checkEnd();
+ end = true;
+ fv.visitEnd();
+ }
+
+ private void checkEnd() {
+ if (end) {
+ throw new IllegalStateException("Cannot call a visit method after visitEnd has been called");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckMethodAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckMethodAdapter.java
new file mode 100644
index 000000000..0123eeeb8
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckMethodAdapter.java
@@ -0,0 +1,942 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodAdapter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.Type;
+
+import java.util.HashMap;
+
+/**
+ * A {@link MethodAdapter} that checks that its methods are properly used. More
+ * precisely this code adapter checks each instruction individually (i.e., each
+ * visit method checks some preconditions based <i>only</i> on its arguments -
+ * such as the fact that the given opcode is correct for a given visit method),
+ * but does <i>not</i> check the <i>sequence</i> of instructions. For example,
+ * in a method whose signature is <tt>void m ()</tt>, the invalid instruction
+ * IRETURN, or the invalid sequence IADD L2I will <i>not</i> be detected by
+ * this code adapter.
+ *
+ * @author Eric Bruneton
+ */
+public class CheckMethodAdapter extends MethodAdapter {
+
+ /**
+ * <tt>true</tt> if the visitCode method has been called.
+ */
+ private boolean startCode;
+
+ /**
+ * <tt>true</tt> if the visitMaxs method has been called.
+ */
+ private boolean endCode;
+
+ /**
+ * <tt>true</tt> if the visitEnd method has been called.
+ */
+ private boolean endMethod;
+
+ /**
+ * The already visited labels. This map associate Integer values to Label
+ * keys.
+ */
+ private HashMap labels;
+
+ /**
+ * Code of the visit method to be used for each opcode.
+ */
+ private final static int[] TYPE;
+
+ static {
+ String s = "BBBBBBBBBBBBBBBBCCIAADDDDDAAAAAAAAAAAAAAAAAAAABBBBBBBBDD"
+ + "DDDAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
+ + "BBBBBBBBBBBBBBBBBBBJBBBBBBBBBBBBBBBBBBBBHHHHHHHHHHHHHHHHD"
+ + "KLBBBBBBFFFFGGGGAECEBBEEBBAMHHAA";
+ TYPE = new int[s.length()];
+ for (int i = 0; i < TYPE.length; ++i) {
+ TYPE[i] = (s.charAt(i) - 'A' - 1);
+ }
+ }
+
+ // code to generate the above string
+ // public static void main (String[] args) {
+ // int[] TYPE = new int[] {
+ // 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
+ // 1, //SIPUSH
+ // 7, //LDC
+ // -1, //LDC_W
+ // -1, //LDC2_W
+ // 2, //ILOAD
+ // 2, //LLOAD
+ // 2, //FLOAD
+ // 2, //DLOAD
+ // 2, //ALOAD
+ // -1, //ILOAD_0
+ // -1, //ILOAD_1
+ // -1, //ILOAD_2
+ // -1, //ILOAD_3
+ // -1, //LLOAD_0
+ // -1, //LLOAD_1
+ // -1, //LLOAD_2
+ // -1, //LLOAD_3
+ // -1, //FLOAD_0
+ // -1, //FLOAD_1
+ // -1, //FLOAD_2
+ // -1, //FLOAD_3
+ // -1, //DLOAD_0
+ // -1, //DLOAD_1
+ // -1, //DLOAD_2
+ // -1, //DLOAD_3
+ // -1, //ALOAD_0
+ // -1, //ALOAD_1
+ // -1, //ALOAD_2
+ // -1, //ALOAD_3
+ // 0, //IALOAD
+ // 0, //LALOAD
+ // 0, //FALOAD
+ // 0, //DALOAD
+ // 0, //AALOAD
+ // 0, //BALOAD
+ // 0, //CALOAD
+ // 0, //SALOAD
+ // 2, //ISTORE
+ // 2, //LSTORE
+ // 2, //FSTORE
+ // 2, //DSTORE
+ // 2, //ASTORE
+ // -1, //ISTORE_0
+ // -1, //ISTORE_1
+ // -1, //ISTORE_2
+ // -1, //ISTORE_3
+ // -1, //LSTORE_0
+ // -1, //LSTORE_1
+ // -1, //LSTORE_2
+ // -1, //LSTORE_3
+ // -1, //FSTORE_0
+ // -1, //FSTORE_1
+ // -1, //FSTORE_2
+ // -1, //FSTORE_3
+ // -1, //DSTORE_0
+ // -1, //DSTORE_1
+ // -1, //DSTORE_2
+ // -1, //DSTORE_3
+ // -1, //ASTORE_0
+ // -1, //ASTORE_1
+ // -1, //ASTORE_2
+ // -1, //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
+ // 8, //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
+ // 6, //IFEQ
+ // 6, //IFNE
+ // 6, //IFLT
+ // 6, //IFGE
+ // 6, //IFGT
+ // 6, //IFLE
+ // 6, //IF_ICMPEQ
+ // 6, //IF_ICMPNE
+ // 6, //IF_ICMPLT
+ // 6, //IF_ICMPGE
+ // 6, //IF_ICMPGT
+ // 6, //IF_ICMPLE
+ // 6, //IF_ACMPEQ
+ // 6, //IF_ACMPNE
+ // 6, //GOTO
+ // 6, //JSR
+ // 2, //RET
+ // 9, //TABLESWITCH
+ // 10, //LOOKUPSWITCH
+ // 0, //IRETURN
+ // 0, //LRETURN
+ // 0, //FRETURN
+ // 0, //DRETURN
+ // 0, //ARETURN
+ // 0, //RETURN
+ // 4, //GETSTATIC
+ // 4, //PUTSTATIC
+ // 4, //GETFIELD
+ // 4, //PUTFIELD
+ // 5, //INVOKEVIRTUAL
+ // 5, //INVOKESPECIAL
+ // 5, //INVOKESTATIC
+ // 5, //INVOKEINTERFACE
+ // -1, //UNUSED
+ // 3, //NEW
+ // 1, //NEWARRAY
+ // 3, //ANEWARRAY
+ // 0, //ARRAYLENGTH
+ // 0, //ATHROW
+ // 3, //CHECKCAST
+ // 3, //INSTANCEOF
+ // 0, //MONITORENTER
+ // 0, //MONITOREXIT
+ // -1, //WIDE
+ // 11, //MULTIANEWARRAY
+ // 6, //IFNULL
+ // 6, //IFNONNULL
+ // -1, //GOTO_W
+ // -1 //JSR_W
+ // };
+ // for (int i = 0; i < TYPE.length; ++i) {
+ // System.out.print((char)(TYPE[i] + 1 + 'A'));
+ // }
+ // System.out.println();
+ // }
+
+ /**
+ * Constructs a new {@link CheckMethodAdapter} object.
+ *
+ * @param cv the code visitor to which this adapter must delegate calls.
+ */
+ public CheckMethodAdapter(final MethodVisitor cv) {
+ super(cv);
+ this.labels = new HashMap();
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ checkEndMethod();
+ checkDesc(desc, false);
+ return new CheckAnnotationAdapter(mv.visitAnnotation(desc, visible));
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ checkEndMethod();
+ return new CheckAnnotationAdapter(mv.visitAnnotationDefault(), false);
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ checkEndMethod();
+ checkDesc(desc, false);
+ return new CheckAnnotationAdapter(mv.visitParameterAnnotation(parameter,
+ desc,
+ visible));
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ checkEndMethod();
+ if (attr == null) {
+ throw new IllegalArgumentException("Invalid attribute (must not be null)");
+ }
+ mv.visitAttribute(attr);
+ }
+
+ public void visitCode() {
+ startCode = true;
+ mv.visitCode();
+ }
+
+ public void visitInsn(final int opcode) {
+ checkStartCode();
+ checkEndCode();
+ checkOpcode(opcode, 0);
+ mv.visitInsn(opcode);
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ checkStartCode();
+ checkEndCode();
+ checkOpcode(opcode, 1);
+ switch (opcode) {
+ case Opcodes.BIPUSH:
+ checkSignedByte(operand, "Invalid operand");
+ break;
+ case Opcodes.SIPUSH:
+ checkSignedShort(operand, "Invalid operand");
+ break;
+ // case Constants.NEWARRAY:
+ default:
+ if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
+ throw new IllegalArgumentException("Invalid operand (must be an array type code T_...): "
+ + operand);
+ }
+ }
+ mv.visitIntInsn(opcode, operand);
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ checkStartCode();
+ checkEndCode();
+ checkOpcode(opcode, 2);
+ checkUnsignedShort(var, "Invalid variable index");
+ mv.visitVarInsn(opcode, var);
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ checkStartCode();
+ checkEndCode();
+ checkOpcode(opcode, 3);
+ if (desc != null && desc.length() > 0 && desc.charAt(0) == '[') {
+ checkDesc(desc, false);
+ } else {
+ checkInternalName(desc, "type");
+ }
+ if (opcode == Opcodes.NEW && desc.charAt(0) == '[') {
+ throw new IllegalArgumentException("NEW cannot be used to create arrays: "
+ + desc);
+ }
+ mv.visitTypeInsn(opcode, desc);
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ checkStartCode();
+ checkEndCode();
+ checkOpcode(opcode, 4);
+ checkInternalName(owner, "owner");
+ checkIdentifier(name, "name");
+ checkDesc(desc, false);
+ mv.visitFieldInsn(opcode, owner, name, desc);
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ checkStartCode();
+ checkEndCode();
+ checkOpcode(opcode, 5);
+ checkMethodIdentifier(name, "name");
+ if (!name.equals("clone")) {
+ // In JDK1.5, clone method can be called on array class descriptors
+ checkInternalName(owner, "owner");
+ }
+ checkMethodDesc(desc);
+ mv.visitMethodInsn(opcode, owner, name, desc);
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ checkStartCode();
+ checkEndCode();
+ checkOpcode(opcode, 6);
+ checkLabel(label, false, "label");
+ mv.visitJumpInsn(opcode, label);
+ }
+
+ public void visitLabel(final Label label) {
+ checkStartCode();
+ checkEndCode();
+ checkLabel(label, false, "label");
+ if (labels.get(label) != null) {
+ throw new IllegalArgumentException("Already visited label");
+ } else {
+ labels.put(label, new Integer(labels.size()));
+ }
+ mv.visitLabel(label);
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ checkStartCode();
+ checkEndCode();
+ if (!(cst instanceof Type)) {
+ checkConstant(cst);
+ }
+ mv.visitLdcInsn(cst);
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ checkStartCode();
+ checkEndCode();
+ checkUnsignedShort(var, "Invalid variable index");
+ checkSignedShort(increment, "Invalid increment");
+ mv.visitIincInsn(var, increment);
+ }
+
+ public void visitTableSwitchInsn(
+ final int min,
+ final int max,
+ final Label dflt,
+ final Label labels[])
+ {
+ checkStartCode();
+ checkEndCode();
+ if (max < min) {
+ throw new IllegalArgumentException("Max = " + max
+ + " must be greater than or equal to min = " + min);
+ }
+ checkLabel(dflt, false, "default label");
+ if (labels == null || labels.length != max - min + 1) {
+ throw new IllegalArgumentException("There must be max - min + 1 labels");
+ }
+ for (int i = 0; i < labels.length; ++i) {
+ checkLabel(labels[i], false, "label at index " + i);
+ }
+ mv.visitTableSwitchInsn(min, max, dflt, labels);
+ }
+
+ public void visitLookupSwitchInsn(
+ final Label dflt,
+ final int keys[],
+ final Label labels[])
+ {
+ checkEndCode();
+ checkStartCode();
+ checkLabel(dflt, false, "default label");
+ if (keys == null || labels == null || keys.length != labels.length) {
+ throw new IllegalArgumentException("There must be the same number of keys and labels");
+ }
+ for (int i = 0; i < labels.length; ++i) {
+ checkLabel(labels[i], false, "label at index " + i);
+ }
+ mv.visitLookupSwitchInsn(dflt, keys, labels);
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ checkStartCode();
+ checkEndCode();
+ checkDesc(desc, false);
+ if (desc.charAt(0) != '[') {
+ throw new IllegalArgumentException("Invalid descriptor (must be an array type descriptor): "
+ + desc);
+ }
+ if (dims < 1) {
+ throw new IllegalArgumentException("Invalid dimensions (must be greater than 0): "
+ + dims);
+ }
+ if (dims > desc.lastIndexOf('[') + 1) {
+ throw new IllegalArgumentException("Invalid dimensions (must not be greater than dims(desc)): "
+ + dims);
+ }
+ mv.visitMultiANewArrayInsn(desc, dims);
+ }
+
+ public void visitTryCatchBlock(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ checkStartCode();
+ checkEndCode();
+ if (type != null) {
+ checkInternalName(type, "type");
+ }
+ mv.visitTryCatchBlock(start, end, handler, type);
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ checkStartCode();
+ checkEndCode();
+ checkIdentifier(name, "name");
+ checkDesc(desc, false);
+ checkLabel(start, true, "start label");
+ checkLabel(end, true, "end label");
+ checkUnsignedShort(index, "Invalid variable index");
+ int s = ((Integer) labels.get(start)).intValue();
+ int e = ((Integer) labels.get(end)).intValue();
+ if (e < s) {
+ throw new IllegalArgumentException("Invalid start and end labels (end must be greater than start)");
+ }
+ mv.visitLocalVariable(name, desc, signature, start, end, index);
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ checkStartCode();
+ checkEndCode();
+ checkUnsignedShort(line, "Invalid line number");
+ checkLabel(start, true, "start label");
+ mv.visitLineNumber(line, start);
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ checkStartCode();
+ checkEndCode();
+ endCode = true;
+ checkUnsignedShort(maxStack, "Invalid max stack");
+ checkUnsignedShort(maxLocals, "Invalid max locals");
+ mv.visitMaxs(maxStack, maxLocals);
+ }
+
+ public void visitEnd() {
+ checkEndMethod();
+ endMethod = true;
+ mv.visitEnd();
+ }
+
+ // -------------------------------------------------------------------------
+
+ /**
+ * Checks that the visitCode method has been called.
+ */
+ void checkStartCode() {
+ if (!startCode) {
+ throw new IllegalStateException("Cannot visit instructions before visitCode has been called.");
+ }
+ }
+
+ /**
+ * Checks that the visitMaxs method has not been called.
+ */
+ void checkEndCode() {
+ if (endCode) {
+ throw new IllegalStateException("Cannot visit instructions after visitMaxs has been called.");
+ }
+ }
+
+ /**
+ * Checks that the visitEnd method has not been called.
+ */
+ void checkEndMethod() {
+ if (endMethod) {
+ throw new IllegalStateException("Cannot visit elements after visitEnd has been called.");
+ }
+ }
+
+ /**
+ * Checks that the type of the given opcode is equal to the given type.
+ *
+ * @param opcode the opcode to be checked.
+ * @param type the expected opcode type.
+ */
+ static void checkOpcode(final int opcode, final int type) {
+ if (opcode < 0 || opcode > 199 || TYPE[opcode] != type) {
+ throw new IllegalArgumentException("Invalid opcode: " + opcode);
+ }
+ }
+
+ /**
+ * Checks that the given value is a signed byte.
+ *
+ * @param value the value to be checked.
+ * @param msg an message to be used in case of error.
+ */
+ static void checkSignedByte(final int value, final String msg) {
+ if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
+ throw new IllegalArgumentException(msg
+ + " (must be a signed byte): " + value);
+ }
+ }
+
+ /**
+ * Checks that the given value is a signed short.
+ *
+ * @param value the value to be checked.
+ * @param msg an message to be used in case of error.
+ */
+ static void checkSignedShort(final int value, final String msg) {
+ if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
+ throw new IllegalArgumentException(msg
+ + " (must be a signed short): " + value);
+ }
+ }
+
+ /**
+ * Checks that the given value is an unsigned short.
+ *
+ * @param value the value to be checked.
+ * @param msg an message to be used in case of error.
+ */
+ static void checkUnsignedShort(final int value, final String msg) {
+ if (value < 0 || value > 65535) {
+ throw new IllegalArgumentException(msg
+ + " (must be an unsigned short): " + value);
+ }
+ }
+
+ /**
+ * Checks that the given value is an {@link Integer}, a{@link Float}, a
+ * {@link Long}, a {@link Double} or a {@link String}.
+ *
+ * @param cst the value to be checked.
+ */
+ static void checkConstant(final Object cst) {
+ if (!(cst instanceof Integer) && !(cst instanceof Float)
+ && !(cst instanceof Long) && !(cst instanceof Double)
+ && !(cst instanceof String))
+ {
+ throw new IllegalArgumentException("Invalid constant: " + cst);
+ }
+ }
+
+ /**
+ * Checks that the given string is a valid Java identifier.
+ *
+ * @param name the string to be checked.
+ * @param msg a message to be used in case of error.
+ */
+ static void checkIdentifier(final String name, final String msg) {
+ checkIdentifier(name, 0, -1, msg);
+ }
+
+ /**
+ * Checks that the given substring is a valid Java identifier.
+ *
+ * @param name the string to be checked.
+ * @param start index of the first character of the identifier (inclusive).
+ * @param end index of the last character of the identifier (exclusive). -1
+ * is equivalent to <tt>name.length()</tt> if name is not
+ * <tt>null</tt>.
+ * @param msg a message to be used in case of error.
+ */
+ static void checkIdentifier(
+ final String name,
+ final int start,
+ final int end,
+ final String msg)
+ {
+ if (name == null || (end == -1 ? name.length() <= start : end <= start))
+ {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not be null or empty)");
+ }
+ if (!Character.isJavaIdentifierStart(name.charAt(start))) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must be a valid Java identifier): " + name);
+ }
+ int max = (end == -1 ? name.length() : end);
+ for (int i = start + 1; i < max; ++i) {
+ if (!Character.isJavaIdentifierPart(name.charAt(i))) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must be a valid Java identifier): " + name);
+ }
+ }
+ }
+
+ /**
+ * Checks that the given string is a valid Java identifier or is equal to
+ * '&lt;init&gt;' or '&lt;clinit&gt;'.
+ *
+ * @param name the string to be checked.
+ * @param msg a message to be used in case of error.
+ */
+ static void checkMethodIdentifier(final String name, final String msg) {
+ if (name == null || name.length() == 0) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not be null or empty)");
+ }
+ if (name.equals("<init>") || name.equals("<clinit>")) {
+ return;
+ }
+ if (!Character.isJavaIdentifierStart(name.charAt(0))) {
+ throw new IllegalArgumentException("Invalid "
+ + msg
+ + " (must be a '<init>', '<clinit>' or a valid Java identifier): "
+ + name);
+ }
+ for (int i = 1; i < name.length(); ++i) {
+ if (!Character.isJavaIdentifierPart(name.charAt(i))) {
+ throw new IllegalArgumentException("Invalid "
+ + msg
+ + " (must be '<init>' or '<clinit>' or a valid Java identifier): "
+ + name);
+ }
+ }
+ }
+
+ /**
+ * Checks that the given string is a valid internal class name.
+ *
+ * @param name the string to be checked.
+ * @param msg a message to be used in case of error.
+ */
+ static void checkInternalName(final String name, final String msg) {
+ checkInternalName(name, 0, -1, msg);
+ }
+
+ /**
+ * Checks that the given substring is a valid internal class name.
+ *
+ * @param name the string to be checked.
+ * @param start index of the first character of the identifier (inclusive).
+ * @param end index of the last character of the identifier (exclusive). -1
+ * is equivalent to <tt>name.length()</tt> if name is not
+ * <tt>null</tt>.
+ * @param msg a message to be used in case of error.
+ */
+ static void checkInternalName(
+ final String name,
+ final int start,
+ final int end,
+ final String msg)
+ {
+ if (name == null || name.length() == 0) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not be null or empty)");
+ }
+ int max = (end == -1 ? name.length() : end);
+ try {
+ int begin = start;
+ int slash;
+ do {
+ slash = name.indexOf('/', begin + 1);
+ if (slash == -1 || slash > max) {
+ slash = max;
+ }
+ checkIdentifier(name, begin, slash, null);
+ begin = slash + 1;
+ } while (slash != max);
+ } catch (IllegalArgumentException _) {
+ throw new IllegalArgumentException("Invalid "
+ + msg
+ + " (must be a fully qualified class name in internal form): "
+ + name);
+ }
+ }
+
+ /**
+ * Checks that the given string is a valid type descriptor.
+ *
+ * @param desc the string to be checked.
+ * @param canBeVoid <tt>true</tt> if <tt>V</tt> can be considered valid.
+ */
+ static void checkDesc(final String desc, final boolean canBeVoid) {
+ int end = checkDesc(desc, 0, canBeVoid);
+ if (end != desc.length()) {
+ throw new IllegalArgumentException("Invalid descriptor: " + desc);
+ }
+ }
+
+ /**
+ * Checks that a the given substring is a valid type descriptor.
+ *
+ * @param desc the string to be checked.
+ * @param start index of the first character of the identifier (inclusive).
+ * @param canBeVoid <tt>true</tt> if <tt>V</tt> can be considered valid.
+ * @return the index of the last character of the type decriptor, plus one.
+ */
+ static int checkDesc(
+ final String desc,
+ final int start,
+ final boolean canBeVoid)
+ {
+ if (desc == null || start >= desc.length()) {
+ throw new IllegalArgumentException("Invalid type descriptor (must not be null or empty)");
+ }
+ int index;
+ switch (desc.charAt(start)) {
+ case 'V':
+ if (canBeVoid) {
+ return start + 1;
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: "
+ + desc);
+ }
+ case 'Z':
+ case 'C':
+ case 'B':
+ case 'S':
+ case 'I':
+ case 'F':
+ case 'J':
+ case 'D':
+ return start + 1;
+ case '[':
+ index = start + 1;
+ while (index < desc.length() && desc.charAt(index) == '[') {
+ ++index;
+ }
+ if (index < desc.length()) {
+ return checkDesc(desc, index, false);
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: "
+ + desc);
+ }
+ case 'L':
+ index = desc.indexOf(';', start);
+ if (index == -1 || index - start < 2) {
+ throw new IllegalArgumentException("Invalid descriptor: "
+ + desc);
+ }
+ try {
+ checkInternalName(desc, start + 1, index, null);
+ } catch (IllegalArgumentException _) {
+ throw new IllegalArgumentException("Invalid descriptor: "
+ + desc);
+ }
+ return index + 1;
+ default:
+ throw new IllegalArgumentException("Invalid descriptor: "
+ + desc);
+ }
+ }
+
+ /**
+ * Checks that the given string is a valid method descriptor.
+ *
+ * @param desc the string to be checked.
+ */
+ static void checkMethodDesc(final String desc) {
+ if (desc == null || desc.length() == 0) {
+ throw new IllegalArgumentException("Invalid method descriptor (must not be null or empty)");
+ }
+ if (desc.charAt(0) != '(' || desc.length() < 3) {
+ throw new IllegalArgumentException("Invalid descriptor: " + desc);
+ }
+ int start = 1;
+ if (desc.charAt(start) != ')') {
+ do {
+ if (desc.charAt(start) == 'V') {
+ throw new IllegalArgumentException("Invalid descriptor: "
+ + desc);
+ }
+ start = checkDesc(desc, start, false);
+ } while (start < desc.length() && desc.charAt(start) != ')');
+ }
+ start = checkDesc(desc, start + 1, true);
+ if (start != desc.length()) {
+ throw new IllegalArgumentException("Invalid descriptor: " + desc);
+ }
+ }
+
+ /**
+ * Checks that the given label is not null. This method can also check that
+ * the label has been visited.
+ *
+ * @param label the label to be checked.
+ * @param checkVisited <tt>true</tt> to check that the label has been
+ * visited.
+ * @param msg a message to be used in case of error.
+ */
+ void checkLabel(
+ final Label label,
+ final boolean checkVisited,
+ final String msg)
+ {
+ if (label == null) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not be null)");
+ }
+ if (checkVisited && labels.get(label) == null) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must be visited first)");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAbstractVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAbstractVisitor.java
new file mode 100644
index 000000000..8a3d4d022
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAbstractVisitor.java
@@ -0,0 +1,180 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.util.attrs.Traceable;
+
+/**
+ * An abstract trace visitor.
+ *
+ * @author Eric Bruneton
+ */
+public abstract class TraceAbstractVisitor extends AbstractVisitor {
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for internal
+ * type names in bytecode notation.
+ */
+ public final static int INTERNAL_NAME = 0;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for field
+ * descriptors, formatted in bytecode notation
+ */
+ public final static int FIELD_DESCRIPTOR = 1;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for field
+ * signatures, formatted in bytecode notation
+ */
+ public final static int FIELD_SIGNATURE = 2;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for method
+ * descriptors, formatted in bytecode notation
+ */
+ public final static int METHOD_DESCRIPTOR = 3;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for method
+ * signatures, formatted in bytecode notation
+ */
+ public final static int METHOD_SIGNATURE = 4;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for class
+ * signatures, formatted in bytecode notation
+ */
+ public final static int CLASS_SIGNATURE = 5;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for field or
+ * method return value signatures, formatted in default Java notation
+ * (non-bytecode)
+ */
+ public final static int TYPE_DECLARATION = 6;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for class
+ * signatures, formatted in default Java notation (non-bytecode)
+ */
+ public final static int CLASS_DECLARATION = 7;
+
+ /**
+ * Constant used in {@link #appendDescriptor appendDescriptor} for method
+ * parameter signatures, formatted in default Java notation (non-bytecode)
+ */
+ public final static int PARAMETERS_DECLARATION = 8;
+
+ /**
+ * Tab for class members.
+ */
+ protected String tab = " ";
+
+ /**
+ * Prints a disassembled view of the given annotation.
+ *
+ * @param desc the class descriptor of the annotation class.
+ * @param visible <tt>true</tt> if the annotation is visible at runtime.
+ * @return a visitor to visit the annotation values.
+ */
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ buf.setLength(0);
+ buf.append(tab).append('@');
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append('(');
+ text.add(buf.toString());
+ TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
+ text.add(tav.getText());
+ text.add(visible ? ")\n" : ") // invisible\n");
+ return tav;
+ }
+
+ /**
+ * Prints a disassembled view of the given attribute.
+ *
+ * @param attr an attribute.
+ */
+ public void visitAttribute(final Attribute attr) {
+ buf.setLength(0);
+ buf.append(tab).append("ATTRIBUTE ");
+ appendDescriptor(-1, attr.type);
+
+ if (attr instanceof Traceable) {
+ ((Traceable) attr).trace(buf, null);
+ } else {
+ buf.append(" : ").append(attr.toString()).append("\n");
+ }
+
+ text.add(buf.toString());
+ }
+
+ /**
+ * Does nothing.
+ */
+ public void visitEnd() {
+ // does nothing
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ protected TraceAnnotationVisitor createTraceAnnotationVisitor() {
+ return new TraceAnnotationVisitor();
+ }
+
+ /**
+ * Appends an internal name, a type descriptor or a type signature to
+ * {@link #buf buf}.
+ *
+ * @param type indicates if desc is an internal name, a field descriptor, a
+ * method descriptor, a class signature, ...
+ * @param desc an internal name, type descriptor, or type signature. May be
+ * <tt>null</tt>.
+ */
+ protected void appendDescriptor(final int type, final String desc) {
+ if (type == CLASS_SIGNATURE || type == FIELD_SIGNATURE
+ || type == METHOD_SIGNATURE)
+ {
+ if (desc != null) {
+ buf.append("// signature ").append(desc).append('\n');
+ }
+ } else {
+ buf.append(desc);
+ }
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAnnotationVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAnnotationVisitor.java
new file mode 100644
index 000000000..ae812d896
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAnnotationVisitor.java
@@ -0,0 +1,272 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Type;
+
+/**
+ * An {@link AnnotationVisitor} that prints a disassembled view of the
+ * annotations it visits.
+ *
+ * @author Eric Bruneton
+ */
+public class TraceAnnotationVisitor extends TraceAbstractVisitor implements
+ AnnotationVisitor
+{
+
+ /**
+ * The {@link AnnotationVisitor} to which this visitor delegates calls. May
+ * be <tt>null</tt>.
+ */
+ protected AnnotationVisitor av;
+
+ private int valueNumber = 0;
+
+ /**
+ * Constructs a new {@link TraceAnnotationVisitor}.
+ */
+ public TraceAnnotationVisitor() {
+ // ignore
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the AnnotationVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(final String name, final Object value) {
+ buf.setLength(0);
+ appendComa(valueNumber++);
+
+ if (name != null) {
+ buf.append(name).append('=');
+ }
+
+ if (value instanceof String) {
+ visitString((String) value);
+ } else if (value instanceof Type) {
+ visitType((Type) value);
+ } else if (value instanceof Byte) {
+ visitByte(((Byte) value).byteValue());
+ } else if (value instanceof Boolean) {
+ visitBoolean(((Boolean) value).booleanValue());
+ } else if (value instanceof Short) {
+ visitShort(((Short) value).shortValue());
+ } else if (value instanceof Character) {
+ visitChar(((Character) value).charValue());
+ } else if (value instanceof Integer) {
+ visitInt(((Integer) value).intValue());
+ } else if (value instanceof Float) {
+ visitFloat(((Float) value).floatValue());
+ } else if (value instanceof Long) {
+ visitLong(((Long) value).longValue());
+ } else if (value instanceof Double) {
+ visitDouble(((Double) value).doubleValue());
+ } else if (value.getClass().isArray()) {
+ buf.append('{');
+ if (value instanceof byte[]) {
+ byte[] v = (byte[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitByte(v[i]);
+ }
+ } else if (value instanceof boolean[]) {
+ boolean[] v = (boolean[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitBoolean(v[i]);
+ }
+ } else if (value instanceof short[]) {
+ short[] v = (short[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitShort(v[i]);
+ }
+ } else if (value instanceof char[]) {
+ char[] v = (char[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitChar(v[i]);
+ }
+ } else if (value instanceof int[]) {
+ int[] v = (int[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitInt(v[i]);
+ }
+ } else if (value instanceof long[]) {
+ long[] v = (long[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitLong(v[i]);
+ }
+ } else if (value instanceof float[]) {
+ float[] v = (float[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitFloat(v[i]);
+ }
+ } else if (value instanceof double[]) {
+ double[] v = (double[]) value;
+ for (int i = 0; i < v.length; i++) {
+ appendComa(i);
+ visitDouble(v[i]);
+ }
+ }
+ buf.append('}');
+ } else {
+ buf.append(value);
+ }
+
+ text.add(buf.toString());
+
+ if (av != null) {
+ av.visit(name, value);
+ }
+ }
+
+ private void visitInt(int value) {
+ buf.append(value);
+ }
+
+ private void visitLong(long value) {
+ buf.append(value).append('L');
+ }
+
+ private void visitFloat(float value) {
+ buf.append(value).append('F');
+ }
+
+ private void visitDouble(double value) {
+ buf.append(value).append('D');
+ }
+
+ private void visitChar(char value) {
+ buf.append("(char)").append((int) value);
+ }
+
+ private void visitShort(short value) {
+ buf.append("(short)").append(value);
+ }
+
+ private void visitByte(byte value) {
+ buf.append("(byte)").append(value);
+ }
+
+ private void visitBoolean(boolean value) {
+ buf.append(value);
+ }
+
+ private void visitString(String value) {
+ appendString(buf, value);
+ }
+
+ private void visitType(Type value) {
+ buf.append(value.getClassName()).append(".class");
+ }
+
+ public void visitEnum(
+ final String name,
+ final String desc,
+ final String value)
+ {
+ buf.setLength(0);
+ appendComa(valueNumber++);
+ if (name != null) {
+ buf.append(name).append('=');
+ }
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append('.').append(value);
+ text.add(buf.toString());
+
+ if (av != null) {
+ av.visitEnum(name, desc, value);
+ }
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ appendComa(valueNumber++);
+ if (name != null) {
+ buf.append(name).append('=');
+ }
+ buf.append('@');
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append('(');
+ text.add(buf.toString());
+ TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
+ text.add(tav.getText());
+ text.add(")");
+ if (av != null) {
+ tav.av = av.visitAnnotation(name, desc);
+ }
+ return tav;
+ }
+
+ public AnnotationVisitor visitArray(final String name) {
+ buf.setLength(0);
+ appendComa(valueNumber++);
+ if (name != null) {
+ buf.append(name).append('=');
+ }
+ buf.append('{');
+ text.add(buf.toString());
+ TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
+ text.add(tav.getText());
+ text.add("}");
+ if (av != null) {
+ tav.av = av.visitArray(name);
+ }
+ return tav;
+ }
+
+ public void visitEnd() {
+ if (av != null) {
+ av.visitEnd();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ protected TraceAnnotationVisitor createTraceAnnotationVisitor() {
+ return new TraceAnnotationVisitor();
+ }
+
+ private void appendComa(int i) {
+ if (i != 0) {
+ buf.append(", ");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceClassVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceClassVisitor.java
new file mode 100644
index 000000000..bbadc911d
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceClassVisitor.java
@@ -0,0 +1,534 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import java.io.FileInputStream;
+import java.io.PrintWriter;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.signature.SignatureReader;
+
+/**
+ * A {@link ClassVisitor} that prints a disassembled view of the classes it
+ * visits. This class visitor can be used alone (see the {@link #main main}
+ * method) to disassemble a class. It can also be used in the middle of class
+ * visitor chain to trace the class that is visited at a given point in this
+ * chain. This may be uselful for debugging purposes. <p> The trace printed when
+ * visiting the <tt>Hello</tt> class is the following: <p> <blockquote>
+ *
+ * <pre>
+ * // class version 49.0 (49)
+ * // access flags 33
+ * public class Hello {
+ *
+ * // compiled from: Hello.java
+ *
+ * // access flags 1
+ * public &lt;init&gt; ()V
+ * ALOAD 0
+ * INVOKESPECIAL java/lang/Object &lt;init&gt; ()V
+ * RETURN
+ * MAXSTACK = 1
+ * MAXLOCALS = 1
+ *
+ * // access flags 9
+ * public static main ([Ljava/lang/String;)V
+ * GETSTATIC java/lang/System out Ljava/io/PrintStream;
+ * LDC &quot;hello&quot;
+ * INVOKEVIRTUAL java/io/PrintStream println (Ljava/lang/String;)V
+ * RETURN
+ * MAXSTACK = 2
+ * MAXLOCALS = 1
+ * }
+ * </pre>
+ *
+ * </blockquote> where <tt>Hello</tt> is defined by: <p> <blockquote>
+ *
+ * <pre>
+ * public class Hello {
+ *
+ * public static void main(String[] args) {
+ * System.out.println(&quot;hello&quot;);
+ * }
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ *
+ * @author Eric Bruneton
+ * @author Eugene Kuleshov
+ */
+public class TraceClassVisitor extends TraceAbstractVisitor implements
+ ClassVisitor
+{
+
+ /**
+ * The {@link ClassVisitor} to which this visitor delegates calls. May be
+ * <tt>null</tt>.
+ */
+ protected final ClassVisitor cv;
+
+ /**
+ * The print writer to be used to print the class.
+ */
+ protected final PrintWriter pw;
+
+ /**
+ * Prints a disassembled view of the given class to the standard output. <p>
+ * Usage: TraceClassVisitor [-debug] &lt;fully qualified class name or class
+ * file name &gt;
+ *
+ * @param args the command line arguments.
+ *
+ * @throws Exception if the class cannot be found, or if an IO exception
+ * occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ int i = 0;
+ boolean skipDebug = true;
+
+ boolean ok = true;
+ if (args.length < 1 || args.length > 2) {
+ ok = false;
+ }
+ if (ok && args[0].equals("-debug")) {
+ i = 1;
+ skipDebug = false;
+ if (args.length != 2) {
+ ok = false;
+ }
+ }
+ if (!ok) {
+ System.err.println("Prints a disassembled view of the given class.");
+ System.err.println("Usage: TraceClassVisitor [-debug] "
+ + "<fully qualified class name or class file name>");
+ return;
+ }
+ ClassReader cr;
+ if (args[i].endsWith(".class") || args[i].indexOf('\\') > -1
+ || args[i].indexOf('/') > -1)
+ {
+ cr = new ClassReader(new FileInputStream(args[i]));
+ } else {
+ cr = new ClassReader(args[i]);
+ }
+ cr.accept(new TraceClassVisitor(new PrintWriter(System.out)),
+ getDefaultAttributes(),
+ skipDebug);
+ }
+
+ /**
+ * Constructs a new {@link TraceClassVisitor}.
+ *
+ * @param pw the print writer to be used to print the class.
+ */
+ public TraceClassVisitor(final PrintWriter pw) {
+ this(null, pw);
+ }
+
+ /**
+ * Constructs a new {@link TraceClassVisitor}.
+ *
+ * @param cv the {@link ClassVisitor} to which this visitor delegates calls.
+ * May be <tt>null</tt>.
+ * @param pw the print writer to be used to print the class.
+ */
+ public TraceClassVisitor(final ClassVisitor cv, final PrintWriter pw) {
+ this.cv = cv;
+ this.pw = pw;
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the ClassVisitor interface
+ // ------------------------------------------------------------------------
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces)
+ {
+ int major = version & 0xFFFF;
+ int minor = version >>> 16;
+ buf.setLength(0);
+ buf.append("// class version ")
+ .append(major)
+ .append('.')
+ .append(minor)
+ .append(" (")
+ .append(version)
+ .append(")\n");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ buf.append("// DEPRECATED\n");
+ }
+ buf.append("// access flags ").append(access).append('\n');
+
+ appendDescriptor(CLASS_SIGNATURE, signature);
+ if (signature != null) {
+ TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
+ SignatureReader r = new SignatureReader(signature);
+ r.accept(sv);
+ buf.append("// declaration: ")
+ .append(name)
+ .append(sv.getDeclaration())
+ .append('\n');
+ }
+
+ appendAccess(access & ~Opcodes.ACC_SUPER);
+ if ((access & Opcodes.ACC_ANNOTATION) != 0) {
+ buf.append("@interface ");
+ } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
+ buf.append("interface ");
+ } else if ((access & Opcodes.ACC_ENUM) != 0) {
+ buf.append("enum ");
+ } else {
+ buf.append("class ");
+ }
+ appendDescriptor(INTERNAL_NAME, name);
+
+ if (superName != null && !superName.equals("java/lang/Object")) {
+ buf.append(" extends ");
+ appendDescriptor(INTERNAL_NAME, superName);
+ buf.append(' ');
+ }
+ if (interfaces != null && interfaces.length > 0) {
+ buf.append(" implements ");
+ for (int i = 0; i < interfaces.length; ++i) {
+ appendDescriptor(INTERNAL_NAME, interfaces[i]);
+ buf.append(' ');
+ }
+ }
+ buf.append(" {\n\n");
+
+ text.add(buf.toString());
+
+ if (cv != null) {
+ cv.visit(version, access, name, signature, superName, interfaces);
+ }
+ }
+
+ public void visitSource(final String file, final String debug) {
+ buf.setLength(0);
+ if (file != null) {
+ buf.append(tab)
+ .append("// compiled from: ")
+ .append(file)
+ .append('\n');
+ }
+ if (debug != null) {
+ buf.append(tab)
+ .append("// debug info: ")
+ .append(debug)
+ .append('\n');
+ }
+ if (buf.length() > 0) {
+ text.add(buf.toString());
+ }
+
+ if (cv != null) {
+ cv.visitSource(file, debug);
+ }
+ }
+
+ public void visitOuterClass(
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ buf.append(tab).append("OUTERCLASS ");
+ appendDescriptor(INTERNAL_NAME, owner);
+ // if enclosing name is null, so why should we show this info?
+ if (name != null) {
+ buf.append(' ').append(name).append(' ');
+ } else {
+ buf.append(' ');
+ }
+ appendDescriptor(METHOD_DESCRIPTOR, desc);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (cv != null) {
+ cv.visitOuterClass(owner, name, desc);
+ }
+ }
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ text.add("\n");
+ AnnotationVisitor tav = super.visitAnnotation(desc, visible);
+ if (cv != null) {
+ ((TraceAnnotationVisitor) tav).av = cv.visitAnnotation(desc,
+ visible);
+ }
+ return tav;
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ text.add("\n");
+ super.visitAttribute(attr);
+
+ if (cv != null) {
+ cv.visitAttribute(attr);
+ }
+ }
+
+ public void visitInnerClass(
+ final String name,
+ final String outerName,
+ final String innerName,
+ final int access)
+ {
+ buf.setLength(0);
+ buf.append(tab).append("// access flags ").append(access
+ & ~Opcodes.ACC_SUPER).append('\n');
+ buf.append(tab);
+ appendAccess(access);
+ buf.append("INNERCLASS ");
+ if ((access & Opcodes.ACC_ENUM) != 0) {
+ buf.append("enum ");
+ }
+ appendDescriptor(INTERNAL_NAME, name);
+ buf.append(' ');
+ appendDescriptor(INTERNAL_NAME, outerName);
+ buf.append(' ');
+ appendDescriptor(INTERNAL_NAME, innerName);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (cv != null) {
+ cv.visitInnerClass(name, outerName, innerName, access);
+ }
+ }
+
+ public FieldVisitor visitField(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final Object value)
+ {
+ buf.setLength(0);
+ buf.append('\n');
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ buf.append(tab).append("// DEPRECATED\n");
+ }
+ buf.append(tab).append("// access flags ").append(access).append('\n');
+ if (signature != null) {
+ buf.append(tab);
+ appendDescriptor(FIELD_SIGNATURE, signature);
+
+ TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
+ SignatureReader r = new SignatureReader(signature);
+ r.acceptType(sv);
+ buf.append(tab)
+ .append("// declaration: ")
+ .append(sv.getDeclaration())
+ .append('\n');
+ }
+
+ buf.append(tab);
+ appendAccess(access);
+ if ((access & Opcodes.ACC_ENUM) != 0) {
+ buf.append("enum ");
+ }
+
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append(' ').append(name);
+ if (value != null) {
+ buf.append(" = ");
+ if (value instanceof String) {
+ buf.append("\"").append(value).append("\"");
+ } else {
+ buf.append(value);
+ }
+ }
+
+ buf.append('\n');
+ text.add(buf.toString());
+
+ TraceFieldVisitor tav = createTraceFieldVisitor();
+ text.add(tav.getText());
+
+ if (cv != null) {
+ tav.fv = cv.visitField(access, name, desc, signature, value);
+ }
+
+ return tav;
+ }
+
+ public MethodVisitor visitMethod(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ buf.setLength(0);
+ buf.append('\n');
+ if ((access & Opcodes.ACC_DEPRECATED) != 0) {
+ buf.append(tab).append("// DEPRECATED\n");
+ }
+ buf.append(tab).append("// access flags ").append(access).append('\n');
+ buf.append(tab);
+ appendDescriptor(METHOD_SIGNATURE, signature);
+
+ if (signature != null) {
+ TraceSignatureVisitor v = new TraceSignatureVisitor(0);
+ SignatureReader r = new SignatureReader(signature);
+ r.accept(v);
+ String genericDecl = v.getDeclaration();
+ String genericReturn = v.getReturnType();
+ String genericExceptions = v.getExceptions();
+
+ buf.append(tab)
+ .append("// declaration: ")
+ .append(genericReturn)
+ .append(' ')
+ .append(name)
+ .append(genericDecl);
+ if (genericExceptions != null) {
+ buf.append(" throws ").append(genericExceptions);
+ }
+ buf.append('\n');
+ }
+
+ appendAccess(access);
+ if ((access & Opcodes.ACC_NATIVE) != 0) {
+ buf.append("native ");
+ }
+ if ((access & Opcodes.ACC_VARARGS) != 0) {
+ buf.append("varargs ");
+ }
+ if ((access & Opcodes.ACC_BRIDGE) != 0) {
+ buf.append("bridge ");
+ }
+
+ buf.append(name);
+ appendDescriptor(METHOD_DESCRIPTOR, desc);
+ if (exceptions != null && exceptions.length > 0) {
+ buf.append(" throws ");
+ for (int i = 0; i < exceptions.length; ++i) {
+ appendDescriptor(INTERNAL_NAME, exceptions[i]);
+ buf.append(' ');
+ }
+ }
+
+ buf.append('\n');
+ text.add(buf.toString());
+
+ TraceMethodVisitor tcv = createTraceMethodVisitor();
+ text.add(tcv.getText());
+
+ if (cv != null) {
+ tcv.mv = cv.visitMethod(access, name, desc, signature, exceptions);
+ }
+
+ return tcv;
+ }
+
+ public void visitEnd() {
+ text.add("}\n");
+
+ printList(pw, text);
+ pw.flush();
+
+ if (cv != null) {
+ cv.visitEnd();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ protected TraceFieldVisitor createTraceFieldVisitor() {
+ return new TraceFieldVisitor();
+ }
+
+ protected TraceMethodVisitor createTraceMethodVisitor() {
+ return new TraceMethodVisitor();
+ }
+
+ /**
+ * Appends a string representation of the given access modifiers to {@link
+ * #buf buf}.
+ *
+ * @param access some access modifiers.
+ */
+ private void appendAccess(final int access) {
+ if ((access & Opcodes.ACC_PUBLIC) != 0) {
+ buf.append("public ");
+ }
+ if ((access & Opcodes.ACC_PRIVATE) != 0) {
+ buf.append("private ");
+ }
+ if ((access & Opcodes.ACC_PROTECTED) != 0) {
+ buf.append("protected ");
+ }
+ if ((access & Opcodes.ACC_FINAL) != 0) {
+ buf.append("final ");
+ }
+ if ((access & Opcodes.ACC_STATIC) != 0) {
+ buf.append("static ");
+ }
+ if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
+ buf.append("synchronized ");
+ }
+ if ((access & Opcodes.ACC_VOLATILE) != 0) {
+ buf.append("volatile ");
+ }
+ if ((access & Opcodes.ACC_TRANSIENT) != 0) {
+ buf.append("transient ");
+ }
+ // if ((access & Constants.ACC_NATIVE) != 0) {
+ // buf.append("native ");
+ // }
+ if ((access & Opcodes.ACC_ABSTRACT) != 0) {
+ buf.append("abstract ");
+ }
+ if ((access & Opcodes.ACC_STRICT) != 0) {
+ buf.append("strictfp ");
+ }
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
+ buf.append("synthetic ");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceFieldVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceFieldVisitor.java
new file mode 100644
index 000000000..4d20efd8b
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceFieldVisitor.java
@@ -0,0 +1,78 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.FieldVisitor;
+
+/**
+ * A {@link FieldVisitor} that prints a disassembled view of the fields it
+ * visits.
+ *
+ * @author Eric Bruneton
+ */
+public class TraceFieldVisitor extends TraceAbstractVisitor implements
+ FieldVisitor
+{
+
+ /**
+ * The {@link FieldVisitor} to which this visitor delegates calls. May be
+ * <tt>null</tt>.
+ */
+ protected FieldVisitor fv;
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ AnnotationVisitor av = super.visitAnnotation(desc, visible);
+ if (fv != null) {
+ ((TraceAnnotationVisitor) av).av = fv.visitAnnotation(desc, visible);
+ }
+ return av;
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ super.visitAttribute(attr);
+
+ if (fv != null) {
+ fv.visitAttribute(attr);
+ }
+ }
+
+ public void visitEnd() {
+ super.visitEnd();
+
+ if (fv != null) {
+ fv.visitEnd();
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceMethodVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceMethodVisitor.java
new file mode 100644
index 000000000..73a511bc3
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceMethodVisitor.java
@@ -0,0 +1,486 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.signature.SignatureReader;
+import org.objectweb.asm.util.attrs.Traceable;
+
+import java.util.HashMap;
+
+/**
+ * A {@link MethodVisitor} that prints a disassembled view of the methods it
+ * visits.
+ *
+ * @author Eric Bruneton
+ */
+public class TraceMethodVisitor extends TraceAbstractVisitor implements
+ MethodVisitor
+{
+
+ /**
+ * The {@link MethodVisitor} to which this visitor delegates calls. May be
+ * <tt>null</tt>.
+ */
+ protected MethodVisitor mv;
+
+ /**
+ * Tab for bytecode instructions.
+ */
+ protected String tab2 = " ";
+
+ /**
+ * Tab for table and lookup switch instructions.
+ */
+ protected String tab3 = " ";
+
+ /**
+ * Tab for labels.
+ */
+ protected String ltab = " ";
+
+ /**
+ * The label names. This map associate String values to Label keys.
+ */
+ protected final HashMap labelNames;
+
+ /**
+ * Constructs a new {@link TraceMethodVisitor}.
+ */
+ public TraceMethodVisitor() {
+ this(null);
+ }
+
+ /**
+ * Constructs a new {@link TraceMethodVisitor}.
+ *
+ * @param mv the {@link MethodVisitor} to which this visitor delegates
+ * calls. May be <tt>null</tt>.
+ */
+ public TraceMethodVisitor(final MethodVisitor mv) {
+ this.labelNames = new HashMap();
+ this.mv = mv;
+ }
+
+ // ------------------------------------------------------------------------
+ // Implementation of the MethodVisitor interface
+ // ------------------------------------------------------------------------
+
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ AnnotationVisitor av = super.visitAnnotation(desc, visible);
+ if (mv != null) {
+ ((TraceAnnotationVisitor) av).av = mv.visitAnnotation(desc, visible);
+ }
+ return av;
+ }
+
+ public void visitAttribute(final Attribute attr) {
+ buf.setLength(0);
+ buf.append(tab).append("ATTRIBUTE ");
+ appendDescriptor(-1, attr.type);
+
+ if (attr instanceof Traceable) {
+ ((Traceable) attr).trace(buf, labelNames);
+ } else {
+ buf.append(" : ").append(attr.toString()).append("\n");
+ }
+
+ text.add(buf.toString());
+ if (mv != null) {
+ mv.visitAttribute(attr);
+ }
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ text.add(tab2 + "default=");
+ TraceAnnotationVisitor tav = new TraceAnnotationVisitor();
+ text.add(tav.getText());
+ text.add("\n");
+ if (mv != null) {
+ tav.av = mv.visitAnnotationDefault();
+ }
+ return tav;
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter,
+ final String desc,
+ final boolean visible)
+ {
+ buf.setLength(0);
+ buf.append(tab2).append('@');
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append('(');
+ text.add(buf.toString());
+ TraceAnnotationVisitor tav = new TraceAnnotationVisitor();
+ text.add(tav.getText());
+ text.add(visible ? ") // parameter " : ") // invisible, parameter ");
+ text.add(new Integer(parameter));
+ text.add("\n");
+ if (mv != null) {
+ tav.av = mv.visitParameterAnnotation(parameter, desc, visible);
+ }
+ return tav;
+ }
+
+ public void visitCode() {
+ if (mv != null) {
+ mv.visitCode();
+ }
+ }
+
+ public void visitInsn(final int opcode) {
+ buf.setLength(0);
+ buf.append(tab2).append(OPCODES[opcode]).append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitInsn(opcode);
+ }
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ buf.setLength(0);
+ buf.append(tab2)
+ .append(OPCODES[opcode])
+ .append(' ')
+ .append(opcode == Opcodes.NEWARRAY
+ ? TYPES[operand]
+ : Integer.toString(operand))
+ .append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitIntInsn(opcode, operand);
+ }
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ buf.setLength(0);
+ buf.append(tab2)
+ .append(OPCODES[opcode])
+ .append(' ')
+ .append(var)
+ .append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitVarInsn(opcode, var);
+ }
+ }
+
+ public void visitTypeInsn(final int opcode, final String desc) {
+ buf.setLength(0);
+ buf.append(tab2).append(OPCODES[opcode]).append(' ');
+ if (desc.startsWith("[")) {
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ } else {
+ appendDescriptor(INTERNAL_NAME, desc);
+ }
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitTypeInsn(opcode, desc);
+ }
+ }
+
+ public void visitFieldInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ buf.append(tab2).append(OPCODES[opcode]).append(' ');
+ appendDescriptor(INTERNAL_NAME, owner);
+ buf.append('.').append(name).append(" : ");
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitFieldInsn(opcode, owner, name, desc);
+ }
+ }
+
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String desc)
+ {
+ buf.setLength(0);
+ buf.append(tab2).append(OPCODES[opcode]).append(' ');
+ appendDescriptor(INTERNAL_NAME, owner);
+ buf.append('.').append(name).append(' ');
+ appendDescriptor(METHOD_DESCRIPTOR, desc);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitMethodInsn(opcode, owner, name, desc);
+ }
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ buf.setLength(0);
+ buf.append(tab2).append(OPCODES[opcode]).append(' ');
+ appendLabel(label);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitJumpInsn(opcode, label);
+ }
+ }
+
+ public void visitLabel(final Label label) {
+ buf.setLength(0);
+ buf.append(ltab);
+ appendLabel(label);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitLabel(label);
+ }
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ buf.setLength(0);
+ buf.append(tab2).append("LDC ");
+ if (cst instanceof String) {
+ AbstractVisitor.appendString(buf, (String) cst);
+ } else if (cst instanceof Type) {
+ buf.append(((Type) cst).getDescriptor() + ".class");
+ } else {
+ buf.append(cst);
+ }
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitLdcInsn(cst);
+ }
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ buf.setLength(0);
+ buf.append(tab2)
+ .append("IINC ")
+ .append(var)
+ .append(' ')
+ .append(increment)
+ .append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitIincInsn(var, increment);
+ }
+ }
+
+ public void visitTableSwitchInsn(
+ final int min,
+ final int max,
+ final Label dflt,
+ final Label labels[])
+ {
+ buf.setLength(0);
+ buf.append(tab2).append("TABLESWITCH\n");
+ for (int i = 0; i < labels.length; ++i) {
+ buf.append(tab3).append(min + i).append(": ");
+ appendLabel(labels[i]);
+ buf.append('\n');
+ }
+ buf.append(tab3).append("default: ");
+ appendLabel(dflt);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitTableSwitchInsn(min, max, dflt, labels);
+ }
+ }
+
+ public void visitLookupSwitchInsn(
+ final Label dflt,
+ final int keys[],
+ final Label labels[])
+ {
+ buf.setLength(0);
+ buf.append(tab2).append("LOOKUPSWITCH\n");
+ for (int i = 0; i < labels.length; ++i) {
+ buf.append(tab3).append(keys[i]).append(": ");
+ appendLabel(labels[i]);
+ buf.append('\n');
+ }
+ buf.append(tab3).append("default: ");
+ appendLabel(dflt);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitLookupSwitchInsn(dflt, keys, labels);
+ }
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ buf.setLength(0);
+ buf.append(tab2).append("MULTIANEWARRAY ");
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append(' ').append(dims).append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitMultiANewArrayInsn(desc, dims);
+ }
+ }
+
+ public void visitTryCatchBlock(
+ final Label start,
+ final Label end,
+ final Label handler,
+ final String type)
+ {
+ buf.setLength(0);
+ buf.append(tab2).append("TRYCATCHBLOCK ");
+ appendLabel(start);
+ buf.append(' ');
+ appendLabel(end);
+ buf.append(' ');
+ appendLabel(handler);
+ buf.append(' ');
+ appendDescriptor(INTERNAL_NAME, type);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitTryCatchBlock(start, end, handler, type);
+ }
+ }
+
+ public void visitLocalVariable(
+ final String name,
+ final String desc,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index)
+ {
+ buf.setLength(0);
+ buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
+ appendDescriptor(FIELD_DESCRIPTOR, desc);
+ buf.append(' ');
+ appendLabel(start);
+ buf.append(' ');
+ appendLabel(end);
+ buf.append(' ').append(index).append('\n');
+
+ if (signature != null) {
+ buf.append(tab2);
+ appendDescriptor(FIELD_SIGNATURE, signature);
+
+ TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
+ SignatureReader r = new SignatureReader(signature);
+ r.acceptType(sv);
+ buf.append(tab2)
+ .append("// declaration: ")
+ .append(sv.getDeclaration())
+ .append('\n');
+ }
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitLocalVariable(name, desc, signature, start, end, index);
+ }
+ }
+
+ public void visitLineNumber(final int line, final Label start) {
+ buf.setLength(0);
+ buf.append(tab2).append("LINENUMBER ").append(line).append(' ');
+ appendLabel(start);
+ buf.append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitLineNumber(line, start);
+ }
+ }
+
+ public void visitMaxs(final int maxStack, final int maxLocals) {
+ buf.setLength(0);
+ buf.append(tab2).append("MAXSTACK = ").append(maxStack).append('\n');
+ text.add(buf.toString());
+
+ buf.setLength(0);
+ buf.append(tab2).append("MAXLOCALS = ").append(maxLocals).append('\n');
+ text.add(buf.toString());
+
+ if (mv != null) {
+ mv.visitMaxs(maxStack, maxLocals);
+ }
+ }
+
+ public void visitEnd() {
+ super.visitEnd();
+
+ if (mv != null) {
+ mv.visitEnd();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Utility methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Appends the name of the given label to {@link #buf buf}. Creates a new
+ * label name if the given label does not yet have one.
+ *
+ * @param l a label.
+ */
+ public void appendLabel(final Label l) {
+ String name = (String) labelNames.get(l);
+ if (name == null) {
+ name = "L" + labelNames.size();
+ labelNames.put(l, name);
+ }
+ buf.append(name);
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceSignatureVisitor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceSignatureVisitor.java
new file mode 100644
index 000000000..e8346c633
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceSignatureVisitor.java
@@ -0,0 +1,300 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.signature.SignatureVisitor;
+
+/**
+ * A {@link SignatureVisitor} that prints a disassembled view of the signature
+ * it visits.
+ *
+ * @author Eugene Kuleshov
+ * @author Eric Bruneton
+ */
+public class TraceSignatureVisitor implements SignatureVisitor {
+
+ private StringBuffer declaration;
+
+ private boolean isInterface;
+
+ private boolean seenFormalParameter;
+
+ private boolean seenInterfaceBound;
+
+ private boolean seenParameter;
+
+ private boolean seenInterface;
+
+ private StringBuffer returnType;
+
+ private StringBuffer exceptions;
+
+ /**
+ * Stack used to keep track of class types that have arguments. Each element
+ * of this stack is a boolean encoded in one bit. The top of the stack is
+ * the lowest order bit. Pushing false = *2, pushing true = *2+1, popping =
+ * /2.
+ */
+ private int argumentStack;
+
+ /**
+ * Stack used to keep track of array class types. Each element of this stack
+ * is a boolean encoded in one bit. The top of the stack is the lowest order
+ * bit. Pushing false = *2, pushing true = *2+1, popping = /2.
+ */
+ private int arrayStack;
+
+ private String separator = "";
+
+ public TraceSignatureVisitor(int access) {
+ isInterface = (access & Opcodes.ACC_INTERFACE) != 0;
+ this.declaration = new StringBuffer();
+ }
+
+ private TraceSignatureVisitor(StringBuffer buf) {
+ this.declaration = buf;
+ }
+
+ public void visitFormalTypeParameter(String name) {
+ declaration.append(seenFormalParameter ? ", " : "<").append(name);
+ seenFormalParameter = true;
+ seenInterfaceBound = false;
+ }
+
+ public SignatureVisitor visitClassBound() {
+ separator = " extends ";
+ startType();
+ return this;
+ }
+
+ public SignatureVisitor visitInterfaceBound() {
+ separator = seenInterfaceBound ? ", " : " extends ";
+ seenInterfaceBound = true;
+ startType();
+ return this;
+ }
+
+ public SignatureVisitor visitSuperclass() {
+ endFormals();
+ separator = " extends ";
+ startType();
+ return this;
+ }
+
+ public SignatureVisitor visitInterface() {
+ separator = seenInterface ? ", " : (isInterface
+ ? " extends "
+ : " implements ");
+ seenInterface = true;
+ startType();
+ return this;
+ }
+
+ public SignatureVisitor visitParameterType() {
+ endFormals();
+ if (!seenParameter) {
+ seenParameter = true;
+ declaration.append('(');
+ } else {
+ declaration.append(", ");
+ }
+ startType();
+ return this;
+ }
+
+ public SignatureVisitor visitReturnType() {
+ endFormals();
+ if (!seenParameter) {
+ declaration.append('(');
+ } else {
+ seenParameter = false;
+ }
+ declaration.append(')');
+ returnType = new StringBuffer();
+ return new TraceSignatureVisitor(returnType);
+ }
+
+ public SignatureVisitor visitExceptionType() {
+ if (exceptions == null) {
+ exceptions = new StringBuffer();
+ } else {
+ exceptions.append(", ");
+ }
+ // startType();
+ return new TraceSignatureVisitor(exceptions);
+ }
+
+ public void visitBaseType(char descriptor) {
+ switch (descriptor) {
+ case 'V':
+ declaration.append("void");
+ break;
+ case 'B':
+ declaration.append("byte");
+ break;
+ case 'J':
+ declaration.append("long");
+ break;
+ case 'Z':
+ declaration.append("boolean");
+ break;
+ case 'I':
+ declaration.append("int");
+ break;
+ case 'S':
+ declaration.append("short");
+ break;
+ case 'C':
+ declaration.append("char");
+ break;
+ case 'F':
+ declaration.append("float");
+ break;
+ // case 'D':
+ default:
+ declaration.append("double");
+ break;
+ }
+ endType();
+ }
+
+ public void visitTypeVariable(String name) {
+ declaration.append(name);
+ endType();
+ }
+
+ public SignatureVisitor visitArrayType() {
+ startType();
+ arrayStack |= 1;
+ return this;
+ }
+
+ public void visitClassType(String name) {
+ if (!"java/lang/Object".equals(name)) {
+ declaration.append(separator).append(name.replace('/', '.'));
+ } else {
+ // Map<java.lang.Object,java.util.List>
+ // or
+ // abstract public V get(Object key); (seen in Dictionary.class)
+ // should have Object
+ // but java.lang.String extends java.lang.Object is unnecessary
+ boolean needObjectClass = argumentStack % 2 == 1 || seenParameter;
+ if (needObjectClass) {
+ declaration.append(separator).append(name.replace('/', '.'));
+ }
+ }
+ separator = "";
+ argumentStack *= 2;
+ }
+
+ public void visitInnerClassType(String name) {
+ if (argumentStack % 2 == 1) {
+ declaration.append('>');
+ }
+ argumentStack /= 2;
+ declaration.append('.');
+ declaration.append(separator).append(name.replace('/', '.'));
+ separator = "";
+ argumentStack *= 2;
+ }
+
+ public void visitTypeArgument() {
+ if (argumentStack % 2 == 0) {
+ ++argumentStack;
+ declaration.append('<');
+ } else {
+ declaration.append(", ");
+ }
+ declaration.append('?');
+ }
+
+ public SignatureVisitor visitTypeArgument(char tag) {
+ if (argumentStack % 2 == 0) {
+ ++argumentStack;
+ declaration.append('<');
+ } else {
+ declaration.append(", ");
+ }
+
+ if (tag == SignatureVisitor.EXTENDS) {
+ declaration.append("? extends ");
+ } else if (tag == SignatureVisitor.SUPER) {
+ declaration.append("? super ");
+ }
+
+ startType();
+ return this;
+ }
+
+ public void visitEnd() {
+ if (argumentStack % 2 == 1) {
+ declaration.append('>');
+ }
+ argumentStack /= 2;
+ endType();
+ }
+
+ public String getDeclaration() {
+ return declaration.toString();
+ }
+
+ public String getReturnType() {
+ return returnType == null ? null : returnType.toString();
+ }
+
+ public String getExceptions() {
+ return exceptions == null ? null : exceptions.toString();
+ }
+
+ // -----------------------------------------------
+
+ private void endFormals() {
+ if (seenFormalParameter) {
+ declaration.append('>');
+ seenFormalParameter = false;
+ }
+ }
+
+ private void startType() {
+ arrayStack *= 2;
+ }
+
+ private void endType() {
+ if (arrayStack % 2 == 1) {
+ while (arrayStack % 2 == 1) {
+ arrayStack /= 2;
+ declaration.append("[]");
+ }
+ } else {
+ arrayStack /= 2;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.java
new file mode 100644
index 000000000..e71e116fe
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.java
@@ -0,0 +1,223 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util.attrs;
+
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.attrs.StackMapAttribute;
+import org.objectweb.asm.attrs.StackMapFrame;
+import org.objectweb.asm.attrs.StackMapType;
+
+/**
+ * An {@link ASMifiable} {@link StackMapAttribute} sub class.
+ *
+ * @author Eugene Kuleshov
+ */
+public class ASMStackMapAttribute extends StackMapAttribute implements
+ ASMifiable,
+ Traceable
+{
+ /**
+ * Length of the attribute used for comparison
+ */
+ private int len;
+
+ public ASMStackMapAttribute() {
+ super();
+ }
+
+ public ASMStackMapAttribute(List frames, int len) {
+ super(frames);
+ this.len = len;
+ }
+
+ protected Attribute read(
+ ClassReader cr,
+ int off,
+ int len,
+ char[] buf,
+ int codeOff,
+ Label[] labels)
+ {
+ StackMapAttribute attr = (StackMapAttribute) super.read(cr,
+ off,
+ len,
+ buf,
+ codeOff,
+ labels);
+
+ return new ASMStackMapAttribute(attr.getFrames(), len);
+ }
+
+ public void asmify(StringBuffer buf, String varName, Map labelNames) {
+ List frames = getFrames();
+ buf.append("{\n");
+ buf.append("StackMapAttribute ").append(varName).append("Attr");
+ buf.append(" = new StackMapAttribute();\n");
+ if (frames.size() > 0) {
+ for (int i = 0; i < frames.size(); i++) {
+ asmify((StackMapFrame) frames.get(i), buf, varName + "frame"
+ + i, labelNames);
+ }
+ }
+ buf.append(varName).append(".visitAttribute(").append(varName);
+ buf.append("Attr);\n}\n");
+ }
+
+ void asmify(
+ StackMapFrame f,
+ StringBuffer buf,
+ String varName,
+ Map labelNames)
+ {
+ declareLabel(buf, labelNames, f.label);
+ buf.append("{\n");
+
+ buf.append("StackMapFrame ")
+ .append(varName)
+ .append(" = new StackMapFrame();\n");
+
+ buf.append(varName)
+ .append(".label = ")
+ .append(labelNames.get(f.label))
+ .append(";\n");
+
+ asmifyTypeInfo(buf, varName, labelNames, f.locals, "locals");
+ asmifyTypeInfo(buf, varName, labelNames, f.stack, "stack");
+
+ buf.append("cvAttr.frames.add(").append(varName).append(");\n");
+ buf.append("}\n");
+ }
+
+ void asmifyTypeInfo(
+ StringBuffer buf,
+ String varName,
+ Map labelNames,
+ List infos,
+ String field)
+ {
+ if (infos.size() > 0) {
+ buf.append("{\n");
+ for (int i = 0; i < infos.size(); i++) {
+ StackMapType typeInfo = (StackMapType) infos.get(i);
+ String localName = varName + "Info" + i;
+ int type = typeInfo.getType();
+ buf.append("StackMapType ")
+ .append(localName)
+ .append(" = StackMapType.getTypeInfo( StackMapType.ITEM_")
+ .append(StackMapType.ITEM_NAMES[type])
+ .append(");\n");
+
+ switch (type) {
+ case StackMapType.ITEM_Object: //
+ buf.append(localName)
+ .append(".setObject(\"")
+ .append(typeInfo.getObject())
+ .append("\");\n");
+ break;
+
+ case StackMapType.ITEM_Uninitialized: //
+ declareLabel(buf, labelNames, typeInfo.getLabel());
+ buf.append(localName)
+ .append(".setLabel(")
+ .append(labelNames.get(typeInfo.getLabel()))
+ .append(");\n");
+ break;
+ }
+ buf.append(varName)
+ .append(".")
+ .append(field)
+ .append(".add(")
+ .append(localName)
+ .append(");\n");
+ }
+ buf.append("}\n");
+ }
+ }
+
+ static void declareLabel(StringBuffer buf, Map labelNames, Label l) {
+ String name = (String) labelNames.get(l);
+ if (name == null) {
+ name = "l" + labelNames.size();
+ labelNames.put(l, name);
+ buf.append("Label ").append(name).append(" = new Label();\n");
+ }
+ }
+
+ public void trace(StringBuffer buf, Map labelNames) {
+ List frames = getFrames();
+ buf.append("[\n");
+ for (int i = 0; i < frames.size(); i++) {
+ StackMapFrame f = (StackMapFrame) frames.get(i);
+
+ buf.append(" Frame:");
+ appendLabel(buf, labelNames, f.label);
+
+ buf.append(" locals[");
+ traceTypeInfo(buf, labelNames, f.locals);
+ buf.append("]");
+ buf.append(" stack[");
+ traceTypeInfo(buf, labelNames, f.stack);
+ buf.append("]\n");
+ }
+ buf.append(" ] length:").append(len).append("\n");
+ }
+
+ private void traceTypeInfo(StringBuffer buf, Map labelNames, List infos) {
+ String sep = "";
+ for (int i = 0; i < infos.size(); i++) {
+ StackMapType t = (StackMapType) infos.get(i);
+
+ buf.append(sep).append(StackMapType.ITEM_NAMES[t.getType()]);
+ sep = ", ";
+ if (t.getType() == StackMapType.ITEM_Object) {
+ buf.append(":").append(t.getObject());
+ }
+ if (t.getType() == StackMapType.ITEM_Uninitialized) {
+ buf.append(":");
+ appendLabel(buf, labelNames, t.getLabel());
+ }
+ }
+ }
+
+ protected void appendLabel(StringBuffer buf, Map labelNames, Label l) {
+ String name = (String) labelNames.get(l);
+ if (name == null) {
+ name = "L" + labelNames.size();
+ labelNames.put(l, name);
+ }
+ buf.append(name);
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.java
new file mode 100644
index 000000000..e591cb935
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.java
@@ -0,0 +1,214 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util.attrs;
+
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.attrs.StackMapTableAttribute;
+import org.objectweb.asm.attrs.StackMapFrame;
+import org.objectweb.asm.attrs.StackMapType;
+
+/**
+ * An {@link ASMifiable} {@link StackMapTableAttribute} sub class.
+ *
+ * @author Eugene Kuleshov
+ */
+public class ASMStackMapTableAttribute extends StackMapTableAttribute implements
+ ASMifiable,
+ Traceable
+{
+ /**
+ * Length of the attribute used for comparison
+ */
+ private int len;
+
+ public ASMStackMapTableAttribute() {
+ super();
+ }
+
+ public ASMStackMapTableAttribute(List frames, int len) {
+ super(frames);
+ this.len = len;
+ }
+
+ protected Attribute read(
+ ClassReader cr,
+ int off,
+ int len,
+ char[] buf,
+ int codeOff,
+ Label[] labels)
+ {
+ StackMapTableAttribute attr = (StackMapTableAttribute) super.read(cr,
+ off,
+ len,
+ buf,
+ codeOff,
+ labels);
+
+ return new ASMStackMapTableAttribute(attr.getFrames(), len);
+ }
+
+ public void asmify(StringBuffer buf, String varName, Map labelNames) {
+ List frames = getFrames();
+ if (frames.size() == 0) {
+ buf.append("List frames = Collections.EMPTY_LIST;\n");
+ } else {
+ buf.append("List frames = new ArrayList();\n");
+ for (int i = 0; i < frames.size(); i++) {
+ buf.append("{\n");
+ StackMapFrame f = (StackMapFrame) frames.get(i);
+ declareLabel(buf, labelNames, f.label);
+
+ String frameVar = varName + "frame" + i;
+ asmifyTypeInfo(buf, frameVar, labelNames, f.locals, "locals");
+ asmifyTypeInfo(buf, frameVar, labelNames, f.stack, "stack");
+
+ buf.append("StackMapFrame ")
+ .append(frameVar)
+ .append(" = new StackMapFrame(")
+ .append(labelNames.get(f.label))
+ .append(", locals, stack);\n");
+ buf.append("frames.add(").append(frameVar).append(");\n");
+ buf.append("}\n");
+ }
+ }
+ buf.append("StackMapTableAttribute ").append(varName);
+ buf.append(" = new StackMapTableAttribute(frames);\n");
+ }
+
+ void asmifyTypeInfo(
+ StringBuffer buf,
+ String varName,
+ Map labelNames,
+ List infos,
+ String field)
+ {
+ if (infos.size() == 0) {
+ buf.append("List ")
+ .append(field)
+ .append(" = Collections.EMPTY_LIST;\n");
+ } else {
+ buf.append("List ").append(field).append(" = new ArrayList();\n");
+ buf.append("{\n");
+ for (int i = 0; i < infos.size(); i++) {
+ StackMapType typeInfo = (StackMapType) infos.get(i);
+ String localName = varName + "Info" + i;
+ int type = typeInfo.getType();
+ buf.append("StackMapType ")
+ .append(localName)
+ .append(" = StackMapType.getTypeInfo( StackMapType.ITEM_")
+ .append(StackMapType.ITEM_NAMES[type])
+ .append(");\n");
+
+ switch (type) {
+ case StackMapType.ITEM_Object: //
+ buf.append(localName)
+ .append(".setObject(\"")
+ .append(typeInfo.getObject())
+ .append("\");\n");
+ break;
+
+ case StackMapType.ITEM_Uninitialized: //
+ declareLabel(buf, labelNames, typeInfo.getLabel());
+ buf.append(localName)
+ .append(".setLabel(")
+ .append(labelNames.get(typeInfo.getLabel()))
+ .append(");\n");
+ break;
+ }
+ buf.append(field)
+ .append(".add(")
+ .append(localName)
+ .append(");\n");
+ }
+ buf.append("}\n");
+ }
+ }
+
+ static void declareLabel(StringBuffer buf, Map labelNames, Label l) {
+ String name = (String) labelNames.get(l);
+ if (name == null) {
+ name = "l" + labelNames.size();
+ labelNames.put(l, name);
+ buf.append("Label ").append(name).append(" = new Label();\n");
+ }
+ }
+
+ public void trace(StringBuffer buf, Map labelNames) {
+ List frames = getFrames();
+ buf.append("[\n");
+ for (int i = 0; i < frames.size(); i++) {
+ StackMapFrame f = (StackMapFrame) frames.get(i);
+
+ buf.append(" Frame:");
+ appendLabel(buf, labelNames, f.label);
+
+ buf.append(" locals[");
+ traceTypeInfo(buf, labelNames, f.locals);
+ buf.append("]");
+ buf.append(" stack[");
+ traceTypeInfo(buf, labelNames, f.stack);
+ buf.append("]\n");
+ }
+ buf.append(" ] length:").append(len).append("\n");
+ }
+
+ private void traceTypeInfo(StringBuffer buf, Map labelNames, List infos) {
+ String sep = "";
+ for (int i = 0; i < infos.size(); i++) {
+ StackMapType t = (StackMapType) infos.get(i);
+
+ buf.append(sep).append(StackMapType.ITEM_NAMES[t.getType()]);
+ sep = ", ";
+ if (t.getType() == StackMapType.ITEM_Object) {
+ buf.append(":").append(t.getObject());
+ }
+ if (t.getType() == StackMapType.ITEM_Uninitialized) {
+ buf.append(":");
+ appendLabel(buf, labelNames, t.getLabel());
+ }
+ }
+ }
+
+ protected void appendLabel(StringBuffer buf, Map labelNames, Label l) {
+ String name = (String) labelNames.get(l);
+ if (name == null) {
+ name = "L" + labelNames.size();
+ labelNames.put(l, name);
+ }
+ buf.append(name);
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMifiable.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMifiable.java
new file mode 100644
index 000000000..f9067bfe1
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMifiable.java
@@ -0,0 +1,53 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util.attrs;
+
+import java.util.Map;
+
+/**
+ * An attribute that can print the ASM code to create an equivalent attribute.
+ *
+ * Implementation should print the ASM code that generates attribute data
+ * structures for current attribute state.
+ *
+ * @author Eugene Kuleshov
+ */
+public interface ASMifiable {
+
+ /**
+ * Prints the ASM code to create an attribute equal to this attribute.
+ *
+ * @param buf A buffer used for printing Java code.
+ * @param varName name of the variable in a printed code used to store
+ * attribute instance.
+ * @param labelNames map of label instances to their names.
+ */
+ void asmify(StringBuffer buf, String varName, Map labelNames);
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/Traceable.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/Traceable.java
new file mode 100644
index 000000000..44680b57e
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/Traceable.java
@@ -0,0 +1,52 @@
+/**
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2005 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.util.attrs;
+
+import java.util.Map;
+
+/**
+ * An attribute that can print eadable representation of the attribute.
+ *
+ * Implementation should construct readable output from an attribute data
+ * structures for current attribute state. Such representation could be used in
+ * unit test assertions.
+ *
+ * @author Eugene Kuleshov
+ */
+public interface Traceable {
+
+ /**
+ * Build a human readable representation of the attribute.
+ *
+ * @param buf A buffer used for printing Java code.
+ * @param labelNames map of label instances to their names.
+ */
+ void trace(StringBuffer buf, Map labelNames);
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java
new file mode 100644
index 000000000..826a7fe7f
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java
@@ -0,0 +1,1215 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Type;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} that transforms XML
+ * document into Java class file. This class can be feeded by any kind of SAX
+ * 2.0 event producers, e.g. XML parser, XSLT or XPath engines, or custom code.
+ *
+ * @see org.objectweb.asm.xml.SAXClassAdapter
+ * @see org.objectweb.asm.xml.Processor
+ *
+ * @author Eugene Kuleshov
+ */
+public class ASMContentHandler extends DefaultHandler implements Opcodes {
+ /**
+ * Stack of the intermediate processing contexts.
+ */
+ private List stack = new ArrayList();
+
+ /**
+ * Complete name of the current element.
+ */
+ private String match = "";
+
+ /**
+ * <tt>true</tt> if the maximum stack size and number of local variables
+ * must be automatically computed.
+ */
+ protected boolean computeMax;
+
+ /**
+ * Output stream to write result bytecode.
+ */
+ protected OutputStream os;
+
+ /**
+ * Current instance of the {@link ClassWriter ClassWriter} used to write
+ * class bytecode.
+ */
+ protected ClassWriter cw;
+
+ /**
+ * Map of the active {@link Label Label} instances for current method.
+ */
+ protected Map labels;
+
+ private static final String BASE = "class";
+
+ private final RuleSet RULES = new RuleSet();
+ {
+ RULES.add(BASE, new ClassRule());
+ RULES.add(BASE + "/interfaces/interface", new InterfaceRule());
+ RULES.add(BASE + "/interfaces", new InterfacesRule());
+ RULES.add(BASE + "/outerclass", new OuterClassRule());
+ RULES.add(BASE + "/innerclass", new InnerClassRule());
+ RULES.add(BASE + "/source", new SourceRule());
+ RULES.add(BASE + "/field", new FieldRule());
+
+ RULES.add(BASE + "/method", new MethodRule());
+ RULES.add(BASE + "/method/exceptions/exception", new ExceptionRule());
+ RULES.add(BASE + "/method/exceptions", new ExceptionsRule());
+
+ RULES.add(BASE + "/method/annotationDefault",
+ new AnnotationDefaultRule());
+
+ RULES.add(BASE + "/method/code/*", new OpcodesRule()); // opcodes
+
+ RULES.add(BASE + "/method/code/TABLESWITCH", new TableSwitchRule());
+ RULES.add(BASE + "/method/code/TABLESWITCH/label",
+ new TableSwitchLabelRule());
+ RULES.add(BASE + "/method/code/LOOKUPSWITCH", new LookupSwitchRule());
+ RULES.add(BASE + "/method/code/LOOKUPSWITCH/label",
+ new LookupSwitchLabelRule());
+
+ RULES.add(BASE + "/method/code/Label", new LabelRule());
+ RULES.add(BASE + "/method/code/TryCatch", new TryCatchRule());
+ RULES.add(BASE + "/method/code/LineNumber", new LineNumberRule());
+ RULES.add(BASE + "/method/code/LocalVar", new LocalVarRule());
+ RULES.add(BASE + "/method/code/Max", new MaxRule());
+
+ RULES.add("*/annotation", new AnnotationRule());
+ RULES.add("*/parameterAnnotation", new AnnotationParameterRule());
+ RULES.add("*/annotationValue", new AnnotationValueRule());
+ RULES.add("*/annotationValueAnnotation",
+ new AnnotationValueAnnotationRule());
+ RULES.add("*/annotationValueEnum", new AnnotationValueEnumRule());
+ RULES.add("*/annotationValueArray", new AnnotationValueArrayRule());
+ }
+
+ private static interface OpcodeGroup {
+ public static final int INSN = 0;
+ public static final int INSN_INT = 1;
+ public static final int INSN_VAR = 2;
+ public static final int INSN_TYPE = 3;
+ public static final int INSN_FIELD = 4;
+ public static final int INSN_METHOD = 5;
+ public static final int INSN_JUMP = 6;
+ public static final int INSN_LDC = 7;
+ public static final int INSN_IINC = 8;
+ public static final int INSN_MULTIANEWARRAY = 9;
+ }
+
+ /**
+ * Map of the opcode names to opcode and opcode group
+ */
+ static final Map OPCODES = new HashMap();
+ static {
+ OPCODES.put("NOP", new Opcode(NOP, OpcodeGroup.INSN));
+ OPCODES.put("ACONST_NULL", new Opcode(ACONST_NULL, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_M1", new Opcode(ICONST_M1, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_0", new Opcode(ICONST_0, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_1", new Opcode(ICONST_1, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_2", new Opcode(ICONST_2, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_3", new Opcode(ICONST_3, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_4", new Opcode(ICONST_4, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_5", new Opcode(ICONST_5, OpcodeGroup.INSN));
+ OPCODES.put("LCONST_0", new Opcode(LCONST_0, OpcodeGroup.INSN));
+ OPCODES.put("LCONST_1", new Opcode(LCONST_1, OpcodeGroup.INSN));
+ OPCODES.put("FCONST_0", new Opcode(FCONST_0, OpcodeGroup.INSN));
+ OPCODES.put("FCONST_1", new Opcode(FCONST_1, OpcodeGroup.INSN));
+ OPCODES.put("FCONST_2", new Opcode(FCONST_2, OpcodeGroup.INSN));
+ OPCODES.put("DCONST_0", new Opcode(DCONST_0, OpcodeGroup.INSN));
+ OPCODES.put("DCONST_1", new Opcode(DCONST_1, OpcodeGroup.INSN));
+ OPCODES.put("BIPUSH", new Opcode(BIPUSH, OpcodeGroup.INSN_INT));
+ OPCODES.put("SIPUSH", new Opcode(SIPUSH, OpcodeGroup.INSN_INT));
+ OPCODES.put("LDC", new Opcode(LDC, OpcodeGroup.INSN_LDC));
+ OPCODES.put("ILOAD", new Opcode(ILOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("LLOAD", new Opcode(LLOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("FLOAD", new Opcode(FLOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("DLOAD", new Opcode(DLOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("ALOAD", new Opcode(ALOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("IALOAD", new Opcode(IALOAD, OpcodeGroup.INSN));
+ OPCODES.put("LALOAD", new Opcode(LALOAD, OpcodeGroup.INSN));
+ OPCODES.put("FALOAD", new Opcode(FALOAD, OpcodeGroup.INSN));
+ OPCODES.put("DALOAD", new Opcode(DALOAD, OpcodeGroup.INSN));
+ OPCODES.put("AALOAD", new Opcode(AALOAD, OpcodeGroup.INSN));
+ OPCODES.put("BALOAD", new Opcode(BALOAD, OpcodeGroup.INSN));
+ OPCODES.put("CALOAD", new Opcode(CALOAD, OpcodeGroup.INSN));
+ OPCODES.put("SALOAD", new Opcode(SALOAD, OpcodeGroup.INSN));
+ OPCODES.put("ISTORE", new Opcode(ISTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("LSTORE", new Opcode(LSTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("FSTORE", new Opcode(FSTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("DSTORE", new Opcode(DSTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("ASTORE", new Opcode(ASTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("IASTORE", new Opcode(IASTORE, OpcodeGroup.INSN));
+ OPCODES.put("LASTORE", new Opcode(LASTORE, OpcodeGroup.INSN));
+ OPCODES.put("FASTORE", new Opcode(FASTORE, OpcodeGroup.INSN));
+ OPCODES.put("DASTORE", new Opcode(DASTORE, OpcodeGroup.INSN));
+ OPCODES.put("AASTORE", new Opcode(AASTORE, OpcodeGroup.INSN));
+ OPCODES.put("BASTORE", new Opcode(BASTORE, OpcodeGroup.INSN));
+ OPCODES.put("CASTORE", new Opcode(CASTORE, OpcodeGroup.INSN));
+ OPCODES.put("SASTORE", new Opcode(SASTORE, OpcodeGroup.INSN));
+ OPCODES.put("POP", new Opcode(POP, OpcodeGroup.INSN));
+ OPCODES.put("POP2", new Opcode(POP2, OpcodeGroup.INSN));
+ OPCODES.put("DUP", new Opcode(DUP, OpcodeGroup.INSN));
+ OPCODES.put("DUP_X1", new Opcode(DUP_X1, OpcodeGroup.INSN));
+ OPCODES.put("DUP_X2", new Opcode(DUP_X2, OpcodeGroup.INSN));
+ OPCODES.put("DUP2", new Opcode(DUP2, OpcodeGroup.INSN));
+ OPCODES.put("DUP2_X1", new Opcode(DUP2_X1, OpcodeGroup.INSN));
+ OPCODES.put("DUP2_X2", new Opcode(DUP2_X2, OpcodeGroup.INSN));
+ OPCODES.put("SWAP", new Opcode(SWAP, OpcodeGroup.INSN));
+ OPCODES.put("IADD", new Opcode(IADD, OpcodeGroup.INSN));
+ OPCODES.put("LADD", new Opcode(LADD, OpcodeGroup.INSN));
+ OPCODES.put("FADD", new Opcode(FADD, OpcodeGroup.INSN));
+ OPCODES.put("DADD", new Opcode(DADD, OpcodeGroup.INSN));
+ OPCODES.put("ISUB", new Opcode(ISUB, OpcodeGroup.INSN));
+ OPCODES.put("LSUB", new Opcode(LSUB, OpcodeGroup.INSN));
+ OPCODES.put("FSUB", new Opcode(FSUB, OpcodeGroup.INSN));
+ OPCODES.put("DSUB", new Opcode(DSUB, OpcodeGroup.INSN));
+ OPCODES.put("IMUL", new Opcode(IMUL, OpcodeGroup.INSN));
+ OPCODES.put("LMUL", new Opcode(LMUL, OpcodeGroup.INSN));
+ OPCODES.put("FMUL", new Opcode(FMUL, OpcodeGroup.INSN));
+ OPCODES.put("DMUL", new Opcode(DMUL, OpcodeGroup.INSN));
+ OPCODES.put("IDIV", new Opcode(IDIV, OpcodeGroup.INSN));
+ OPCODES.put("LDIV", new Opcode(LDIV, OpcodeGroup.INSN));
+ OPCODES.put("FDIV", new Opcode(FDIV, OpcodeGroup.INSN));
+ OPCODES.put("DDIV", new Opcode(DDIV, OpcodeGroup.INSN));
+ OPCODES.put("IREM", new Opcode(IREM, OpcodeGroup.INSN));
+ OPCODES.put("LREM", new Opcode(LREM, OpcodeGroup.INSN));
+ OPCODES.put("FREM", new Opcode(FREM, OpcodeGroup.INSN));
+ OPCODES.put("DREM", new Opcode(DREM, OpcodeGroup.INSN));
+ OPCODES.put("INEG", new Opcode(INEG, OpcodeGroup.INSN));
+ OPCODES.put("LNEG", new Opcode(LNEG, OpcodeGroup.INSN));
+ OPCODES.put("FNEG", new Opcode(FNEG, OpcodeGroup.INSN));
+ OPCODES.put("DNEG", new Opcode(DNEG, OpcodeGroup.INSN));
+ OPCODES.put("ISHL", new Opcode(ISHL, OpcodeGroup.INSN));
+ OPCODES.put("LSHL", new Opcode(LSHL, OpcodeGroup.INSN));
+ OPCODES.put("ISHR", new Opcode(ISHR, OpcodeGroup.INSN));
+ OPCODES.put("LSHR", new Opcode(LSHR, OpcodeGroup.INSN));
+ OPCODES.put("IUSHR", new Opcode(IUSHR, OpcodeGroup.INSN));
+ OPCODES.put("LUSHR", new Opcode(LUSHR, OpcodeGroup.INSN));
+ OPCODES.put("IAND", new Opcode(IAND, OpcodeGroup.INSN));
+ OPCODES.put("LAND", new Opcode(LAND, OpcodeGroup.INSN));
+ OPCODES.put("IOR", new Opcode(IOR, OpcodeGroup.INSN));
+ OPCODES.put("LOR", new Opcode(LOR, OpcodeGroup.INSN));
+ OPCODES.put("IXOR", new Opcode(IXOR, OpcodeGroup.INSN));
+ OPCODES.put("LXOR", new Opcode(LXOR, OpcodeGroup.INSN));
+ OPCODES.put("IINC", new Opcode(IINC, OpcodeGroup.INSN_IINC));
+ OPCODES.put("I2L", new Opcode(I2L, OpcodeGroup.INSN));
+ OPCODES.put("I2F", new Opcode(I2F, OpcodeGroup.INSN));
+ OPCODES.put("I2D", new Opcode(I2D, OpcodeGroup.INSN));
+ OPCODES.put("L2I", new Opcode(L2I, OpcodeGroup.INSN));
+ OPCODES.put("L2F", new Opcode(L2F, OpcodeGroup.INSN));
+ OPCODES.put("L2D", new Opcode(L2D, OpcodeGroup.INSN));
+ OPCODES.put("F2I", new Opcode(F2I, OpcodeGroup.INSN));
+ OPCODES.put("F2L", new Opcode(F2L, OpcodeGroup.INSN));
+ OPCODES.put("F2D", new Opcode(F2D, OpcodeGroup.INSN));
+ OPCODES.put("D2I", new Opcode(D2I, OpcodeGroup.INSN));
+ OPCODES.put("D2L", new Opcode(D2L, OpcodeGroup.INSN));
+ OPCODES.put("D2F", new Opcode(D2F, OpcodeGroup.INSN));
+ OPCODES.put("I2B", new Opcode(I2B, OpcodeGroup.INSN));
+ OPCODES.put("I2C", new Opcode(I2C, OpcodeGroup.INSN));
+ OPCODES.put("I2S", new Opcode(I2S, OpcodeGroup.INSN));
+ OPCODES.put("LCMP", new Opcode(LCMP, OpcodeGroup.INSN));
+ OPCODES.put("FCMPL", new Opcode(FCMPL, OpcodeGroup.INSN));
+ OPCODES.put("FCMPG", new Opcode(FCMPG, OpcodeGroup.INSN));
+ OPCODES.put("DCMPL", new Opcode(DCMPL, OpcodeGroup.INSN));
+ OPCODES.put("DCMPG", new Opcode(DCMPG, OpcodeGroup.INSN));
+ OPCODES.put("IFEQ", new Opcode(IFEQ, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFNE", new Opcode(IFNE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFLT", new Opcode(IFLT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFGE", new Opcode(IFGE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFGT", new Opcode(IFGT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFLE", new Opcode(IFLE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPEQ", new Opcode(IF_ICMPEQ, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPNE", new Opcode(IF_ICMPNE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPLT", new Opcode(IF_ICMPLT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPGE", new Opcode(IF_ICMPGE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPGT", new Opcode(IF_ICMPGT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPLE", new Opcode(IF_ICMPLE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ACMPEQ", new Opcode(IF_ACMPEQ, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ACMPNE", new Opcode(IF_ACMPNE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("GOTO", new Opcode(GOTO, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("JSR", new Opcode(JSR, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("RET", new Opcode(RET, OpcodeGroup.INSN_VAR));
+ // OPCODES.put( "TABLESWITCH", new Opcode( TABLESWITCH,
+ // "visiTableSwitchInsn"));
+ // OPCODES.put( "LOOKUPSWITCH", new Opcode( LOOKUPSWITCH,
+ // "visitLookupSwitch"));
+ OPCODES.put("IRETURN", new Opcode(IRETURN, OpcodeGroup.INSN));
+ OPCODES.put("LRETURN", new Opcode(LRETURN, OpcodeGroup.INSN));
+ OPCODES.put("FRETURN", new Opcode(FRETURN, OpcodeGroup.INSN));
+ OPCODES.put("DRETURN", new Opcode(DRETURN, OpcodeGroup.INSN));
+ OPCODES.put("ARETURN", new Opcode(ARETURN, OpcodeGroup.INSN));
+ OPCODES.put("RETURN", new Opcode(RETURN, OpcodeGroup.INSN));
+ OPCODES.put("GETSTATIC", new Opcode(GETSTATIC, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("PUTSTATIC", new Opcode(PUTSTATIC, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("GETFIELD", new Opcode(GETFIELD, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("PUTFIELD", new Opcode(PUTFIELD, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("INVOKEVIRTUAL", new Opcode(INVOKEVIRTUAL,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("INVOKESPECIAL", new Opcode(INVOKESPECIAL,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("INVOKESTATIC", new Opcode(INVOKESTATIC,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("INVOKEINTERFACE", new Opcode(INVOKEINTERFACE,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("NEW", new Opcode(NEW, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("NEWARRAY", new Opcode(NEWARRAY, OpcodeGroup.INSN_INT));
+ OPCODES.put("ANEWARRAY", new Opcode(ANEWARRAY, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("ARRAYLENGTH", new Opcode(ARRAYLENGTH, OpcodeGroup.INSN));
+ OPCODES.put("ATHROW", new Opcode(ATHROW, OpcodeGroup.INSN));
+ OPCODES.put("CHECKCAST", new Opcode(CHECKCAST, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("INSTANCEOF", new Opcode(INSTANCEOF, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("MONITORENTER", new Opcode(MONITORENTER, OpcodeGroup.INSN));
+ OPCODES.put("MONITOREXIT", new Opcode(MONITOREXIT, OpcodeGroup.INSN));
+ OPCODES.put("MULTIANEWARRAY", new Opcode(MULTIANEWARRAY,
+ OpcodeGroup.INSN_MULTIANEWARRAY));
+ OPCODES.put("IFNULL", new Opcode(IFNULL, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFNONNULL", new Opcode(IFNONNULL, OpcodeGroup.INSN_JUMP));
+ }
+
+ /**
+ * Constructs a new {@link ASMContentHandler ASMContentHandler} object.
+ *
+ * @param os output stream to write generated class.
+ * @param computeMax <tt>true</tt> if the maximum stack size and the
+ * maximum number of local variables must be automatically computed.
+ * This value is passed to {@link ClassWriter ClassWriter} instance.
+ */
+ public ASMContentHandler(OutputStream os, boolean computeMax) {
+ this.os = os;
+ this.computeMax = computeMax;
+ }
+
+ /**
+ * Returns the bytecode of the class that was build with underneath class
+ * writer.
+ *
+ * @return the bytecode of the class that was build with underneath class
+ * writer or null if there are no classwriter created.
+ */
+ public byte[] toByteArray() {
+ return cw == null ? null : cw.toByteArray();
+ }
+
+ /**
+ * Process notification of the start of an XML element being reached.
+ *
+ * @param ns - The Namespace URI, or the empty string if the element has no
+ * Namespace URI or if Namespace processing is not being performed.
+ * @param localName - The local name (without prefix), or the empty string
+ * if Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix), or the empty string if
+ * qualified names are not available.
+ * @param list - The attributes attached to the element. If there are no
+ * attributes, it shall be an empty Attributes object.
+ * @exception SAXException if a parsing error is to be reported
+ */
+ public final void startElement(
+ String ns,
+ String localName,
+ String qName,
+ Attributes list) throws SAXException
+ {
+ // the actual element name is either in localName or qName, depending
+ // on whether the parser is namespace aware
+ String name = localName;
+ if (name == null || name.length() < 1) {
+ name = qName;
+ }
+
+ // Compute the current matching rule
+ StringBuffer sb = new StringBuffer(match);
+ if (match.length() > 0) {
+ sb.append('/');
+ }
+ sb.append(name);
+ match = sb.toString();
+
+ // Fire "begin" events for all relevant rules
+ Rule r = (Rule) RULES.match(match);
+ if (r != null)
+ r.begin(name, list);
+ }
+
+ /**
+ * Process notification of the end of an XML element being reached.
+ *
+ * @param ns - The Namespace URI, or the empty string if the element has no
+ * Namespace URI or if Namespace processing is not being performed.
+ * @param localName - The local name (without prefix), or the empty string
+ * if Namespace processing is not being performed.
+ * @param qName - The qualified XML 1.0 name (with prefix), or the empty
+ * string if qualified names are not available.
+ *
+ * @exception SAXException if a parsing error is to be reported
+ */
+ public final void endElement(String ns, String localName, String qName)
+ throws SAXException
+ {
+ // the actual element name is either in localName or qName, depending
+ // on whether the parser is namespace aware
+ String name = localName;
+ if (name == null || name.length() < 1) {
+ name = qName;
+ }
+
+ // Fire "end" events for all relevant rules in reverse order
+ Rule r = (Rule) RULES.match(match);
+ if (r != null)
+ r.end(name);
+
+ // Recover the previous match expression
+ int slash = match.lastIndexOf('/');
+ if (slash >= 0) {
+ match = match.substring(0, slash);
+ } else {
+ match = "";
+ }
+ }
+
+ /**
+ * Process notification of the end of a document and write generated
+ * bytecode into output stream.
+ *
+ * @exception SAXException if parsing or writing error is to be reported.
+ */
+ public final void endDocument() throws SAXException {
+ try {
+ os.write(cw.toByteArray());
+ } catch (IOException ex) {
+ throw new SAXException(ex.toString(), ex);
+ }
+ }
+
+ /**
+ * Return the top object on the stack without removing it. If there are no
+ * objects on the stack, return <code>null</code>.
+ *
+ * @return the top object on the stack without removing it.
+ */
+ final Object peek() {
+ return stack.size() == 0 ? null : stack.get(stack.size() - 1);
+ }
+
+ /**
+ * Return the n'th object down the stack, where 0 is the top element and
+ * [getCount()-1] is the bottom element. If the specified index is out of
+ * range, return <code>null</code>.
+ *
+ * @param n Index of the desired element, where 0 is the top of the stack, 1
+ * is the next element down, and so on.
+ * @return the n'th object down the stack.
+ */
+ final Object peek(int n) {
+ return stack.size() < (n + 1) ? null : stack.get(n);
+ }
+
+ /**
+ * Pop the top object off of the stack, and return it. If there are no
+ * objects on the stack, return <code>null</code>.
+ *
+ * @return the top object off of the stack.
+ */
+ final Object pop() {
+ return stack.size() == 0 ? null : stack.remove(stack.size() - 1);
+ }
+
+ /**
+ * Push a new object onto the top of the object stack.
+ *
+ * @param object The new object
+ */
+ final void push(Object object) {
+ stack.add(object);
+ }
+
+ private static final class RuleSet {
+ private Map rules = new HashMap();
+
+ private List lpatterns = new ArrayList();
+
+ private List rpatterns = new ArrayList();
+
+ public void add(String path, Object rule) {
+ String pattern = path;
+ if (path.startsWith("*/")) {
+ pattern = path.substring(1);
+ lpatterns.add(pattern);
+ } else if (path.endsWith("/*")) {
+ pattern = path.substring(0, path.length() - 1);
+ rpatterns.add(pattern);
+ }
+ rules.put(pattern, rule);
+ }
+
+ public Object match(String path) {
+ if (rules.containsKey(path)) {
+ return rules.get(path);
+ }
+
+ int n = path.lastIndexOf('/');
+ for (Iterator it = lpatterns.iterator(); it.hasNext();) {
+ String pattern = (String) it.next();
+ if (path.substring(n).endsWith(pattern)) {
+ return rules.get(pattern);
+ }
+ }
+
+ for (Iterator it = rpatterns.iterator(); it.hasNext();) {
+ String pattern = (String) it.next();
+ if (path.startsWith(pattern)) {
+ return rules.get(pattern);
+ }
+ }
+
+ return null;
+ }
+
+ }
+
+ /**
+ * Rule
+ */
+ protected abstract class Rule {
+
+ public void begin(String name, Attributes attrs) {
+ }
+
+ public void end(String name) {
+ }
+
+ protected final Object getValue(String desc, String val) {
+ Object value = null;
+ if (val != null) {
+ if (desc.equals("Ljava/lang/String;")) {
+ value = decode(val);
+ } else if ("Ljava/lang/Integer;".equals(desc)
+ || "I".equals(desc) || "S".equals(desc)
+ || "B".equals(desc) || "C".equals(desc)
+ || desc.equals("Z"))
+ {
+ value = new Integer(val);
+
+ } else if ("Ljava/lang/Short;".equals(desc)) {
+ value = new Short(val);
+
+ } else if ("Ljava/lang/Byte;".equals(desc)) {
+ value = new Byte(val);
+
+ } else if ("Ljava/lang/Character;".equals(desc)) {
+ value = new Character(decode(val).charAt(0));
+
+ } else if ("Ljava/lang/Boolean;".equals(desc)) {
+ value = Boolean.valueOf(val);
+
+ // } else if ("Ljava/lang/Integer;".equals(desc)
+ // || desc.equals("I"))
+ // {
+ // value = new Integer(val);
+ // } else if ("Ljava/lang/Character;".equals(desc)
+ // || desc.equals("C"))
+ // {
+ // value = new Character(decode(val).charAt(0));
+ // } else if ("Ljava/lang/Short;".equals(desc) ||
+ // desc.equals("S"))
+ // {
+ // value = Short.valueOf(val);
+ // } else if ("Ljava/lang/Byte;".equals(desc) ||
+ // desc.equals("B"))
+ // {
+ // value = Byte.valueOf(val);
+
+ } else if ("Ljava/lang/Long;".equals(desc) || desc.equals("J"))
+ {
+ value = new Long(val);
+ } else if ("Ljava/lang/Float;".equals(desc) || desc.equals("F"))
+ {
+ value = new Float(val);
+ } else if ("Ljava/lang/Double;".equals(desc)
+ || desc.equals("D"))
+ {
+ value = new Double(val);
+ } else if (Type.getDescriptor(Type.class).equals(desc)) {
+ value = Type.getType(val);
+
+ // } else if ("[I".equals(desc)) {
+ // value = new int[0]; // TODO
+ // } else if ("[C".equals(desc)) {
+ // value = new char[0]; // TODO
+ // } else if ("[Z".equals(desc)) {
+ // value = new boolean[0]; // TODO
+ // } else if ("[S".equals(desc)) {
+ // value = new short[0]; // TODO
+ // } else if ("[B".equals(desc)) {
+ // value = new byte[0]; // TODO
+ // } else if ("[J".equals(desc)) {
+ // value = new long[0]; // TODO
+ // } else if ("[F".equals(desc)) {
+ // value = new float[0]; // TODO
+ // } else if ("[D".equals(desc)) {
+ // value = new double[0]; // TODO
+
+ } else {
+ throw new RuntimeException("Invalid value:" + val
+ + " desc:" + desc + " ctx:" + this);
+ }
+ }
+ return value;
+ }
+
+ private final String decode(String val) {
+ StringBuffer sb = new StringBuffer(val.length());
+ try {
+ int n = 0;
+ while (n < val.length()) {
+ char c = val.charAt(n);
+ if (c == '\\') {
+ n++;
+ c = val.charAt(n);
+ if (c == '\\') {
+ sb.append('\\');
+ } else {
+ n++; // skip 'u'
+ sb.append((char) Integer.parseInt(val.substring(n,
+ n + 4), 16));
+ n += 3;
+ }
+ } else {
+ sb.append(c);
+ }
+ n++;
+ }
+
+ } catch (RuntimeException ex) {
+ System.err.println(val + "\n" + ex.toString());
+ ex.printStackTrace();
+ throw ex;
+ }
+ return sb.toString();
+ }
+
+ protected final Label getLabel(Object label) {
+ Label lbl = (Label) labels.get(label);
+ if (lbl == null) {
+ lbl = new Label();
+ labels.put(label, lbl);
+ }
+ return lbl;
+ }
+
+ // TODO verify move to stack
+ protected final MethodVisitor getCodeVisitor() {
+ return (MethodVisitor) peek();
+ }
+
+ protected final int getAccess(String s) {
+ int access = 0;
+ if (s.indexOf("public") != -1)
+ access |= Opcodes.ACC_PUBLIC;
+ if (s.indexOf("private") != -1)
+ access |= Opcodes.ACC_PRIVATE;
+ if (s.indexOf("protected") != -1)
+ access |= Opcodes.ACC_PROTECTED;
+ if (s.indexOf("static") != -1)
+ access |= Opcodes.ACC_STATIC;
+ if (s.indexOf("final") != -1)
+ access |= Opcodes.ACC_FINAL;
+ if (s.indexOf("super") != -1)
+ access |= Opcodes.ACC_SUPER;
+ if (s.indexOf("synchronized") != -1)
+ access |= Opcodes.ACC_SYNCHRONIZED;
+ if (s.indexOf("volatile") != -1)
+ access |= Opcodes.ACC_VOLATILE;
+ if (s.indexOf("bridge") != -1)
+ access |= Opcodes.ACC_BRIDGE;
+ if (s.indexOf("varargs") != -1)
+ access |= Opcodes.ACC_VARARGS;
+ if (s.indexOf("transient") != -1)
+ access |= Opcodes.ACC_TRANSIENT;
+ if (s.indexOf("native") != -1)
+ access |= Opcodes.ACC_NATIVE;
+ if (s.indexOf("interface") != -1)
+ access |= Opcodes.ACC_INTERFACE;
+ if (s.indexOf("abstract") != -1)
+ access |= Opcodes.ACC_ABSTRACT;
+ if (s.indexOf("strict") != -1)
+ access |= Opcodes.ACC_STRICT;
+ if (s.indexOf("synthetic") != -1)
+ access |= Opcodes.ACC_SYNTHETIC;
+ if (s.indexOf("annotation") != -1)
+ access |= Opcodes.ACC_ANNOTATION;
+ if (s.indexOf("enum") != -1)
+ access |= Opcodes.ACC_ENUM;
+ if (s.indexOf("deprecated") != -1)
+ access |= Opcodes.ACC_DEPRECATED;
+ return access;
+ }
+
+ }
+
+ /**
+ * ClassRule
+ */
+ private final class ClassRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ int major = Integer.parseInt(attrs.getValue("major"));
+ int minor = Integer.parseInt(attrs.getValue("minor"));
+ cw = new ClassWriter(computeMax);
+ Map vals = new HashMap();
+ vals.put("version", new Integer(minor << 16 | major));
+ vals.put("access", attrs.getValue("access"));
+ vals.put("name", attrs.getValue("name"));
+ vals.put("parent", attrs.getValue("parent"));
+ vals.put("source", attrs.getValue("source"));
+ vals.put("signature", attrs.getValue("signature"));
+ vals.put("interfaces", new ArrayList());
+ push(vals);
+ // values will be extracted in InterfacesRule.end();
+ }
+
+ }
+
+ private final class SourceRule extends Rule {
+
+ public void begin(String name, Attributes attrs) {
+ String file = attrs.getValue("file");
+ String debug = attrs.getValue("debug");
+ cw.visitSource(file, debug);
+ }
+
+ }
+
+ /**
+ * InterfaceRule
+ */
+ private final class InterfaceRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ ((List) ((Map) peek()).get("interfaces")).add(attrs.getValue("name"));
+ }
+
+ }
+
+ /**
+ * InterfacesRule
+ */
+ private final class InterfacesRule extends Rule {
+
+ public final void end(String element) {
+ Map vals = (Map) pop();
+ int version = ((Integer) vals.get("version")).intValue();
+ int access = getAccess((String) vals.get("access"));
+ String name = (String) vals.get("name");
+ String signature = (String) vals.get("signature");
+ String parent = (String) vals.get("parent");
+ List infs = (List) vals.get("interfaces");
+ String[] interfaces = (String[]) infs.toArray(new String[infs.size()]);
+ cw.visit(version, access, name, signature, parent, interfaces);
+ push(cw);
+ }
+
+ }
+
+ /**
+ * OuterClassRule
+ */
+ private final class OuterClassRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ String owner = attrs.getValue("owner");
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ cw.visitOuterClass(owner, name, desc);
+ }
+
+ }
+
+ /**
+ * InnerClassRule
+ */
+ private final class InnerClassRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ int access = getAccess(attrs.getValue("access"));
+ String name = attrs.getValue("name");
+ String outerName = attrs.getValue("outerName");
+ String innerName = attrs.getValue("innerName");
+ cw.visitInnerClass(name, outerName, innerName, access);
+ }
+
+ }
+
+ /**
+ * FieldRule
+ */
+ private final class FieldRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ int access = getAccess(attrs.getValue("access"));
+ String name = attrs.getValue("name");
+ String signature = attrs.getValue("signature");
+ String desc = attrs.getValue("desc");
+ Object value = getValue(desc, attrs.getValue("value"));
+ push(cw.visitField(access, name, desc, signature, value));
+ }
+
+ public void end(String name) {
+ ((FieldVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ /**
+ * MethodRule
+ */
+ private final class MethodRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ labels = new HashMap();
+ Map vals = new HashMap();
+ vals.put("access", attrs.getValue("access"));
+ vals.put("name", attrs.getValue("name"));
+ vals.put("desc", attrs.getValue("desc"));
+ vals.put("signature", attrs.getValue("signature"));
+ vals.put("exceptions", new ArrayList());
+ push(vals);
+ // values will be extracted in ExceptionsRule.end();
+ }
+
+ public final void end(String name) {
+ ((MethodVisitor) pop()).visitEnd();
+ labels = null;
+ }
+
+ }
+
+ /**
+ * ExceptionRule
+ */
+ private final class ExceptionRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ ((List) ((Map) peek()).get("exceptions")).add(attrs.getValue("name"));
+ }
+
+ }
+
+ /**
+ * ExceptionsRule
+ */
+ private final class ExceptionsRule extends Rule {
+
+ public final void end(String element) {
+ Map vals = (Map) pop();
+ int access = getAccess((String) vals.get("access"));
+ String name = (String) vals.get("name");
+ String desc = (String) vals.get("desc");
+ String signature = (String) vals.get("signature");
+ List excs = (List) vals.get("exceptions");
+ String[] exceptions = (String[]) excs.toArray(new String[excs.size()]);
+
+ push(cw.visitMethod(access, name, desc, signature, exceptions));
+ }
+
+ }
+
+ /**
+ * TableSwitchRule
+ */
+ private class TableSwitchRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Map vals = new HashMap();
+ vals.put("min", attrs.getValue("min"));
+ vals.put("max", attrs.getValue("max"));
+ vals.put("dflt", attrs.getValue("dflt"));
+ vals.put("labels", new ArrayList());
+ push(vals);
+ }
+
+ public final void end(String name) {
+ Map vals = (Map) pop();
+ int min = Integer.parseInt((String) vals.get("min"));
+ int max = Integer.parseInt((String) vals.get("max"));
+ Label dflt = getLabel(vals.get("dflt"));
+ List lbls = (List) vals.get("labels");
+ Label[] labels = (Label[]) lbls.toArray(new Label[lbls.size()]);
+ getCodeVisitor().visitTableSwitchInsn(min, max, dflt, labels);
+ }
+
+ }
+
+ /**
+ * TableSwitchLabelRule
+ */
+ private final class TableSwitchLabelRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ ((List) ((Map) peek()).get("labels")).add(getLabel(attrs.getValue("name")));
+ }
+
+ }
+
+ /**
+ * LookupSwitchRule
+ */
+ private final class LookupSwitchRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Map vals = new HashMap();
+ vals.put("dflt", attrs.getValue("dflt"));
+ vals.put("labels", new ArrayList());
+ vals.put("keys", new ArrayList());
+ push(vals);
+ }
+
+ public final void end(String name) {
+ Map vals = (Map) pop();
+ Label dflt = getLabel(vals.get("dflt"));
+ List keyList = (List) vals.get("keys");
+ List lbls = (List) vals.get("labels");
+ Label[] labels = (Label[]) lbls.toArray(new Label[lbls.size()]);
+ int[] keys = new int[keyList.size()];
+ for (int i = 0; i < keys.length; i++) {
+ keys[i] = Integer.parseInt((String) keyList.get(i));
+ }
+ getCodeVisitor().visitLookupSwitchInsn(dflt, keys, labels);
+ }
+
+ }
+
+ /**
+ * LookupSwitchLabelRule
+ */
+ private final class LookupSwitchLabelRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Map vals = (Map) peek();
+ ((List) vals.get("labels")).add(getLabel(attrs.getValue("name")));
+ ((List) vals.get("keys")).add(attrs.getValue("key"));
+ }
+
+ }
+
+ /**
+ * LabelRule
+ */
+ private final class LabelRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ getCodeVisitor().visitLabel(getLabel(attrs.getValue("name")));
+ }
+
+ }
+
+ /**
+ * TryCatchRule
+ */
+ private final class TryCatchRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Label start = getLabel(attrs.getValue("start"));
+ Label end = getLabel(attrs.getValue("end"));
+ Label handler = getLabel(attrs.getValue("handler"));
+ String type = attrs.getValue("type");
+ getCodeVisitor().visitTryCatchBlock(start, end, handler, type);
+ }
+
+ }
+
+ /**
+ * LineNumberRule
+ */
+ private final class LineNumberRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ int line = Integer.parseInt(attrs.getValue("line"));
+ Label start = getLabel(attrs.getValue("start"));
+ getCodeVisitor().visitLineNumber(line, start);
+ }
+
+ }
+
+ /**
+ * LocalVarRule
+ */
+ private final class LocalVarRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ String signature = attrs.getValue("signature");
+ Label start = getLabel(attrs.getValue("start"));
+ Label end = getLabel(attrs.getValue("end"));
+ int var = Integer.parseInt(attrs.getValue("var"));
+ getCodeVisitor().visitLocalVariable(name,
+ desc,
+ signature,
+ start,
+ end,
+ var);
+ }
+
+ }
+
+ /**
+ * OpcodesRule
+ */
+ private final class OpcodesRule extends Rule {
+
+ // public boolean match( String match, String element) {
+ // return match.startsWith( path) && OPCODES.containsKey( element);
+ // }
+
+ public final void begin(String element, Attributes attrs) {
+ Opcode o = ((Opcode) OPCODES.get(element));
+ if (o == null)
+ return;
+
+ switch (o.type) {
+ case OpcodeGroup.INSN:
+ getCodeVisitor().visitInsn(o.opcode);
+ break;
+
+ case OpcodeGroup.INSN_FIELD:
+ getCodeVisitor().visitFieldInsn(o.opcode,
+ attrs.getValue("owner"),
+ attrs.getValue("name"),
+ attrs.getValue("desc"));
+ break;
+
+ case OpcodeGroup.INSN_INT:
+ getCodeVisitor().visitIntInsn(o.opcode,
+ Integer.parseInt(attrs.getValue("value")));
+ break;
+
+ case OpcodeGroup.INSN_JUMP:
+ getCodeVisitor().visitJumpInsn(o.opcode,
+ getLabel(attrs.getValue("label")));
+ break;
+
+ case OpcodeGroup.INSN_METHOD:
+ getCodeVisitor().visitMethodInsn(o.opcode,
+ attrs.getValue("owner"),
+ attrs.getValue("name"),
+ attrs.getValue("desc"));
+ break;
+
+ case OpcodeGroup.INSN_TYPE:
+ getCodeVisitor().visitTypeInsn(o.opcode,
+ attrs.getValue("desc"));
+ break;
+
+ case OpcodeGroup.INSN_VAR:
+ getCodeVisitor().visitVarInsn(o.opcode,
+ Integer.parseInt(attrs.getValue("var")));
+ break;
+
+ case OpcodeGroup.INSN_IINC:
+ getCodeVisitor().visitIincInsn(Integer.parseInt(attrs.getValue("var")),
+ Integer.parseInt(attrs.getValue("inc")));
+ break;
+
+ case OpcodeGroup.INSN_LDC:
+ getCodeVisitor().visitLdcInsn(getValue(attrs.getValue("desc"),
+ attrs.getValue("cst")));
+ break;
+
+ case OpcodeGroup.INSN_MULTIANEWARRAY:
+ getCodeVisitor().visitMultiANewArrayInsn(attrs.getValue("desc"),
+ Integer.parseInt(attrs.getValue("dims")));
+ break;
+
+ default:
+ throw new RuntimeException("Invalid element: " + element
+ + " at " + match);
+
+ }
+ }
+ }
+
+ /**
+ * MaxRule
+ */
+ private final class MaxRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ int maxStack = Integer.parseInt(attrs.getValue("maxStack"));
+ int maxLocals = Integer.parseInt(attrs.getValue("maxLocals"));
+ getCodeVisitor().visitMaxs(maxStack, maxLocals);
+ }
+
+ }
+
+ private final class AnnotationRule extends Rule {
+
+ public void begin(String name, Attributes attrs) {
+ String desc = attrs.getValue("desc");
+ boolean visible = Boolean.valueOf(attrs.getValue("visible"))
+ .booleanValue();
+
+ Object v = peek();
+ if (v instanceof ClassVisitor) {
+ push(((ClassVisitor) v).visitAnnotation(desc, visible));
+ } else if (v instanceof FieldVisitor) {
+ push(((FieldVisitor) v).visitAnnotation(desc, visible));
+ } else if (v instanceof MethodVisitor) {
+ push(((MethodVisitor) v).visitAnnotation(desc, visible));
+ }
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationParameterRule extends Rule {
+
+ public void begin(String name, Attributes attrs) {
+ int parameter = Integer.parseInt(attrs.getValue("parameter"));
+ String desc = attrs.getValue("desc");
+ boolean visible = Boolean.valueOf(attrs.getValue("visible"))
+ .booleanValue();
+
+ push(((MethodVisitor) peek()).visitParameterAnnotation(parameter,
+ desc,
+ visible));
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationValueRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ String value = attrs.getValue("value");
+ ((AnnotationVisitor) peek()).visit(name, getValue(desc, value));
+ }
+
+ }
+
+ private final class AnnotationValueEnumRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ String value = attrs.getValue("value");
+ ((AnnotationVisitor) peek()).visitEnum(name, desc, value);
+ }
+
+ }
+
+ private final class AnnotationValueAnnotationRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ push(((AnnotationVisitor) peek()).visitAnnotation(name, desc));
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationValueArrayRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ push(((AnnotationVisitor) peek()).visitArray(name));
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationDefaultRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ push(((MethodVisitor) peek()).visitAnnotationDefault());
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ /**
+ * Opcode
+ */
+ private final static class Opcode {
+ public int opcode;
+
+ public int type;
+
+ public Opcode(int opcode, int type) {
+ this.opcode = opcode;
+ this.type = type;
+ }
+
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/Processor.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/Processor.java
new file mode 100644
index 000000000..28bf2ec95
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/Processor.java
@@ -0,0 +1,1048 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamSource;
+
+import org.objectweb.asm.ClassReader;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Processor is a command line tool that can be used for bytecode waving
+ * directed by XSL transformation. <p> In order to use a concrete XSLT engine,
+ * system property <tt>javax.xml.transform.TransformerFactory</tt> must be set
+ * to one of the following values.
+ *
+ * <blockquote> <table border="1" cellspacing="0" cellpadding="3"> <tr> <td>jd.xslt</td>
+ * <td>jd.xml.xslt.trax.TransformerFactoryImpl</td> </tr>
+ *
+ * <tr> <td>Saxon</td> <td>net.sf.saxon.TransformerFactoryImpl</td> </tr>
+ *
+ * <tr> <td>Caucho</td> <td>com.caucho.xsl.Xsl</td> </tr>
+ *
+ * <tr> <td>Xalan interpeter</td> <td>org.apache.xalan.processor.TransformerFactory</td>
+ * </tr>
+ *
+ * <tr> <td>Xalan xsltc</td> <td>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</td>
+ * </tr> </table> </blockquote>
+ *
+ * @author Eugene Kuleshov
+ */
+public class Processor {
+
+ public static final int BYTECODE = 1;
+
+ public static final int MULTI_XML = 2;
+
+ public static final int SINGLE_XML = 3;
+
+ private static final String SINGLE_XML_NAME = "classes.xml";
+
+ private int inRepresentation;
+
+ private int outRepresentation;
+
+ private InputStream input = null;
+
+ private OutputStream output = null;
+
+ private Source xslt = null;
+
+ private boolean computeMax;
+
+ private int n = 0;
+
+ public Processor(
+ int inRepresenation,
+ int outRepresentation,
+ InputStream input,
+ OutputStream output,
+ Source xslt)
+ {
+ this.inRepresentation = inRepresenation;
+ this.outRepresentation = outRepresentation;
+ this.input = input;
+ this.output = output;
+ this.xslt = xslt;
+ this.computeMax = true;
+ }
+
+ public int process() throws TransformerException, IOException, SAXException
+ {
+ ZipInputStream zis = new ZipInputStream(input);
+ final ZipOutputStream zos = new ZipOutputStream(output);
+ final OutputStreamWriter osw = new OutputStreamWriter(zos);
+
+ Thread.currentThread()
+ .setContextClassLoader(getClass().getClassLoader());
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+ if (!tf.getFeature(SAXSource.FEATURE)
+ || !tf.getFeature(SAXResult.FEATURE))
+ return 0;
+
+ SAXTransformerFactory saxtf = (SAXTransformerFactory) tf;
+ Templates templates = null;
+ if (xslt != null) {
+ templates = saxtf.newTemplates(xslt);
+ }
+
+ // configuring outHandlerFactory
+ // ///////////////////////////////////////////////////////
+
+ EntryElement entryElement = getEntryElement(zos);
+
+ ContentHandler outDocHandler = null;
+ switch (outRepresentation) {
+ case BYTECODE:
+ outDocHandler = new OutputSlicingHandler(new ASMContentHandlerFactory(zos,
+ computeMax),
+ entryElement,
+ false);
+ break;
+
+ case MULTI_XML:
+ outDocHandler = new OutputSlicingHandler(new SAXWriterFactory(osw,
+ true),
+ entryElement,
+ true);
+ break;
+
+ case SINGLE_XML:
+ ZipEntry outputEntry = new ZipEntry(SINGLE_XML_NAME);
+ zos.putNextEntry(outputEntry);
+ outDocHandler = new SAXWriter(osw, false);
+ break;
+
+ }
+
+ // configuring inputDocHandlerFactory
+ // /////////////////////////////////////////////////
+ ContentHandler inDocHandler = null;
+ if (templates == null) {
+ inDocHandler = outDocHandler;
+ } else {
+ inDocHandler = new InputSlicingHandler("class",
+ outDocHandler,
+ new TransformerHandlerFactory(saxtf,
+ templates,
+ outDocHandler));
+ }
+ ContentHandlerFactory inDocHandlerFactory = new SubdocumentHandlerFactory(inDocHandler);
+
+ if (inDocHandler != null && inRepresentation != SINGLE_XML) {
+ inDocHandler.startDocument();
+ inDocHandler.startElement("",
+ "classes",
+ "classes",
+ new AttributesImpl());
+ }
+
+ int i = 0;
+ ZipEntry ze = null;
+ while ((ze = zis.getNextEntry()) != null) {
+ update(ze.getName(), n++);
+ if (isClassEntry(ze)) {
+ processEntry(zis, ze, inDocHandlerFactory);
+ } else {
+ OutputStream os = entryElement.openEntry(getName(ze));
+ copyEntry(zis, os);
+ entryElement.closeEntry();
+ }
+
+ i++;
+ }
+
+ if (inDocHandler != null && inRepresentation != SINGLE_XML) {
+ inDocHandler.endElement("", "classes", "classes");
+ inDocHandler.endDocument();
+ }
+
+ if (outRepresentation == SINGLE_XML) {
+ zos.closeEntry();
+ }
+ zos.flush();
+ zos.close();
+
+ return i;
+ }
+
+ private void copyEntry(InputStream is, OutputStream os) throws IOException {
+ if (outRepresentation == SINGLE_XML)
+ return;
+
+ byte[] buff = new byte[2048];
+ int i;
+ while ((i = is.read(buff)) != -1) {
+ os.write(buff, 0, i);
+ }
+ }
+
+ private boolean isClassEntry(ZipEntry ze) {
+ String name = ze.getName();
+ return inRepresentation == SINGLE_XML && name.equals(SINGLE_XML_NAME)
+ || name.endsWith(".class") || name.endsWith(".class.xml");
+ }
+
+ private void processEntry(
+ final ZipInputStream zis,
+ ZipEntry ze,
+ ContentHandlerFactory handlerFactory)
+ {
+ ContentHandler handler = handlerFactory.createContentHandler();
+ try {
+
+ // if (CODE2ASM.equals(command)) { // read bytecode and process it
+ // // with TraceClassVisitor
+ // ClassReader cr = new ClassReader(readEntry(zis, ze));
+ // cr.accept(new TraceClassVisitor(null, new PrintWriter(os)),
+ // false);
+ // }
+
+ boolean singleInputDocument = inRepresentation == SINGLE_XML;
+ if (inRepresentation == BYTECODE) { // read bytecode and process it
+ // with handler
+ ClassReader cr = new ClassReader(readEntry(zis, ze));
+ cr.accept(new SAXClassAdapter(handler, singleInputDocument),
+ false);
+
+ } else { // read XML and process it with handler
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(singleInputDocument
+ ? (InputStream) new ProtectedInputStream(zis)
+ : new ByteArrayInputStream(readEntry(zis, ze))));
+
+ }
+ } catch (Exception ex) {
+ update(ze.getName(), 0);
+ update(ex, 0);
+ }
+ }
+
+ private EntryElement getEntryElement(ZipOutputStream zos) {
+ if (outRepresentation == SINGLE_XML) {
+ return new SingleDocElement(zos);
+ }
+ return new ZipEntryElement(zos);
+ }
+
+ // private ContentHandlerFactory getHandlerFactory(
+ // OutputStream os,
+ // SAXTransformerFactory saxtf,
+ // Templates templates)
+ // {
+ // ContentHandlerFactory factory = null;
+ // if (templates == null) {
+ // if (outputRepresentation == BYTECODE) { // factory used to write
+ // // bytecode
+ // factory = new ASMContentHandlerFactory(os, computeMax);
+ // } else { // factory used to write XML
+ // factory = new SAXWriterFactory(os, true);
+ // }
+ // } else {
+ // if (outputRepresentation == BYTECODE) { // factory used to transform
+ // // and then write bytecode
+ // factory = new ASMTransformerHandlerFactory(saxtf,
+ // templates,
+ // os,
+ // computeMax);
+ // } else { // factory used to transformand then write XML
+ // factory = new TransformerHandlerFactory(saxtf,
+ // templates,
+ // os,
+ // outputRepresentation == SINGLE_XML);
+ // }
+ // }
+ // return factory;
+ // }
+
+ private String getName(ZipEntry ze) {
+ String name = ze.getName();
+ if (isClassEntry(ze)) {
+ if (inRepresentation != BYTECODE && outRepresentation == BYTECODE) {
+ name = name.substring(0, name.length() - 4); // .class.xml to
+ // .class
+ } else if (inRepresentation == BYTECODE
+ && outRepresentation != BYTECODE)
+ {
+ name = name.concat(".xml"); // .class to .class.xml
+ }
+ // } else if( CODE2ASM.equals( command)) {
+ // name = name.substring( 0, name.length()-6).concat( ".asm");
+ }
+ return name;
+ }
+
+ private byte[] readEntry(ZipInputStream zis, ZipEntry ze)
+ throws IOException
+ {
+ long size = ze.getSize();
+ if (size > -1) {
+ byte[] buff = new byte[(int) size];
+ int k = 0;
+ int n;
+ while(( n = zis.read(buff, k, buff.length-k)) > 0) {
+ k += n;
+ }
+ return buff;
+ }
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buff = new byte[4096];
+ int i;
+ while ((i = zis.read(buff)) != -1) {
+ bos.write(buff, 0, i);
+ }
+ return bos.toByteArray();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
+ */
+ protected void update(Object arg, int n) {
+ if (arg instanceof Throwable) {
+ ((Throwable) arg).printStackTrace();
+ } else {
+ if ((n % 100) == 0) {
+ System.err.println(n + " " + arg);
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (args.length < 2) {
+ showUsage();
+ return;
+ }
+
+ int inRepresentation = getRepresentation(args[0]);
+ int outRepresentation = getRepresentation(args[1]);
+
+ InputStream is = System.in;
+ OutputStream os = new BufferedOutputStream(System.out);
+
+ Source xslt = null;
+ // boolean computeMax = true;
+
+ for (int i = 2; i < args.length; i++) {
+ if ("-in".equals(args[i])) {
+ is = new FileInputStream(args[++i]);
+
+ } else if ("-out".equals(args[i])) {
+ os = new BufferedOutputStream(new FileOutputStream(args[++i]));
+
+ } else if ("-xslt".equals(args[i])) {
+ xslt = new StreamSource(new FileInputStream(args[++i]));
+
+ // } else if( "-computemax".equals( args[ i].toLowerCase())) {
+ // computeMax = true;
+
+ } else {
+ showUsage();
+ return;
+
+ }
+ }
+
+ if (inRepresentation == 0 || outRepresentation == 0) {
+ showUsage();
+ return;
+ }
+
+ Processor m = new Processor(inRepresentation,
+ outRepresentation,
+ is,
+ os,
+ xslt);
+
+ long l1 = System.currentTimeMillis();
+ int n = m.process();
+ long l2 = System.currentTimeMillis();
+ System.err.println(n);
+ System.err.println("" + (l2 - l1) + "ms " + (1000f * n / (l2 - l1))
+ + " resources/sec");
+ }
+
+ private static int getRepresentation(String s) {
+ if ("code".equals(s)) {
+ return BYTECODE;
+ } else if ("xml".equals(s)) {
+ return MULTI_XML;
+ } else if ("singlexml".equals(s)) {
+ return SINGLE_XML;
+ }
+ return 0;
+ }
+
+ private static void showUsage() {
+ System.err.println("Usage: Main <in format> <out format> [-in <input jar>] [-out <output jar>] [-xslt <xslt file>]");
+ System.err.println(" when -in or -out is omitted sysin and sysout would be used");
+ System.err.println(" <in format> and <out format> - code | xml | singlexml");
+ }
+
+ /**
+ * IputStream wrapper class used to protect input streams from being closed
+ * by some stupid XML parsers.
+ */
+ private static final class ProtectedInputStream extends InputStream {
+ private final InputStream is;
+
+ private ProtectedInputStream(InputStream is) {
+ super();
+ this.is = is;
+ }
+
+ public final void close() throws IOException {
+ }
+
+ public final int read() throws IOException {
+ return is.read();
+ }
+
+ public final int read(byte[] b, int off, int len) throws IOException {
+ return is.read(b, off, len);
+ }
+
+ public final int available() throws IOException {
+ return is.available();
+ }
+ }
+
+ /**
+ * A {@link ContentHandlerFactory ContentHandlerFactory} is used to create
+ * {@link org.xml.sax.ContentHandler ContentHandler} instances for concrete
+ * context.
+ */
+ private static interface ContentHandlerFactory {
+
+ /**
+ * Creates an instance of the content handler.
+ *
+ * @return content handler
+ */
+ ContentHandler createContentHandler();
+
+ }
+
+ /**
+ * SAXWriterFactory
+ */
+ private static final class SAXWriterFactory implements
+ ContentHandlerFactory
+ {
+ private Writer w;
+
+ private boolean optimizeEmptyElements;
+
+ public SAXWriterFactory(Writer w, boolean optimizeEmptyElements) {
+ this.w = w;
+ this.optimizeEmptyElements = optimizeEmptyElements;
+ }
+
+ public final ContentHandler createContentHandler() {
+ return new SAXWriter(w, optimizeEmptyElements);
+ }
+
+ }
+
+ /**
+ * ASMContentHandlerFactory
+ */
+ private static final class ASMContentHandlerFactory implements
+ ContentHandlerFactory
+ {
+ private OutputStream os;
+
+ private boolean computeMax;
+
+ public ASMContentHandlerFactory(OutputStream os, boolean computeMax) {
+ this.os = os;
+ this.computeMax = computeMax;
+ }
+
+ public final ContentHandler createContentHandler() {
+ return new ASMContentHandler(os, computeMax);
+ }
+
+ }
+
+ /**
+ * TransformerHandlerFactory
+ */
+ private static final class TransformerHandlerFactory implements
+ ContentHandlerFactory
+ {
+ private SAXTransformerFactory saxtf;
+
+ private Templates templates;
+
+ private ContentHandler outputHandler;
+
+ public TransformerHandlerFactory(
+ SAXTransformerFactory saxtf,
+ Templates templates,
+ ContentHandler outputHandler)
+ {
+ this.saxtf = saxtf;
+ this.templates = templates;
+ this.outputHandler = outputHandler;
+ }
+
+ public final ContentHandler createContentHandler() {
+ try {
+ TransformerHandler handler = saxtf.newTransformerHandler(templates);
+ handler.setResult(new SAXResult(outputHandler));
+ return handler;
+ } catch (TransformerConfigurationException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+ }
+
+ /**
+ * SubdocumentHandlerFactory
+ */
+ private final static class SubdocumentHandlerFactory implements
+ ContentHandlerFactory
+ {
+ private ContentHandler subdocumentHandler;
+
+ public SubdocumentHandlerFactory(ContentHandler subdocumentHandler) {
+ this.subdocumentHandler = subdocumentHandler;
+ }
+
+ public final ContentHandler createContentHandler() {
+ return subdocumentHandler;
+ }
+
+ }
+
+ /**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} and
+ * {@link org.xml.sax.ext.LexicalHandler LexicalHandler} that serializes XML
+ * from SAX 2.0 events into {@link java.io.Writer Writer}.
+ *
+ * <i><blockquote> This implementation does not support namespaces, entity
+ * definitions (uncluding DTD), CDATA and text elements. </blockquote></i>
+ */
+ private final static class SAXWriter extends DefaultHandler implements
+ LexicalHandler
+ {
+ private static final char[] OFF = " ".toCharArray();
+
+ private Writer w;
+
+ private boolean optimizeEmptyElements;
+
+ private boolean openElement = false;
+
+ private int ident = 0;
+
+ /**
+ * Creates <code>SAXWriter</code>.
+ *
+ * @param w writer
+ * @param optimizeEmptyElements if set to <code>true</code>, short
+ * XML syntax will be used for empty elements
+ */
+ public SAXWriter(Writer w, boolean optimizeEmptyElements) {
+ this.w = w;
+ this.optimizeEmptyElements = optimizeEmptyElements;
+ }
+
+ public final void startElement(
+ String ns,
+ String localName,
+ String qName,
+ Attributes atts) throws SAXException
+ {
+ try {
+ closeElement();
+
+ writeIdent();
+ w.write("<".concat(qName));
+ if (atts != null && atts.getLength() > 0)
+ writeAttributes(atts);
+
+ if (!optimizeEmptyElements) {
+ w.write(">\n");
+ } else {
+ openElement = true;
+ }
+ ident += 2;
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void endElement(String ns, String localName, String qName)
+ throws SAXException
+ {
+ ident -= 2;
+ try {
+ if (openElement) {
+ w.write("/>\n");
+ openElement = false;
+ } else {
+ writeIdent();
+ w.write("</" + qName + ">\n");
+ }
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void endDocument() throws SAXException {
+ try {
+ w.flush();
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void comment(char[] ch, int off, int len)
+ throws SAXException
+ {
+ try {
+ closeElement();
+
+ writeIdent();
+ w.write("<!-- ");
+ w.write(ch, off, len);
+ w.write(" -->\n");
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void startDTD(String arg0, String arg1, String arg2)
+ throws SAXException
+ {
+ }
+
+ public final void endDTD() throws SAXException {
+ }
+
+ public final void startEntity(String arg0) throws SAXException {
+ }
+
+ public final void endEntity(String arg0) throws SAXException {
+ }
+
+ public final void startCDATA() throws SAXException {
+ }
+
+ public final void endCDATA() throws SAXException {
+ }
+
+ private final void writeAttributes(Attributes atts) throws IOException {
+ StringBuffer sb = new StringBuffer();
+ int len = atts.getLength();
+ for (int i = 0; i < len; i++) {
+ sb.append(" ")
+ .append(atts.getLocalName(i))
+ .append("=\"")
+ .append(esc(atts.getValue(i)))
+ .append("\"");
+ }
+ w.write(sb.toString());
+ }
+
+ /**
+ * Encode string with escaping.
+ *
+ * @param str string to encode.
+ * @return encoded string
+ */
+ private final String esc(String str) {
+ StringBuffer sb = new StringBuffer(str.length());
+ for (int i = 0; i < str.length(); i++) {
+ char ch = str.charAt(i);
+ switch (ch) {
+ case '&':
+ sb.append("&amp;");
+ break;
+
+ case '<':
+ sb.append("&lt;");
+ break;
+
+ case '>':
+ sb.append("&gt;");
+ break;
+
+ case '\"':
+ sb.append("&quot;");
+ break;
+
+ default:
+ if (ch > 0x7f) {
+ sb.append("&#")
+ .append(Integer.toString(ch))
+ .append(';');
+ } else {
+ sb.append(ch);
+ }
+
+ }
+ }
+ return sb.toString();
+ }
+
+ private final void writeIdent() throws IOException {
+ int n = ident;
+ while (n > 0) {
+ if (n > OFF.length) {
+ w.write(OFF);
+ n -= OFF.length;
+ } else {
+ w.write(OFF, 0, n);
+ n = 0;
+ }
+ }
+ }
+
+ private final void closeElement() throws IOException {
+ if (openElement) {
+ w.write(">\n");
+ }
+ openElement = false;
+ }
+
+ }
+
+ /**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} that splits XML
+ * documents into smaller chunks. Each chunk is processed by the nested
+ * {@link org.xml.sax.ContentHandler ContentHandler} obtained from
+ * {@link java.net.ContentHandlerFactory ContentHandlerFactory}. This is
+ * useful for running XSLT engine against large XML document that will
+ * hardly fit into the memory all together. <p> TODO use complete path for
+ * subdocumentRoot
+ */
+ private final static class InputSlicingHandler extends DefaultHandler {
+ private String subdocumentRoot;
+
+ private ContentHandler rootHandler;
+
+ private ContentHandlerFactory subdocumentHandlerFactory;
+
+ private boolean subdocument = false;
+
+ private ContentHandler subdocumentHandler;
+
+ /**
+ * Constructs a new {@link InputSlicingHandler SubdocumentHandler}
+ * object.
+ *
+ * @param subdocumentRoot name/path to the root element of the
+ * subdocument
+ * @param rootHandler content handler for the entire document
+ * (subdocument envelope).
+ * @param subdocumentHandlerFactory a
+ * {@link ContentHandlerFactory ContentHandlerFactory} used to
+ * create {@link ContentHandler ContentHandler} instances for
+ * subdocuments.
+ */
+ public InputSlicingHandler(
+ String subdocumentRoot,
+ ContentHandler rootHandler,
+ ContentHandlerFactory subdocumentHandlerFactory)
+ {
+ this.subdocumentRoot = subdocumentRoot;
+ this.rootHandler = rootHandler;
+ this.subdocumentHandlerFactory = subdocumentHandlerFactory;
+ }
+
+ public final void startElement(
+ String namespaceURI,
+ String localName,
+ String qName,
+ Attributes list) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ } else if (localName.equals(subdocumentRoot)) {
+ subdocumentHandler = subdocumentHandlerFactory.createContentHandler();
+ subdocumentHandler.startDocument();
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ subdocument = true;
+ } else if (rootHandler != null) {
+ rootHandler.startElement(namespaceURI, localName, qName, list);
+ }
+ }
+
+ public final void endElement(
+ String namespaceURI,
+ String localName,
+ String qName) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.endElement(namespaceURI, localName, qName);
+ if (localName.equals(subdocumentRoot)) {
+ subdocumentHandler.endDocument();
+ subdocument = false;
+ }
+ } else if (rootHandler != null) {
+ rootHandler.endElement(namespaceURI, localName, qName);
+ }
+ }
+
+ public final void startDocument() throws SAXException {
+ if (rootHandler != null) {
+ rootHandler.startDocument();
+ }
+ }
+
+ public final void endDocument() throws SAXException {
+ if (rootHandler != null) {
+ rootHandler.endDocument();
+
+ }
+ }
+
+ public final void characters(char[] buff, int offset, int size)
+ throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.characters(buff, offset, size);
+ } else if (rootHandler != null) {
+ rootHandler.characters(buff, offset, size);
+ }
+ }
+
+ }
+
+ /**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} that splits XML
+ * documents into smaller chunks. Each chunk is processed by the nested
+ * {@link org.xml.sax.ContentHandler ContentHandler} obtained from
+ * {@link java.net.ContentHandlerFactory ContentHandlerFactory}. This is
+ * useful for running XSLT engine against large XML document that will
+ * hardly fit into the memory all together. <p> TODO use complete path for
+ * subdocumentRoot
+ */
+ private static final class OutputSlicingHandler extends DefaultHandler {
+ private String subdocumentRoot;
+
+ private ContentHandlerFactory subdocumentHandlerFactory;
+
+ private EntryElement entryElement;
+
+ private boolean isXml;
+
+ private boolean subdocument = false;
+
+ private ContentHandler subdocumentHandler;
+
+ /**
+ * Constructs a new {@link OutputSlicingHandler SubdocumentHandler}
+ * object.
+ *
+ * @param subdocumentHandlerFactory a
+ * {@link ContentHandlerFactory ContentHandlerFactory} used to
+ * create {@link ContentHandler ContentHandler} instances for
+ * subdocuments.
+ * @param entryElement TODO.
+ * @param isXml TODO.
+ */
+ public OutputSlicingHandler(
+ ContentHandlerFactory subdocumentHandlerFactory,
+ EntryElement entryElement,
+ boolean isXml)
+ {
+ this.subdocumentRoot = "class";
+ this.subdocumentHandlerFactory = subdocumentHandlerFactory;
+ this.entryElement = entryElement;
+ this.isXml = isXml;
+ }
+
+ public final void startElement(
+ String namespaceURI,
+ String localName,
+ String qName,
+ Attributes list) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ } else if (localName.equals(subdocumentRoot)) {
+ String name = list.getValue("name");
+ if (name == null || name.length() == 0)
+ throw new SAXException("Class element without name attribute.");
+ try {
+ entryElement.openEntry(isXml
+ ? name.concat(".class.xml")
+ : name.concat(".class"));
+ } catch (IOException ex) {
+ throw new SAXException(ex.toString(), ex);
+ }
+ subdocumentHandler = subdocumentHandlerFactory.createContentHandler();
+ subdocumentHandler.startDocument();
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ subdocument = true;
+ }
+ }
+
+ public final void endElement(
+ String namespaceURI,
+ String localName,
+ String qName) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.endElement(namespaceURI, localName, qName);
+ if (localName.equals(subdocumentRoot)) {
+ subdocumentHandler.endDocument();
+ subdocument = false;
+ try {
+ entryElement.closeEntry();
+ } catch (IOException ex) {
+ throw new SAXException(ex.toString(), ex);
+ }
+ }
+ }
+ }
+
+ public final void startDocument() throws SAXException {
+ }
+
+ public final void endDocument() throws SAXException {
+ }
+
+ public final void characters(char[] buff, int offset, int size)
+ throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.characters(buff, offset, size);
+ }
+ }
+
+ }
+
+ private static interface EntryElement {
+
+ OutputStream openEntry(String name) throws IOException;
+
+ void closeEntry() throws IOException;
+
+ }
+
+ private static final class SingleDocElement implements EntryElement {
+ private OutputStream os;
+
+ public SingleDocElement(OutputStream os) {
+ this.os = os;
+ }
+
+ public OutputStream openEntry(String name) throws IOException {
+ return os;
+ }
+
+ public void closeEntry() throws IOException {
+ os.flush();
+ }
+
+ }
+
+ private static final class ZipEntryElement implements EntryElement {
+ private ZipOutputStream zos;
+
+ public ZipEntryElement(ZipOutputStream zos) {
+ this.zos = zos;
+ }
+
+ public OutputStream openEntry(String name) throws IOException {
+ ZipEntry entry = new ZipEntry(name);
+ zos.putNextEntry(entry);
+ return zos;
+ }
+
+ public void closeEntry() throws IOException {
+ zos.flush();
+ zos.closeEntry();
+ }
+
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java
new file mode 100644
index 000000000..5168fb574
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java
@@ -0,0 +1,91 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * SAXAdapter
+ *
+ * @author Eugene Kuleshov
+ */
+public abstract class SAXAdapter {
+ private final ContentHandler h;
+
+ public SAXAdapter(ContentHandler h) {
+ this.h = h;
+ }
+
+ protected ContentHandler getContentHandler() {
+ return h;
+ }
+
+ protected final void addEnd(String name) {
+ try {
+ h.endElement("", name, name);
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+ protected final void addStart(String name, Attributes attrs) {
+ try {
+ h.startElement("", name, name, attrs);
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+ protected final void addElement(String name, Attributes attrs) {
+ addStart(name, attrs);
+ addEnd(name);
+ }
+
+ protected void addDocumentStart() {
+ try {
+ h.startDocument();
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.getException());
+ }
+ }
+
+ protected void addDocumentEnd() {
+ try {
+ h.endDocument();
+ } catch (SAXException ex) {
+ // ex.getException().printStackTrace();
+ // ex.printStackTrace();
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java
new file mode 100644
index 000000000..6e9605c93
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java
@@ -0,0 +1,191 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Type;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * SAXAnnotationAdapter
+ *
+ * @author Eugene Kuleshov
+ */
+public class SAXAnnotationAdapter extends SAXAdapter implements
+ AnnotationVisitor
+{
+ private final String elementName;
+
+ public SAXAnnotationAdapter(
+ ContentHandler h,
+ String elementName,
+ int visible,
+ String name,
+ String desc)
+ {
+ this(h, elementName, visible, desc, name, -1);
+ }
+
+ public SAXAnnotationAdapter(
+ ContentHandler h,
+ String elementName,
+ int visible,
+ int parameter,
+ String desc)
+ {
+ this(h, elementName, visible, desc, null, parameter);
+ }
+
+ private SAXAnnotationAdapter(
+ ContentHandler h,
+ String elementName,
+ int visible,
+ String desc,
+ String name,
+ int parameter)
+ {
+ super(h);
+ this.elementName = elementName;
+
+ AttributesImpl att = new AttributesImpl();
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (visible != 0)
+ att.addAttribute("", "visible", "visible", "", visible > 0
+ ? "true"
+ : "false");
+ if (parameter != -1)
+ att.addAttribute("",
+ "parameter",
+ "parameter",
+ "",
+ Integer.toString(parameter));
+ if (desc != null)
+ att.addAttribute("", "desc", "desc", "", desc);
+
+ addStart(elementName, att);
+ }
+
+ public void visit(String name, Object value) {
+ Class c = value.getClass();
+ if (c.isArray()) {
+ AnnotationVisitor av = visitArray(name);
+ if (value instanceof byte[]) {
+ byte[] b = (byte[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Byte(b[i]));
+
+ } else if (value instanceof char[]) {
+ char[] b = (char[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Character(b[i]));
+
+ } else if (value instanceof boolean[]) {
+ boolean[] b = (boolean[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, Boolean.valueOf(b[i]));
+
+ } else if (value instanceof int[]) {
+ int[] b = (int[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Integer(b[i]));
+
+ } else if (value instanceof long[]) {
+ long[] b = (long[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Long(b[i]));
+
+ } else if (value instanceof float[]) {
+ float[] b = (float[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Float(b[i]));
+
+ } else if (value instanceof double[]) {
+ double[] b = (double[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Double(b[i]));
+
+ }
+ av.visitEnd();
+ } else {
+ addValueElement("annotationValue",
+ name,
+ Type.getDescriptor(c),
+ value.toString());
+ }
+ }
+
+ public void visitEnum(String name, String desc, String value) {
+ addValueElement("annotationValueEnum", name, desc, value);
+ }
+
+ public AnnotationVisitor visitAnnotation(String name, String desc) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotationValueAnnotation",
+ 0,
+ name,
+ desc);
+ }
+
+ public AnnotationVisitor visitArray(String name) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotationValueArray",
+ 0,
+ name,
+ null);
+ }
+
+ public void visitEnd() {
+ addEnd(elementName);
+ }
+
+ private void addValueElement(
+ String element,
+ String name,
+ String desc,
+ String value)
+ {
+ AttributesImpl att = new AttributesImpl();
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (desc != null)
+ att.addAttribute("", "desc", "desc", "", desc);
+ if (value != null)
+ att.addAttribute("",
+ "value",
+ "value",
+ "",
+ SAXClassAdapter.encode(value));
+
+ addElement(element, att);
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java
new file mode 100644
index 000000000..55b9effe7
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java
@@ -0,0 +1,351 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * A {@link org.objectweb.asm.ClassVisitor ClassVisitor} that generates SAX 2.0
+ * events from the visited class. It can feed any kind of
+ * {@link org.xml.sax.ContentHandler ContentHandler}, e.g. XML serializer, XSLT
+ * or XQuery engines.
+ *
+ * @see org.objectweb.asm.xml.Processor
+ * @see org.objectweb.asm.xml.ASMContentHandler
+ *
+ * @author Eugene Kuleshov
+ */
+public final class SAXClassAdapter extends SAXAdapter implements ClassVisitor {
+ private boolean singleDocument;
+
+ /**
+ * Constructs a new {@link SAXClassAdapter SAXClassAdapter} object.
+ *
+ * @param h content handler that will be used to send SAX 2.0 events.
+ * @param singleDocument if <tt>true</tt> adapter will not produce
+ * {@link ContentHandler#startDocument() startDocument()} and
+ * {@link ContentHandler#endDocument() endDocument()} events.
+ */
+ public SAXClassAdapter(ContentHandler h, boolean singleDocument) {
+ super(h);
+ this.singleDocument = singleDocument;
+ if (!singleDocument) {
+ addDocumentStart();
+ }
+ }
+
+ public void visitSource(String source, String debug) {
+ if (source == null && debug == null) {
+ return;
+ }
+
+ AttributesImpl att = new AttributesImpl();
+ if (source != null)
+ att.addAttribute("", "file", "file", "", encode(source));
+ if (debug != null)
+ att.addAttribute("", "debug", "debug", "", encode(debug));
+
+ addElement("source", att);
+ }
+
+ public void visitOuterClass(String owner, String name, String desc) {
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "owner", "owner", "", owner);
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (desc != null)
+ att.addAttribute("", "desc", "desc", "", desc);
+
+ addElement("outerclass", att);
+ }
+
+ public final void visitAttribute(Attribute attr) {
+ // TODO Auto-generated SAXClassAdapter.visitAttribute
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotation",
+ visible ? 1 : -1,
+ null,
+ desc);
+ }
+
+ public void visit(
+ int version,
+ int access,
+ String name,
+ String signature,
+ String superName,
+ String[] interfaces)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_SUPER) != 0)
+ sb.append("super ");
+ if ((access & Opcodes.ACC_INTERFACE) != 0)
+ sb.append("interface ");
+ if ((access & Opcodes.ACC_ABSTRACT) != 0)
+ sb.append("abstract ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_ANNOTATION) != 0)
+ sb.append("annotation ");
+ if ((access & Opcodes.ACC_ENUM) != 0)
+ sb.append("enum ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "access", "access", "", sb.toString());
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (signature != null)
+ att.addAttribute("",
+ "signature",
+ "signature",
+ "",
+ encode(signature));
+ if (superName != null)
+ att.addAttribute("", "parent", "parent", "", superName);
+ att.addAttribute("",
+ "major",
+ "major",
+ "",
+ Integer.toString(version & 0xFFFF));
+ att.addAttribute("",
+ "minor",
+ "minor",
+ "",
+ Integer.toString(version >>> 16));
+ addStart("class", att);
+
+ addStart("interfaces", new AttributesImpl());
+ if (interfaces != null && interfaces.length > 0) {
+ for (int i = 0; i < interfaces.length; i++) {
+ AttributesImpl att2 = new AttributesImpl();
+ att2.addAttribute("", "name", "name", "", interfaces[i]);
+ addElement("interface", att2);
+ }
+ }
+ addEnd("interfaces");
+ }
+
+ public FieldVisitor visitField(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ Object value)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_STATIC) != 0)
+ sb.append("static ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_VOLATILE) != 0)
+ sb.append("volatile ");
+ if ((access & Opcodes.ACC_TRANSIENT) != 0)
+ sb.append("transient ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_ENUM) != 0)
+ sb.append("enum ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "access", "access", "", sb.toString());
+ att.addAttribute("", "name", "name", "", name);
+ att.addAttribute("", "desc", "desc", "", desc);
+ if (signature != null)
+ att.addAttribute("",
+ "signature",
+ "signature",
+ "",
+ encode(signature));
+ if (value != null) {
+ att.addAttribute("", "value", "value", "", encode(value.toString()));
+ }
+
+ return new SAXFieldAdapter(getContentHandler(), att);
+ }
+
+ public MethodVisitor visitMethod(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ String[] exceptions)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_STATIC) != 0)
+ sb.append("static ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_SYNCHRONIZED) != 0)
+ sb.append("synchronized ");
+ if ((access & Opcodes.ACC_BRIDGE) != 0)
+ sb.append("bridge ");
+ if ((access & Opcodes.ACC_VARARGS) != 0)
+ sb.append("varargs ");
+ if ((access & Opcodes.ACC_NATIVE) != 0)
+ sb.append("native ");
+ if ((access & Opcodes.ACC_ABSTRACT) != 0)
+ sb.append("abstract ");
+ if ((access & Opcodes.ACC_STRICT) != 0)
+ sb.append("strict ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "access", "access", "", sb.toString());
+ att.addAttribute("", "name", "name", "", name);
+ att.addAttribute("", "desc", "desc", "", desc);
+ if (signature != null) {
+ att.addAttribute("", "signature", "signature", "", signature);
+ }
+ addStart("method", att);
+
+ addStart("exceptions", new AttributesImpl());
+ if (exceptions != null && exceptions.length > 0) {
+ for (int i = 0; i < exceptions.length; i++) {
+ AttributesImpl att2 = new AttributesImpl();
+ att2.addAttribute("", "name", "name", "", exceptions[i]);
+ addElement("exception", att2);
+ }
+ }
+ addEnd("exceptions");
+
+ return new SAXCodeAdapter(getContentHandler(), access);
+ }
+
+ public final void visitInnerClass(
+ String name,
+ String outerName,
+ String innerName,
+ int access)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_STATIC) != 0)
+ sb.append("static ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_SUPER) != 0)
+ sb.append("super ");
+ if ((access & Opcodes.ACC_INTERFACE) != 0)
+ sb.append("interface ");
+ if ((access & Opcodes.ACC_ABSTRACT) != 0)
+ sb.append("abstract ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_ANNOTATION) != 0)
+ sb.append("annotation ");
+ if ((access & Opcodes.ACC_ENUM) != 0)
+ sb.append("enum ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "access", "access", "", sb.toString());
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (outerName != null)
+ att.addAttribute("", "outerName", "outerName", "", outerName);
+ if (innerName != null)
+ att.addAttribute("", "innerName", "innerName", "", innerName);
+ addElement("innerclass", att);
+ }
+
+ public final void visitEnd() {
+ addEnd("class");
+ if (!singleDocument) {
+ addDocumentEnd();
+ }
+ }
+
+ static final String encode(String s) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (c == '\\') {
+ sb.append("\\\\");
+ } else if (c < 0x20 || c > 0x7f) {
+ sb.append("\\u");
+ if (c < 0x10) {
+ sb.append("000");
+ } else if (c < 0x100) {
+ sb.append("00");
+ } else if (c < 0x1000) {
+ sb.append("0");
+ }
+ sb.append(Integer.toString(c, 16));
+ } else {
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java
new file mode 100644
index 000000000..decb492ff
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java
@@ -0,0 +1,310 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.util.AbstractVisitor;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * A {@link MethodVisitor} that generates SAX 2.0 events from the visited
+ * method.
+ *
+ * @see org.objectweb.asm.xml.SAXClassAdapter
+ * @see org.objectweb.asm.xml.Processor
+ *
+ * @author Eugene Kuleshov
+ */
+public final class SAXCodeAdapter extends SAXAdapter implements MethodVisitor {
+ private Map labelNames;
+
+ /**
+ * Constructs a new {@link SAXCodeAdapter SAXCodeAdapter} object.
+ *
+ * @param h content handler that will be used to send SAX 2.0 events.
+ * @param access
+ */
+ public SAXCodeAdapter(ContentHandler h, int access) {
+ super(h);
+ labelNames = new HashMap();
+
+ if ((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE | Opcodes.ACC_NATIVE)) == 0)
+ {
+ addStart("code", new AttributesImpl());
+ }
+ }
+
+ public final void visitCode() {
+ }
+
+ public final void visitInsn(int opcode) {
+ addElement(AbstractVisitor.OPCODES[opcode], new AttributesImpl());
+ }
+
+ public final void visitIntInsn(int opcode, int operand) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "value", "value", "", Integer.toString(operand));
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitVarInsn(int opcode, int var) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "var", "var", "", Integer.toString(var));
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitTypeInsn(int opcode, String desc) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitFieldInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "owner", "owner", "", owner);
+ attrs.addAttribute("", "name", "name", "", name);
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitMethodInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "owner", "owner", "", owner);
+ attrs.addAttribute("", "name", "name", "", name);
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitJumpInsn(int opcode, Label label) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "label", "label", "", getLabel(label));
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitLabel(Label label) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "name", "name", "", getLabel(label));
+ addElement("Label", attrs);
+ }
+
+ public final void visitLdcInsn(Object cst) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("",
+ "cst",
+ "cst",
+ "",
+ SAXClassAdapter.encode(cst.toString()));
+ attrs.addAttribute("",
+ "desc",
+ "desc",
+ "",
+ Type.getDescriptor(cst.getClass()));
+ addElement(AbstractVisitor.OPCODES[Opcodes.LDC], attrs);
+ }
+
+ public final void visitIincInsn(int var, int increment) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "var", "var", "", Integer.toString(var));
+ attrs.addAttribute("", "inc", "inc", "", Integer.toString(increment));
+ addElement(AbstractVisitor.OPCODES[Opcodes.IINC], attrs);
+ }
+
+ public final void visitTableSwitchInsn(
+ int min,
+ int max,
+ Label dflt,
+ Label[] labels)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "min", "min", "", Integer.toString(min));
+ attrs.addAttribute("", "max", "max", "", Integer.toString(max));
+ attrs.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
+ String o = AbstractVisitor.OPCODES[Opcodes.TABLESWITCH];
+ addStart(o, attrs);
+ for (int i = 0; i < labels.length; i++) {
+ AttributesImpl att2 = new AttributesImpl();
+ att2.addAttribute("", "name", "name", "", getLabel(labels[i]));
+ addElement("label", att2);
+ }
+ addEnd(o);
+ }
+
+ public final void visitLookupSwitchInsn(
+ Label dflt,
+ int[] keys,
+ Label[] labels)
+ {
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
+ String o = AbstractVisitor.OPCODES[Opcodes.LOOKUPSWITCH];
+ addStart(o, att);
+ for (int i = 0; i < labels.length; i++) {
+ AttributesImpl att2 = new AttributesImpl();
+ att2.addAttribute("", "name", "name", "", getLabel(labels[i]));
+ att2.addAttribute("", "key", "key", "", Integer.toString(keys[i]));
+ addElement("label", att2);
+ }
+ addEnd(o);
+ }
+
+ public final void visitMultiANewArrayInsn(String desc, int dims) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ attrs.addAttribute("", "dims", "dims", "", Integer.toString(dims));
+ addElement(AbstractVisitor.OPCODES[Opcodes.MULTIANEWARRAY], attrs);
+ }
+
+ public final void visitTryCatchBlock(
+ Label start,
+ Label end,
+ Label handler,
+ String type)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "start", "start", "", getLabel(start));
+ attrs.addAttribute("", "end", "end", "", getLabel(end));
+ attrs.addAttribute("", "handler", "handler", "", getLabel(handler));
+ if (type != null)
+ attrs.addAttribute("", "type", "type", "", type);
+ addElement("TryCatch", attrs);
+ }
+
+ public final void visitMaxs(int maxStack, int maxLocals) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("",
+ "maxStack",
+ "maxStack",
+ "",
+ Integer.toString(maxStack));
+ attrs.addAttribute("",
+ "maxLocals",
+ "maxLocals",
+ "",
+ Integer.toString(maxLocals));
+ addElement("Max", attrs);
+
+ addEnd("code");
+ }
+
+ public void visitLocalVariable(
+ String name,
+ String desc,
+ String signature,
+ Label start,
+ Label end,
+ int index)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "name", "name", "", name);
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ if (signature != null)
+ attrs.addAttribute("",
+ "signature",
+ "signature",
+ "",
+ SAXClassAdapter.encode(signature));
+ attrs.addAttribute("", "start", "start", "", getLabel(start));
+ attrs.addAttribute("", "end", "end", "", getLabel(end));
+ attrs.addAttribute("", "var", "var", "", Integer.toString(index));
+ addElement("LocalVar", attrs);
+ }
+
+ public final void visitLineNumber(int line, Label start) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "line", "line", "", Integer.toString(line));
+ attrs.addAttribute("", "start", "start", "", getLabel(start));
+ addElement("LineNumber", attrs);
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotationDefault",
+ 0,
+ null,
+ null);
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotation",
+ visible ? 1 : -1,
+ null,
+ desc);
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ int parameter,
+ String desc,
+ boolean visible)
+ {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "parameterAnnotation",
+ visible ? 1 : -1,
+ parameter,
+ desc);
+ }
+
+ public void visitEnd() {
+ addEnd("method");
+ }
+
+ public final void visitAttribute(Attribute attr) {
+ // TODO Auto-generated SAXCodeAdapter.visitAttribute
+ }
+
+ private final String getLabel(Label label) {
+ String name = (String) labelNames.get(label);
+ if (name == null) {
+ name = Integer.toString(labelNames.size());
+ labelNames.put(label, name);
+ }
+ return name;
+ }
+
+}
diff --git a/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java
new file mode 100644
index 000000000..edfba0401
--- /dev/null
+++ b/libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java
@@ -0,0 +1,77 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.FieldVisitor;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * SAXFieldAdapter
+ *
+ * @author Eugene Kuleshov
+ */
+public class SAXFieldAdapter implements FieldVisitor {
+ private final ContentHandler h;
+
+ public SAXFieldAdapter(ContentHandler h, AttributesImpl att) {
+ this.h = h;
+
+ try {
+ h.startElement("", "field", "field", att);
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return new SAXAnnotationAdapter(h,
+ "annotation",
+ visible ? 1 : -1,
+ null,
+ desc);
+ }
+
+ public void visitAttribute(Attribute attr) {
+ // TODO Auto-generated method stub
+ }
+
+ public void visitEnd() {
+ try {
+ h.endElement("", "field", "field");
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+}
diff --git a/libjava/classpath/tools/gappletviewer.in b/libjava/classpath/tools/gappletviewer.in
new file mode 100644
index 000000000..d957e4564
--- /dev/null
+++ b/libjava/classpath/tools/gappletviewer.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+## A simple shell script to launch the GNU Classpath appletviewer tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.appletviewer.Main "$@"
diff --git a/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.java b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.java
new file mode 100644
index 000000000..58d7b3f8a
--- /dev/null
+++ b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.java
@@ -0,0 +1,1962 @@
+// $ANTLR 2.7.7 (20080530): "java-expression.g" -> "JavaLexer.java"$
+
+ package gnu.classpath.tools.gjdoc.expr;
+
+import java.io.InputStream;
+import antlr.TokenStreamException;
+import antlr.TokenStreamIOException;
+import antlr.TokenStreamRecognitionException;
+import antlr.CharStreamException;
+import antlr.CharStreamIOException;
+import antlr.ANTLRException;
+import java.io.Reader;
+import java.util.Hashtable;
+import antlr.CharScanner;
+import antlr.InputBuffer;
+import antlr.ByteBuffer;
+import antlr.CharBuffer;
+import antlr.Token;
+import antlr.CommonToken;
+import antlr.RecognitionException;
+import antlr.NoViableAltForCharException;
+import antlr.MismatchedCharException;
+import antlr.TokenStream;
+import antlr.ANTLRHashString;
+import antlr.LexerSharedInputState;
+import antlr.collections.impl.BitSet;
+import antlr.SemanticException;
+
+public class JavaLexer extends antlr.CharScanner implements JavaTokenTypes, TokenStream
+ {
+public JavaLexer(InputStream in) {
+ this(new ByteBuffer(in));
+}
+public JavaLexer(Reader in) {
+ this(new CharBuffer(in));
+}
+public JavaLexer(InputBuffer ib) {
+ this(new LexerSharedInputState(ib));
+}
+public JavaLexer(LexerSharedInputState state) {
+ super(state);
+ caseSensitiveLiterals = true;
+ setCaseSensitive(true);
+ literals = new Hashtable();
+ literals.put(new ANTLRHashString("String", this), new Integer(55));
+ literals.put(new ANTLRHashString("final", this), new Integer(39));
+ literals.put(new ANTLRHashString("false", this), new Integer(84));
+ literals.put(new ANTLRHashString("true", this), new Integer(83));
+ literals.put(new ANTLRHashString("void", this), new Integer(46));
+ literals.put(new ANTLRHashString("float", this), new Integer(52));
+ literals.put(new ANTLRHashString("boolean", this), new Integer(47));
+ literals.put(new ANTLRHashString("long", this), new Integer(53));
+ literals.put(new ANTLRHashString("null", this), new Integer(85));
+ literals.put(new ANTLRHashString("short", this), new Integer(50));
+ literals.put(new ANTLRHashString("char", this), new Integer(49));
+ literals.put(new ANTLRHashString("abstract", this), new Integer(40));
+ literals.put(new ANTLRHashString("byte", this), new Integer(48));
+ literals.put(new ANTLRHashString("int", this), new Integer(51));
+ literals.put(new ANTLRHashString("double", this), new Integer(54));
+ literals.put(new ANTLRHashString("strictfp", this), new Integer(41));
+}
+
+public Token nextToken() throws TokenStreamException {
+ Token theRetToken=null;
+tryAgain:
+ for (;;) {
+ Token _token = null;
+ int _ttype = Token.INVALID_TYPE;
+ resetText();
+ try { // for char stream error handling
+ try { // for lexical error handling
+ switch ( LA(1)) {
+ case '?':
+ {
+ mQUESTION(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '(':
+ {
+ mLPAREN(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case ')':
+ {
+ mRPAREN(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '[':
+ {
+ mLBRACK(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case ']':
+ {
+ mRBRACK(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '{':
+ {
+ mLCURLY(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '}':
+ {
+ mRCURLY(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case ':':
+ {
+ mCOLON(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case ',':
+ {
+ mCOMMA(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '~':
+ {
+ mBNOT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case ';':
+ {
+ mSEMI(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\t': case '\n': case '\u000c': case '\r':
+ case ' ':
+ {
+ mWS(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\'':
+ {
+ mCHAR_LITERAL(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '"':
+ {
+ mSTRING_LITERAL(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '$': case 'A': case 'B': case 'C':
+ case 'D': case 'E': case 'F': case 'G':
+ case 'H': case 'I': case 'J': case 'K':
+ case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S':
+ case 'T': case 'U': case 'V': case 'W':
+ case 'X': case 'Y': case 'Z': case '_':
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p':
+ case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ {
+ mIDENT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '.': case '0': case '1': case '2':
+ case '3': case '4': case '5': case '6':
+ case '7': case '8': case '9':
+ {
+ mNUM_INT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ default:
+ if ((LA(1)=='>') && (LA(2)=='>') && (LA(3)=='>') && (LA(4)=='=')) {
+ mBSR_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='>') && (LA(2)=='>') && (LA(3)=='=')) {
+ mSR_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='>') && (LA(2)=='>') && (LA(3)=='>') && (true)) {
+ mBSR(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='<') && (LA(2)=='<') && (LA(3)=='=')) {
+ mSL_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='=') && (LA(2)=='=')) {
+ mEQUAL(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='!') && (LA(2)=='=')) {
+ mNOT_EQUAL(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='/') && (LA(2)=='=')) {
+ mDIV_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='+') && (LA(2)=='=')) {
+ mPLUS_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='+') && (LA(2)=='+')) {
+ mINC(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='-') && (LA(2)=='=')) {
+ mMINUS_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='-') && (LA(2)=='-')) {
+ mDEC(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='*') && (LA(2)=='=')) {
+ mSTAR_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='%') && (LA(2)=='=')) {
+ mMOD_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='>') && (LA(2)=='>') && (true)) {
+ mSR(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='>') && (LA(2)=='=')) {
+ mGE(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='<') && (LA(2)=='<') && (true)) {
+ mSL(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='<') && (LA(2)=='=')) {
+ mLE(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='^') && (LA(2)=='=')) {
+ mBXOR_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='|') && (LA(2)=='=')) {
+ mBOR_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='|') && (LA(2)=='|')) {
+ mLOR(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='&') && (LA(2)=='=')) {
+ mBAND_ASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='&') && (LA(2)=='&')) {
+ mLAND(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='/') && (LA(2)=='/')) {
+ mSL_COMMIT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='/') && (LA(2)=='*')) {
+ mML_COMMENT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='=') && (true)) {
+ mASSIGN(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='!') && (true)) {
+ mLNOT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='/') && (true)) {
+ mDIV(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='+') && (true)) {
+ mPLUS(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='-') && (true)) {
+ mMINUS(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='*') && (true)) {
+ mSTAR(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='%') && (true)) {
+ mMOD(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='>') && (true)) {
+ mGT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='<') && (true)) {
+ mLT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='^') && (true)) {
+ mBXOR(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='|') && (true)) {
+ mBOR(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='&') && (true)) {
+ mBAND(true);
+ theRetToken=_returnToken;
+ }
+ else {
+ if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
+ else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+ }
+ if ( _returnToken==null ) continue tryAgain; // found SKIP token
+ _ttype = _returnToken.getType();
+ _returnToken.setType(_ttype);
+ return _returnToken;
+ }
+ catch (RecognitionException e) {
+ throw new TokenStreamRecognitionException(e);
+ }
+ }
+ catch (CharStreamException cse) {
+ if ( cse instanceof CharStreamIOException ) {
+ throw new TokenStreamIOException(((CharStreamIOException)cse).io);
+ }
+ else {
+ throw new TokenStreamException(cse.getMessage());
+ }
+ }
+ }
+}
+
+ public final void mQUESTION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = QUESTION;
+ int _saveIndex;
+
+ match('?');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LPAREN;
+ int _saveIndex;
+
+ match('(');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mRPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = RPAREN;
+ int _saveIndex;
+
+ match(')');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LBRACK;
+ int _saveIndex;
+
+ match('[');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mRBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = RBRACK;
+ int _saveIndex;
+
+ match(']');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLCURLY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LCURLY;
+ int _saveIndex;
+
+ match('{');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mRCURLY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = RCURLY;
+ int _saveIndex;
+
+ match('}');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mCOLON(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = COLON;
+ int _saveIndex;
+
+ match(':');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = COMMA;
+ int _saveIndex;
+
+ match(',');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ASSIGN;
+ int _saveIndex;
+
+ match('=');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mEQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = EQUAL;
+ int _saveIndex;
+
+ match("==");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLNOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LNOT;
+ int _saveIndex;
+
+ match('!');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBNOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BNOT;
+ int _saveIndex;
+
+ match('~');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mNOT_EQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = NOT_EQUAL;
+ int _saveIndex;
+
+ match("!=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mDIV(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = DIV;
+ int _saveIndex;
+
+ match('/');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mDIV_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = DIV_ASSIGN;
+ int _saveIndex;
+
+ match("/=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = PLUS;
+ int _saveIndex;
+
+ match('+');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mPLUS_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = PLUS_ASSIGN;
+ int _saveIndex;
+
+ match("+=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mINC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = INC;
+ int _saveIndex;
+
+ match("++");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = MINUS;
+ int _saveIndex;
+
+ match('-');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mMINUS_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = MINUS_ASSIGN;
+ int _saveIndex;
+
+ match("-=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mDEC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = DEC;
+ int _saveIndex;
+
+ match("--");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSTAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = STAR;
+ int _saveIndex;
+
+ match('*');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSTAR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = STAR_ASSIGN;
+ int _saveIndex;
+
+ match("*=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mMOD(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = MOD;
+ int _saveIndex;
+
+ match('%');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mMOD_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = MOD_ASSIGN;
+ int _saveIndex;
+
+ match("%=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SR;
+ int _saveIndex;
+
+ match(">>");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SR_ASSIGN;
+ int _saveIndex;
+
+ match(">>=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBSR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BSR;
+ int _saveIndex;
+
+ match(">>>");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBSR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BSR_ASSIGN;
+ int _saveIndex;
+
+ match(">>>=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mGE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = GE;
+ int _saveIndex;
+
+ match(">=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mGT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = GT;
+ int _saveIndex;
+
+ match(">");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SL;
+ int _saveIndex;
+
+ match("<<");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSL_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SL_ASSIGN;
+ int _saveIndex;
+
+ match("<<=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LE;
+ int _saveIndex;
+
+ match("<=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LT;
+ int _saveIndex;
+
+ match('<');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBXOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BXOR;
+ int _saveIndex;
+
+ match('^');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBXOR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BXOR_ASSIGN;
+ int _saveIndex;
+
+ match("^=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BOR;
+ int _saveIndex;
+
+ match('|');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBOR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BOR_ASSIGN;
+ int _saveIndex;
+
+ match("|=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LOR;
+ int _saveIndex;
+
+ match("||");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBAND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BAND;
+ int _saveIndex;
+
+ match('&');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBAND_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BAND_ASSIGN;
+ int _saveIndex;
+
+ match("&=");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLAND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LAND;
+ int _saveIndex;
+
+ match("&&");
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSEMI(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SEMI;
+ int _saveIndex;
+
+ match(';');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = WS;
+ int _saveIndex;
+
+ {
+ int _cnt105=0;
+ _loop105:
+ do {
+ switch ( LA(1)) {
+ case ' ':
+ {
+ match(' ');
+ break;
+ }
+ case '\t':
+ {
+ match('\t');
+ break;
+ }
+ case '\u000c':
+ {
+ match('\f');
+ break;
+ }
+ case '\n': case '\r':
+ {
+ {
+ if ((LA(1)=='\r') && (LA(2)=='\n') && (true) && (true)) {
+ match("\r\n");
+ }
+ else if ((LA(1)=='\r') && (true) && (true) && (true)) {
+ match('\r');
+ }
+ else if ((LA(1)=='\n')) {
+ match('\n');
+ }
+ else {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+
+ }
+ if ( inputState.guessing==0 ) {
+ newline();
+ }
+ break;
+ }
+ default:
+ {
+ if ( _cnt105>=1 ) { break _loop105; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+ }
+ _cnt105++;
+ } while (true);
+ }
+ if ( inputState.guessing==0 ) {
+ _ttype = Token.SKIP;
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSL_COMMIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SL_COMMIT;
+ int _saveIndex;
+
+ match("//");
+ {
+ _loop109:
+ do {
+ if ((_tokenSet_0.member(LA(1)))) {
+ {
+ match(_tokenSet_0);
+ }
+ }
+ else {
+ break _loop109;
+ }
+
+ } while (true);
+ }
+ {
+ switch ( LA(1)) {
+ case '\n':
+ {
+ match('\n');
+ break;
+ }
+ case '\r':
+ {
+ match('\r');
+ {
+ if ((LA(1)=='\n')) {
+ match('\n');
+ }
+ else {
+ }
+
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+ _ttype = Token.SKIP; newline();
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mML_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ML_COMMENT;
+ int _saveIndex;
+
+ match("/*");
+ {
+ _loop115:
+ do {
+ if ((LA(1)=='\r') && (LA(2)=='\n') && ((LA(3) >= '\u0003' && LA(3) <= '\uffff')) && ((LA(4) >= '\u0003' && LA(4) <= '\uffff'))) {
+ match('\r');
+ match('\n');
+ if ( inputState.guessing==0 ) {
+ newline();
+ }
+ }
+ else if (((LA(1)=='*') && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')) && ((LA(3) >= '\u0003' && LA(3) <= '\uffff')))&&( LA(2)!='/' )) {
+ match('*');
+ }
+ else if ((LA(1)=='\r') && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')) && ((LA(3) >= '\u0003' && LA(3) <= '\uffff')) && (true)) {
+ match('\r');
+ if ( inputState.guessing==0 ) {
+ newline();
+ }
+ }
+ else if ((LA(1)=='\n')) {
+ match('\n');
+ if ( inputState.guessing==0 ) {
+ newline();
+ }
+ }
+ else if ((_tokenSet_1.member(LA(1)))) {
+ {
+ match(_tokenSet_1);
+ }
+ }
+ else {
+ break _loop115;
+ }
+
+ } while (true);
+ }
+ match("*/");
+ if ( inputState.guessing==0 ) {
+ _ttype = Token.SKIP;
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mCHAR_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = CHAR_LITERAL;
+ int _saveIndex;
+
+ match('\'');
+ {
+ if ((LA(1)=='\\')) {
+ mESC(false);
+ }
+ else if ((_tokenSet_2.member(LA(1)))) {
+ {
+ match(_tokenSet_2);
+ }
+ }
+ else {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+
+ }
+ match('\'');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ protected final void mESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ESC;
+ int _saveIndex;
+
+ match('\\');
+ {
+ switch ( LA(1)) {
+ case 'n':
+ {
+ match('n');
+ break;
+ }
+ case 'r':
+ {
+ match('r');
+ break;
+ }
+ case 't':
+ {
+ match('t');
+ break;
+ }
+ case 'b':
+ {
+ match('b');
+ break;
+ }
+ case 'f':
+ {
+ match('f');
+ break;
+ }
+ case '"':
+ {
+ match('"');
+ break;
+ }
+ case '\'':
+ {
+ match('\'');
+ break;
+ }
+ case '\\':
+ {
+ match('\\');
+ break;
+ }
+ case 'u':
+ {
+ {
+ int _cnt126=0;
+ _loop126:
+ do {
+ if ((LA(1)=='u')) {
+ match('u');
+ }
+ else {
+ if ( _cnt126>=1 ) { break _loop126; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt126++;
+ } while (true);
+ }
+ mHEX_DIGIT(false);
+ mHEX_DIGIT(false);
+ mHEX_DIGIT(false);
+ mHEX_DIGIT(false);
+ break;
+ }
+ case '0': case '1': case '2': case '3':
+ {
+ matchRange('0','3');
+ {
+ if (((LA(1) >= '0' && LA(1) <= '7')) && (_tokenSet_0.member(LA(2))) && (true) && (true)) {
+ matchRange('0','7');
+ {
+ if (((LA(1) >= '0' && LA(1) <= '7')) && (_tokenSet_0.member(LA(2))) && (true) && (true)) {
+ matchRange('0','7');
+ }
+ else if ((_tokenSet_0.member(LA(1))) && (true) && (true) && (true)) {
+ }
+ else {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+
+ }
+ }
+ else if ((_tokenSet_0.member(LA(1))) && (true) && (true) && (true)) {
+ }
+ else {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+
+ }
+ break;
+ }
+ case '4': case '5': case '6': case '7':
+ {
+ matchRange('4','7');
+ {
+ if (((LA(1) >= '0' && LA(1) <= '7')) && (_tokenSet_0.member(LA(2))) && (true) && (true)) {
+ matchRange('0','7');
+ }
+ else if ((_tokenSet_0.member(LA(1))) && (true) && (true) && (true)) {
+ }
+ else {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSTRING_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = STRING_LITERAL;
+ int _saveIndex;
+
+ match('"');
+ {
+ _loop122:
+ do {
+ if ((LA(1)=='\\')) {
+ mESC(false);
+ }
+ else if ((_tokenSet_3.member(LA(1)))) {
+ {
+ match(_tokenSet_3);
+ }
+ }
+ else {
+ break _loop122;
+ }
+
+ } while (true);
+ }
+ match('"');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ protected final void mHEX_DIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = HEX_DIGIT;
+ int _saveIndex;
+
+ {
+ switch ( LA(1)) {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ {
+ matchRange('0','9');
+ break;
+ }
+ case 'A': case 'B': case 'C': case 'D':
+ case 'E': case 'F':
+ {
+ matchRange('A','F');
+ break;
+ }
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f':
+ {
+ matchRange('a','f');
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ protected final void mVOCAB(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = VOCAB;
+ int _saveIndex;
+
+ matchRange('\3','\377');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mIDENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = IDENT;
+ int _saveIndex;
+
+ {
+ switch ( LA(1)) {
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p':
+ case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ {
+ matchRange('a','z');
+ break;
+ }
+ case 'A': case 'B': case 'C': case 'D':
+ case 'E': case 'F': case 'G': case 'H':
+ case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P':
+ case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ {
+ matchRange('A','Z');
+ break;
+ }
+ case '_':
+ {
+ match('_');
+ break;
+ }
+ case '$':
+ {
+ match('$');
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ {
+ _loop136:
+ do {
+ switch ( LA(1)) {
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p':
+ case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ {
+ matchRange('a','z');
+ break;
+ }
+ case 'A': case 'B': case 'C': case 'D':
+ case 'E': case 'F': case 'G': case 'H':
+ case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P':
+ case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ {
+ matchRange('A','Z');
+ break;
+ }
+ case '_':
+ {
+ match('_');
+ break;
+ }
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ {
+ matchRange('0','9');
+ break;
+ }
+ case '$':
+ {
+ match('$');
+ break;
+ }
+ default:
+ {
+ break _loop136;
+ }
+ }
+ } while (true);
+ }
+ _ttype = testLiteralsTable(_ttype);
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mNUM_INT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = NUM_INT;
+ int _saveIndex;
+ Token f1=null;
+ Token f2=null;
+ Token f3=null;
+ Token f4=null;
+ boolean isDecimal=false; Token t=null;
+
+ switch ( LA(1)) {
+ case '.':
+ {
+ match('.');
+ if ( inputState.guessing==0 ) {
+ _ttype = DOT;
+ }
+ {
+ if (((LA(1) >= '0' && LA(1) <= '9'))) {
+ {
+ int _cnt140=0;
+ _loop140:
+ do {
+ if (((LA(1) >= '0' && LA(1) <= '9'))) {
+ matchRange('0','9');
+ }
+ else {
+ if ( _cnt140>=1 ) { break _loop140; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt140++;
+ } while (true);
+ }
+ {
+ if ((LA(1)=='E'||LA(1)=='e')) {
+ mEXPONENT(false);
+ }
+ else {
+ }
+
+ }
+ {
+ if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) {
+ mFLOAT_SUFFIX(true);
+ f1=_returnToken;
+ if ( inputState.guessing==0 ) {
+ t=f1;
+ }
+ }
+ else {
+ }
+
+ }
+ if ( inputState.guessing==0 ) {
+
+ if (t != null && t.getText().toUpperCase().indexOf('F')>=0) {
+ _ttype = NUM_FLOAT;
+ }
+ else {
+ _ttype = NUM_DOUBLE; // assume double
+ }
+
+ }
+ }
+ else {
+ }
+
+ }
+ break;
+ }
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ {
+ {
+ switch ( LA(1)) {
+ case '0':
+ {
+ match('0');
+ if ( inputState.guessing==0 ) {
+ isDecimal = true;
+ }
+ {
+ if ((LA(1)=='X'||LA(1)=='x')) {
+ {
+ switch ( LA(1)) {
+ case 'x':
+ {
+ match('x');
+ break;
+ }
+ case 'X':
+ {
+ match('X');
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ {
+ int _cnt147=0;
+ _loop147:
+ do {
+ if ((_tokenSet_4.member(LA(1))) && (true) && (true) && (true)) {
+ mHEX_DIGIT(false);
+ }
+ else {
+ if ( _cnt147>=1 ) { break _loop147; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt147++;
+ } while (true);
+ }
+ }
+ else {
+ boolean synPredMatched152 = false;
+ if ((((LA(1) >= '0' && LA(1) <= '9')) && (true) && (true) && (true))) {
+ int _m152 = mark();
+ synPredMatched152 = true;
+ inputState.guessing++;
+ try {
+ {
+ {
+ int _cnt150=0;
+ _loop150:
+ do {
+ if (((LA(1) >= '0' && LA(1) <= '9'))) {
+ matchRange('0','9');
+ }
+ else {
+ if ( _cnt150>=1 ) { break _loop150; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt150++;
+ } while (true);
+ }
+ {
+ switch ( LA(1)) {
+ case '.':
+ {
+ match('.');
+ break;
+ }
+ case 'E': case 'e':
+ {
+ mEXPONENT(false);
+ break;
+ }
+ case 'D': case 'F': case 'd': case 'f':
+ {
+ mFLOAT_SUFFIX(false);
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ }
+ }
+ catch (RecognitionException pe) {
+ synPredMatched152 = false;
+ }
+ rewind(_m152);
+inputState.guessing--;
+ }
+ if ( synPredMatched152 ) {
+ {
+ int _cnt154=0;
+ _loop154:
+ do {
+ if (((LA(1) >= '0' && LA(1) <= '9'))) {
+ matchRange('0','9');
+ }
+ else {
+ if ( _cnt154>=1 ) { break _loop154; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt154++;
+ } while (true);
+ }
+ }
+ else if (((LA(1) >= '0' && LA(1) <= '7')) && (true) && (true) && (true)) {
+ {
+ int _cnt156=0;
+ _loop156:
+ do {
+ if (((LA(1) >= '0' && LA(1) <= '7'))) {
+ matchRange('0','7');
+ }
+ else {
+ if ( _cnt156>=1 ) { break _loop156; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt156++;
+ } while (true);
+ }
+ }
+ else {
+ }
+ }
+ }
+ break;
+ }
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8':
+ case '9':
+ {
+ {
+ matchRange('1','9');
+ }
+ {
+ _loop159:
+ do {
+ if (((LA(1) >= '0' && LA(1) <= '9'))) {
+ matchRange('0','9');
+ }
+ else {
+ break _loop159;
+ }
+
+ } while (true);
+ }
+ if ( inputState.guessing==0 ) {
+ isDecimal=true;
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ {
+ if ((LA(1)=='L'||LA(1)=='l')) {
+ {
+ switch ( LA(1)) {
+ case 'l':
+ {
+ match('l');
+ break;
+ }
+ case 'L':
+ {
+ match('L');
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+ _ttype = NUM_LONG;
+ }
+ }
+ else if (((LA(1)=='.'||LA(1)=='D'||LA(1)=='E'||LA(1)=='F'||LA(1)=='d'||LA(1)=='e'||LA(1)=='f'))&&(isDecimal)) {
+ {
+ switch ( LA(1)) {
+ case '.':
+ {
+ match('.');
+ {
+ _loop164:
+ do {
+ if (((LA(1) >= '0' && LA(1) <= '9'))) {
+ matchRange('0','9');
+ }
+ else {
+ break _loop164;
+ }
+
+ } while (true);
+ }
+ {
+ if ((LA(1)=='E'||LA(1)=='e')) {
+ mEXPONENT(false);
+ }
+ else {
+ }
+
+ }
+ {
+ if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) {
+ mFLOAT_SUFFIX(true);
+ f2=_returnToken;
+ if ( inputState.guessing==0 ) {
+ t=f2;
+ }
+ }
+ else {
+ }
+
+ }
+ break;
+ }
+ case 'E': case 'e':
+ {
+ mEXPONENT(false);
+ {
+ if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) {
+ mFLOAT_SUFFIX(true);
+ f3=_returnToken;
+ if ( inputState.guessing==0 ) {
+ t=f3;
+ }
+ }
+ else {
+ }
+
+ }
+ break;
+ }
+ case 'D': case 'F': case 'd': case 'f':
+ {
+ mFLOAT_SUFFIX(true);
+ f4=_returnToken;
+ if ( inputState.guessing==0 ) {
+ t=f4;
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+
+ if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0) {
+ _ttype = NUM_FLOAT;
+ }
+ else {
+ _ttype = NUM_DOUBLE; // assume double
+ }
+
+ }
+ }
+ else {
+ }
+
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ protected final void mEXPONENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = EXPONENT;
+ int _saveIndex;
+
+ {
+ switch ( LA(1)) {
+ case 'e':
+ {
+ match('e');
+ break;
+ }
+ case 'E':
+ {
+ match('E');
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ {
+ switch ( LA(1)) {
+ case '+':
+ {
+ match('+');
+ break;
+ }
+ case '-':
+ {
+ match('-');
+ break;
+ }
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ }
+ {
+ int _cnt172=0;
+ _loop172:
+ do {
+ if (((LA(1) >= '0' && LA(1) <= '9'))) {
+ matchRange('0','9');
+ }
+ else {
+ if ( _cnt172>=1 ) { break _loop172; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt172++;
+ } while (true);
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ protected final void mFLOAT_SUFFIX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = FLOAT_SUFFIX;
+ int _saveIndex;
+
+ switch ( LA(1)) {
+ case 'f':
+ {
+ match('f');
+ break;
+ }
+ case 'F':
+ {
+ match('F');
+ break;
+ }
+ case 'd':
+ {
+ match('d');
+ break;
+ }
+ case 'D':
+ {
+ match('D');
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
+ }
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = new long[2048];
+ data[0]=-9224L;
+ for (int i = 1; i<=1023; i++) { data[i]=-1L; }
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+ private static final long[] mk_tokenSet_1() {
+ long[] data = new long[2048];
+ data[0]=-4398046520328L;
+ for (int i = 1; i<=1023; i++) { data[i]=-1L; }
+ return data;
+ }
+ public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
+ private static final long[] mk_tokenSet_2() {
+ long[] data = new long[2048];
+ data[0]=-549755823112L;
+ data[1]=-268435457L;
+ for (int i = 2; i<=1023; i++) { data[i]=-1L; }
+ return data;
+ }
+ public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
+ private static final long[] mk_tokenSet_3() {
+ long[] data = new long[2048];
+ data[0]=-17179878408L;
+ data[1]=-268435457L;
+ for (int i = 2; i<=1023; i++) { data[i]=-1L; }
+ return data;
+ }
+ public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
+ private static final long[] mk_tokenSet_4() {
+ long[] data = new long[1025];
+ data[0]=287948901175001088L;
+ data[1]=541165879422L;
+ return data;
+ }
+ public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
+
+ }
diff --git a/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.smap b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.smap
new file mode 100644
index 000000000..045e3e308
--- /dev/null
+++ b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.smap
@@ -0,0 +1,1280 @@
+SMAP
+JavaLexer.java
+G
+*S G
+*F
++ 0 java-expression.g
+java-expression.g
+*L
+0:75
+0:81
+0:87
+0:93
+0:99
+0:105
+0:111
+0:117
+0:123
+0:129
+0:135
+0:142
+0:148
+0:154
+0:173
+0:181
+0:187
+0:191
+0:195
+0:199
+0:203
+0:207
+0:211
+0:215
+0:219
+0:223
+0:227
+0:231
+0:235
+0:239
+0:243
+0:247
+0:251
+0:255
+0:259
+0:263
+0:267
+0:271
+0:275
+0:279
+0:283
+0:287
+0:291
+0:295
+0:299
+0:303
+0:307
+0:311
+0:315
+0:319
+0:323
+0:327
+19:3
+231:355
+231:356
+231:357
+231:358
+231:360
+231:361
+231:362
+231:363
+231:364
+231:365
+231:366
+232:368
+232:369
+232:370
+232:371
+232:373
+232:374
+232:375
+232:376
+232:377
+232:378
+232:379
+233:381
+233:382
+233:383
+233:384
+233:386
+233:387
+233:388
+233:389
+233:390
+233:391
+233:392
+234:394
+234:395
+234:396
+234:397
+234:399
+234:400
+234:401
+234:402
+234:403
+234:404
+234:405
+235:407
+235:408
+235:409
+235:410
+235:412
+235:413
+235:414
+235:415
+235:416
+235:417
+235:418
+236:420
+236:421
+236:422
+236:423
+236:425
+236:426
+236:427
+236:428
+236:429
+236:430
+236:431
+237:433
+237:434
+237:435
+237:436
+237:438
+237:439
+237:440
+237:441
+237:442
+237:443
+237:444
+238:446
+238:447
+238:448
+238:449
+238:451
+238:452
+238:453
+238:454
+238:455
+238:456
+238:457
+239:459
+239:460
+239:461
+239:462
+239:464
+239:465
+239:466
+239:467
+239:468
+239:469
+239:470
+241:472
+241:473
+241:474
+241:475
+241:477
+241:478
+241:479
+241:480
+241:481
+241:482
+241:483
+242:485
+242:486
+242:487
+242:488
+242:490
+242:491
+242:492
+242:493
+242:494
+242:495
+242:496
+243:498
+243:499
+243:500
+243:501
+243:503
+243:504
+243:505
+243:506
+243:507
+243:508
+243:509
+244:511
+244:512
+244:513
+244:514
+244:516
+244:517
+244:518
+244:519
+244:520
+244:521
+244:522
+245:524
+245:525
+245:526
+245:527
+245:529
+245:530
+245:531
+245:532
+245:533
+245:534
+245:535
+246:537
+246:538
+246:539
+246:540
+246:542
+246:543
+246:544
+246:545
+246:546
+246:547
+246:548
+247:550
+247:551
+247:552
+247:553
+247:555
+247:556
+247:557
+247:558
+247:559
+247:560
+247:561
+248:563
+248:564
+248:565
+248:566
+248:568
+248:569
+248:570
+248:571
+248:572
+248:573
+248:574
+249:576
+249:577
+249:578
+249:579
+249:581
+249:582
+249:583
+249:584
+249:585
+249:586
+249:587
+250:589
+250:590
+250:591
+250:592
+250:594
+250:595
+250:596
+250:597
+250:598
+250:599
+250:600
+251:602
+251:603
+251:604
+251:605
+251:607
+251:608
+251:609
+251:610
+251:611
+251:612
+251:613
+252:615
+252:616
+252:617
+252:618
+252:620
+252:621
+252:622
+252:623
+252:624
+252:625
+252:626
+253:628
+253:629
+253:630
+253:631
+253:633
+253:634
+253:635
+253:636
+253:637
+253:638
+253:639
+254:641
+254:642
+254:643
+254:644
+254:646
+254:647
+254:648
+254:649
+254:650
+254:651
+254:652
+255:654
+255:655
+255:656
+255:657
+255:659
+255:660
+255:661
+255:662
+255:663
+255:664
+255:665
+256:667
+256:668
+256:669
+256:670
+256:672
+256:673
+256:674
+256:675
+256:676
+256:677
+256:678
+257:680
+257:681
+257:682
+257:683
+257:685
+257:686
+257:687
+257:688
+257:689
+257:690
+257:691
+258:693
+258:694
+258:695
+258:696
+258:698
+258:699
+258:700
+258:701
+258:702
+258:703
+258:704
+259:706
+259:707
+259:708
+259:709
+259:711
+259:712
+259:713
+259:714
+259:715
+259:716
+259:717
+260:719
+260:720
+260:721
+260:722
+260:724
+260:725
+260:726
+260:727
+260:728
+260:729
+260:730
+261:732
+261:733
+261:734
+261:735
+261:737
+261:738
+261:739
+261:740
+261:741
+261:742
+261:743
+262:745
+262:746
+262:747
+262:748
+262:750
+262:751
+262:752
+262:753
+262:754
+262:755
+262:756
+263:758
+263:759
+263:760
+263:761
+263:763
+263:764
+263:765
+263:766
+263:767
+263:768
+263:769
+264:771
+264:772
+264:773
+264:774
+264:776
+264:777
+264:778
+264:779
+264:780
+264:781
+264:782
+265:784
+265:785
+265:786
+265:787
+265:789
+265:790
+265:791
+265:792
+265:793
+265:794
+265:795
+266:797
+266:798
+266:799
+266:800
+266:802
+266:803
+266:804
+266:805
+266:806
+266:807
+266:808
+267:810
+267:811
+267:812
+267:813
+267:815
+267:816
+267:817
+267:818
+267:819
+267:820
+267:821
+268:823
+268:824
+268:825
+268:826
+268:828
+268:829
+268:830
+268:831
+268:832
+268:833
+268:834
+269:836
+269:837
+269:838
+269:839
+269:841
+269:842
+269:843
+269:844
+269:845
+269:846
+269:847
+270:849
+270:850
+270:851
+270:852
+270:854
+270:855
+270:856
+270:857
+270:858
+270:859
+270:860
+271:862
+271:863
+271:864
+271:865
+271:867
+271:868
+271:869
+271:870
+271:871
+271:872
+271:873
+272:875
+272:876
+272:877
+272:878
+272:880
+272:881
+272:882
+272:883
+272:884
+272:885
+272:886
+273:888
+273:889
+273:890
+273:891
+273:893
+273:894
+273:895
+273:896
+273:897
+273:898
+273:899
+274:901
+274:902
+274:903
+274:904
+274:906
+274:907
+274:908
+274:909
+274:910
+274:911
+274:912
+275:914
+275:915
+275:916
+275:917
+275:919
+275:920
+275:921
+275:922
+275:923
+275:924
+275:925
+276:927
+276:928
+276:929
+276:930
+276:932
+276:933
+276:934
+276:935
+276:936
+276:937
+276:938
+280:940
+280:941
+280:942
+280:943
+280:946
+280:947
+280:948
+280:949
+280:950
+280:951
+280:952
+280:987
+280:988
+280:989
+280:990
+280:991
+280:992
+280:993
+280:994
+280:998
+280:999
+280:1000
+280:1001
+280:1002
+280:1003
+281:955
+281:956
+281:957
+282:960
+282:961
+282:962
+284:965
+284:966
+284:970
+284:973
+284:976
+284:977
+284:978
+284:979
+285:968
+285:969
+286:971
+286:972
+287:974
+287:975
+289:982
+289:983
+291:995
+291:996
+295:1005
+295:1006
+295:1007
+295:1008
+295:1054
+295:1055
+295:1056
+295:1057
+295:1058
+295:1059
+296:1010
+297:1011
+297:1012
+297:1013
+297:1014
+297:1016
+297:1018
+297:1019
+297:1020
+297:1021
+297:1023
+297:1024
+297:1026
+297:1027
+297:1028
+297:1029
+297:1032
+297:1033
+297:1034
+297:1036
+297:1037
+297:1038
+297:1040
+297:1045
+297:1046
+297:1047
+297:1048
+297:1049
+298:1051
+298:1052
+302:1061
+302:1062
+302:1063
+302:1064
+302:1107
+302:1108
+302:1109
+302:1110
+302:1111
+302:1112
+303:1066
+304:1067
+304:1068
+304:1069
+304:1076
+304:1079
+304:1085
+304:1091
+304:1096
+304:1097
+304:1098
+304:1099
+304:1101
+304:1102
+315:1077
+315:1078
+316:1070
+316:1071
+316:1072
+316:1073
+316:1074
+317:1080
+317:1081
+317:1082
+317:1083
+318:1086
+318:1087
+318:1088
+318:1089
+319:1092
+319:1094
+321:1103
+322:1104
+322:1105
+327:1114
+327:1115
+327:1116
+327:1117
+327:1135
+327:1136
+327:1137
+327:1138
+327:1139
+327:1140
+328:1119
+328:1121
+328:1122
+328:1123
+328:1124
+328:1126
+328:1128
+328:1129
+328:1130
+328:1131
+328:1134
+332:1268
+332:1269
+332:1270
+332:1271
+332:1292
+332:1293
+332:1294
+332:1295
+332:1296
+332:1297
+333:1273
+333:1274
+333:1275
+333:1276
+333:1277
+333:1278
+333:1279
+333:1280
+333:1282
+333:1284
+333:1285
+333:1286
+333:1287
+333:1289
+333:1290
+333:1291
+346:1142
+346:1143
+346:1144
+346:1145
+346:1261
+346:1262
+346:1263
+346:1264
+346:1265
+346:1266
+347:1147
+348:1149
+348:1150
+348:1151
+348:1152
+348:1255
+348:1256
+348:1257
+348:1258
+348:1259
+349:1155
+349:1156
+349:1157
+350:1160
+350:1161
+350:1162
+351:1165
+351:1166
+351:1167
+352:1170
+352:1171
+352:1172
+353:1175
+353:1176
+353:1177
+354:1180
+354:1181
+354:1182
+355:1185
+355:1186
+355:1187
+356:1190
+356:1191
+356:1193
+356:1194
+356:1195
+356:1196
+356:1197
+356:1198
+356:1199
+356:1200
+356:1201
+356:1203
+356:1204
+356:1205
+356:1206
+356:1207
+356:1208
+356:1209
+357:1212
+357:1213
+357:1214
+358:1229
+358:1231
+358:1232
+358:1233
+358:1234
+362:1216
+362:1217
+363:1221
+363:1223
+363:1224
+363:1225
+363:1226
+367:1219
+367:1220
+370:1239
+370:1240
+370:1241
+371:1245
+371:1247
+371:1248
+371:1249
+371:1250
+375:1243
+375:1244
+383:1299
+383:1300
+383:1301
+383:1302
+383:1331
+383:1332
+383:1333
+383:1334
+383:1335
+383:1336
+384:1305
+384:1306
+384:1307
+384:1308
+384:1309
+384:1310
+384:1313
+384:1314
+384:1315
+384:1316
+384:1319
+384:1320
+384:1321
+384:1322
+384:1325
+384:1326
+384:1327
+384:1328
+384:1329
+391:1338
+391:1339
+391:1340
+391:1341
+391:1344
+391:1345
+391:1346
+391:1347
+391:1348
+391:1349
+392:1343
+399:1351
+399:1352
+399:1353
+399:1354
+399:1446
+399:1447
+399:1448
+399:1449
+399:1450
+399:1451
+399:1452
+401:1357
+401:1358
+401:1359
+401:1360
+401:1361
+401:1362
+401:1363
+401:1364
+401:1365
+401:1366
+401:1369
+401:1370
+401:1371
+401:1372
+401:1373
+401:1374
+401:1375
+401:1376
+401:1377
+401:1380
+401:1381
+401:1382
+401:1385
+401:1386
+401:1387
+401:1390
+401:1391
+401:1392
+401:1393
+401:1394
+401:1396
+401:1397
+401:1398
+401:1399
+401:1400
+401:1401
+401:1402
+401:1403
+401:1404
+401:1405
+401:1406
+401:1407
+401:1408
+401:1411
+401:1412
+401:1413
+401:1414
+401:1415
+401:1416
+401:1417
+401:1418
+401:1419
+401:1422
+401:1423
+401:1424
+401:1427
+401:1428
+401:1429
+401:1430
+401:1431
+401:1434
+401:1435
+401:1436
+401:1439
+401:1440
+401:1441
+401:1442
+401:1443
+401:1444
+401:1445
+406:1454
+406:1455
+406:1456
+406:1457
+406:1462
+406:1464
+406:1805
+406:1806
+406:1807
+406:1808
+406:1809
+406:1810
+406:1811
+406:1812
+406:1813
+406:1814
+406:1815
+408:1465
+408:1466
+408:1467
+408:1468
+408:1469
+409:1458
+409:1472
+409:1474
+409:1475
+409:1476
+409:1477
+409:1478
+409:1479
+409:1480
+409:1481
+409:1482
+409:1484
+409:1485
+409:1486
+409:1488
+409:1489
+409:1490
+409:1492
+409:1496
+409:1497
+409:1498
+409:1499
+409:1500
+409:1502
+409:1504
+409:1517
+409:1519
+410:1507
+411:1509
+412:1510
+413:1511
+414:1512
+415:1513
+416:1514
+420:1524
+420:1525
+420:1526
+420:1527
+420:1529
+420:1530
+420:1531
+420:1532
+420:1533
+420:1534
+420:1686
+420:1687
+420:1688
+420:1689
+420:1690
+421:1537
+421:1539
+421:1540
+421:1541
+421:1542
+421:1545
+421:1546
+421:1547
+421:1550
+421:1551
+421:1552
+421:1553
+421:1554
+421:1570
+421:1639
+421:1655
+421:1657
+421:1658
+422:1557
+422:1558
+422:1559
+422:1562
+422:1563
+422:1564
+422:1565
+422:1567
+422:1568
+422:1569
+431:1560
+431:1561
+435:1571
+435:1572
+435:1573
+435:1574
+435:1575
+435:1576
+435:1577
+435:1580
+435:1581
+435:1582
+435:1583
+435:1584
+435:1585
+435:1586
+435:1587
+435:1588
+435:1590
+435:1591
+435:1592
+435:1594
+435:1595
+435:1596
+435:1597
+435:1600
+435:1601
+435:1602
+435:1605
+435:1606
+435:1607
+435:1610
+435:1611
+435:1612
+435:1613
+435:1614
+435:1617
+435:1618
+435:1619
+435:1620
+435:1621
+435:1622
+435:1623
+435:1624
+435:1626
+435:1627
+435:1628
+435:1629
+435:1630
+435:1631
+435:1632
+435:1633
+435:1634
+435:1636
+435:1637
+435:1638
+437:1640
+437:1642
+437:1643
+437:1644
+437:1645
+437:1646
+437:1647
+437:1648
+437:1649
+437:1650
+437:1652
+437:1653
+437:1654
+439:1662
+439:1663
+439:1664
+439:1665
+439:1667
+439:1669
+439:1670
+439:1671
+439:1672
+439:1673
+439:1674
+439:1675
+439:1676
+439:1677
+439:1679
+439:1680
+439:1681
+439:1682
+441:1693
+441:1695
+441:1696
+441:1697
+441:1698
+441:1701
+441:1702
+441:1703
+441:1706
+441:1707
+441:1708
+441:1709
+441:1710
+441:1712
+441:1713
+441:1715
+441:1798
+441:1800
+445:1459
+445:1716
+445:1718
+445:1719
+445:1720
+445:1721
+445:1722
+445:1723
+445:1724
+445:1725
+445:1726
+445:1727
+445:1728
+445:1729
+445:1730
+445:1732
+445:1733
+445:1735
+445:1736
+445:1737
+445:1739
+445:1743
+445:1744
+445:1745
+445:1746
+445:1747
+445:1749
+445:1751
+445:1782
+445:1783
+445:1784
+445:1785
+445:1786
+446:1460
+446:1756
+446:1757
+446:1758
+446:1760
+446:1761
+446:1762
+446:1763
+446:1764
+446:1766
+446:1768
+447:1461
+447:1773
+447:1774
+447:1775
+447:1776
+447:1777
+447:1778
+449:1788
+450:1790
+451:1791
+452:1792
+453:1793
+454:1794
+455:1795
+463:1817
+463:1818
+463:1819
+463:1820
+463:1878
+463:1879
+463:1880
+463:1881
+463:1882
+463:1883
+464:1823
+464:1824
+464:1825
+464:1826
+464:1829
+464:1830
+464:1831
+464:1834
+464:1835
+464:1836
+464:1837
+464:1838
+464:1841
+464:1842
+464:1843
+464:1844
+464:1847
+464:1848
+464:1849
+464:1858
+464:1859
+464:1860
+464:1861
+464:1862
+464:1865
+464:1866
+464:1867
+464:1868
+464:1869
+464:1870
+464:1871
+464:1872
+464:1873
+464:1875
+464:1876
+464:1877
+469:1885
+469:1886
+469:1887
+469:1888
+469:1890
+469:1911
+469:1912
+469:1913
+469:1914
+469:1915
+469:1916
+469:1917
+469:1918
+469:1919
+469:1920
+469:1921
+470:1891
+470:1892
+470:1893
+470:1896
+470:1897
+470:1898
+470:1901
+470:1902
+470:1903
+470:1906
+470:1907
+470:1908
+*E
diff --git a/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.java b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.java
new file mode 100644
index 000000000..bd43bf3b6
--- /dev/null
+++ b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.java
@@ -0,0 +1,1406 @@
+// $ANTLR 2.7.7 (20080530): "java-expression.g" -> "JavaRecognizer.java"$
+
+ package gnu.classpath.tools.gjdoc.expr;
+
+import antlr.TokenBuffer;
+import antlr.TokenStreamException;
+import antlr.TokenStreamIOException;
+import antlr.ANTLRException;
+import antlr.LLkParser;
+import antlr.Token;
+import antlr.TokenStream;
+import antlr.RecognitionException;
+import antlr.NoViableAltException;
+import antlr.MismatchedTokenException;
+import antlr.SemanticException;
+import antlr.ParserSharedInputState;
+import antlr.collections.impl.BitSet;
+import antlr.collections.AST;
+import java.util.Hashtable;
+import antlr.ASTFactory;
+import antlr.ASTPair;
+import antlr.collections.impl.ASTArray;
+
+public class JavaRecognizer extends antlr.LLkParser implements JavaTokenTypes
+ {
+
+protected JavaRecognizer(TokenBuffer tokenBuf, int k) {
+ super(tokenBuf,k);
+ tokenNames = _tokenNames;
+ buildTokenTypeASTClassMap();
+ astFactory = new ASTFactory(getTokenTypeToASTClassMap());
+}
+
+public JavaRecognizer(TokenBuffer tokenBuf) {
+ this(tokenBuf,2);
+}
+
+protected JavaRecognizer(TokenStream lexer, int k) {
+ super(lexer,k);
+ tokenNames = _tokenNames;
+ buildTokenTypeASTClassMap();
+ astFactory = new ASTFactory(getTokenTypeToASTClassMap());
+}
+
+public JavaRecognizer(TokenStream lexer) {
+ this(lexer,2);
+}
+
+public JavaRecognizer(ParserSharedInputState state) {
+ super(state,2);
+ tokenNames = _tokenNames;
+ buildTokenTypeASTClassMap();
+ astFactory = new ASTFactory(getTokenTypeToASTClassMap());
+}
+
+ public final Type builtInTypeSpec(
+ boolean addImagNode
+ ) throws RecognitionException, TokenStreamException {
+ Type t = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST builtInTypeSpec_AST = null;
+ Token lb = null;
+ AST lb_AST = null;
+
+ t=builtInType();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop3:
+ do {
+ if ((LA(1)==LBRACK)) {
+ lb = LT(1);
+ lb_AST = astFactory.create(lb);
+ astFactory.makeASTRoot(currentAST, lb_AST);
+ match(LBRACK);
+ if ( inputState.guessing==0 ) {
+ lb_AST.setType(ARRAY_DECLARATOR);
+ }
+ match(RBRACK);
+ }
+ else {
+ break _loop3;
+ }
+
+ } while (true);
+ }
+ if ( inputState.guessing==0 ) {
+ builtInTypeSpec_AST = (AST)currentAST.root;
+
+ if ( addImagNode ) {
+ builtInTypeSpec_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(TYPE,"TYPE")).add(builtInTypeSpec_AST));
+ }
+
+ currentAST.root = builtInTypeSpec_AST;
+ currentAST.child = builtInTypeSpec_AST!=null &&builtInTypeSpec_AST.getFirstChild()!=null ?
+ builtInTypeSpec_AST.getFirstChild() : builtInTypeSpec_AST;
+ currentAST.advanceChildToEnd();
+ }
+ builtInTypeSpec_AST = (AST)currentAST.root;
+ returnAST = builtInTypeSpec_AST;
+ return t;
+ }
+
+ public final Type builtInType() throws RecognitionException, TokenStreamException {
+ Type t = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST builtInType_AST = null;
+
+ switch ( LA(1)) {
+ case LITERAL_void:
+ {
+ AST tmp2_AST = null;
+ tmp2_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp2_AST);
+ match(LITERAL_void);
+ if ( inputState.guessing==0 ) {
+ t=Type.VOID;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_boolean:
+ {
+ AST tmp3_AST = null;
+ tmp3_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp3_AST);
+ match(LITERAL_boolean);
+ if ( inputState.guessing==0 ) {
+ t=Type.BOOLEAN;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_byte:
+ {
+ AST tmp4_AST = null;
+ tmp4_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp4_AST);
+ match(LITERAL_byte);
+ if ( inputState.guessing==0 ) {
+ t=Type.BYTE;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_char:
+ {
+ AST tmp5_AST = null;
+ tmp5_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp5_AST);
+ match(LITERAL_char);
+ if ( inputState.guessing==0 ) {
+ t=Type.CHAR;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_short:
+ {
+ AST tmp6_AST = null;
+ tmp6_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp6_AST);
+ match(LITERAL_short);
+ if ( inputState.guessing==0 ) {
+ t=Type.SHORT;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_int:
+ {
+ AST tmp7_AST = null;
+ tmp7_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp7_AST);
+ match(LITERAL_int);
+ if ( inputState.guessing==0 ) {
+ t=Type.INTEGER;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_float:
+ {
+ AST tmp8_AST = null;
+ tmp8_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp8_AST);
+ match(LITERAL_float);
+ if ( inputState.guessing==0 ) {
+ t=Type.FLOAT;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_long:
+ {
+ AST tmp9_AST = null;
+ tmp9_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp9_AST);
+ match(LITERAL_long);
+ if ( inputState.guessing==0 ) {
+ t=Type.LONG;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_double:
+ {
+ AST tmp10_AST = null;
+ tmp10_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp10_AST);
+ match(LITERAL_double);
+ if ( inputState.guessing==0 ) {
+ t=Type.DOUBLE;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_String:
+ {
+ AST tmp11_AST = null;
+ tmp11_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp11_AST);
+ match(LITERAL_String);
+ if ( inputState.guessing==0 ) {
+ t=Type.STRING;
+ }
+ builtInType_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ returnAST = builtInType_AST;
+ return t;
+ }
+
+ public final Type type() throws RecognitionException, TokenStreamException {
+ Type t;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST type_AST = null;
+
+ t=builtInType();
+ astFactory.addASTChild(currentAST, returnAST);
+ type_AST = (AST)currentAST.root;
+ returnAST = type_AST;
+ return t;
+ }
+
+ public final String identifier() throws RecognitionException, TokenStreamException {
+ String s = null;;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST identifier_AST = null;
+ Token i = null;
+ AST i_AST = null;
+ Token i2 = null;
+ AST i2_AST = null;
+
+ i = LT(1);
+ i_AST = astFactory.create(i);
+ astFactory.addASTChild(currentAST, i_AST);
+ match(IDENT);
+ if ( inputState.guessing==0 ) {
+ s=i.getText();
+ }
+ {
+ _loop8:
+ do {
+ if ((LA(1)==DOT)) {
+ AST tmp12_AST = null;
+ tmp12_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp12_AST);
+ match(DOT);
+ i2 = LT(1);
+ i2_AST = astFactory.create(i2);
+ astFactory.addASTChild(currentAST, i2_AST);
+ match(IDENT);
+ if ( inputState.guessing==0 ) {
+ s+="."+i2.getText();
+ }
+ }
+ else {
+ break _loop8;
+ }
+
+ } while (true);
+ }
+ identifier_AST = (AST)currentAST.root;
+ returnAST = identifier_AST;
+ return s;
+ }
+
+ public final Expression expression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST expression_AST = null;
+
+ e=conditionalExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ match(Token.EOF_TYPE);
+ expression_AST = (AST)currentAST.root;
+ returnAST = expression_AST;
+ return e;
+ }
+
+ public final Expression conditionalExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST conditionalExpression_AST = null;
+ Expression a,b,c;
+
+ e=logicalOrExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ switch ( LA(1)) {
+ case QUESTION:
+ {
+ AST tmp14_AST = null;
+ tmp14_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp14_AST);
+ match(QUESTION);
+ b=conditionalExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ match(COLON);
+ c=conditionalExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new ConditionalExpression(e,b,c);
+ }
+ break;
+ }
+ case EOF:
+ case COLON:
+ case RPAREN:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ conditionalExpression_AST = (AST)currentAST.root;
+ returnAST = conditionalExpression_AST;
+ return e;
+ }
+
+ public final Expression logicalOrExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST logicalOrExpression_AST = null;
+ Expression a,b;
+
+ e=logicalAndExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop14:
+ do {
+ if ((LA(1)==LOR)) {
+ AST tmp16_AST = null;
+ tmp16_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp16_AST);
+ match(LOR);
+ b=logicalAndExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new LogicalOrExpression(e,b);
+ }
+ }
+ else {
+ break _loop14;
+ }
+
+ } while (true);
+ }
+ logicalOrExpression_AST = (AST)currentAST.root;
+ returnAST = logicalOrExpression_AST;
+ return e;
+ }
+
+ public final Expression logicalAndExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST logicalAndExpression_AST = null;
+ Expression a,b;
+
+ e=inclusiveOrExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop17:
+ do {
+ if ((LA(1)==LAND)) {
+ AST tmp17_AST = null;
+ tmp17_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp17_AST);
+ match(LAND);
+ b=inclusiveOrExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new LogicalAndExpression(e,b);
+ }
+ }
+ else {
+ break _loop17;
+ }
+
+ } while (true);
+ }
+ logicalAndExpression_AST = (AST)currentAST.root;
+ returnAST = logicalAndExpression_AST;
+ return e;
+ }
+
+ public final Expression inclusiveOrExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST inclusiveOrExpression_AST = null;
+ Expression a,b;
+
+ e=exclusiveOrExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop20:
+ do {
+ if ((LA(1)==BOR)) {
+ AST tmp18_AST = null;
+ tmp18_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp18_AST);
+ match(BOR);
+ b=exclusiveOrExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new InclusiveOrExpression(e,b);
+ }
+ }
+ else {
+ break _loop20;
+ }
+
+ } while (true);
+ }
+ inclusiveOrExpression_AST = (AST)currentAST.root;
+ returnAST = inclusiveOrExpression_AST;
+ return e;
+ }
+
+ public final Expression exclusiveOrExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST exclusiveOrExpression_AST = null;
+ Expression a,b;
+
+ e=andExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop23:
+ do {
+ if ((LA(1)==BXOR)) {
+ AST tmp19_AST = null;
+ tmp19_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp19_AST);
+ match(BXOR);
+ b=andExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new ExclusiveOrExpression(e,b);
+ }
+ }
+ else {
+ break _loop23;
+ }
+
+ } while (true);
+ }
+ exclusiveOrExpression_AST = (AST)currentAST.root;
+ returnAST = exclusiveOrExpression_AST;
+ return e;
+ }
+
+ public final Expression andExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST andExpression_AST = null;
+ Expression a,b;
+
+ e=equalityExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop26:
+ do {
+ if ((LA(1)==BAND)) {
+ AST tmp20_AST = null;
+ tmp20_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp20_AST);
+ match(BAND);
+ b=equalityExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new AndExpression(e,b);
+ }
+ }
+ else {
+ break _loop26;
+ }
+
+ } while (true);
+ }
+ andExpression_AST = (AST)currentAST.root;
+ returnAST = andExpression_AST;
+ return e;
+ }
+
+ public final Expression equalityExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST equalityExpression_AST = null;
+ Expression a,b;
+
+ e=relationalExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop30:
+ do {
+ if ((LA(1)==NOT_EQUAL||LA(1)==EQUAL)) {
+ {
+ switch ( LA(1)) {
+ case NOT_EQUAL:
+ {
+ AST tmp21_AST = null;
+ tmp21_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp21_AST);
+ match(NOT_EQUAL);
+ a=relationalExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new NotEqualExpression(e,a);
+ }
+ break;
+ }
+ case EQUAL:
+ {
+ AST tmp22_AST = null;
+ tmp22_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp22_AST);
+ match(EQUAL);
+ a=relationalExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new EqualExpression(e,a);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+ else {
+ break _loop30;
+ }
+
+ } while (true);
+ }
+ equalityExpression_AST = (AST)currentAST.root;
+ returnAST = equalityExpression_AST;
+ return e;
+ }
+
+ public final Expression relationalExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST relationalExpression_AST = null;
+ Expression a,b;
+
+ e=shiftExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ {
+ _loop35:
+ do {
+ if (((LA(1) >= LT && LA(1) <= GE))) {
+ {
+ switch ( LA(1)) {
+ case LT:
+ {
+ AST tmp23_AST = null;
+ tmp23_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp23_AST);
+ match(LT);
+ a=shiftExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new LessThanExpression(e,a);
+ }
+ break;
+ }
+ case GT:
+ {
+ AST tmp24_AST = null;
+ tmp24_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp24_AST);
+ match(GT);
+ a=shiftExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new GreaterThanExpression(e,a);
+ }
+ break;
+ }
+ case LE:
+ {
+ AST tmp25_AST = null;
+ tmp25_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp25_AST);
+ match(LE);
+ a=shiftExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new LessThanOrEqualExpression(e,a);
+ }
+ break;
+ }
+ case GE:
+ {
+ AST tmp26_AST = null;
+ tmp26_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp26_AST);
+ match(GE);
+ a=shiftExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new GreaterThanOrEqualExpression(e,a);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+ else {
+ break _loop35;
+ }
+
+ } while (true);
+ }
+ }
+ relationalExpression_AST = (AST)currentAST.root;
+ returnAST = relationalExpression_AST;
+ return e;
+ }
+
+ public final Expression shiftExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST shiftExpression_AST = null;
+ Expression a,b;
+
+ e=additiveExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop39:
+ do {
+ if (((LA(1) >= SL && LA(1) <= BSR))) {
+ {
+ switch ( LA(1)) {
+ case SL:
+ {
+ AST tmp27_AST = null;
+ tmp27_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp27_AST);
+ match(SL);
+ a=additiveExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new ShiftLeftExpression(e,a);
+ }
+ break;
+ }
+ case SR:
+ {
+ AST tmp28_AST = null;
+ tmp28_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp28_AST);
+ match(SR);
+ a=additiveExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new ShiftRightExpression(e,a);
+ }
+ break;
+ }
+ case BSR:
+ {
+ AST tmp29_AST = null;
+ tmp29_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp29_AST);
+ match(BSR);
+ a=additiveExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new BitShiftRightExpression(e,a);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+ else {
+ break _loop39;
+ }
+
+ } while (true);
+ }
+ shiftExpression_AST = (AST)currentAST.root;
+ returnAST = shiftExpression_AST;
+ return e;
+ }
+
+ public final Expression additiveExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST additiveExpression_AST = null;
+ Expression a,b;
+
+ e=multiplicativeExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop43:
+ do {
+ if ((LA(1)==PLUS||LA(1)==MINUS)) {
+ {
+ switch ( LA(1)) {
+ case PLUS:
+ {
+ AST tmp30_AST = null;
+ tmp30_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp30_AST);
+ match(PLUS);
+ a=multiplicativeExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new AdditionExpression(e,a);
+ }
+ break;
+ }
+ case MINUS:
+ {
+ AST tmp31_AST = null;
+ tmp31_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp31_AST);
+ match(MINUS);
+ a=multiplicativeExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new SubtractionExpression(e,a);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+ else {
+ break _loop43;
+ }
+
+ } while (true);
+ }
+ additiveExpression_AST = (AST)currentAST.root;
+ returnAST = additiveExpression_AST;
+ return e;
+ }
+
+ public final Expression multiplicativeExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST multiplicativeExpression_AST = null;
+ Expression a,b;
+
+ e=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ {
+ _loop47:
+ do {
+ if (((LA(1) >= STAR && LA(1) <= MOD))) {
+ {
+ switch ( LA(1)) {
+ case STAR:
+ {
+ AST tmp32_AST = null;
+ tmp32_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp32_AST);
+ match(STAR);
+ a=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new MultiplicationExpression(e,a);
+ }
+ break;
+ }
+ case DIV:
+ {
+ AST tmp33_AST = null;
+ tmp33_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp33_AST);
+ match(DIV);
+ a=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new DivisionExpression(e,a);
+ }
+ break;
+ }
+ case MOD:
+ {
+ AST tmp34_AST = null;
+ tmp34_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp34_AST);
+ match(MOD);
+ a=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new ModuloExpression(e,a);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+ else {
+ break _loop47;
+ }
+
+ } while (true);
+ }
+ multiplicativeExpression_AST = (AST)currentAST.root;
+ returnAST = multiplicativeExpression_AST;
+ return e;
+ }
+
+ public final Expression unaryExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST unaryExpression_AST = null;
+ Expression a,b;
+
+ switch ( LA(1)) {
+ case MINUS:
+ {
+ AST tmp35_AST = null;
+ tmp35_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp35_AST);
+ match(MINUS);
+ if ( inputState.guessing==0 ) {
+ tmp35_AST.setType(UNARY_MINUS);
+ }
+ a=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new NegateExpression(a);
+ }
+ unaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ case PLUS:
+ {
+ AST tmp36_AST = null;
+ tmp36_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp36_AST);
+ match(PLUS);
+ if ( inputState.guessing==0 ) {
+ tmp36_AST.setType(UNARY_PLUS);
+ }
+ e=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ unaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ case IDENT:
+ case BNOT:
+ case LNOT:
+ case LPAREN:
+ case LITERAL_true:
+ case LITERAL_false:
+ case LITERAL_null:
+ case NUM_INT:
+ case CHAR_LITERAL:
+ case STRING_LITERAL:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case NUM_DOUBLE:
+ {
+ e=unaryExpressionNotPlusMinus();
+ astFactory.addASTChild(currentAST, returnAST);
+ unaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ returnAST = unaryExpression_AST;
+ return e;
+ }
+
+ public final Expression unaryExpressionNotPlusMinus() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST unaryExpressionNotPlusMinus_AST = null;
+ Token lpb = null;
+ AST lpb_AST = null;
+ Expression a; Type t;
+
+ switch ( LA(1)) {
+ case BNOT:
+ {
+ AST tmp37_AST = null;
+ tmp37_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp37_AST);
+ match(BNOT);
+ a=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new NotExpression(a);
+ }
+ unaryExpressionNotPlusMinus_AST = (AST)currentAST.root;
+ break;
+ }
+ case LNOT:
+ {
+ AST tmp38_AST = null;
+ tmp38_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp38_AST);
+ match(LNOT);
+ a=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new LogicalNotExpression(a);
+ }
+ unaryExpressionNotPlusMinus_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ boolean synPredMatched51 = false;
+ if (((LA(1)==LPAREN) && ((LA(2) >= LITERAL_void && LA(2) <= LITERAL_String)))) {
+ int _m51 = mark();
+ synPredMatched51 = true;
+ inputState.guessing++;
+ try {
+ {
+ match(LPAREN);
+ builtInTypeSpec(true);
+ match(RPAREN);
+ }
+ }
+ catch (RecognitionException pe) {
+ synPredMatched51 = false;
+ }
+ rewind(_m51);
+inputState.guessing--;
+ }
+ if ( synPredMatched51 ) {
+ lpb = LT(1);
+ lpb_AST = astFactory.create(lpb);
+ astFactory.makeASTRoot(currentAST, lpb_AST);
+ match(LPAREN);
+ if ( inputState.guessing==0 ) {
+ lpb_AST.setType(TYPECAST);
+ }
+ t=builtInTypeSpec(true);
+ astFactory.addASTChild(currentAST, returnAST);
+ match(RPAREN);
+ a=unaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new TypeCastExpression(t,a);
+ }
+ unaryExpressionNotPlusMinus_AST = (AST)currentAST.root;
+ }
+ else if ((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2)))) {
+ e=primaryExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ unaryExpressionNotPlusMinus_AST = (AST)currentAST.root;
+ }
+ else {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ returnAST = unaryExpressionNotPlusMinus_AST;
+ return e;
+ }
+
+ public final Expression primaryExpression() throws RecognitionException, TokenStreamException {
+ Expression e = null; String i = null;;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST primaryExpression_AST = null;
+
+ switch ( LA(1)) {
+ case NUM_INT:
+ case CHAR_LITERAL:
+ case STRING_LITERAL:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case NUM_DOUBLE:
+ {
+ e=constant();
+ astFactory.addASTChild(currentAST, returnAST);
+ primaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ case IDENT:
+ {
+ i=identifier();
+ astFactory.addASTChild(currentAST, returnAST);
+ if ( inputState.guessing==0 ) {
+ e=new IdentifierExpression(i);
+ }
+ primaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_true:
+ {
+ AST tmp40_AST = null;
+ tmp40_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp40_AST);
+ match(LITERAL_true);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantBoolean(true);
+ }
+ primaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_false:
+ {
+ AST tmp41_AST = null;
+ tmp41_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp41_AST);
+ match(LITERAL_false);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantBoolean(false);
+ }
+ primaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ case LITERAL_null:
+ {
+ AST tmp42_AST = null;
+ tmp42_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp42_AST);
+ match(LITERAL_null);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantNull();
+ }
+ primaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ case LPAREN:
+ {
+ match(LPAREN);
+ e=conditionalExpression();
+ astFactory.addASTChild(currentAST, returnAST);
+ match(RPAREN);
+ primaryExpression_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ returnAST = primaryExpression_AST;
+ return e;
+ }
+
+ public final Expression constant() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST constant_AST = null;
+ Token l1 = null;
+ AST l1_AST = null;
+ Token l2 = null;
+ AST l2_AST = null;
+ Token l3 = null;
+ AST l3_AST = null;
+ Token l4 = null;
+ AST l4_AST = null;
+ Token l5 = null;
+ AST l5_AST = null;
+ Token l6 = null;
+ AST l6_AST = null;
+
+ switch ( LA(1)) {
+ case NUM_INT:
+ {
+ l1 = LT(1);
+ l1_AST = astFactory.create(l1);
+ astFactory.addASTChild(currentAST, l1_AST);
+ match(NUM_INT);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantInteger(l1.getText());
+ }
+ constant_AST = (AST)currentAST.root;
+ break;
+ }
+ case CHAR_LITERAL:
+ {
+ l2 = LT(1);
+ l2_AST = astFactory.create(l2);
+ astFactory.addASTChild(currentAST, l2_AST);
+ match(CHAR_LITERAL);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantChar(l2.getText());
+ }
+ constant_AST = (AST)currentAST.root;
+ break;
+ }
+ case STRING_LITERAL:
+ {
+ l3 = LT(1);
+ l3_AST = astFactory.create(l3);
+ astFactory.addASTChild(currentAST, l3_AST);
+ match(STRING_LITERAL);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantString(l3.getText().substring(1, l3.getText().length()-1));
+ }
+ constant_AST = (AST)currentAST.root;
+ break;
+ }
+ case NUM_FLOAT:
+ {
+ l4 = LT(1);
+ l4_AST = astFactory.create(l4);
+ astFactory.addASTChild(currentAST, l4_AST);
+ match(NUM_FLOAT);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantFloat(l4.getText());
+ }
+ constant_AST = (AST)currentAST.root;
+ break;
+ }
+ case NUM_LONG:
+ {
+ l5 = LT(1);
+ l5_AST = astFactory.create(l5);
+ astFactory.addASTChild(currentAST, l5_AST);
+ match(NUM_LONG);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantLong(l5.getText());
+ }
+ constant_AST = (AST)currentAST.root;
+ break;
+ }
+ case NUM_DOUBLE:
+ {
+ l6 = LT(1);
+ l6_AST = astFactory.create(l6);
+ astFactory.addASTChild(currentAST, l6_AST);
+ match(NUM_DOUBLE);
+ if ( inputState.guessing==0 ) {
+ e=new ConstantDouble(l6.getText());
+ }
+ constant_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ returnAST = constant_AST;
+ return e;
+ }
+
+/** Match a, a.b.c refs
+ */
+ public final Expression identPrimary() throws RecognitionException, TokenStreamException {
+ Expression e = null;
+
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST identPrimary_AST = null;
+
+ AST tmp45_AST = null;
+ tmp45_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp45_AST);
+ match(IDENT);
+ {
+ _loop55:
+ do {
+ if ((LA(1)==DOT)) {
+ AST tmp46_AST = null;
+ tmp46_AST = astFactory.create(LT(1));
+ astFactory.makeASTRoot(currentAST, tmp46_AST);
+ match(DOT);
+ AST tmp47_AST = null;
+ tmp47_AST = astFactory.create(LT(1));
+ astFactory.addASTChild(currentAST, tmp47_AST);
+ match(IDENT);
+ }
+ else {
+ break _loop55;
+ }
+
+ } while (true);
+ }
+ identPrimary_AST = (AST)currentAST.root;
+ returnAST = identPrimary_AST;
+ return e;
+ }
+
+
+ public static final String[] _tokenNames = {
+ "<0>",
+ "EOF",
+ "<2>",
+ "NULL_TREE_LOOKAHEAD",
+ "BLOCK",
+ "MODIFIERS",
+ "OBJBLOCK",
+ "SLIST",
+ "CTOR_DEF",
+ "METHOD_DEF",
+ "VARIABLE_DEF",
+ "INSTANCE_INIT",
+ "STATIC_INIT",
+ "TYPE",
+ "CLASS_DEF",
+ "INTERFACE_DEF",
+ "PACKAGE_DEF",
+ "ARRAY_DECLARATOR",
+ "EXTENDS_CLAUSE",
+ "IMPLEMENTS_CLAUSE",
+ "PARAMETERS",
+ "PARAMETER_DEF",
+ "LABELED_STAT",
+ "TYPECAST",
+ "INDEX_OP",
+ "POST_INC",
+ "POST_DEC",
+ "METHOD_CALL",
+ "EXPR",
+ "ARRAY_INIT",
+ "IMPORT",
+ "UNARY_MINUS",
+ "UNARY_PLUS",
+ "CASE_GROUP",
+ "ELIST",
+ "FOR_INIT",
+ "FOR_CONDITION",
+ "FOR_ITERATOR",
+ "EMPTY_STAT",
+ "\"final\"",
+ "\"abstract\"",
+ "\"strictfp\"",
+ "SUPER_CTOR_CALL",
+ "CTOR_CALL",
+ "LBRACK",
+ "RBRACK",
+ "\"void\"",
+ "\"boolean\"",
+ "\"byte\"",
+ "\"char\"",
+ "\"short\"",
+ "\"int\"",
+ "\"float\"",
+ "\"long\"",
+ "\"double\"",
+ "\"String\"",
+ "IDENT",
+ "DOT",
+ "QUESTION",
+ "COLON",
+ "LOR",
+ "LAND",
+ "BOR",
+ "BXOR",
+ "BAND",
+ "NOT_EQUAL",
+ "EQUAL",
+ "LT",
+ "GT",
+ "LE",
+ "GE",
+ "SL",
+ "SR",
+ "BSR",
+ "PLUS",
+ "MINUS",
+ "STAR",
+ "DIV",
+ "MOD",
+ "BNOT",
+ "LNOT",
+ "LPAREN",
+ "RPAREN",
+ "\"true\"",
+ "\"false\"",
+ "\"null\"",
+ "NUM_INT",
+ "CHAR_LITERAL",
+ "STRING_LITERAL",
+ "NUM_FLOAT",
+ "NUM_LONG",
+ "NUM_DOUBLE",
+ "LCURLY",
+ "RCURLY",
+ "COMMA",
+ "ASSIGN",
+ "DIV_ASSIGN",
+ "PLUS_ASSIGN",
+ "INC",
+ "MINUS_ASSIGN",
+ "DEC",
+ "STAR_ASSIGN",
+ "MOD_ASSIGN",
+ "SR_ASSIGN",
+ "BSR_ASSIGN",
+ "SL_ASSIGN",
+ "BXOR_ASSIGN",
+ "BOR_ASSIGN",
+ "BAND_ASSIGN",
+ "SEMI",
+ "WS",
+ "SL_COMMIT",
+ "ML_COMMENT",
+ "ESC",
+ "HEX_DIGIT",
+ "VOCAB",
+ "EXPONENT",
+ "FLOAT_SUFFIX"
+ };
+
+ protected void buildTokenTypeASTClassMap() {
+ tokenTypeToASTClassMap=null;
+ };
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = { 72057594037927936L, 268042240L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+ private static final long[] mk_tokenSet_1() {
+ long[] data = { -72057594037927934L, 268435455L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
+
+ }
diff --git a/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.smap b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.smap
new file mode 100644
index 000000000..667caad55
--- /dev/null
+++ b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.smap
@@ -0,0 +1,987 @@
+SMAP
+JavaRecognizer.java
+G
+*S G
+*F
++ 0 java-expression.g
+java-expression.g
+*L
+19:3
+46:56
+46:57
+46:58
+46:59
+46:61
+46:62
+46:63
+46:101
+46:102
+46:103
+47:64
+47:65
+47:67
+47:68
+47:69
+47:70
+47:71
+47:72
+47:73
+47:74
+47:75
+47:76
+47:77
+47:78
+47:80
+47:81
+47:82
+47:83
+47:84
+47:86
+47:87
+48:88
+48:89
+48:95
+48:97
+48:98
+49:91
+49:100
+50:92
+51:93
+57:242
+57:243
+57:245
+57:246
+57:247
+57:252
+57:253
+57:254
+58:249
+58:250
+58:251
+62:105
+62:106
+62:108
+62:109
+62:110
+62:112
+62:233
+62:234
+62:235
+62:236
+62:237
+62:238
+62:239
+62:240
+63:113
+63:114
+63:115
+63:116
+63:117
+63:118
+63:119
+63:120
+64:125
+64:126
+64:127
+64:128
+64:129
+64:130
+64:131
+64:132
+65:137
+65:138
+65:139
+65:140
+65:141
+65:142
+65:143
+65:144
+66:122
+66:149
+66:150
+66:151
+66:152
+66:153
+66:154
+66:155
+66:156
+67:134
+67:161
+67:162
+67:163
+67:164
+67:165
+67:166
+67:167
+67:168
+68:146
+68:173
+68:174
+68:175
+68:176
+68:177
+68:178
+68:179
+68:180
+69:158
+69:185
+69:186
+69:187
+69:188
+69:189
+69:190
+69:191
+69:192
+70:170
+70:197
+70:198
+70:199
+70:200
+70:201
+70:202
+70:203
+70:204
+71:182
+71:209
+71:210
+71:211
+71:212
+71:213
+71:214
+71:215
+71:216
+72:194
+72:221
+72:222
+72:223
+72:224
+72:225
+72:226
+72:227
+72:228
+73:206
+74:218
+75:230
+77:256
+77:257
+77:259
+77:260
+77:261
+77:297
+77:298
+77:299
+78:262
+78:263
+78:264
+78:265
+78:267
+78:268
+78:269
+78:270
+78:271
+78:272
+78:274
+78:275
+78:276
+78:277
+78:278
+78:279
+78:280
+78:281
+78:282
+78:283
+78:284
+78:285
+78:286
+78:287
+78:289
+78:290
+78:291
+78:292
+78:294
+78:295
+78:296
+81:301
+81:302
+81:304
+81:305
+81:306
+81:312
+81:313
+81:314
+82:308
+82:309
+82:310
+84:311
+86:316
+86:317
+86:319
+86:320
+86:321
+86:322
+86:357
+86:358
+86:359
+87:324
+87:325
+88:327
+88:328
+88:329
+88:330
+88:331
+88:332
+88:333
+88:334
+88:335
+88:336
+88:337
+88:338
+88:339
+88:340
+88:350
+88:351
+88:352
+88:353
+88:354
+89:356
+93:361
+93:362
+93:364
+93:365
+93:366
+93:367
+93:392
+93:393
+93:394
+94:369
+94:370
+94:371
+94:372
+94:373
+94:374
+94:375
+94:376
+94:377
+94:378
+94:379
+94:380
+94:381
+94:382
+94:384
+94:385
+94:386
+94:387
+94:389
+94:390
+94:391
+99:396
+99:397
+99:399
+99:400
+99:401
+99:402
+99:427
+99:428
+99:429
+100:404
+100:405
+100:406
+100:407
+100:408
+100:409
+100:410
+100:411
+100:412
+100:413
+100:414
+100:415
+100:416
+100:417
+100:419
+100:420
+100:421
+100:422
+100:424
+100:425
+100:426
+105:431
+105:432
+105:434
+105:435
+105:436
+105:437
+105:462
+105:463
+105:464
+106:439
+106:440
+106:441
+106:442
+106:443
+106:444
+106:445
+106:446
+106:447
+106:448
+106:449
+106:450
+106:451
+106:452
+106:454
+106:455
+106:456
+106:457
+106:459
+106:460
+106:461
+111:466
+111:467
+111:469
+111:470
+111:471
+111:472
+111:497
+111:498
+111:499
+112:474
+112:475
+112:476
+112:477
+112:478
+112:479
+112:480
+112:481
+112:482
+112:483
+112:484
+112:485
+112:486
+112:487
+112:489
+112:490
+112:491
+112:492
+112:494
+112:495
+112:496
+117:501
+117:502
+117:504
+117:505
+117:506
+117:507
+117:532
+117:533
+117:534
+118:509
+118:510
+118:511
+118:512
+118:513
+118:514
+118:515
+118:516
+118:517
+118:518
+118:519
+118:520
+118:521
+118:522
+118:524
+118:525
+118:526
+118:527
+118:529
+118:530
+118:531
+123:536
+123:537
+123:539
+123:540
+123:541
+123:542
+123:592
+123:593
+123:594
+124:544
+124:545
+124:546
+124:547
+124:548
+124:549
+124:551
+124:552
+124:553
+124:554
+124:555
+124:556
+124:557
+124:558
+124:559
+124:560
+124:561
+124:565
+124:566
+124:567
+124:568
+124:569
+124:570
+124:571
+124:572
+124:573
+124:574
+124:578
+124:579
+124:580
+124:581
+124:582
+124:584
+124:585
+124:586
+124:587
+124:589
+124:590
+124:591
+129:596
+129:597
+129:599
+129:600
+129:601
+129:602
+129:680
+129:681
+129:682
+130:604
+130:605
+131:607
+131:608
+131:609
+131:610
+131:612
+131:613
+131:614
+131:615
+131:616
+131:617
+131:618
+131:619
+131:620
+131:621
+131:622
+131:665
+131:666
+131:667
+131:668
+131:669
+131:671
+131:672
+131:673
+131:674
+131:676
+131:677
+132:626
+132:627
+132:628
+132:629
+132:630
+132:631
+132:632
+132:633
+132:634
+132:635
+132:679
+133:639
+133:640
+133:641
+133:642
+133:643
+133:644
+133:645
+133:646
+133:647
+133:648
+134:652
+134:653
+134:654
+134:655
+134:656
+134:657
+134:658
+134:659
+134:660
+134:661
+143:684
+143:685
+143:687
+143:688
+143:689
+143:690
+143:753
+143:754
+143:755
+144:692
+144:693
+144:694
+144:695
+144:696
+144:697
+144:699
+144:700
+144:701
+144:702
+144:703
+144:704
+144:705
+144:706
+144:707
+144:708
+144:709
+144:713
+144:714
+144:715
+144:716
+144:717
+144:718
+144:719
+144:720
+144:721
+144:722
+144:726
+144:727
+144:728
+144:729
+144:730
+144:731
+144:732
+144:733
+144:734
+144:735
+144:739
+144:740
+144:741
+144:742
+144:743
+144:745
+144:746
+144:747
+144:748
+144:750
+144:751
+144:752
+149:757
+149:758
+149:760
+149:761
+149:762
+149:763
+149:813
+149:814
+149:815
+150:765
+150:766
+150:767
+150:768
+150:769
+150:770
+150:772
+150:773
+150:774
+150:775
+150:776
+150:777
+150:778
+150:779
+150:780
+150:781
+150:782
+150:786
+150:787
+150:788
+150:789
+150:790
+150:791
+150:792
+150:793
+150:794
+150:795
+150:799
+150:800
+150:801
+150:802
+150:803
+150:805
+150:806
+150:807
+150:808
+150:810
+150:811
+150:812
+155:817
+155:818
+155:820
+155:821
+155:822
+155:823
+155:886
+155:887
+155:888
+156:825
+156:826
+156:827
+156:828
+156:829
+156:830
+156:832
+156:833
+156:834
+156:835
+156:836
+156:837
+156:838
+156:839
+156:840
+156:841
+156:842
+156:846
+156:847
+156:848
+156:849
+156:850
+156:851
+156:852
+156:853
+156:854
+156:855
+156:859
+156:860
+156:861
+156:862
+156:863
+156:864
+156:865
+156:866
+156:867
+156:868
+156:872
+156:873
+156:874
+156:875
+156:876
+156:878
+156:879
+156:880
+156:881
+156:883
+156:884
+156:885
+160:890
+160:891
+160:893
+160:894
+160:895
+160:896
+160:898
+160:949
+160:950
+160:951
+160:952
+160:953
+160:954
+160:955
+160:956
+161:899
+161:900
+161:901
+161:902
+161:903
+161:904
+161:905
+161:906
+161:908
+161:909
+161:910
+161:911
+162:916
+162:917
+162:918
+162:919
+162:920
+162:921
+162:922
+162:923
+162:925
+162:926
+162:927
+163:930
+163:931
+163:932
+163:933
+163:934
+163:935
+163:936
+163:937
+163:938
+163:939
+163:940
+163:941
+163:942
+163:943
+163:944
+163:945
+163:946
+164:913
+166:958
+166:959
+166:961
+166:962
+166:963
+166:966
+166:968
+166:997
+166:1033
+166:1038
+166:1039
+166:1040
+166:1041
+166:1042
+166:1043
+166:1044
+166:1045
+167:969
+167:970
+167:971
+167:972
+167:973
+167:974
+167:975
+167:976
+167:977
+167:978
+168:983
+168:984
+168:985
+168:986
+168:987
+168:988
+168:989
+168:990
+168:991
+168:992
+170:980
+171:994
+171:998
+171:999
+171:1000
+171:1001
+171:1002
+171:1003
+171:1005
+171:1006
+171:1007
+171:1009
+171:1010
+171:1011
+171:1012
+171:1013
+171:1014
+171:1015
+171:1016
+172:964
+172:965
+172:1017
+172:1018
+172:1019
+172:1020
+172:1021
+172:1022
+172:1024
+172:1025
+172:1026
+173:1027
+173:1028
+173:1029
+173:1030
+175:1034
+175:1035
+175:1036
+175:1037
+176:1032
+179:1047
+179:1048
+179:1050
+179:1051
+179:1052
+179:1054
+179:1122
+179:1123
+179:1124
+179:1125
+179:1126
+179:1127
+179:1128
+179:1129
+180:1055
+180:1056
+180:1057
+180:1058
+180:1059
+180:1060
+180:1061
+180:1062
+180:1063
+180:1064
+181:1067
+181:1068
+181:1069
+181:1070
+181:1071
+181:1072
+182:1077
+182:1078
+182:1079
+182:1080
+182:1081
+182:1082
+182:1083
+182:1084
+183:1089
+183:1090
+183:1091
+183:1092
+183:1093
+183:1094
+183:1095
+183:1096
+184:1074
+184:1101
+184:1102
+184:1103
+184:1104
+184:1105
+184:1106
+184:1107
+184:1108
+185:1086
+185:1113
+185:1114
+185:1115
+185:1116
+185:1117
+185:1118
+186:1098
+187:1110
+187:1119
+190:1232
+190:1234
+190:1235
+190:1237
+190:1238
+190:1239
+190:1265
+190:1266
+190:1267
+191:1233
+191:1241
+191:1242
+191:1243
+191:1244
+192:1245
+192:1246
+192:1247
+192:1257
+192:1258
+192:1259
+192:1260
+192:1262
+192:1263
+192:1264
+198:1248
+198:1249
+198:1250
+198:1251
+198:1252
+198:1253
+198:1254
+198:1255
+198:1256
+202:1131
+202:1132
+202:1134
+202:1135
+202:1136
+202:1150
+202:1223
+202:1224
+202:1225
+202:1226
+202:1227
+202:1228
+202:1229
+202:1230
+203:1137
+203:1138
+203:1151
+203:1152
+203:1153
+203:1154
+203:1155
+203:1156
+203:1157
+203:1158
+204:1139
+204:1140
+204:1163
+204:1164
+204:1165
+204:1166
+204:1167
+204:1168
+204:1169
+204:1170
+205:1141
+205:1142
+205:1175
+205:1176
+205:1177
+205:1178
+205:1179
+205:1180
+205:1181
+205:1182
+206:1143
+206:1144
+206:1160
+206:1187
+206:1188
+206:1189
+206:1190
+206:1191
+206:1192
+206:1193
+206:1194
+207:1145
+207:1146
+207:1172
+207:1199
+207:1200
+207:1201
+207:1202
+207:1203
+207:1204
+207:1205
+207:1206
+208:1147
+208:1148
+208:1184
+208:1211
+208:1212
+208:1213
+208:1214
+208:1215
+208:1216
+208:1217
+208:1218
+209:1196
+210:1208
+211:1220
+*E
diff --git a/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.java b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.java
new file mode 100644
index 000000000..9387c93f9
--- /dev/null
+++ b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.java
@@ -0,0 +1,122 @@
+// $ANTLR 2.7.7 (20080530): "java-expression.g" -> "JavaLexer.java"$
+
+ package gnu.classpath.tools.gjdoc.expr;
+
+public interface JavaTokenTypes {
+ int EOF = 1;
+ int NULL_TREE_LOOKAHEAD = 3;
+ int BLOCK = 4;
+ int MODIFIERS = 5;
+ int OBJBLOCK = 6;
+ int SLIST = 7;
+ int CTOR_DEF = 8;
+ int METHOD_DEF = 9;
+ int VARIABLE_DEF = 10;
+ int INSTANCE_INIT = 11;
+ int STATIC_INIT = 12;
+ int TYPE = 13;
+ int CLASS_DEF = 14;
+ int INTERFACE_DEF = 15;
+ int PACKAGE_DEF = 16;
+ int ARRAY_DECLARATOR = 17;
+ int EXTENDS_CLAUSE = 18;
+ int IMPLEMENTS_CLAUSE = 19;
+ int PARAMETERS = 20;
+ int PARAMETER_DEF = 21;
+ int LABELED_STAT = 22;
+ int TYPECAST = 23;
+ int INDEX_OP = 24;
+ int POST_INC = 25;
+ int POST_DEC = 26;
+ int METHOD_CALL = 27;
+ int EXPR = 28;
+ int ARRAY_INIT = 29;
+ int IMPORT = 30;
+ int UNARY_MINUS = 31;
+ int UNARY_PLUS = 32;
+ int CASE_GROUP = 33;
+ int ELIST = 34;
+ int FOR_INIT = 35;
+ int FOR_CONDITION = 36;
+ int FOR_ITERATOR = 37;
+ int EMPTY_STAT = 38;
+ int FINAL = 39;
+ int ABSTRACT = 40;
+ int STRICTFP = 41;
+ int SUPER_CTOR_CALL = 42;
+ int CTOR_CALL = 43;
+ int LBRACK = 44;
+ int RBRACK = 45;
+ int LITERAL_void = 46;
+ int LITERAL_boolean = 47;
+ int LITERAL_byte = 48;
+ int LITERAL_char = 49;
+ int LITERAL_short = 50;
+ int LITERAL_int = 51;
+ int LITERAL_float = 52;
+ int LITERAL_long = 53;
+ int LITERAL_double = 54;
+ int LITERAL_String = 55;
+ int IDENT = 56;
+ int DOT = 57;
+ int QUESTION = 58;
+ int COLON = 59;
+ int LOR = 60;
+ int LAND = 61;
+ int BOR = 62;
+ int BXOR = 63;
+ int BAND = 64;
+ int NOT_EQUAL = 65;
+ int EQUAL = 66;
+ int LT = 67;
+ int GT = 68;
+ int LE = 69;
+ int GE = 70;
+ int SL = 71;
+ int SR = 72;
+ int BSR = 73;
+ int PLUS = 74;
+ int MINUS = 75;
+ int STAR = 76;
+ int DIV = 77;
+ int MOD = 78;
+ int BNOT = 79;
+ int LNOT = 80;
+ int LPAREN = 81;
+ int RPAREN = 82;
+ int LITERAL_true = 83;
+ int LITERAL_false = 84;
+ int LITERAL_null = 85;
+ int NUM_INT = 86;
+ int CHAR_LITERAL = 87;
+ int STRING_LITERAL = 88;
+ int NUM_FLOAT = 89;
+ int NUM_LONG = 90;
+ int NUM_DOUBLE = 91;
+ int LCURLY = 92;
+ int RCURLY = 93;
+ int COMMA = 94;
+ int ASSIGN = 95;
+ int DIV_ASSIGN = 96;
+ int PLUS_ASSIGN = 97;
+ int INC = 98;
+ int MINUS_ASSIGN = 99;
+ int DEC = 100;
+ int STAR_ASSIGN = 101;
+ int MOD_ASSIGN = 102;
+ int SR_ASSIGN = 103;
+ int BSR_ASSIGN = 104;
+ int SL_ASSIGN = 105;
+ int BXOR_ASSIGN = 106;
+ int BOR_ASSIGN = 107;
+ int BAND_ASSIGN = 108;
+ int SEMI = 109;
+ int WS = 110;
+ int SL_COMMIT = 111;
+ int ML_COMMENT = 112;
+ int ESC = 113;
+ int HEX_DIGIT = 114;
+ int VOCAB = 115;
+ int EXPONENT = 116;
+ int FLOAT_SUFFIX = 117;
+}
diff --git a/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.txt b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.txt
new file mode 100644
index 000000000..b9983e22f
--- /dev/null
+++ b/libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.txt
@@ -0,0 +1,116 @@
+// $ANTLR 2.7.7 (20080530): java-expression.g -> JavaTokenTypes.txt$
+Java // output token vocab name
+BLOCK=4
+MODIFIERS=5
+OBJBLOCK=6
+SLIST=7
+CTOR_DEF=8
+METHOD_DEF=9
+VARIABLE_DEF=10
+INSTANCE_INIT=11
+STATIC_INIT=12
+TYPE=13
+CLASS_DEF=14
+INTERFACE_DEF=15
+PACKAGE_DEF=16
+ARRAY_DECLARATOR=17
+EXTENDS_CLAUSE=18
+IMPLEMENTS_CLAUSE=19
+PARAMETERS=20
+PARAMETER_DEF=21
+LABELED_STAT=22
+TYPECAST=23
+INDEX_OP=24
+POST_INC=25
+POST_DEC=26
+METHOD_CALL=27
+EXPR=28
+ARRAY_INIT=29
+IMPORT=30
+UNARY_MINUS=31
+UNARY_PLUS=32
+CASE_GROUP=33
+ELIST=34
+FOR_INIT=35
+FOR_CONDITION=36
+FOR_ITERATOR=37
+EMPTY_STAT=38
+FINAL="final"=39
+ABSTRACT="abstract"=40
+STRICTFP="strictfp"=41
+SUPER_CTOR_CALL=42
+CTOR_CALL=43
+LBRACK=44
+RBRACK=45
+LITERAL_void="void"=46
+LITERAL_boolean="boolean"=47
+LITERAL_byte="byte"=48
+LITERAL_char="char"=49
+LITERAL_short="short"=50
+LITERAL_int="int"=51
+LITERAL_float="float"=52
+LITERAL_long="long"=53
+LITERAL_double="double"=54
+LITERAL_String="String"=55
+IDENT=56
+DOT=57
+QUESTION=58
+COLON=59
+LOR=60
+LAND=61
+BOR=62
+BXOR=63
+BAND=64
+NOT_EQUAL=65
+EQUAL=66
+LT=67
+GT=68
+LE=69
+GE=70
+SL=71
+SR=72
+BSR=73
+PLUS=74
+MINUS=75
+STAR=76
+DIV=77
+MOD=78
+BNOT=79
+LNOT=80
+LPAREN=81
+RPAREN=82
+LITERAL_true="true"=83
+LITERAL_false="false"=84
+LITERAL_null="null"=85
+NUM_INT=86
+CHAR_LITERAL=87
+STRING_LITERAL=88
+NUM_FLOAT=89
+NUM_LONG=90
+NUM_DOUBLE=91
+LCURLY=92
+RCURLY=93
+COMMA=94
+ASSIGN=95
+DIV_ASSIGN=96
+PLUS_ASSIGN=97
+INC=98
+MINUS_ASSIGN=99
+DEC=100
+STAR_ASSIGN=101
+MOD_ASSIGN=102
+SR_ASSIGN=103
+BSR_ASSIGN=104
+SL_ASSIGN=105
+BXOR_ASSIGN=106
+BOR_ASSIGN=107
+BAND_ASSIGN=108
+SEMI=109
+WS=110
+SL_COMMIT=111
+ML_COMMENT=112
+ESC=113
+HEX_DIGIT=114
+VOCAB=115
+EXPONENT=116
+FLOAT_SUFFIX=117
diff --git a/libjava/classpath/tools/gjar.in b/libjava/classpath/tools/gjar.in
new file mode 100644
index 000000000..e3dcea21b
--- /dev/null
+++ b/libjava/classpath/tools/gjar.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath jar tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.jar.Main "$@"
diff --git a/libjava/classpath/tools/gjarsigner.in b/libjava/classpath/tools/gjarsigner.in
new file mode 100644
index 000000000..d51541815
--- /dev/null
+++ b/libjava/classpath/tools/gjarsigner.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath jarsigner tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.jarsigner.Main "$@"
diff --git a/libjava/classpath/tools/gjavah.in b/libjava/classpath/tools/gjavah.in
new file mode 100644
index 000000000..d6f3ab1e3
--- /dev/null
+++ b/libjava/classpath/tools/gjavah.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath javah tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.javah.Main "$@"
diff --git a/libjava/classpath/tools/gjdoc.in b/libjava/classpath/tools/gjdoc.in
new file mode 100644
index 000000000..1fb6ca657
--- /dev/null
+++ b/libjava/classpath/tools/gjdoc.in
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath javadoc tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+antlr_jar=@ANTLR_JAR@
+
+exec @JAVA@ -classpath "${tools_cp}:${antlr_jar}" gnu.classpath.tools.gjdoc.Main "$@"
diff --git a/libjava/classpath/tools/gkeytool.in b/libjava/classpath/tools/gkeytool.in
new file mode 100644
index 000000000..3c886f89c
--- /dev/null
+++ b/libjava/classpath/tools/gkeytool.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath keytool tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.keytool.Main "$@"
diff --git a/libjava/classpath/tools/gnative2ascii.in b/libjava/classpath/tools/gnative2ascii.in
new file mode 100644
index 000000000..52d8f6926
--- /dev/null
+++ b/libjava/classpath/tools/gnative2ascii.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath native2ascii tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.native2ascii.Native2ASCII "$@"
diff --git a/libjava/classpath/tools/gnu/classpath/tools/FileSystemClassLoader.java b/libjava/classpath/tools/gnu/classpath/tools/FileSystemClassLoader.java
new file mode 100644
index 000000000..a6bd72831
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/FileSystemClassLoader.java
@@ -0,0 +1,312 @@
+/* gnu.classpath.tools.FileSystemClassLoader
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
+
+/**
+ * A <code>ClassLoader</code> implementation which looks for classes
+ * on the local filesystem given a standard search path.
+ */
+public class FileSystemClassLoader extends ClassLoader {
+
+ private File[] pathComponents;
+
+ /**
+ * Initialize the class loader with a normal path string. The path
+ * string should contain path components separated by {@link
+ * File.pathSeparator}. Each path component should either denote a
+ * directory or a .jar or .zip file.
+ */
+ public FileSystemClassLoader(String path)
+ {
+ List components = new ArrayList();
+ for (StringTokenizer st = new StringTokenizer(path, File.pathSeparator); st.hasMoreTokens(); ) {
+ File pathComponent = new File(st.nextToken());
+ components.add(pathComponent);
+ if (pathComponent.exists() && !pathComponent.isDirectory()) {
+ List subComponents = tryGetJarFileClassPathComponents(pathComponent);
+ if (null != subComponents) {
+ components.addAll(subComponents);
+ }
+ }
+ }
+ File[] componentArray = new File[components.size()];
+ this.pathComponents = (File[])components.toArray(componentArray);
+ }
+
+ /**
+ * Initialize the class loader with an array of path
+ * components. Each path component should either denote a
+ * directory or a .jar or .zip file.
+ */
+ public FileSystemClassLoader(File[] pathComponents)
+ {
+ this.pathComponents = pathComponents;
+ for (int i = 0; i < pathComponents.length; ++i) {
+ if (!pathComponents[i].exists()) {
+ System.err.println("WARNING: Path component '" + pathComponents[i] + "' not found.");
+ }
+ }
+ }
+
+ public Class loadClass(String name)
+ throws ClassNotFoundException {
+
+ return super.loadClass(name);
+ }
+
+ public Class findClass(String name)
+ throws ClassNotFoundException {
+
+ byte[] b = loadClassData(name);
+ return defineClass(name, b, 0, b.length);
+ }
+
+ public URL findResource(String name)
+ {
+ StreamInfo streamInfo = getResourceStream(name);
+ if (null == streamInfo) {
+ return super.findResource(name);
+ }
+ else {
+ try {
+ return streamInfo.getURL();
+ }
+ catch (MalformedURLException e) {
+ System.err.println("WARNING: In FileSystemClassLoader: could not derive URL from file or jar entry: " + e.toString());
+ return null;
+ }
+ }
+ }
+
+ private byte[] readFromStream(InputStream in, long size)
+ throws IOException
+ {
+ byte[] result = new byte[(int)size];
+ int nread = 0;
+ int offset = 0;
+ while (offset < size && (nread = in.read(result, offset, (int)(size - offset))) >= 0) {
+ offset += nread;
+ }
+ in.close();
+ return result;
+ }
+
+ private byte[] readFromStream(StreamInfo streamInfo)
+ throws IOException
+ {
+ InputStream in = streamInfo.openStream();
+ long size = streamInfo.getSize();
+
+ byte[] result = new byte[(int)size];
+ int nread = 0;
+ int offset = 0;
+ while (offset < size && (nread = in.read(result, offset, (int)(size - offset))) >= 0) {
+ offset += nread;
+ }
+ in.close();
+ return result;
+ }
+
+ private static interface StreamInfo
+ {
+ public InputStream openStream()
+ throws IOException;
+ public long getSize();
+ public URL getURL()
+ throws MalformedURLException;
+ }
+
+ private static class FileStreamInfo
+ implements StreamInfo
+ {
+ File file;
+
+ FileStreamInfo(File file)
+ {
+ this.file = file;
+ }
+
+ public InputStream openStream()
+ throws IOException
+ {
+ return new FileInputStream(file);
+ }
+
+ public long getSize()
+ {
+ return file.length();
+ }
+
+ public URL getURL()
+ throws MalformedURLException
+ {
+ return file.toURL();
+ }
+ }
+
+ private static class JarStreamInfo
+ implements StreamInfo
+ {
+ private File file;
+ private JarFile jarFile;
+ private JarEntry jarEntry;
+
+ JarStreamInfo(File file, JarFile jarFile, JarEntry jarEntry)
+ {
+ this.file = file;
+ this.jarFile = jarFile;
+ this.jarEntry = jarEntry;
+ }
+
+ public InputStream openStream()
+ throws IOException
+ {
+ return jarFile.getInputStream(jarEntry);
+ }
+
+ public long getSize()
+ {
+ return jarEntry.getSize();
+ }
+
+ public URL getURL()
+ throws MalformedURLException
+ {
+ String urlString = "jar:" + file.toURL() + "!/" + jarEntry.getName();
+ return new URL(urlString);
+ }
+ }
+
+ private StreamInfo getResourceStream(String path)
+ {
+ for (int i = 0; i < pathComponents.length; ++i) {
+ try {
+ File parent = pathComponents[i];
+ if (parent.isDirectory()) {
+ File file = new File(parent, path);
+ if (file.exists()) {
+ return new FileStreamInfo(file);
+ }
+ }
+ else {
+ JarFile jarFile = new JarFile(parent, false, JarFile.OPEN_READ);
+ JarEntry jarEntry = jarFile.getJarEntry(path);
+ if (null != jarEntry) {
+ return new JarStreamInfo(parent, jarFile, jarEntry);
+ }
+ }
+ }
+ catch (IOException ignore) {
+ }
+ }
+ return null;
+ }
+
+ private byte[] loadClassData(String className)
+ throws ClassNotFoundException
+ {
+ String classFileName = className.replace('.', File.separatorChar) + ".class";
+ StreamInfo streamInfo = getResourceStream(classFileName);
+
+ try {
+ if (null != streamInfo) {
+ return readFromStream(streamInfo);
+ }
+ }
+ catch (IOException ignore) {
+ }
+
+ throw new ClassNotFoundException(className);
+ }
+
+ private static List tryGetJarFileClassPathComponents(File file)
+ {
+ try {
+ JarFile jarFile = new JarFile(file, false, JarFile.OPEN_READ);
+ Manifest manifest = jarFile.getManifest();
+ if (null != manifest) {
+ Attributes mainAttributes = manifest.getMainAttributes();
+ if (null != mainAttributes) {
+ String classPath = mainAttributes.getValue(Attributes.Name.CLASS_PATH);
+ if (null != classPath) {
+ List result = new LinkedList();
+ StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(classPath));
+ tokenizer.resetSyntax();
+ tokenizer.wordChars(0, Integer.MAX_VALUE);
+ tokenizer.whitespaceChars(9, 9); // tab
+ tokenizer.whitespaceChars(10, 10); // lf
+ tokenizer.whitespaceChars(13, 13); // cr
+ tokenizer.whitespaceChars(32, 32); // space
+ tokenizer.quoteChar('"');
+ int token;
+ while ((token = tokenizer.nextToken()) != StreamTokenizer.TT_EOF) {
+ if (StreamTokenizer.TT_WORD == token) {
+ result.add(new File(file.getParentFile(), tokenizer.sval));
+ }
+ }
+ return result;
+ }
+ }
+ }
+ }
+ catch (IOException ignore) {
+ }
+ return null;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/IOToolkit.java b/libjava/classpath/tools/gnu/classpath/tools/IOToolkit.java
new file mode 100644
index 000000000..e0ee7ba4f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/IOToolkit.java
@@ -0,0 +1,216 @@
+/* gnu.classpath.tools.IOToolkit
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import java.util.Set;
+
+/**
+ * Provides various I/O-related helper methods.
+ *
+ * @author Julian Scheid
+ */
+public class IOToolkit
+{
+ /**
+ * Prevents instantiation.
+ */
+ private IOToolkit() {}
+
+ /**
+ * Read all binary data from the given InputStream and write it to
+ * the given OutputStream. This method doesn't close either
+ * stream.
+ *
+ * @param in the stream from which to read data
+ * @param out the stream to which to write data
+ */
+ public static void copyStream(InputStream in, OutputStream out)
+ throws IOException
+ {
+ byte[] buf = new byte[256];
+ int nread;
+
+ while ((nread = in.read(buf)) >= 0) {
+ out.write(buf, 0, nread);
+ }
+ }
+
+ /**
+ * Read all character data from the given Reader and write it to
+ * the given Writer. This method doesn't close either stream.
+ *
+ * @param in the Reader from which to read character data
+ * @param out the Writer to which to write character data
+ */
+ public static void copyStream(Reader in, Writer out)
+ throws IOException
+ {
+ char[] buf = new char[256];
+ int nread;
+
+ while ((nread = in.read(buf)) >= 0) {
+ out.write(buf, 0, nread);
+ }
+ }
+
+ /**
+ * Recursively copy the contents of the input directory to the
+ * output directory. The output directory is created if it doesn't
+ * exist. If the output directory doesn't exist and can't be
+ * created, an IOException is thrown.
+ *
+ * @param sourceDir source directory from which to copy files
+ * @param targetDir target directory to which to copy files
+ * @param recursive if true, recursively copy subdirectoryies
+ * @param excludeDirs if non null, must be a Set of String. Each
+ * element from the set specifies the name of a direct
+ * subdirectory of the source directory which should be excluded
+ * from recursive copying.
+ */
+ public static void copyDirectory(File sourceDir, File targetDir,
+ boolean recursive,
+ Set excludeDirs)
+ throws IOException
+ {
+ if (!targetDir.exists() && !targetDir.mkdirs()) {
+ throw new IOException("Cannot create directory " + targetDir);
+ }
+
+ File[] sourceFiles = sourceDir.listFiles();
+ for (int i=0; i<sourceFiles.length; ++i) {
+ if (sourceFiles[i].isDirectory()) {
+ if (recursive && (null == excludeDirs
+ || !excludeDirs.contains(sourceFiles[i].getName()))) {
+ File targetSubDir = new File(targetDir,
+ sourceFiles[i].getName());
+ if (targetSubDir.exists() || targetSubDir.mkdir()) {
+ copyDirectory(sourceFiles[i], targetSubDir, recursive, null);
+ }
+ else {
+ throw new IOException("Cannot create directory " + targetSubDir);
+ }
+ }
+ }
+ else {
+ copyFile(sourceFiles[i], new File(targetDir, sourceFiles[i].getName()));
+ }
+ }
+ }
+
+ /**
+ * Copy the contents of the input file to the output file. The
+ * output file's parent directory must exist.
+ *
+ * @param sourceFile specifies the file to copy
+ * @param targetFile specifies the file to create
+ */
+ public static void copyFile(File sourceFile, File targetFile)
+ throws IOException
+ {
+ InputStream in = new FileInputStream(sourceFile);
+ OutputStream out = new FileOutputStream(targetFile);
+ int nread;
+ byte[] buf = new byte[512];
+ while ((nread = in.read(buf)) >= 0) {
+ out.write(buf, 0, nread);
+ }
+ in.close();
+ out.close();
+ }
+
+ /**
+ * Read the (remaining) contents of the given reader into a char
+ * array. This method doesn't close the reader when it is done.
+ *
+ * @param reader the Reader to read characters from
+ * @return an array with the contents of the Reader
+ */
+ public static char[] readFully(Reader reader)
+ throws IOException
+ {
+ StringWriter writer = new StringWriter();
+ final int readBufferSize = 256;
+ char[] chunk = new char[readBufferSize];
+ int nread;
+ while ((nread=reader.read(chunk))>=0) {
+ writer.write(chunk,0,nread);
+ }
+ StringBuffer buffer = writer.getBuffer();
+ char[] result = new char[buffer.length()];
+ buffer.getChars(0, buffer.length(), result, 0);
+ return result;
+ }
+
+ public static String getLineFromFile(File file, int line)
+ throws IOException
+ {
+ FileReader reader = new FileReader(file);
+ BufferedReader bufferedReader = new BufferedReader(reader);
+ while (line > 1) {
+ bufferedReader.readLine();
+ -- line;
+ }
+ String result = bufferedReader.readLine();
+ reader.close();
+ return result;
+ }
+
+ public static String getColumnDisplayLine(int column)
+ {
+ StringBuffer result = new StringBuffer();
+ while (column > 0) {
+ result.append(' ');
+ --column;
+ }
+ result.append('^');
+ return result.toString();
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/MalformedInputEvent.java b/libjava/classpath/tools/gnu/classpath/tools/MalformedInputEvent.java
new file mode 100644
index 000000000..951766f6a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/MalformedInputEvent.java
@@ -0,0 +1,110 @@
+/* gnu.classpath.tools.MalformedInputEvent
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools;
+
+import java.util.EventObject;
+
+/**
+ * Encapsulates information about malformed input encountered by a
+ * {@link NotifyingInputStreamReader}.
+ *
+ * You can use {@link getSource()} to fetch a reference to the
+ * <code>NotifyingInputStreamReader</code> which encountered the
+ * malformed input.
+ *
+ * @author Julian Scheid
+ */
+public class MalformedInputEvent
+ extends EventObject
+{
+ private int lineNumber;
+ private int columnNumber;
+ private int length;
+
+ MalformedInputEvent(NotifyingInputStreamReader source,
+ int lineNumber,
+ int columnNumber,
+ int length)
+ {
+ super(source);
+ this.columnNumber = columnNumber;
+ this.lineNumber = lineNumber;
+ this.length = length;
+ }
+
+ /**
+ * Return the 1-based line number where the malformed input begins
+ * in the stream read by the
+ * <code>NotifyingInputStreamReader</code>.
+ */
+ public int getLineNumber()
+ {
+ return lineNumber;
+ }
+
+ /**
+ * Return the 0-based column number where the malformed input
+ * begins in the stream read by the
+ * <code>NotifyingInputStreamReader</code>.
+ */
+ public int getColumnNumber()
+ {
+ return columnNumber;
+ }
+
+ /**
+ * Return the length (in bytes) of the malformed input encountered
+ * by the <code>NotifyingInputStreamReader</code>. Note that a
+ * consecutive run of malformed input isn't necessarily reported
+ * as a whole; depending on the <code>Charset</code> and
+ * implementation details of <code>CharsetDecoder</code>, the run
+ * could be reported in chunks down to individual bytes.
+ */
+ public int getLength()
+ {
+ return length;
+ }
+
+ public String toString()
+ {
+ return "MalformedInputEvent{line=" + lineNumber
+ + ",column=" + columnNumber
+ + ",length=" + length
+ + "}";
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/MalformedInputListener.java b/libjava/classpath/tools/gnu/classpath/tools/MalformedInputListener.java
new file mode 100644
index 000000000..53f806bf8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/MalformedInputListener.java
@@ -0,0 +1,56 @@
+/* gnu.classpath.tools.MalformedInputListener
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools;
+
+/**
+ * Classes implementing this interface can be notified when a {@link
+ * NotifyingInputStreamReader} encounters malformed input.
+ *
+ * @author Julian Scheid
+ */
+public interface MalformedInputListener
+{
+ /**
+ * Invoked when a <code>NotifyingInputStreamReader</code> this
+ * listener is registered with encounters malformed input.
+ *
+ * @param MalformedInputEvent contains detailed information about
+ * the event.
+ */
+ public void malformedInputEncountered(MalformedInputEvent event);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/NotifyingInputStreamReader.java b/libjava/classpath/tools/gnu/classpath/tools/NotifyingInputStreamReader.java
new file mode 100644
index 000000000..70e19b1d3
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/NotifyingInputStreamReader.java
@@ -0,0 +1,423 @@
+/* gnu.classpath.tools.NotifyingInputStreamReader
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * Similar to {@link java.io.InputStreamReader}, but can give
+ * notification when malformed input is encountered.
+ *
+ * <p> Users of this class can register interest in the event of
+ * malformed input by calling {@link
+ * #addMalformedInputListener}. Each time a run of malformed input
+ * data is encountered, all listener objects are notified. For
+ * instance, this allows the calling code to inform the user about
+ * problems in the input stream. </p>
+ *
+ * <p> <strong>Background:</strong> The default
+ * <code>InputStreamReader</code> implementation will ignore
+ * malformed input, silently replacing it with the default
+ * replacement string (usually the question mark). Alternatively, you
+ * can configure a <code>CharsetDecoder</code> for the default
+ * <char>InputStreamReader</code> implementation, instructing it to
+ * ignore malformed input without replacing it; to replace it with a
+ * different string; or to throw an exception when malformed input is
+ * encountered. However, you cannot configure an
+ * <code>InputStreamReader</code> to gracefully handle malformed data
+ * but notify the client code about such
+ * problems. <code>NotifyingInputStreamReader</code> fills this
+ * gap. </p>
+ *
+ * @author Julian Scheid
+ */
+public class NotifyingInputStreamReader
+ extends Reader
+{
+ /**
+ * The default size (in bytes) for byteBuf, i.e. the size of data
+ * chunks read from the underlying input stream.
+ */
+ private static final int DEFAULT_INPUT_BUFFER_SIZE = 64;
+
+ /**
+ * The default size (in chars) for charBuf. This should be large
+ * enough to hold a decoded chunk of input data for the Charset
+ * with the minimum number of bytes per character. Since the
+ * minimum number of bytes per character for usual Charsets is
+ * one, this number should be identical to
+ * DEFAULT_INPUT_BUFFER_SIZE.
+ */
+ private static final int DEFAULT_OUTPUT_BUFFER_SIZE = 64;
+
+ /**
+ * The underlying InputStream.
+ */
+ private InputStream in;
+
+ /**
+ * The CharsetDecoder used to decode the underlying stream.
+ */
+ private CharsetDecoder decoder;
+
+ /**
+ * Holds bytes already read from the underlying stream, but not
+ * yet decoded.
+ */
+ private ByteBuffer byteBuffer;
+
+ /**
+ * Holds characters already decoded, but not yet fetched via
+ * read().
+ */
+ private CharBuffer charBuffer;
+
+ /**
+ * This is the primitive byte array wrapped in byteBuffer for
+ * passing to to InputStream.read().
+ */
+ private byte[] readBuffer;
+
+ /**
+ * Keeps track of the current line number (1-based).
+ */
+ private int lineNumber = 1;
+
+ /**
+ * Keeps track of the current column number (0-based).
+ */
+ private int columnNumber = 0;
+
+ /**
+ * Becomes true as soon as EOF has been reached in the underlying
+ * InputStream. At this point, byteBuffer contains the last chunk
+ * of data from the underlying InputStream.
+ */
+ private boolean allInputConsumed = false;
+
+ /**
+ * Becomes true as soon as the decoder has been supplied with the
+ * last chunk of data from the InputStream after EOF has been
+ * reached. At this point, the last chunk of data has been drained
+ * from the byteBuffer.
+ */
+ private boolean decodingFinished = false;
+
+ /**
+ * Becomes true as soon as the decoder has been flushed. At this
+ * point, the last chunk of character data has been written to the
+ * charBuffer.
+ */
+ private boolean flushed = false;
+
+ /**
+ * Stores all registered MalformedInputListeners.
+ */
+ private Set listeners = new LinkedHashSet();
+
+ /**
+ * Initializes a new instance for reading from the given
+ * InputStream using the default encoding. The default encoding is
+ * currently determined by looking at the system property
+ * <code>file.encoding</code>. If this property isn't set,
+ * <code>ISO-8859-1</code> is used as a fallback.
+ *
+ * <p>This method should use {@link Charset.defaultCharset()}
+ * instead, but this isn't implemented in Classpath at the
+ * moment.</p>
+ *
+ * @param in the <code>InputStream</code> to read from.
+ */
+ public NotifyingInputStreamReader(InputStream in)
+ {
+ this(in, System.getProperty("file.encoding", "ISO-8859-1"));
+ }
+
+ /**
+ * Initializes a new instance for reading from the given
+ * InputStream using the specified charset.
+ *
+ * @param in the <code>InputStream</code> to read from.
+ * @param charsetName the canonical name or an alias of a
+ * <code>Charset</code>.
+ *
+ * @throws IllegalCharsetNameException if there is no
+ * <code>Charset</code> with the given canonical name or alias.
+ *
+ * @throws UnsupportedCharsetException if there is no support for
+ * the specified <code>Charset</code> in the runtime environment.
+ */
+ public NotifyingInputStreamReader(InputStream in, String charsetName)
+ throws IllegalCharsetNameException, UnsupportedCharsetException
+ {
+ this(in, Charset.forName(charsetName));
+ }
+
+ /**
+ * Initializes a new instance for reading from the given
+ * InputStream using the specified charset.
+ *
+ * @param in the <code>InputStream</code> to read from.
+ * @param charset the <code>Charset</code> to use for decoding
+ * characters.
+ */
+ public NotifyingInputStreamReader(InputStream in, Charset charset)
+ {
+ this(in, charset.newDecoder());
+ }
+
+ /**
+ * Initializes a new instance for reading from the given
+ * InputStream using the specified charset decoder.
+ *
+ * <strong>Note:</strong> the
+ * <code>NotifyingInputStreamReader</code> will not exhibit the
+ * advertised behaviour if you changed the action to take on
+ * malformed input in the specified
+ * <code>CharsetDecoder</code>. In other words, you should not
+ * call {@link CharsetDecoder.onMalformedInput(CodingErrorAction)}
+ * on the specified decoder before or while this reader is being
+ * used unless you know what you're doing.
+ *
+ * @param in the <code>InputStream</code> to read from.
+ * @param charset the <code>CharsetDecoder</code> to use for
+ * decoding characters.
+ */
+ public NotifyingInputStreamReader(InputStream in, CharsetDecoder decoder)
+ {
+ this.in = in;
+ this.decoder = decoder;
+ this.charBuffer = CharBuffer.wrap(new char[DEFAULT_INPUT_BUFFER_SIZE]);
+ this.charBuffer.position(charBuffer.limit());
+ this.readBuffer = new byte[DEFAULT_OUTPUT_BUFFER_SIZE];
+ this.byteBuffer = ByteBuffer.wrap(readBuffer);
+ this.byteBuffer.position(byteBuffer.limit());
+ }
+
+ public void close()
+ throws IOException
+ {
+ in.close();
+ }
+
+ /**
+ * Fill charBuffer with new character data. This method returns if
+ * either the charBuffer has been filled completely with decoded
+ * character data, or if EOF is reached in the underlying
+ * InputStream. When this method returns, charBuffer is flipped
+ * and ready to be read from.
+ */
+ private void fillCharBuf()
+ throws IOException
+ {
+ charBuffer.clear();
+ outer:
+ while (!flushed) {
+ CoderResult coderResult;
+ int charBufferPositionBefore = charBuffer.position();
+ if (!decodingFinished) {
+ coderResult = decoder.decode(byteBuffer, charBuffer, allInputConsumed);
+ if (allInputConsumed) {
+ decodingFinished = true;
+ }
+ }
+ else {
+ coderResult = decoder.flush(charBuffer);
+ flushed = coderResult.isUnderflow();
+ }
+
+ int charBufferPositionAfter = charBuffer.position();
+ for (int i=charBufferPositionBefore; i<charBufferPositionAfter; ++i) {
+ if (10 == charBuffer.get(i)) {
+ ++ lineNumber;
+ columnNumber = 0;
+ }
+ else {
+ ++ columnNumber;
+ }
+ }
+ if (coderResult.isOverflow()) {
+ break;
+ }
+ else if (coderResult.isUnderflow()) {
+ if (!allInputConsumed) {
+ int nRemainingBytes = 0;
+ if (byteBuffer.position() > 0) {
+ nRemainingBytes = Math.max(0, byteBuffer.limit() - byteBuffer.position());
+ }
+ if (nRemainingBytes > 0) {
+ byteBuffer.get(readBuffer, 0, nRemainingBytes);
+ }
+ byteBuffer.rewind();
+ int nread = in.read(readBuffer, nRemainingBytes,
+ readBuffer.length - nRemainingBytes);
+ if (nread < 0) {
+ allInputConsumed = true;
+ }
+ byteBuffer.limit(nRemainingBytes + Math.max(0, nread));
+ }
+ else {
+ break;
+ }
+ }
+ else if (coderResult.isMalformed()) {
+ fireMalformedInputEncountered(coderResult.length());
+ String replacement = decoder.replacement();
+ for (int i=0; i<coderResult.length(); ++i) {
+ if (charBuffer.remaining() > replacement.length()) {
+ charBuffer.put(replacement);
+ byteBuffer.position(byteBuffer.position() + 1);
+ columnNumber ++;
+ }
+ else {
+ break outer;
+ }
+ }
+ }
+ else if (coderResult.isUnmappable()) {
+ // This should not happen, since unmappable input bytes
+ // trigger a "malformed" event instead.
+ coderResult.throwException();
+ }
+ else {
+ // This should only happen if run in a future environment
+ // where additional events apart from underflow, overflow,
+ // malformed and unmappable can be generated.
+ coderResult.throwException();
+ }
+ }
+ charBuffer.flip();
+ }
+
+ /**
+ * Fire a MalformedInputEvent, notifying all registered listeners.
+ */
+ private void fireMalformedInputEncountered(int length)
+ {
+ MalformedInputEvent event
+ = new MalformedInputEvent(this, lineNumber, columnNumber, length);
+ Iterator it = listeners.iterator();
+ while (it.hasNext()) {
+ MalformedInputListener listener
+ = (MalformedInputListener)it.next();
+ listener.malformedInputEncountered(event);
+ }
+ }
+
+ public int read(char[] cbuf, int offset, int length)
+ throws IOException
+ {
+ if (flushed) {
+ return -1;
+ }
+ else {
+ int nread = 0;
+ while (nread < length && !flushed) {
+ while (charBuffer.hasRemaining() && nread < length) {
+ int copyLen = Math.min(length - nread,
+ charBuffer.remaining());
+ charBuffer.get(cbuf, offset + nread, copyLen);
+ nread += copyLen;
+ }
+ if (nread < length) {
+ fillCharBuf();
+ }
+ }
+ return nread;
+ }
+ }
+
+ public int read()
+ throws IOException
+ {
+ while (!flushed) {
+ if (charBuffer.hasRemaining()) {
+ return charBuffer.get();
+ }
+ else {
+ fillCharBuf();
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Returns whether this reader is ready. The reader is ready if
+ * there is data in the internal buffer, or if additional data can
+ * be read from the underlying InputStream.
+ */
+ public boolean ready()
+ {
+ return charBuffer.hasRemaining() || !flushed;
+ }
+
+ /**
+ * Register a <code>MalformedInputListener</code> which should be
+ * notified when malformed input is encountered.
+ */
+ public void addMalformedInputListener(MalformedInputListener listener)
+ {
+ this.listeners.add(listener);
+ }
+
+ /**
+ * Unregister a previously registered
+ * <code>MalformedInputListener</code> if it should no longer be
+ * notified when malformed input is encountered.
+ */
+ public void removeMalformedInputListener(MalformedInputListener listener)
+ {
+ this.listeners.remove(listener);
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/StringToolkit.java b/libjava/classpath/tools/gnu/classpath/tools/StringToolkit.java
new file mode 100644
index 000000000..dbb552707
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/StringToolkit.java
@@ -0,0 +1,84 @@
+/* gnu.classpath.tools.StringToolkit
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools;
+
+/**
+ * Provides various String-related helper methods.
+ *
+ * @author Julian Scheid
+ */
+public class StringToolkit
+{
+ /**
+ * Prevents instantiation.
+ */
+ private StringToolkit() {}
+
+ /**
+ * Return <code>haystack</code> with all occurrences of
+ * <code>needle</code> replaced by </code>replacement</code>.
+ *
+ * @param haystack the string to replace occurrences of <code>needle</code> in
+ * @param needle the substring to replace
+ * @param replacement the substring to replace <code>needle</code> with
+ *
+ * @return <code>haystack</code> with all occurrences of
+ * <code>needle</code> replaced by </code>replacement</code>.
+ */
+ public static String replace(String haystack, String needle, String replacement)
+ {
+ int ndx = haystack.indexOf(needle);
+ if (ndx < 0) {
+ return haystack;
+ }
+ else {
+ StringBuffer result = new StringBuffer();
+ result.append(haystack.substring(0, ndx));
+ result.append(replacement);
+ ndx += needle.length();
+ int ndx2;
+ while ((ndx2 = haystack.indexOf(needle, ndx)) >= 0) {
+ result.append(haystack.substring(ndx, ndx2));
+ result.append(replacement);
+ ndx = ndx2 + needle.length();
+ }
+ result.append(haystack.substring(ndx));
+ return result.toString();
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java
new file mode 100644
index 000000000..dfbedfe36
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java
@@ -0,0 +1,81 @@
+/* AppletClassLoader -- a loader for applet classes
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+
+public class AppletClassLoader extends URLClassLoader
+{
+ /**
+ * Constructs a new <code>AppletLoader</code> object.
+ *
+ * @param codebase the codebase of the applet
+ * @param archives the urls to add to the search path
+ */
+ public AppletClassLoader(URL codebase, ArrayList archives)
+ {
+ super(new URL[0]);
+
+ for (int count = 0; count < archives.size(); count++)
+ addURL((URL) archives.get(count));
+
+ addURL(codebase);
+ }
+
+ /**
+ * Finds the specified class. This method should be overridden by
+ * class loader implementations that follow the delegation model for
+ * loading classes, and will be invoked by the loadClass method after
+ * checking the parent class loader for the requested class. The default
+ * implementation throws a ClassNotFoundException.
+ *
+ * (description copied from java.lang.ClassLoader.findClass(String))
+ *
+ * @param name The name of the class.
+ *
+ * @return the resulting <code>Class</code> object.
+ *
+ * @exception ClassNotFoundException if the class is not found.
+ */
+ protected Class findClass(String name) throws ClassNotFoundException
+ {
+ return super.findClass(name);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java
new file mode 100644
index 000000000..6522a9ec1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java
@@ -0,0 +1,95 @@
+/* AppletSecurityManager.java -- an applet security manager
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.io.FilePermission;
+import java.net.SocketPermission;
+import java.security.Permission;
+import java.security.SecurityPermission;
+import java.util.PropertyPermission;
+
+class AppletSecurityManager extends SecurityManager
+{
+ private boolean plugin;
+
+ AppletSecurityManager(boolean plugin)
+ {
+ this.plugin = plugin;
+ }
+
+ public void checkPermission(Permission permission)
+ {
+ if (permission == null)
+ throw new NullPointerException();
+
+ // FIXME: we need to restrict this.
+ //
+ // libgcj asks for "java.io.FilePermission <<ALL FILES>> execute"
+ // to be able to execute "addr2line" to get proper stack traces.
+ if (permission instanceof FilePermission)
+ return;
+
+ // FIXME: we need to restrict this.
+ if (permission instanceof SecurityPermission)
+ return;
+
+ // FIXME: is this really needed ?
+ if (permission instanceof PropertyPermission)
+ return;
+
+ // Needed to allow to access AWT event queue.
+ if (permission.getName().equals("accessEventQueue"))
+ return;
+
+ // Needed to create a class loader for each codebase.
+ if (permission.getName().equals("createClassLoader"))
+ return;
+
+ // FIXME: we need to allow access to codebase here.
+
+ if (permission instanceof SocketPermission // for net access
+ || permission instanceof RuntimePermission) // for checkWrite(FileDescriptor)
+ return;
+
+ if (! plugin && permission.getName().equals("exitVM"))
+ return;
+
+ // Reject all other permissions.
+ throw new SecurityException();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java
new file mode 100644
index 000000000..d3910a2a6
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java
@@ -0,0 +1,489 @@
+/* AppletTag.java -- a representation of an HTML APPLET tag
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import gnu.xml.dom.html2.DomHTMLAppletElement;
+import gnu.xml.dom.html2.DomHTMLEmbedElement;
+import gnu.xml.dom.html2.DomHTMLObjectElement;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+
+import java.io.File;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Locale;
+
+/**
+ * @author Lillian Angel (langel@redhat.com)
+ * @author Thomas Fitzsimmons (fitzsim@redhat.com)
+ */
+class AppletTag
+{
+
+ /**
+ * The document base of this applet.
+ */
+ URL documentbase;
+
+ /**
+ * name of applet tag.
+ */
+ String name = "";
+
+ /**
+ * code of applet tag.
+ */
+ String code = "";
+
+ /**
+ * codebase of applet tag.
+ */
+ String codebase = "";
+
+ /**
+ * The archives.
+ */
+ ArrayList archives = new ArrayList();
+
+ /**
+ * The parameters.
+ */
+ HashMap parameters = new HashMap();
+
+ /**
+ * The screen size.
+ */
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+
+ /**
+ * Default constructor.
+ */
+ AppletTag()
+ {
+ // Do nothing.
+ }
+
+ /**
+ * Constructs an AppletTag and parses the given applet element.
+ *
+ * @param appElement - the Applet element to parse.
+ */
+ AppletTag(DomHTMLAppletElement appElement)
+ {
+ name = appElement.getName();
+ parameters.put("name", name);
+
+ parameters.put("object", appElement.getObject());
+ parameters.put("align", appElement.getAlign());
+ parameters.put("alt", appElement.getAlt());
+ parameters.put("height", appElement.getHeight());
+ parameters.put("hspace", Integer.toString(appElement.getHspace()));
+ parameters.put("vspace", Integer.toString(appElement.getVspace()));
+ parameters.put("width", appElement.getWidth());
+
+ TagParser.parseParams(appElement, this);
+
+ if (code.equals(""))
+ {
+ code = appElement.getCode();
+ if (code.equals(""))
+ code = appElement.getCls();
+ }
+
+ // Must initialize codebase before archives
+ if (codebase.equals(""))
+ {
+ codebase = appElement.getCodeBase();
+ if (codebase.equals(""))
+ codebase = appElement.getSrc();
+ }
+
+ if (archives.size() == 0)
+ {
+ String arcs = "";
+ String arch = appElement.getArchive();
+
+ if (code.indexOf(".") < 0)
+ arcs = code + ".jar";
+
+ if (!arch.equals(""))
+ arcs += "," + arch;
+
+ if (!arcs.equals(""))
+ archives = TagParser.parseArchives(arcs, this);
+ }
+ }
+
+ /**
+ * Constructs an AppletTag and parses the given embed element.
+ *
+ * @param embElement - the Embed element to parse.
+ */
+ AppletTag(DomHTMLEmbedElement embElement)
+ {
+ // In an EMBED tag, a parameter is any non-standard attribute. This
+ // is a problem for applets that take parameters named "code",
+ // "codebase", "archive", "object", or "type". The solution is to
+ // allow the same attributes, prefixed by "java_". The presence of
+ // a "java_" attribute indicates that the non-prefixed attribute
+ // should be interpreted as a parameter. For example if "java_code"
+ // and "code" attributes are present in the EMBED tag then the
+ // "code" attribute is interpreted as a parameter.
+
+ name = embElement.getName();
+ parameters.put("name", name);
+
+ String jobj = embElement.getJavaObject();
+ if (!jobj.equals(""))
+ parameters.put("java_object", jobj);
+ else
+ parameters.put("object", embElement.getObject());
+
+ parameters.put("width", embElement.getWidth());
+ parameters.put("height", embElement.getHeight());
+ parameters.put("align", embElement.getAlign());
+ parameters.put("alt", embElement.getAlt());
+ parameters.put("hspace", Integer.toString(embElement.getHspace()));
+ parameters.put("mayscript", embElement.getMayscript());
+ parameters.put("pluginspage", embElement.getPluginsPage());
+ parameters.put("title", embElement.getTitle());
+ parameters.put("type", embElement.getType());
+ parameters.put("java_type", embElement.getJavaType());
+ parameters.put("vspace", Integer.toString(embElement.getVspace()));
+
+ TagParser.parseParams(embElement, this);
+
+ // Must initialize codebase before archives
+ if (codebase.equals(""))
+ {
+ String javacb = embElement.getJavaCodeBase();
+ if (!javacb.equals(""))
+ codebase = javacb;
+ else
+ codebase = embElement.getCodeBase();
+ }
+
+ if (code.equals(""))
+ {
+ String jcode = embElement.getJavaCode();
+ if (!jcode.equals(""))
+ code = jcode;
+ else
+ code = embElement.getCode();
+ }
+
+ if (archives.size() == 0)
+ {
+ String arcs = "";
+ String jarch = embElement.getJavaArchive();
+ String arch = embElement.getArchive();
+
+ if (code.indexOf(".") < 0)
+ arcs = code + ".jar";
+
+ if (!jarch.equals(""))
+ arcs += "," + jarch;
+ else if (!arch.equals(""))
+ arcs += "," + arch;
+
+ if (!arcs.equals(""))
+ archives = TagParser.parseArchives(arcs, this);
+ }
+ }
+
+ /**
+ * Constructs an AppletTag and parses the given object element.
+ *
+ * @param objElement - the Object element to parse.
+ */
+ AppletTag(DomHTMLObjectElement objElement)
+ {
+ // In an OBJECT tag, a parameter is any non-standard attribute. This
+ // is a problem for applets that take parameters named "code",
+ // "codebase", "archive", "object", or "type". The solution is to
+ // allow the same attributes, prefixed by "java_". The presence of
+ // a "java_" attribute indicates that the non-prefixed attribute
+ // should be interpreted as a parameter. For example if "java_code"
+ // and "code" attributes are present in the OBJECT tag then the
+ // "code" attribute is interpreted as a parameter.
+
+ name = objElement.getName();
+ parameters.put("name", name);
+
+ String jobj = objElement.getJavaObject();
+ if (!jobj.equals(""))
+ parameters.put("java_object", jobj);
+ else
+ parameters.put("object", objElement.getObject());
+
+ parameters.put("type", objElement.getType());
+ parameters.put("java_type", objElement.getJavaType());
+ parameters.put("align", objElement.getAlign());
+ parameters.put("codetype", objElement.getCodeType());
+ parameters.put("data", objElement.getData());
+ parameters.put("declare", Boolean.toString(objElement.getDeclare()));
+ parameters.put("height", objElement.getHeight());
+ parameters.put("hspace", Integer.toString(objElement.getHspace()));
+ parameters.put("border", objElement.getBorder());
+ parameters.put("standby", objElement.getStandby());
+ parameters.put("tabindex", Integer.toString(objElement.getTabIndex()));
+ parameters.put("usemap", objElement.getUseMap());
+ parameters.put("vspace", Integer.toString(objElement.getVspace()));
+ parameters.put("width", objElement.getWidth());
+ parameters.put("mayscript", objElement.getMayscript());
+ parameters.put("scriptable", objElement.getScriptable());
+
+ TagParser.parseParams(objElement, this);
+
+ // Must initialize codebase before archives
+ if (codebase.equals(""))
+ {
+ String javacb = objElement.getJavaCodeBase();
+ if (! javacb.equals(""))
+ codebase = javacb;
+ else
+ codebase = objElement.getCodeBase();
+ }
+
+ if (code.equals(""))
+ {
+ String jcode = objElement.getJavaCode();
+ if (!jcode.equals(""))
+ code = jcode;
+ else
+ code = objElement.getCode();
+ }
+
+ if (archives.size() == 0)
+ {
+ String arcs = "";
+ String jarch = objElement.getJavaArchive();
+ String arch = objElement.getArchive();
+
+ if (code.indexOf(".") < 0)
+ arcs = code + ".jar";
+
+ if (!jarch.equals(""))
+ arcs += "," + jarch;
+ else if (!arch.equals(""))
+ arcs += "," + arch;
+
+ if (!arcs.equals(""))
+ archives = TagParser.parseArchives(arcs, this);
+ }
+ }
+
+ /**
+ * String representation of the tag.
+ *
+ * @return the string representation.
+ */
+ public String toString()
+ {
+ return (" name=" + name + "\n" + " code=" + code + "\n" + " codebase="
+ + codebase + "\n" + " archive=" + archives + "\n" + " parameters="
+ + parameters + "\n" + " documentbase=" + documentbase + "\n");
+ }
+
+ /**
+ * Returns the size of the applet.
+ *
+ * @return the size.
+ */
+ Dimension getSize()
+ {
+ Dimension size = new Dimension(320, 200);
+
+ try
+ {
+ String widthStr = (String) parameters.get("width");
+
+ if (widthStr != null && ! widthStr.equals(""))
+ {
+ if (widthStr.charAt(widthStr.length() - 1) == '%')
+ {
+ double p = NumberFormat.getPercentInstance(Locale.US).parse(widthStr).intValue() / 100.0;
+ size.width = (int)(p * screenSize.width);
+ }
+ else
+ size.width = NumberFormat.getInstance(Locale.US).parse(widthStr).intValue();
+ }
+ }
+ catch (ParseException e)
+ {
+ // Use default.
+ }
+
+ try
+ {
+ String heightStr = (String) parameters.get("height");
+
+ if (heightStr != null && !heightStr.equals(""))
+ {
+ if (heightStr.charAt(heightStr.length() - 1) == '%')
+ {
+ double p = NumberFormat.getPercentInstance(Locale.US).parse(heightStr).intValue() / 100.0;
+ size.height = (int) (p * screenSize.height);
+ }
+ else
+ size.height = NumberFormat.getInstance(Locale.US).parse(heightStr).intValue();
+ }
+ }
+ catch (ParseException e)
+ {
+ // Use default.
+ }
+
+ return size;
+ }
+
+ /**
+ * Gets the code base.
+ *
+ * @return the codebase.
+ */
+ String getCodeBase()
+ {
+ return codebase;
+ }
+
+ /**
+ * Gets the archive list.
+ *
+ * @return the archive list.
+ */
+ ArrayList getArchives()
+ {
+ return archives;
+ }
+
+ /**
+ * Gets the code.
+ *
+ * @return the code.
+ */
+ String getCode()
+ {
+ return code;
+ }
+
+ /**
+ * Gets the document base.
+ *
+ * @return the document base.
+ */
+ URL getDocumentBase()
+ {
+ return documentbase;
+ }
+
+ /**
+ * Gets the specified parameter.
+ *
+ * @param name - the specified parameter.
+ * @return the parameter.
+ */
+ String getParameter(String name)
+ {
+ return (String) parameters.get(name.toLowerCase());
+ }
+
+ /**
+ * Prepends the base to the codebase.
+ *
+ * @return the new URL.
+ */
+ URL prependCodeBase(String base) throws MalformedURLException
+ {
+ if (documentbase == null)
+ documentbase = TagParser.db;
+
+ URL fullcodebase;
+
+ //If no codebase was specified, default to documentbase.
+ if (codebase.equals(""))
+ {
+ if (documentbase.getFile().endsWith(File.separator))
+ fullcodebase = documentbase;
+ else
+ {
+ String dirname = documentbase.getFile();
+ if (dirname.indexOf(".") < 0)
+ fullcodebase = new URL(documentbase + File.separator);
+ else
+ {
+ // Determine dirname for file by stripping everything
+ // past the last file separator.
+ dirname = dirname.substring(0,
+ dirname.lastIndexOf(File.separatorChar) + 1);
+
+ fullcodebase = new URL(documentbase.getProtocol(),
+ documentbase.getHost(),
+ documentbase.getPort(), dirname);
+ }
+ }
+ }
+ else
+ {
+ // codebase was specified.
+ URL codebaseURL = new URL(documentbase, codebase);
+
+ if ("file".equals(codebaseURL.getProtocol()))
+ {
+ if (new File(codebaseURL.getFile()).isDirectory() && !codebase.endsWith(File.separator))
+ fullcodebase = new URL(documentbase, codebase + File.separator);
+ else
+ fullcodebase = new URL(documentbase, codebase);
+ }
+ else if (codebase.endsWith(File.separator))
+ fullcodebase = new URL(documentbase, codebase);
+ else
+ fullcodebase = new URL(documentbase, codebase + File.separator);
+ }
+
+ return new URL(fullcodebase, base);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java
new file mode 100644
index 000000000..ebdd35922
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java
@@ -0,0 +1,133 @@
+/* CommonAppletContext.java -- a common applet's context
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.applet.AudioClip;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+
+/*
+ * CommonAppletContext represents the common context stuff for both
+ * types, plugins and standalone.
+ */
+abstract class CommonAppletContext
+ implements AppletContext
+{
+ // FIXME: this needs to be static, and we need one AppletContext per
+ // Applet.
+ List applets = new ArrayList();
+ HashMap streams = new HashMap();
+
+ void addApplet(Applet applet)
+ {
+ applets.add(applet);
+ }
+
+ ///////////////////////////////
+ //// AppletContext methods ////
+ ///////////////////////////////
+ public AudioClip getAudioClip(URL url)
+ {
+ return Applet.newAudioClip(url);
+ }
+
+ public Image getImage(URL url)
+ {
+ return Toolkit.getDefaultToolkit().getImage(url);
+ }
+
+ public Applet getApplet(String name)
+ {
+ Applet a;
+ String appletName;
+ Iterator i = applets.iterator();
+
+ while (i.hasNext())
+ {
+ a = (Applet) i.next();
+
+ appletName = a.getParameter("name");
+ if (a != null && appletName != null && appletName.equals(name))
+ return a;
+ }
+ return null;
+ }
+
+ public Enumeration getApplets()
+ {
+ return Collections.enumeration(applets);
+ }
+
+ public void showDocument(URL url)
+ {
+ showDocument(url, "_self");
+ }
+
+ /*
+ // FIXME: implement.
+ public abstract void showDocument (URL url, String target);
+
+ // FIXME: implement.
+ public abstract void showStatus (String status);
+ */
+ public void setStream(String key, InputStream stream)
+ {
+ streams.put(key, stream);
+ }
+
+ public InputStream getStream(String key)
+ {
+ return (InputStream) streams.get(key);
+ }
+
+ public Iterator getStreamKeys()
+ {
+ return streams.keySet().iterator();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
new file mode 100644
index 000000000..bf14db573
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
@@ -0,0 +1,139 @@
+/* CommonAppletStub.java -- an applet-browser interface class
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.applet.AppletContext;
+import java.applet.AppletStub;
+import java.applet.Applet;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+
+class CommonAppletStub
+ implements AppletStub
+{
+ private AppletTag tag;
+ private AppletContext context;
+ private Applet applet;
+
+ CommonAppletStub(AppletTag tag, AppletContext context, Applet applet)
+ {
+ this.tag = tag;
+ this.context = context;
+ this.applet = applet;
+ }
+
+ ////////////////////////////////
+ ////// AppletStub Methods //////
+ ////////////////////////////////
+
+ /**
+ * Tests whether or not this applet is currently active. An applet
+ * becomes active just before the browser invokes start (), and
+ * becomes inactive just before the browser invokes stop ().
+ *
+ * @return true if applet is active, false otherwise
+ */
+ public boolean isActive()
+ {
+ return true;
+ }
+
+ /**
+ * Returns the basename URL of the document in which this applet is
+ * embedded.
+ *
+ * @return the document base url.
+ */
+ public URL getDocumentBase()
+ {
+ return tag.getDocumentBase();
+ }
+
+ /**
+ * Returns the URL of the code base for this applet.
+ *
+ * @return the codebase url
+ */
+ public URL getCodeBase()
+ {
+ try
+ {
+ return tag.prependCodeBase("");
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Attempted to create"
+ + " invalid codebase URL.", e);
+ }
+ }
+
+ /**
+ * Returns the value of the specified parameter that was specified
+ * in the <code>APPLET</code> tag for this applet.
+ *
+ * @param name the key name
+ *
+ * @return the key value
+ */
+ public String getParameter(String name)
+ {
+ return tag.getParameter(name.toLowerCase());
+ }
+
+ /**
+ * Returns the applet context for this applet.
+ *
+ * @return the context
+ */
+ public AppletContext getAppletContext()
+ {
+ return context;
+ }
+
+ /**
+ * Requests that the applet window for this applet be resized.
+ *
+ * @param width the new witdh
+ * @param height the new height
+ */
+ public void appletResize(int width, int height)
+ {
+ applet.setBounds (0, 0, width, height);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java
new file mode 100644
index 000000000..059dbee40
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java
@@ -0,0 +1,53 @@
+/* ErrorApplet.java -- an applet to load in case of an error
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.applet.Applet;
+import java.awt.BorderLayout;
+import java.awt.Button;
+
+public class ErrorApplet extends Applet
+{
+ public ErrorApplet(String message)
+ {
+ setLayout(new BorderLayout());
+
+ Button button = new Button(message);
+ add(button);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java
new file mode 100644
index 000000000..f6e02dbaa
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java
@@ -0,0 +1,323 @@
+/* Main.java -- a standalone viewer for Java applets
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import java.applet.Applet;
+import java.awt.Dimension;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+
+class Main
+{
+ private static HashMap classLoaderCache = new HashMap();
+
+ private static ClassLoader getClassLoader(URL codebase, ArrayList archives)
+ {
+ // Should load class loader each time. It is possible that there
+ // are more than one applet to be loaded with different archives.
+ AppletClassLoader loader = new AppletClassLoader(codebase, archives);
+ classLoaderCache.put(codebase, loader);
+
+ return loader;
+ }
+
+ private static String code = null;
+ private static String codebase = null;
+ private static String archive = null;
+ private static List parameters = new ArrayList();
+ private static Dimension dimensions = new Dimension(-1, -1);
+ private static String pipeInName = null;
+ private static String pipeOutName = null;
+ private static boolean pluginMode = false;
+ private static Parser parser = null;
+
+ static Applet createApplet(AppletTag tag)
+ {
+ Applet applet = null;
+
+ try
+ {
+ ClassLoader loader = getClassLoader(tag.prependCodeBase(""),
+ tag.getArchives());
+ String code = tag.getCode();
+
+ if (code.endsWith(".class"))
+ code = code.substring(0, code.length() - 6).replace('/', '.');
+
+ Class c = loader.loadClass(code);
+ applet = (Applet) c.newInstance();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (applet == null)
+ applet = new ErrorApplet(Messages.getString ("Main.ErrorApplet"));
+
+ return applet;
+ }
+
+ protected static boolean verbose;
+
+ /**
+ * The main method starting the applet viewer.
+ *
+ * @param args the arguments given on the command line.
+ *
+ * @exception IOException if an error occurs.
+ */
+ public static void main(String[] args) throws IOException
+ {
+ parser = new ClasspathToolParser("appletviewer", true);
+ parser.setHeader(Messages.getString("Main.Usage"));
+
+ OptionGroup attributeGroup
+ = new OptionGroup(Messages.getString("Main.AppletTagOptions"));
+
+ attributeGroup.add(new Option("code",
+ Messages.getString("Main.CodeDescription"),
+ Messages.getString("Main.CodeArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ code = argument;
+ }
+ });
+ attributeGroup.add
+ (new Option("codebase",
+ Messages.getString("Main.CodebaseDescription"),
+ Messages.getString("Main.CodebaseArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ codebase = argument;
+ }
+ });
+ attributeGroup.add
+ (new Option("archive",
+ Messages.getString("Main.ArchiveDescription"),
+ Messages.getString("Main.ArchiveArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ archive = argument;
+ }
+ });
+ attributeGroup.add(new Option("width",
+ Messages.getString("Main.WidthDescription"),
+ Messages.getString("Main.WidthArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ dimensions.width = Integer.parseInt(argument);
+ }
+ });
+ attributeGroup.add(new Option("height",
+ Messages.getString("Main.HeightDescription"),
+ Messages.getString("Main.HeightArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ dimensions.height = Integer.parseInt(argument);
+ }
+ });
+ attributeGroup.add(new Option("param",
+ Messages.getString("Main.ParamDescription"),
+ Messages.getString("Main.ParamArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ parameters.add(argument);
+ }
+ });
+ OptionGroup pluginGroup
+ = new OptionGroup(Messages.getString("Main.PluginOption"));
+ pluginGroup.add(new Option("plugin",
+ Messages.getString("Main.PluginDescription"),
+ Messages.getString("Main.PluginArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ pluginMode = true;
+ int comma = argument.indexOf(',');
+ pipeInName = argument.substring(0, comma);
+ pipeOutName = argument.substring(comma + 1);
+ }
+ });
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebuggingOption"));
+ debuggingGroup.add
+ (new Option("verbose",
+ Messages.getString("Main.VerboseDescription"),
+ (String) null)
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ OptionGroup compatibilityGroup
+ = new OptionGroup(Messages.getString("Main.CompatibilityOptions"));
+ compatibilityGroup.add
+ (new Option("debug",
+ Messages.getString("Main.DebugDescription"),
+ (String) null)
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ // Currently ignored.
+ }
+ });
+ compatibilityGroup.add
+ (new Option("encoding",
+ Messages.getString("Main.EncodingDescription"),
+ Messages.getString("Main.EncodingArgument"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ // FIXME: We should probably be using
+ // java.nio.charset.CharsetDecoder to handle the encoding. What
+ // is the status of Classpath's implementation?
+ }
+ });
+ parser.add(attributeGroup);
+ parser.add(pluginGroup);
+ parser.add(debuggingGroup);
+ parser.add(compatibilityGroup);
+
+ String[] urls = parser.parse(args);
+
+ // Print arguments.
+ printArguments(args);
+
+ args = urls;
+
+ if (dimensions.height < 0)
+ dimensions.height = 200;
+
+ if (dimensions.width < 0)
+ dimensions.width = (int) (1.6 * dimensions.height);
+
+ //System.setSecurityManager(new AppletSecurityManager(pluginMode));
+
+ if (pluginMode)
+ {
+ // Plugin will warn user about missing security manager.
+ InputStream in;
+ OutputStream out;
+
+ in = new FileInputStream(pipeInName);
+ out = new FileOutputStream(pipeOutName);
+
+ PluginAppletViewer.start(in, out);
+ }
+ else
+ {
+ // Warn user about missing security manager.
+ System.err.println(Messages.getString("Main.SecurityWarning") + "\n");
+
+ System.err.println(Messages.getString("Main.ContinuationPrompt"));
+
+ BufferedReader stdin
+ = new BufferedReader(new InputStreamReader(System.in));
+ String response = null;
+
+ try
+ {
+ response = stdin.readLine();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to read response"
+ + " to continuation prompt.", e);
+ }
+
+ if (!(response.equals("c") || response.equals("C")))
+ {
+ System.exit(0);
+ }
+
+ if (code == null)
+ {
+ // The --code option wasn't given and there are no URL
+ // arguments so we have nothing to work with.
+ if (args.length == 0)
+ {
+ System.err.println(Messages.getString("Main.NoInputFiles"));
+ System.exit(1);
+ }
+ // Create a standalone appletviewer from a list of URLs.
+ new StandaloneAppletViewer(args);
+ }
+ else
+ {
+ // Create a standalone appletviewer from the --code
+ // option.
+ new StandaloneAppletViewer(code, codebase, archive,
+ parameters, dimensions);
+ }
+ }
+ }
+
+ static void printArguments(String[] args)
+ {
+ if (verbose)
+ {
+ System.out.println(Messages.getString("Main.RawArguments"));
+
+ for (int i = 0; i < args.length; i++)
+ System.out.println(" " + args[i]);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Messages.java
new file mode 100644
index 000000000..614a509fd
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for appletviewer
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.appletviewer;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.appletviewer.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
new file mode 100644
index 000000000..bc445a6b3
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
@@ -0,0 +1,72 @@
+/* PluginAppletContext.java -- an applet's context within a web browser
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.net.URL;
+import java.io.IOException;
+
+/*
+ * PluginAppletContext represents the context within a webpage of a
+ * group of applets that all share the same codebase.
+ */
+class PluginAppletContext extends CommonAppletContext
+{
+ public void showDocument(URL url, String target)
+ {
+ try
+ {
+ PluginAppletViewer.write("url " + url + " " + target);
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeException("showDocument failed.", e);
+ }
+ }
+
+ public void showStatus(String status)
+ {
+ try
+ {
+ PluginAppletViewer.write("status " + status);
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeException("showStatus failed.", e);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
new file mode 100644
index 000000000..da8399b6b
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
@@ -0,0 +1,178 @@
+/* PluginAppletViewer.java -- manages embeddable applet windows
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+
+
+/**
+ * PluginAppletViewer communicates through pipes with a web browser
+ * plugin. A PluginAppletViewer manages applet windows that may be
+ * embedded into web pages.
+ */
+class PluginAppletViewer
+{
+ // A mapping of instance IDs to PluginAppletWindows.
+ static HashMap appletWindows = new HashMap ();
+
+ private static BufferedReader pluginInputStream;
+ private static BufferedWriter pluginOutputStream;
+
+ static void start(InputStream inputStream, OutputStream outputStream)
+ throws MalformedURLException, IOException
+ {
+ // Set up input and output pipes. Use UTF-8 encoding.
+ pluginInputStream =
+ new BufferedReader(new InputStreamReader(inputStream,
+ Charset.forName("UTF-8")));
+ pluginOutputStream =
+ new BufferedWriter(new OutputStreamWriter(outputStream,
+ Charset.forName("UTF-8")));
+
+ write("running");
+
+ // Read first message.
+ String message = read();
+
+ PluginAppletWindow currentWindow = null;
+
+ while (true)
+ {
+ if (message.startsWith("instance"))
+ {
+ // Read applet instance identifier.
+ String key = message.substring(9);
+
+ if (appletWindows.get(key) == null)
+ appletWindows.put(key, new PluginAppletWindow());
+
+ currentWindow = (PluginAppletWindow) appletWindows.get(key);
+ }
+ else if (message.startsWith("tag"))
+ {
+ int pos = message.indexOf(' ', 4);
+ String documentbase = message.substring(4, pos);
+ String tag = message.substring(pos + 1);
+ currentWindow.setParser(tag, documentbase);
+ }
+ else if (message.startsWith("handle"))
+ {
+ long handle = Long.parseLong(message.substring(7));
+
+ currentWindow.setHandle(handle);
+ }
+ else if (message.startsWith("width"))
+ {
+ int width = Integer.parseInt(message.substring(6));
+
+ currentWindow.setSize(width, currentWindow.getHeight());
+ }
+ else if (message.startsWith("height"))
+ {
+ int height = Integer.parseInt(message.substring(7));
+
+ currentWindow.setSize(currentWindow.getWidth(), height);
+ }
+ else if (message.startsWith("destroy"))
+ {
+ appletWindows.remove(currentWindow);
+ currentWindow.dispose();
+ }
+
+ // Read next message.
+ message = read();
+ }
+ }
+
+ /**
+ * Write string to plugin.
+ *
+ * @param message the message to write
+ *
+ * @exception IOException if an error occurs
+ */
+ static void write(String message) throws IOException
+ {
+ pluginOutputStream.write(message, 0, message.length());
+ pluginOutputStream.newLine();
+ pluginOutputStream.flush();
+
+ System.err.println
+ (" " + Messages.getString("PluginAppletViewer.AppletViewerWrote")
+ + message);
+ }
+
+ /**
+ * Read string from plugin.
+ *
+ * @return the read string
+ *
+ * @exception IOException if an error occurs
+ */
+ static String read() throws IOException
+ {
+ String message = pluginInputStream.readLine();
+
+ System.err.println
+ (" " + Messages.getString("PluginAppletViewer.AppletViewerRead")
+ + message);
+
+ if (message == null || message.equals("shutdown"))
+ {
+ // Close input/output channels to plugin.
+ pluginInputStream.close();
+ pluginOutputStream.close();
+
+ System.err.println
+ (Messages.getString("PluginAppletViewer.AppletViewerExiting"));
+
+ System.exit(0);
+ }
+
+ return message;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
new file mode 100644
index 000000000..bc44a73d8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
@@ -0,0 +1,448 @@
+/* PluginAppletWindow.java -- an embeddable applet window
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import gnu.java.awt.EmbeddedWindow;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.awt.Dimension;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+
+class PluginAppletWindow
+ extends EmbeddedWindow
+ implements ContainerListener, ComponentListener, MouseListener,
+ MouseMotionListener, InputMethodListener, HierarchyListener,
+ HierarchyBoundsListener
+{
+
+ // This class implements various listeners because the author of an applet
+ // may attach listeners to it, unaware of the applet's parent (this class).
+ // So, we must pass all listener events on this plugin applet window to the
+ // actual applet.
+
+ private static HashMap contexts = new HashMap();
+ private Applet applet;
+ private TagParser parser;
+ private AppletTag tag;
+
+ PluginAppletWindow()
+ {
+ super();
+ addContainerListener(this);
+ addComponentListener(this);
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ addInputMethodListener(this);
+ addHierarchyListener(this);
+ addHierarchyBoundsListener(this);
+ }
+
+ ///////////////////////////////////
+ /// ContainerListener Methods /////
+ ///////////////////////////////////
+
+ /**
+ * This method is called when a component is added to the container.
+ *
+ * @param event the <code>ContainerEvent</code> indicating component
+ * addition
+ */
+ public void componentAdded(ContainerEvent event)
+ {
+ if (applet != null)
+ {
+ ContainerListener[] l = applet.getContainerListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentAdded(event);
+ }
+ }
+
+ /**
+ * This method is called when a component is removed from the container.
+ *
+ * @param event the <code>ContainerEvent</code> indicating component removal
+ */
+ public void componentRemoved(ContainerEvent event)
+ {
+ if (applet != null)
+ {
+ ContainerListener[] l = applet.getContainerListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentRemoved(event);
+ }
+ }
+
+ ///////////////////////////////////
+ /// ComponentListener Methods /////
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the component is resized.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the resize
+ */
+ public void componentResized(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentResized(event);
+ }
+ }
+
+ /**
+ * This method is called when the component is moved.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the move
+ */
+ public void componentMoved(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentMoved(event);
+ }
+ }
+
+ /**
+ * This method is called when the component is made visible.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the visibility
+ */
+ public void componentShown(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentShown(event);
+ }
+ }
+
+ /**
+ * This method is called when the component is hidden.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the visibility
+ */
+ public void componentHidden(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentHidden(event);
+ }
+ }
+
+ ///////////////////////////////////
+ ////// MouseListener Methods //////
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the mouse is clicked (pressed and released
+ * in short succession) on a component.
+ *
+ * @param event the <code>MouseEvent</code> indicating the click
+ */
+ public void mouseClicked(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseClicked(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse is pressed over a component.
+ *
+ * @param event the <code>MouseEvent</code> for the press
+ */
+ public void mousePressed(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mousePressed(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse is released over a component.
+ *
+ * @param event the <code>MouseEvent</code> for the release
+ */
+ public void mouseReleased(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseReleased(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse enters a component.
+ *
+ * @param event the <code>MouseEvent</code> for the entry
+ */
+ public void mouseEntered(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseEntered(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse exits a component.
+ *
+ * @param event the <code>MouseEvent</code> for the exit
+ */
+ public void mouseExited(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseExited(event);
+ }
+ }
+
+ ///////////////////////////////////
+ /// MouseMotionListener Methods ///
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the mouse is moved over a component
+ * while a button has been pressed.
+ *
+ * @param event the <code>MouseEvent</code> indicating the motion
+ */
+ public void mouseDragged(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseMotionListener[] l = applet.getMouseMotionListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseDragged(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse is moved over a component
+ * while no button is pressed.
+ *
+ * @param event the <code>MouseEvent</code> indicating the motion
+ */
+ public void mouseMoved(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseMotionListener[] l = applet.getMouseMotionListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseMoved(event);
+ }
+ }
+
+ ///////////////////////////////////
+ /// InputMethodListener Methods ///
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the text is changed.
+ *
+ * @param event the <code>InputMethodEvent</code> indicating the text change
+ */
+ public void inputMethodTextChanged(InputMethodEvent event)
+ {
+ if (applet != null)
+ {
+ InputMethodListener[] l = applet.getInputMethodListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].inputMethodTextChanged(event);
+ }
+ }
+
+ /**
+ * This method is called when the cursor position within the text is changed.
+ *
+ * @param event the <code>InputMethodEvent</code> indicating the change
+ */
+ public void caretPositionChanged(InputMethodEvent event)
+ {
+ if (applet != null)
+ {
+ InputMethodListener[] l = applet.getInputMethodListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].caretPositionChanged(event);
+ }
+ }
+
+ ///////////////////////////////////
+ //// HierarchyListener Methods ////
+ ///////////////////////////////////
+
+ /**
+ * Called when the hierarchy of this component changes. Use
+ * <code>getChangeFlags()</code> on the event to see what exactly changed.
+ *
+ * @param event the event describing the change
+ */
+ public void hierarchyChanged(HierarchyEvent event)
+ {
+ if (applet != null)
+ {
+ HierarchyListener[] l = applet.getHierarchyListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].hierarchyChanged(event);
+ }
+ }
+
+ /////////////////////////////////////////
+ //// HierarchyBoundsListener Methods ////
+ /////////////////////////////////////////
+
+ /**
+ * Called when an ancestor component of the source is moved.
+ *
+ * @param e the event describing the ancestor's motion
+ */
+ public void ancestorMoved(HierarchyEvent e)
+ {
+ if (applet != null)
+ {
+ HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].ancestorMoved(e);
+ }
+ }
+
+ /**
+ * Called when an ancestor component is resized.
+ *
+ * @param e the event describing the ancestor's resizing
+ */
+ public void ancestorResized(HierarchyEvent e)
+ {
+ if (applet != null)
+ {
+ HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].ancestorResized(e);
+ }
+ }
+
+ void setParser(String tag, String documentbase) throws MalformedURLException, IOException
+ {
+ URL documentbaseURL = TagParser.getLocationToURL(documentbase);
+ StringReader in = new StringReader(tag);
+ this.parser = new TagParser(in, documentbaseURL);
+ }
+
+ // /////////////////////////////////
+ // //// EmbeddedWindow Method //////
+ // /////////////////////////////////
+
+ /**
+ * Set the native handle of the window system to embed the window in.
+ *
+ * @param handle the native handle.
+ */
+ public void setHandle(long handle)
+ {
+ super.setHandle(handle);
+ addNotify();
+
+ ArrayList l = parser.parseAppletTags();
+ int s = l.size();
+
+ for (int i = 0; i < s; i++)
+ {
+ tag = (AppletTag) l.get(i);
+ applet = Main.createApplet(tag);
+
+ if (contexts.get(tag.getCodeBase()) == null)
+ contexts.put(tag.getCodeBase(), new PluginAppletContext());
+
+ add(applet);
+
+ AppletContext context = (AppletContext) contexts.get(tag.getCodeBase());
+ ((PluginAppletContext) context).addApplet(applet);
+
+ applet.setStub(new CommonAppletStub(tag, context, applet));
+ Dimension size = getSize();
+ if (size.width == 0 || size.height == 0)
+ size = tag.getSize();
+ applet.setSize(size);
+
+ // Initialize the applet before showing this window so that
+ // the applet doesn't receive events before it has been
+ // initialized.
+ applet.init();
+ applet.start();
+ setVisible(true);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
new file mode 100644
index 000000000..48468f84d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
@@ -0,0 +1,76 @@
+/* StandaloneAppletContext.java -- an applet's context within the
+ standalone viewer
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * StandaloneAppletContext represents the context within a webpage of a
+ * group of applets that all share the same codebase.
+ */
+class StandaloneAppletContext extends CommonAppletContext
+{
+ private List appletWindows;
+
+ StandaloneAppletContext(List appletWindows)
+ {
+ this.appletWindows = appletWindows;
+ }
+
+ public void showDocument(URL url, String target)
+ {
+ System.err.println
+ (Messages.getString("StandaloneAppletContext.ShowDocumentError"));
+ }
+
+ // In standalone mode, there are potentially several windows, each
+ // with its own status bar. In plugin mode, all the applets in the
+ // same context (on the same page) share the browser's status bar.
+ // The best way to simulate the plugin mode behaviour in standalone
+ // mode is to show the same status on each window's status bar.
+ public void showStatus(String status)
+ {
+ Iterator window = appletWindows.iterator();
+ while (window.hasNext())
+ ((StandaloneAppletWindow) window.next()).showStatus(status);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
new file mode 100644
index 000000000..a59b03bfd
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
@@ -0,0 +1,148 @@
+/* StandaloneAppletViewer.java -- a standalone viewer for Java applets
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.awt.Dimension;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+
+/**
+ * StandaloneAppletViewer displays an applet in its own Frame. Most
+ * of the context that is available to an applet within a webpage is
+ * available to it in StandaloneAppletViewer.
+ */
+class StandaloneAppletViewer extends Main
+{
+ static ArrayList appletTags = new ArrayList();
+ static ArrayList appletWindows = new ArrayList();
+
+ StandaloneAppletViewer(String[] urls)
+ throws MalformedURLException, IOException
+ {
+ // Handle each file specified on the command line.
+ for (int i = 0; i < urls.length; i++)
+ {
+ TagParser parser = new TagParser(urls[i]);
+ appletTags.addAll(parser.parseAppletTags());
+ }
+
+ printTags();
+ createWindows();
+ }
+
+ StandaloneAppletViewer(String code, String codebase, String archives,
+ List parameters, Dimension dimensions)
+ throws IOException
+ {
+ if (!(code.equals("") || code.endsWith(".class")))
+ {
+ System.err.println
+ (Messages.getString("StandaloneAppletViewer.CodeOptionError"));
+ System.exit(1);
+ }
+
+ String tagString =
+ "<EMBED"
+ + " CODE=\"" + code + "\""
+ + " WIDTH=" + dimensions.width
+ + " HEIGHT=" + dimensions.height
+ + " CODEBASE=\"" + codebase + "\""
+ + " ARCHIVE=\"" + archives + "\">";
+
+ // Handle parameters.
+ Iterator pairs = parameters.iterator();
+ while (pairs.hasNext())
+ {
+ StringTokenizer paramTokenizer =
+ new StringTokenizer((String) pairs.next(), ",");
+ tagString +=
+ "<PARAM NAME=" + paramTokenizer.nextToken().trim() + " VALUE="
+ + paramTokenizer.nextToken().trim() + ">";
+ }
+
+ tagString += "</EMBED>";
+
+ StringReader reader = new StringReader(tagString);
+ String path = System.getProperty("user.dir") + File.separator;
+ TagParser parser = new TagParser(reader,
+ new URL("file", "", path));
+ appletTags.addAll(parser.parseAppletTags());
+
+ printTags();
+ createWindows();
+ }
+
+ void printTags()
+ {
+ if (verbose)
+ {
+ System.out.println
+ (Messages.getString("StandaloneAppletViewer.ParsedAppletTags"));
+
+ for (int i = 0; i < appletTags.size(); i++)
+ {
+ AppletTag tag = (AppletTag) appletTags.get(i);
+
+ System.out.println
+ (" " + Messages.getString("StandaloneAppletViewer.Tag")
+ + " " + i + ":");
+ System.out.println(tag);
+ }
+ }
+ }
+
+ void createWindows()
+ {
+ for (int i = 0; i < appletTags.size(); i++)
+ {
+ AppletTag tag = (AppletTag) appletTags.get(i);
+
+ // Create a StandaloneAppletWindow and add it to the
+ // appletWindows list.
+ new StandaloneAppletWindow(tag, appletWindows);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
new file mode 100644
index 000000000..64d3007f3
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
@@ -0,0 +1,560 @@
+/* StandaloneAppletWindow.java -- an applet frame
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Insets;
+import java.awt.Label;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.HashMap;
+import java.util.List;
+
+class StandaloneAppletWindow
+ extends Frame
+ implements ActionListener, ContainerListener, ComponentListener,
+ MouseListener, MouseMotionListener, InputMethodListener, HierarchyListener,
+ HierarchyBoundsListener
+{
+
+ // This class implements various listeners because the author of an applet
+ // may attach listeners to it, unaware of the applet's parent (this class).
+ // So, we must pass all listener events on this plugin applet window to the
+ // actual applet.
+
+ private static int testWindowCount;
+ private static HashMap contexts = new HashMap();
+ private Applet applet;
+ private Label status = new Label();
+
+ private MenuItem restartItem;
+ private MenuItem reloadItem;
+ private MenuItem cancelItem;
+ private MenuItem saveItem;
+ private MenuItem startItem;
+ private MenuItem cloneItem;
+ private MenuItem tagItem;
+ private MenuItem infoItem;
+ private MenuItem editItem;
+ private MenuItem encodingItem;
+ private MenuItem printItem;
+ private MenuItem propertiesItem;
+ private MenuItem closeItem;
+ private MenuItem quitItem;
+
+ StandaloneAppletWindow(AppletTag tag, List appletWindows)
+ {
+ appletWindows.add(this);
+ applet = Main.createApplet(tag);
+
+ if (contexts.get(tag.codebase) == null)
+ contexts.put(tag.codebase, new StandaloneAppletContext(appletWindows));
+
+ setLayout(new BorderLayout());
+ add(applet, BorderLayout.CENTER);
+ add(status, BorderLayout.SOUTH);
+
+ addWindowListener(new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent event)
+ {
+ applet.stop();
+ StandaloneAppletWindow.this.hide();
+ System.exit(0);
+ }
+ });
+
+ addContainerListener(this);
+ addComponentListener(this);
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ addInputMethodListener(this);
+ addHierarchyListener(this);
+ addHierarchyBoundsListener(this);
+
+ restartItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuRestart"));
+ restartItem.setEnabled(false);
+ restartItem.addActionListener(this);
+ reloadItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuReload"));
+ reloadItem.setEnabled(false);
+ reloadItem.addActionListener(this);
+ cancelItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuCancel"));
+ cancelItem.setEnabled(false);
+ cancelItem.addActionListener(this);
+ saveItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuSave"));
+ saveItem.setEnabled(false);
+ saveItem.addActionListener(this);
+ startItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuStart"));
+ startItem.setEnabled(false);
+ startItem.addActionListener(this);
+ cloneItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuClone"));
+ cloneItem.setEnabled(false);
+ cloneItem.addActionListener(this);
+ closeItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuClose"));
+ closeItem.setEnabled(false);
+ closeItem.addActionListener(this);
+ tagItem =
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuTag"));
+ tagItem.setEnabled(false);
+ tagItem.addActionListener(this);
+ infoItem =
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuInfo"));
+ infoItem.setEnabled(false);
+ infoItem.addActionListener(this);
+ editItem =
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuEdit"));
+ editItem.setEnabled(false);
+ editItem.addActionListener(this);
+ editItem.setEnabled(false);
+ encodingItem =
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuEncoding"));
+ encodingItem.setEnabled(false);
+ encodingItem.addActionListener(this);
+ printItem =
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuPrint"));
+ printItem.setEnabled(false);
+ printItem.addActionListener(this);
+ propertiesItem =
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuProperties"));
+ propertiesItem.setEnabled(false);
+ propertiesItem.addActionListener(this);
+ quitItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuQuit"));
+ quitItem.addActionListener(this);
+
+ MenuBar menuBar = new MenuBar();
+ Menu menuApplet = new Menu(Messages.getString("StandaloneAppletWindow.MenuTitle"));
+ menuBar.add(menuApplet);
+ menuApplet.add(restartItem);
+ menuApplet.add(reloadItem);
+ menuApplet.add(cancelItem);
+ menuApplet.add(saveItem);
+ menuApplet.add(startItem);
+ menuApplet.add(cloneItem);
+ menuApplet.addSeparator();
+ menuApplet.add(tagItem);
+ menuApplet.add(infoItem);
+ menuApplet.add(editItem);
+ menuApplet.add(encodingItem);
+ menuApplet.addSeparator();
+ menuApplet.add(printItem);
+ menuApplet.addSeparator();
+ menuApplet.add(propertiesItem);
+ menuApplet.addSeparator();
+ menuApplet.add(closeItem);
+ menuApplet.add(quitItem);
+ setMenuBar(menuBar);
+ setTitle(Messages.getString("StandaloneAppletWindow.WindowTitle")
+ + " " + tag.code);
+
+ AppletContext context = (AppletContext) contexts.get(tag.codebase);
+ ((StandaloneAppletContext) context).addApplet(applet);
+
+ applet.setStub(new CommonAppletStub(tag, context, applet));
+
+ // Create the frame's peer. Otherwise getPreferredSize will read
+ // its insets as 0.
+ addNotify();
+ Insets i = getInsets();
+ Dimension size = tag.getSize();
+ setSize(i.left + size.width + i.right,
+ i.top + size.height + status.getPreferredSize().height
+ + i.bottom);
+ applet.setSize(size);
+
+ // Initialize the applet before showing this window so that the
+ // applet doesn't receive events before it has been initialized.
+ applet.init();
+ applet.start();
+ setVisible(true);
+ }
+
+ private void closeWindow()
+ {
+ applet.stop();
+ StandaloneAppletViewer.appletWindows.remove(this);
+ StandaloneAppletWindow.this.hide();
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == quitItem)
+ {
+ closeWindow();
+ System.exit(0);
+ }
+ else if (e.getSource() == closeItem)
+ {
+ // Close current window.
+ closeWindow();
+
+ // Exit if there are other windows left.
+ if (StandaloneAppletViewer.appletWindows.isEmpty())
+ System.exit(0);
+ }
+ }
+
+ void showStatus(String status)
+ {
+ this.status.setText(status);
+ }
+
+
+ ///////////////////////////////////
+ /// ContainerListener Methods /////
+ ///////////////////////////////////
+
+ /**
+ * This method is called when a component is added to the container.
+ *
+ * @param event the <code>ContainerEvent</code> indicating component
+ * addition
+ */
+ public void componentAdded(ContainerEvent event)
+ {
+ if (applet != null)
+ {
+ ContainerListener[] l = applet.getContainerListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentAdded(event);
+ }
+ }
+
+ /**
+ * This method is called when a component is removed from the container.
+ *
+ * @param event the <code>ContainerEvent</code> indicating component removal
+ */
+ public void componentRemoved(ContainerEvent event)
+ {
+ if (applet != null)
+ {
+ ContainerListener[] l = applet.getContainerListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentRemoved(event);
+ }
+ }
+
+ ///////////////////////////////////
+ /// ComponentListener Methods /////
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the component is resized.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the resize
+ */
+ public void componentResized(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentResized(event);
+ }
+ }
+
+ /**
+ * This method is called when the component is moved.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the move
+ */
+ public void componentMoved(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentMoved(event);
+ }
+ }
+
+ /**
+ * This method is called when the component is made visible.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the visibility
+ */
+ public void componentShown(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentShown(event);
+ }
+ }
+
+ /**
+ * This method is called when the component is hidden.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the visibility
+ */
+ public void componentHidden(ComponentEvent event)
+ {
+ if (applet != null)
+ {
+ ComponentListener[] l = applet.getComponentListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].componentHidden(event);
+ }
+ }
+
+ ///////////////////////////////////
+ ////// MouseListener Methods //////
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the mouse is clicked (pressed and released
+ * in short succession) on a component.
+ *
+ * @param event the <code>MouseEvent</code> indicating the click
+ */
+ public void mouseClicked(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseClicked(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse is pressed over a component.
+ *
+ * @param event the <code>MouseEvent</code> for the press
+ */
+ public void mousePressed(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mousePressed(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse is released over a component.
+ *
+ * @param event the <code>MouseEvent</code> for the release
+ */
+ public void mouseReleased(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseReleased(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse enters a component.
+ *
+ * @param event the <code>MouseEvent</code> for the entry
+ */
+ public void mouseEntered(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseEntered(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse exits a component.
+ *
+ * @param event the <code>MouseEvent</code> for the exit
+ */
+ public void mouseExited(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseListener[] l = applet.getMouseListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseExited(event);
+ }
+ }
+
+ ///////////////////////////////////
+ /// MouseMotionListener Methods ///
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the mouse is moved over a component
+ * while a button has been pressed.
+ *
+ * @param event the <code>MouseEvent</code> indicating the motion
+ */
+ public void mouseDragged(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseMotionListener[] l = applet.getMouseMotionListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseDragged(event);
+ }
+ }
+
+ /**
+ * This method is called when the mouse is moved over a component
+ * while no button is pressed.
+ *
+ * @param event the <code>MouseEvent</code> indicating the motion
+ */
+ public void mouseMoved(MouseEvent event)
+ {
+ if (applet != null)
+ {
+ MouseMotionListener[] l = applet.getMouseMotionListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].mouseMoved(event);
+ }
+ }
+
+ ///////////////////////////////////
+ /// InputMethodListener Methods ///
+ ///////////////////////////////////
+
+ /**
+ * This method is called when the text is changed.
+ *
+ * @param event the <code>InputMethodEvent</code> indicating the text change
+ */
+ public void inputMethodTextChanged(InputMethodEvent event)
+ {
+ if (applet != null)
+ {
+ InputMethodListener[] l = applet.getInputMethodListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].inputMethodTextChanged(event);
+ }
+ }
+
+ /**
+ * This method is called when the cursor position within the text is changed.
+ *
+ * @param event the <code>InputMethodEvent</code> indicating the change
+ */
+ public void caretPositionChanged(InputMethodEvent event)
+ {
+ if (applet != null)
+ {
+ InputMethodListener[] l = applet.getInputMethodListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].caretPositionChanged(event);
+ }
+ }
+
+ ///////////////////////////////////
+ //// HierarchyListener Methods ////
+ ///////////////////////////////////
+
+ /**
+ * Called when the hierarchy of this component changes. Use
+ * <code>getChangeFlags()</code> on the event to see what exactly changed.
+ *
+ * @param event the event describing the change
+ */
+ public void hierarchyChanged(HierarchyEvent event)
+ {
+ if (applet != null)
+ {
+ HierarchyListener[] l = applet.getHierarchyListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].hierarchyChanged(event);
+ }
+ }
+
+ /////////////////////////////////////////
+ //// HierarchyBoundsListener Methods ////
+ /////////////////////////////////////////
+
+ /**
+ * Called when an ancestor component of the source is moved.
+ *
+ * @param e the event describing the ancestor's motion
+ */
+ public void ancestorMoved(HierarchyEvent e)
+ {
+ if (applet != null)
+ {
+ HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].ancestorMoved(e);
+ }
+ }
+
+ /**
+ * Called when an ancestor component is resized.
+ *
+ * @param e the event describing the ancestor's resizing
+ */
+ public void ancestorResized(HierarchyEvent e)
+ {
+ if (applet != null)
+ {
+ HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+ for (int i = 0; i < l.length; i++)
+ l[i].ancestorResized(e);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java
new file mode 100644
index 000000000..711b26ee5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java
@@ -0,0 +1,356 @@
+/* TagParser.java -- a parser for applet tags
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import gnu.javax.swing.text.html.parser.HTML_401F;
+
+import gnu.xml.dom.DomNode;
+import gnu.xml.dom.html2.DomHTMLAppletElement;
+import gnu.xml.dom.html2.DomHTMLDocument;
+import gnu.xml.dom.html2.DomHTMLEmbedElement;
+import gnu.xml.dom.html2.DomHTMLObjectElement;
+import gnu.xml.dom.html2.DomHTMLParamElement;
+import gnu.xml.dom.html2.DomHTMLParser;
+
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.w3c.dom.NodeList;
+
+
+public class TagParser
+{
+
+ /**
+ * Parsed document.
+ */
+ DomHTMLDocument document;
+
+ /**
+ * The document base of this applet.
+ */
+ URL documentbase;
+
+ /**
+ * The document base of all the applets.
+ */
+ static URL db;
+
+ /**
+ * The tags in the document.
+ */
+ Vector tags = new Vector();
+
+ /**
+ * Default constructor.
+ */
+ TagParser()
+ {
+ // Do nothing.
+ }
+
+ /**
+ * Constructs and parses document using the given location.
+ *
+ * @param location - location of applet
+ */
+ TagParser(String location) throws IOException
+ {
+ documentbase = getLocationToURL(location);
+ db = documentbase;
+ InputStreamReader in = new InputStreamReader(documentbase.openStream());
+ document = (DomHTMLDocument) (new DomHTMLParser(HTML_401F.getInstance()).parseDocument(in));
+ }
+
+ /**
+ * Constructs and parses document.
+ *
+ * @param in - Reader to parse document from.
+ * @param documentBase - the URL of the applet
+ * @throws IOException - is thrown if any IO error occurs.
+ */
+ TagParser(Reader in, URL documentBase) throws IOException
+ {
+ documentbase = documentBase;
+ db = documentbase;
+ document = (DomHTMLDocument) (new DomHTMLParser(HTML_401F.getInstance()).parseDocument(in));
+ }
+
+ /**
+ * Parses all applet tags in document.
+ *
+ * @return a list of AppletTag objects representing the applet tags
+ * in document
+ */
+ ArrayList parseAppletTags()
+ {
+ ArrayList allTags = new ArrayList();
+ if (document == null)
+ return null;
+
+ recurseDocument(document.getChildNodes());
+
+ int sz = tags.size();
+ for (int j = 0; j < sz; j++)
+ {
+ Object curr = tags.get(j);
+ // Order of checking is important here.
+ // Must check embed element before applet element
+ // because DomHTMLEmbedElement extends DomHTMLAppletElement
+ AppletTag a = null;
+ if (curr instanceof DomHTMLEmbedElement)
+ a = new AppletTag((DomHTMLEmbedElement) curr);
+ else if (curr instanceof DomHTMLAppletElement)
+ a = new AppletTag((DomHTMLAppletElement) curr);
+ else if (curr instanceof DomHTMLObjectElement)
+ a = new AppletTag((DomHTMLObjectElement) curr);
+ a.documentbase = documentbase;
+ allTags.add(a);
+ }
+
+ return allTags;
+ }
+
+ /**
+ * Recurses the document in search for the appropriate tags.
+ *
+ * @param list - the Node list.
+ */
+ private void recurseDocument(NodeList list)
+ {
+ // Recurse and store all APPLET, OBJECT and EMBED tags.
+ int length = list.getLength();
+ for (int i = 0; i < length; i++)
+ {
+ DomNode curr = (DomNode) list.item(i);
+ if ((curr instanceof DomHTMLEmbedElement) ||
+ (curr instanceof DomHTMLAppletElement) ||
+ (curr instanceof DomHTMLObjectElement))
+ tags.add(curr);
+ recurseDocument(curr.getChildNodes());
+ }
+ }
+
+ /**
+ * Parses the param elements for a given node.
+ *
+ * @param node - the node element to parse.
+ */
+ static void parseParams(DomNode node, AppletTag t)
+ {
+ boolean ja = false;
+ boolean jb = false;
+ boolean jc = false;
+ NodeList l = node.getChildNodes();
+ int size = l.getLength();
+
+ if (size != 0)
+ for (int i = 0; i < size; i++)
+ {
+ Object c = l.item(i);
+ if (! (c instanceof DomHTMLParamElement))
+ continue;
+ DomHTMLParamElement curr = (DomHTMLParamElement) c;
+ String key = curr.getName();
+ String val = curr.getValue();
+
+ if (key.equals("java_code"))
+ {
+ jc = true;
+ t.code = val;
+ }
+ else if (key.equals("java_codebase"))
+ {
+ jb = true;
+ t.codebase = val;
+ }
+ else if (!jc && key.equals("code"))
+ t.code = val;
+ else if (!jc && key.equals("classid"))
+ {
+ int x = val.indexOf(":");
+ if (x != -1)
+ val = val.substring(x + 1);
+ t.code = val;
+ }
+ else if (!jb && key.equals("codebase"))
+ t.codebase = val;
+ else if (key.equals("java_archive"))
+ {
+ ja = true;
+ t.archives = parseArchives(val, t);
+ val = t.archives.toString();
+ }
+ else if (!ja && key.equals("archive"))
+ {
+ t.archives = parseArchives(val, t);
+ val = t.archives.toString();
+ }
+ val = unescapeString(val);
+ t.parameters.put(key.toLowerCase(), val);
+ }
+ }
+
+ /**
+ * This method does the same thing as the g_strcompress function in glib.
+ *
+ * @param value
+ * @return value in its original one-byte equivalence.
+ */
+ private static String unescapeString(String value)
+ {
+ String unescVal = "";
+ for (int i = 0; i < value.length(); i++)
+ {
+ if (i == value.length() - 1)
+ {
+ unescVal = unescVal.concat(value.substring(i));
+ break;
+ }
+ if (value.charAt(i) == '\\')
+ {
+ switch (value.charAt(i + 1))
+ {
+ case 'b':
+ unescVal = unescVal.concat("\b");
+ break;
+ case 'f':
+ unescVal = unescVal.concat("\f");
+ break;
+ case 'n':
+ unescVal = unescVal.concat("\n");
+ break;
+ case 'r':
+ unescVal = unescVal.concat("\r");
+ break;
+ case 't':
+ unescVal = unescVal.concat("\t");
+ break;
+ case '\\':
+ unescVal = unescVal.concat("\\");
+ break;
+ case '\"':
+ unescVal = unescVal.concat("\"");
+ break;
+ default:
+ unescVal = unescVal.concat("\\");
+ unescVal = unescVal.concat(value.substring(i + 1, i + 2));
+ break;
+ }
+ i++;
+ }
+ else
+ unescVal = unescVal.concat(value.substring(i, i + 1));
+ }
+ return unescVal;
+ }
+
+ /**
+ * Parses the archive string and returns a list.
+ *
+ * @param arcs the list of archives (comma-separated) in a String.
+ */
+ static ArrayList parseArchives(String arcs, AppletTag t)
+ {
+ try
+ {
+ ArrayList list = new ArrayList();
+
+ StringTokenizer tagTokenizer = new StringTokenizer(arcs, ",");
+ while (tagTokenizer.hasMoreTokens())
+ list.add(t.prependCodeBase(tagTokenizer.nextToken().trim()));
+
+ return list;
+ }
+ catch (MalformedURLException e)
+ {
+ }
+ return null;
+ }
+
+ /**
+ * Gets the location to the URL, given a location.
+ *
+ * @param location - the given location.
+ * @return the URL.
+ */
+ static URL getLocationToURL(String location) throws IOException
+ {
+ URL tmpDocumentBase = null;
+
+ try
+ {
+ // Try parsing location as a URL.
+ tmpDocumentBase = new URL(location);
+
+ // If no file was specified in the URL the assume the user
+ // meant the root page.
+ String f = tmpDocumentBase.getFile();
+ if (f.indexOf(".") == -1 && !f.endsWith(File.separator))
+ if (new File(tmpDocumentBase.getFile()).isDirectory())
+ tmpDocumentBase = new URL(location.concat(File.separator));
+ }
+ catch (MalformedURLException e)
+ {
+ // location is not a URL. See if it is an HTML file.
+ String path;
+
+ if (location.startsWith(File.separator))
+ path = new File(location).getCanonicalPath();
+ else
+ path = new File(System.getProperty("user.dir") + File.separator
+ + location).getCanonicalPath();
+
+ tmpDocumentBase = new URL("file", "", path);
+
+ if (new File(tmpDocumentBase.getFile()).isDirectory())
+ tmpDocumentBase = new URL("file", "", path + File.separator);
+ }
+
+ return tmpDocumentBase;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java b/libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java
new file mode 100644
index 000000000..838d7403a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java
@@ -0,0 +1,145 @@
+/* CallbackUtil.java -- Callback related utilities
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import gnu.javax.security.auth.callback.ConsoleCallbackHandler;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.CallbackHandler;
+
+/**
+ * A <i>Helper</i> class containing general purpose utlity methods dealing with
+ * callback handlers and their <i>Security Provider</i>.
+ */
+public abstract class CallbackUtil
+{
+ private static final Logger log = Logger.getLogger(CallbackUtil.class.getName());
+
+ // default 0-arguments constructor
+
+ // Class methods
+ // --------------------------------------------------------------------------
+
+ /**
+ * Return an implementation of the {@link CallbackHandler}, from any
+ * {@link Provider}, capable of handling callbacks through the <i>console</i>;
+ * i.e. <code>System.in</code> and <code>System.out</code>.
+ * <p>
+ * If no <i>Security Provider</i> for this type of callback was found, this
+ * method returns the default GNU implementation.
+ *
+ * @return a console {@link CallbackHandler} implementation.
+ */
+ public static final CallbackHandler getConsoleHandler()
+ {
+ CallbackHandler result = getHandler("Console");
+ if (result == null)
+ {
+ log.fine("No console callback handler found. Will use ours");
+ result = new ConsoleCallbackHandler();
+ }
+ return result;
+ }
+
+ /**
+ * Return a {@link CallbackHandler}, of a designated type, for interacting
+ * with the user.
+ * <p>
+ * This method first finds all currently installed <i>Security Providers</i>
+ * capable of providing such service and then in turn attempts to instantiate
+ * the handler from those providers. As soon as one provider returns a non-
+ * null instance of the callback handler, the search stops and that instance
+ * is returned.
+ *
+ * @return a {@link CallbackHandler} of the designated type, or
+ * <code>null</code> if no provider was found for theis type of
+ * callback.
+ */
+ private static final CallbackHandler getHandler(String handlerType)
+ {
+ log.entering(CallbackUtil.class.getName(), "getHandler", handlerType);
+
+ CallbackHandler result = null;
+ String service = "CallbackHandler." + handlerType;
+ Provider[] providers = Security.getProviders(service);
+ if (providers != null)
+ for (int i = 0; i < providers.length; i++)
+ {
+ Provider p = providers[i];
+ String className = p.getProperty(service);
+ if (className != null)
+ try
+ {
+ result = (CallbackHandler) Class.forName(className.trim()).newInstance();
+ }
+ catch (InstantiationException x)
+ {
+ log.fine("InstantiationException while creating ["
+ + className + "] from provider [" + p.getName()
+ + "]. Ignore");
+ }
+ catch (IllegalAccessException x)
+ {
+ log.fine("IllegalAccessException while creating ["
+ + className + "] from provider [" + p.getName()
+ + "]. Ignore");
+ }
+ catch (ClassNotFoundException x)
+ {
+ log.fine("ClassNotFoundException while creating ["
+ + className + "] from provider [" + p.getName()
+ + "]. Ignore");
+ }
+
+ if (result != null)
+ {
+
+ log.fine("Will use [" + result.getClass().getName()
+ + "] from [" + p.getName() + "]");
+ break;
+ }
+ }
+
+ log.exiting(CallbackUtil.class.getName(), "getHandler", result);
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/common/ClasspathToolParser.java b/libjava/classpath/tools/gnu/classpath/tools/common/ClasspathToolParser.java
new file mode 100644
index 000000000..d740646e5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/common/ClasspathToolParser.java
@@ -0,0 +1,239 @@
+/* ClasspathToolParser.java -- Parser subclass for classpath tools
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.Reader;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+/**
+ * This is like the Parser class, but is specialized for use by
+ * tools distributed with GNU Classpath. In particular it automatically
+ * computes the version string using the program's name.
+ */
+public class ClasspathToolParser
+ extends Parser
+{
+ private static String getVersionString(String programName)
+ {
+ String fmt = (Messages.getString("ClasspathToolParser.VersionFormat")); //$NON-NLS-1$
+ return MessageFormat.format(fmt,
+ new Object[]
+ {
+ programName,
+ Configuration.CLASSPATH_VERSION
+ });
+ }
+
+ public ClasspathToolParser(String programName)
+ {
+ this(programName, false);
+ }
+
+ public ClasspathToolParser(String programName, boolean longOnly)
+ {
+ super(programName, getVersionString(programName), longOnly);
+ addFinal(new Option('J',
+ Messages.getString("ClasspathToolParser.JArgument"),//$NON-NLS-1$
+ Messages.getString("ClasspathToolParser.JName"), //$NON-NLS-1$
+ true)
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ // -J should be handled by the wrapper binary.
+ // We add it here so that it shows up in the --help output.
+ }
+ });
+ }
+
+ public void parse(String[] inArgs, FileArgumentCallback files,
+ boolean handleFileLists)
+ {
+ FileArgumentCallback cb;
+
+ if (handleFileLists)
+ cb = new AtFileArgumentCallback(files);
+ else
+ cb = files;
+
+ parse(inArgs, cb);
+ }
+
+ public String[] parse(String[] inArgs, boolean handleFileLists)
+ {
+ final ArrayList<String> fileResult = new ArrayList<String>();
+
+ final FileArgumentCallback cb = new FileArgumentCallback()
+ {
+ public void notifyFile(String fileArgument)
+ {
+ fileResult.add(fileArgument);
+ }
+ };
+
+ if (handleFileLists)
+ parse(inArgs, new AtFileArgumentCallback(cb));
+ else
+ parse(inArgs, cb);
+
+ return fileResult.toArray(new String[fileResult.size()]);
+ }
+
+
+ /**
+ * Simple function that takes the given {@link Reader}, treats it like
+ * a textfile and reads all the whitespace separated entries from it
+ * and adds them to the @{link FileArgumentCallback} instance.
+ *
+ * @param reader the reader to read from.
+ * @param cb the callback to post the filenames to.
+ * @throws OptionException if an error occurs reading the list.
+ */
+ public void parseFileList(Reader reader, FileArgumentCallback cb)
+ throws OptionException
+ {
+ BufferedReader breader = new BufferedReader(reader);
+ String line = null;
+
+ try
+ {
+ while ((line = breader.readLine()) != null)
+ parseLine(line, cb);
+
+ reader.close();
+ }
+ catch (IOException ioe)
+ {
+ throw new OptionException("I/O error while reading a file list", ioe);
+ }
+
+ }
+
+ /**
+ * Parses whitespace separated file entries.
+ *
+ * Note: This is not coping with whitespace in files or quoting.
+ *
+ * @param line the line of the file to parse.
+ * @param cb the callback to pass the parsed file to.
+ * @throws IOException if an I/O error occurs.
+ * @throws OptionException if an error occurs in the callback.
+ */
+ private void parseLine(String line, FileArgumentCallback cb)
+ throws IOException, OptionException
+ {
+ final int length = line.length();
+ int start = 0;
+ int end = 0;
+
+ // While not reached end of line ...
+ while (start < length)
+ {
+ // Search for first non-whitespace character for the start of a word.
+ while (Character.isWhitespace(line.codePointAt(start)))
+ {
+ start++;
+
+ if (start == length)
+ return;
+ }
+
+ end = start + 1;
+
+ // Search for first whitespace character for the end of a word.
+ while (end < length && !Character.isWhitespace(line.codePointAt(end)))
+ end++;
+
+ cb.notifyFile(line.substring(start, end));
+
+ start = end + 1;
+ }
+ }
+
+ /**
+ * Implementation of {@link FileArgumentCallback} that handles
+ * file arguments in {@link #notifyFile} starting with a <code>@</code>
+ * through {@link ClasspathToolParser#parseFileList}.
+ */
+ class AtFileArgumentCallback extends FileArgumentCallback
+ {
+ FileArgumentCallback cb;
+
+ AtFileArgumentCallback(FileArgumentCallback cb)
+ {
+ this.cb = cb;
+ }
+
+ @Override
+ public void notifyFile(String fileArgument)
+ throws OptionException
+ {
+ if (fileArgument.codePointAt(0) == '@')
+ {
+ FileReader fr = null;
+
+ try
+ {
+ fr = new FileReader(fileArgument.substring(1));
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ throw new OptionException("File not found: " + fileArgument.substring(1),
+ fnfe);
+ }
+
+ ClasspathToolParser.this.parseFileList(fr, cb);
+ }
+ else
+ cb.notifyFile(fileArgument);
+ }
+
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/common/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/common/Messages.java
new file mode 100644
index 000000000..1c92d348d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/common/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- i18n support for tools common code
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.common.Messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/common/Persistent.java b/libjava/classpath/tools/gnu/classpath/tools/common/Persistent.java
new file mode 100644
index 000000000..5c85c9072
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/common/Persistent.java
@@ -0,0 +1,87 @@
+/* PersistentBidiHasthable.java -- Constants for the persistent tables.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.common;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * The static fields, shared by the multiple classes, implementing the
+ * persistent work.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public interface Persistent
+{
+ /**
+ * Sheduled termination task.
+ */
+ static class ExitTask extends TimerTask
+ {
+ public void run()
+ {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * The timer, sheduling all disk database update events, shared by all
+ * instances.
+ */
+ static Timer timer = new Timer(true);
+
+ /**
+ * The longest time, in ms, after that the database content on the disk must
+ * be updated. The algorithm is written to avoid the very frequent writings to
+ * the disk.
+ */
+ static long SAVE_AT_MOST_AFTER = 5000;
+
+ /**
+ * States how long the database may stay not updated during the intensive
+ * operations, in ms. Otherwise the intensively used structure may never
+ * be stored to the disk.
+ */
+ static long ALWAYS_UPDATE = 300000;
+
+ /**
+ * Write the database content to the disk.
+ */
+ void writeContent();
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java b/libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java
new file mode 100644
index 000000000..bc6d93146
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java
@@ -0,0 +1,163 @@
+/* ProviderUtil.java -- Security Provider related utilities
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+import java.security.Security;
+import java.util.logging.Logger;
+
+/**
+ * A <i>Helper</i> class containing general purpose utlity methods dealing with
+ * installing and removing <i>Security Providers</i> at runtime.
+ */
+public abstract class ProviderUtil
+{
+ private static final Logger log = Logger.getLogger(ProviderUtil.class.getName());
+
+ // default 0-arguments constructor
+
+ // Class methods
+ // --------------------------------------------------------------------------
+
+ /**
+ * Attempt to (a) instantiate, and (b) add a designated {@link Provider} by
+ * inserting at at the top of the list of <i>Security Providers</i> already
+ * present at runtime, only if it is not already installed.
+ * <p>
+ * <b>IMPORTANT</b>: This method overrides the security check usually carried
+ * out by the security manager when inserting a new {@link Provider}.
+ *
+ * @param providerClass a fully qualified, non-null, class name of a
+ * <i>Security Provider</i> to add if it is not already installed.
+ * @return an instance of {@link SecurityProviderInfo} referencing the
+ * {@link Provider} instance created with the designated class name,
+ * and its position in the underlying JVM runtime.
+ */
+ public static final SecurityProviderInfo addProvider(String providerClass)
+ {
+ log.entering(ProviderUtil.class.getName(), "addProvider", providerClass);
+
+ Provider provider = null;
+ try
+ {
+ provider = (Provider) Class.forName(providerClass.trim()).newInstance();
+ }
+ catch (InstantiationException x)
+ {
+ log.fine("InstantiationException while creating [" + providerClass
+ + "]. Ignore");
+ }
+ catch (IllegalAccessException x)
+ {
+ log.fine("IllegalAccessException while creating [" + providerClass
+ + "]. Ignore");
+ }
+ catch (ClassNotFoundException x)
+ {
+ log.fine("ClassNotFoundException while creating [" + providerClass
+ + "]. Ignore");
+ }
+
+ int position = provider != null ? addProvider(provider) : -1;
+ SecurityProviderInfo result = new SecurityProviderInfo(provider, position);
+
+ log.exiting(ProviderUtil.class.getName(), "addProvider", result);
+ return result;
+ }
+
+ /**
+ * Attempt to add the designated {@link Provider} by inserting at at the top
+ * of the list of <i>Security Providers</i> already present at runtime, only
+ * if it is not already installed.
+ * <p>
+ * <b>IMPORTANT</b>: This method overrides the security check usually carried
+ * out by the security manager when inserting a new {@link Provider}.
+ *
+ * @param provider a non-null <i>Security Provider</i> to add if it is not
+ * already installed.
+ * @return the new position of the designated provider in the list if it was
+ * not already present, or <code>-1</code> if it was already
+ * installed.
+ */
+ public static final int addProvider(final Provider provider)
+ {
+ log.entering(ProviderUtil.class.getName(), "addProvider", provider);
+
+ Integer actualPosition = (Integer) AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ int result = Security.insertProviderAt(provider, 1);
+ return Integer.valueOf(result);
+ }
+ });
+
+ int result = actualPosition.intValue();
+ log.fine("Provider [" + provider.getName() + "] installed? " + (result != - 1));
+
+ log.exiting(ProviderUtil.class.getName(), "addProvider", actualPosition);
+ return result;
+ }
+
+ /**
+ * Remove a designated <i>Security Provider</i>.
+ * <p>
+ * <b>IMPORTANT</b>: This method overrides the security check usually carried
+ * out by the security manager when removing a {@link Provider}.
+ *
+ * @param providerName the name of the {@link Provider} to remove.
+ */
+ public static final void removeProvider(final String providerName)
+ {
+ log.entering(ProviderUtil.class.getName(), "removeProvider", providerName);
+
+ AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Security.removeProvider(providerName);
+ return null;
+ }
+ });
+
+ log.exiting(ProviderUtil.class.getName(), "removeProvider");
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java b/libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java
new file mode 100644
index 000000000..44faebf76
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java
@@ -0,0 +1,99 @@
+/* SecurityProviderInfo.java -- Data Access Object for a security provider
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.security.Provider;
+
+/**
+ * A Data Access Object (DAO) referenceing a <i>Security Provider</i> and its
+ * position in the list of installed <i>Security Providers</i> in the underlying
+ * JVM runtime.
+ */
+public class SecurityProviderInfo
+{
+ final private Provider provider;
+ final private int position;
+ private transient String str;
+
+ /**
+ * Constructs an instance of <code>SecurityProviderInfo</code>.
+ * <p>
+ * Used by {@link ProviderUtil} to indicate the result of adding a provider,
+ * given its class name.
+ *
+ * @param provider the possibly <code>null</code> {@link Provider}.
+ * @param position the position of <code>provider</code> in the list of
+ * <i>Security Providers</i> in the underlying JVM runtime. <code>-1</code>
+ * if that provider (a) is <code>null</code>, or (b) was not added because it
+ * was already there.
+ */
+ SecurityProviderInfo(Provider provider, int position)
+ {
+ super();
+
+ this.provider = provider;
+ this.position = position;
+ }
+
+ /** @return the possibly <code>null</code> {@link Provider} instance. */
+ public Provider getProvider()
+ {
+ return this.provider;
+ }
+
+ /**
+ * @return the position of the {@link Provider}, or <code>-1</code> if it
+ * was not added.
+ */
+ public int getPosition()
+ {
+ return this.position;
+ }
+
+ public String toString()
+ {
+ if (str == null)
+ if (provider == null)
+ str = "SecurityProviderInfo{null, -1}";
+ else
+ str = "SecurityProviderInfo{" + provider.getName() + ", " + position + "}";
+
+ return str;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/AbstractDoclet.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/AbstractDoclet.java
new file mode 100644
index 000000000..4369782f9
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/AbstractDoclet.java
@@ -0,0 +1,1386 @@
+/* gnu.classpath.tools.doclets.AbstractDoclet
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.ConstructorDoc;
+import com.sun.javadoc.Doc;
+import com.sun.javadoc.Doclet;
+import com.sun.javadoc.ExecutableMemberDoc;
+import com.sun.javadoc.FieldDoc;
+import com.sun.javadoc.MethodDoc;
+import com.sun.javadoc.PackageDoc;
+import com.sun.javadoc.Parameter;
+import com.sun.javadoc.RootDoc;
+import com.sun.javadoc.Tag;
+import com.sun.javadoc.Type;
+
+import com.sun.tools.doclets.Taglet;
+
+import gnu.classpath.tools.taglets.GnuExtendedTaglet;
+import gnu.classpath.tools.taglets.AuthorTaglet;
+import gnu.classpath.tools.taglets.CodeTaglet;
+import gnu.classpath.tools.taglets.DeprecatedTaglet;
+import gnu.classpath.tools.taglets.GenericTaglet;
+import gnu.classpath.tools.taglets.SinceTaglet;
+import gnu.classpath.tools.taglets.ValueTaglet;
+import gnu.classpath.tools.taglets.VersionTaglet;
+import gnu.classpath.tools.taglets.TagletContext;
+
+import gnu.classpath.tools.IOToolkit;
+import gnu.classpath.tools.FileSystemClassLoader;
+
+import java.io.File;
+import java.io.IOException;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.InvocationTargetException;
+
+import java.text.MessageFormat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * An abstract Doclet implementation with helpers for common tasks
+ * performed by Doclets.
+ */
+public abstract class AbstractDoclet
+{
+ /**
+ * Mapping from tag type to Taglet for user Taglets specified on
+ * the command line.
+ */
+ protected Map tagletMap = new LinkedHashMap();
+
+ /**
+ * Stores the package groups specified in the user
+ * options. Contains objects of type PackageGroup.
+ */
+ private List packageGroups = new LinkedList();
+
+ /**
+ * The current classpath for loading taglet classes.
+ */
+ private String tagletPath;
+
+ /**
+ * Keeps track of the tags mentioned by the user during option
+ * processiong so that an error can be emitted if a tag is
+ * mentioned more than once.
+ */
+ private List mentionedTags = new LinkedList();
+
+ public static int optionLength(String option) {
+ return instance.getOptionLength(option);
+ }
+
+ public static boolean validOptions(String[][] options) {
+ return true;
+ }
+
+ private static AbstractDoclet instance;
+
+ protected static void setInstance(AbstractDoclet instance)
+ {
+ AbstractDoclet.instance = instance;
+ }
+
+ protected abstract void run()
+ throws DocletConfigurationException, IOException;
+
+ public static boolean start(RootDoc rootDoc)
+ {
+ try {
+
+ instance.startInstance(rootDoc);
+ return true;
+ }
+ catch (DocletConfigurationException e) {
+ instance.printError(e.getMessage());
+ return false;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ protected RootDoc getRootDoc()
+ {
+ return this.rootDoc;
+ }
+
+ private RootDoc rootDoc;
+
+ protected abstract InlineTagRenderer getInlineTagRenderer();
+
+ private void startInstance(RootDoc rootDoc)
+ throws DocletConfigurationException, IOException
+ {
+ this.rootDoc = rootDoc;
+
+ // Set the default Taglet order
+
+ registerTaglet(new VersionTaglet());
+ registerTaglet(new AuthorTaglet());
+ registerTaglet(new SinceTaglet(getInlineTagRenderer()));
+ registerTaglet(new StandardTaglet("serial"));
+ registerTaglet(new StandardTaglet("deprecated"));
+ registerTaglet(new StandardTaglet("see"));
+ registerTaglet(new StandardTaglet("param"));
+ registerTaglet(new StandardTaglet("return"));
+
+ registerTaglet(new ValueTaglet());
+ registerTaglet(new CodeTaglet());
+
+ // Process command line options
+
+ for (int i=0, ilim=rootDoc.options().length; i<ilim; ++i) {
+
+ String[] optionArr = rootDoc.options()[i];
+ String _optionTag = optionArr[0];
+
+ DocletOption option = (DocletOption)nameToOptionMap.get(_optionTag.toLowerCase());
+
+ if (null != option) {
+ option.set(optionArr);
+ }
+ }
+
+ // Enable/disable standard taglets based on user input
+
+ AuthorTaglet.setTagletEnabled(optionAuthor.getValue());
+ VersionTaglet.setTagletEnabled(optionVersion.getValue());
+ SinceTaglet.setTagletEnabled(!optionNoSince.getValue());
+ DeprecatedTaglet.setTagletEnabled(!optionNoDeprecated.getValue());
+
+ if (!getTargetDirectory().exists()) {
+ if (!getTargetDirectory().mkdirs()) {
+ throw new DocletConfigurationException("Cannot create target directory "
+ + getTargetDirectory());
+ }
+ }
+
+ run();
+ }
+
+ public File getTargetDirectory()
+ {
+ return optionTargetDirectory.getValue();
+ }
+
+ private DocletOptionFile optionTargetDirectory =
+ new DocletOptionFile("-d",
+ new File(System.getProperty("user.dir")));
+
+ private DocletOptionFlag optionNoEmailWarn =
+ new DocletOptionFlag("-noemailwarn");
+
+ private DocletOptionFlag optionAuthor =
+ new DocletOptionFlag("-author");
+
+ private DocletOptionFlag optionVersion =
+ new DocletOptionFlag("-version");
+
+ private DocletOptionFlag optionNoSince =
+ new DocletOptionFlag("-nosince");
+
+ private DocletOptionFlag optionNoDeprecated =
+ new DocletOptionFlag("-nodeprecated");
+
+ private DocletOptionGroup optionGroup =
+ new DocletOptionGroup("-group");
+
+ private DocletOptionPackageWildcard optionNoQualifier =
+ new DocletOptionPackageWildcard("-noqualifier", true);
+
+ private DocletOptionFlag optionDocFilesSubDirs =
+ new DocletOptionFlag("-docfilessubdirs");
+
+ private DocletOptionColonSeparated optionExcludeDocFilesSubDir =
+ new DocletOptionColonSeparated("-excludedocfilessubdir");
+
+ private DocletOptionTagletPath optionTagletPath =
+ new DocletOptionTagletPath("-tagletpath");
+
+ private DocletOptionTag optionTaglet =
+ new DocletOptionTag("-taglet");
+
+ private DocletOptionTag optionTag =
+ new DocletOptionTag("-tag");
+
+ private class DocletOptionTaglet
+ extends DocletOption
+ {
+ DocletOptionTaglet(String optionName)
+ {
+ super(optionName);
+ }
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+
+ boolean tagletLoaded = false;
+
+ String useTagletPath = AbstractDoclet.this.tagletPath;
+ if (null == useTagletPath) {
+ useTagletPath = System.getProperty("java.class.path");
+ }
+
+ try {
+ Class tagletClass;
+ try {
+ tagletClass
+ = new FileSystemClassLoader(useTagletPath).loadClass(optionArr[1]);
+ }
+ catch (ClassNotFoundException e) {
+ // If not found on specified tagletpath, try default classloader
+ tagletClass
+ = Class.forName(optionArr[1]);
+ }
+ Method registerTagletMethod
+ = tagletClass.getDeclaredMethod("register", new Class[] { java.util.Map.class });
+
+ if (!registerTagletMethod.getReturnType().equals(Void.TYPE)) {
+ printError("Taglet class '" + optionArr[1] + "' found, but register method doesn't return void.");
+ }
+ else if (registerTagletMethod.getExceptionTypes().length > 0) {
+ printError("Taglet class '" + optionArr[1] + "' found, but register method contains throws clause.");
+ }
+ else if ((registerTagletMethod.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC | Modifier.ABSTRACT)) != (Modifier.STATIC | Modifier.PUBLIC)) {
+ printError("Taglet class '" + optionArr[1] + "' found, but register method isn't public static, or is abstract..");
+ }
+ else {
+ Map tempMap = new HashMap();
+ registerTagletMethod.invoke(null, new Object[] { tempMap });
+ tagletLoaded = true;
+ String name = (String)tempMap.keySet().iterator().next();
+ Taglet taglet = (Taglet)tempMap.get(name);
+ tagletMap.put(name, taglet);
+ mentionedTags.add(taglet);
+ }
+ }
+ catch (NoSuchMethodException e) {
+ printError("Taglet class '" + optionArr[1] + "' found, but doesn't contain the register method.");
+ }
+ catch (SecurityException e) {
+ printError("Taglet class '" + optionArr[1] + "' cannot be loaded: " + e.getMessage());
+ }
+ catch (InvocationTargetException e) {
+ printError("Taglet class '" + optionArr[1] + "' found, but register method throws exception: " + e.toString());
+ }
+ catch (IllegalAccessException e) {
+ printError("Taglet class '" + optionArr[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
+ }
+ catch (IllegalArgumentException e) {
+ printError("Taglet class '" + optionArr[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
+ }
+ catch (ClassNotFoundException e) {
+ printError("Taglet class '" + optionArr[1] + "' cannot be found.");
+ }
+ return tagletLoaded;
+ }
+ }
+
+ private class DocletOptionGroup
+ extends DocletOption
+ {
+ DocletOptionGroup(String optionName)
+ {
+ super(optionName);
+ }
+
+ public int getLength()
+ {
+ return 3;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ try {
+ PackageMatcher packageMatcher = new PackageMatcher();
+
+ StringTokenizer tokenizer = new StringTokenizer(optionArr[2], ":");
+ while (tokenizer.hasMoreTokens()) {
+ String packageWildcard = tokenizer.nextToken();
+ packageMatcher.addWildcard(packageWildcard);
+ }
+
+ SortedSet groupPackages = packageMatcher.filter(rootDoc.specifiedPackages());
+
+ packageGroups.add(new PackageGroup(optionArr[1], groupPackages));
+
+ return true;
+ }
+ catch (InvalidPackageWildcardException e) {
+ return false;
+ }
+ }
+ }
+
+
+ private class DocletOptionTagletPath
+ extends DocletOption
+ {
+ DocletOptionTagletPath(String optionName)
+ {
+ super(optionName);
+ }
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ AbstractDoclet.this.tagletPath = optionArr[1];
+ return true;
+ }
+ }
+
+ private class DocletOptionTag
+ extends DocletOption
+ {
+ DocletOptionTag(String optionName)
+ {
+ super(optionName);
+ }
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ String tagSpec = optionArr[1];
+ boolean validTagSpec = false;
+ int ndx1 = tagSpec.indexOf(':');
+ if (ndx1 < 0) {
+ Taglet taglet = (Taglet)tagletMap.get(tagSpec);
+ if (null == taglet) {
+ printError("There is no standard tag '" + tagSpec + "'.");
+ }
+ else {
+ if (mentionedTags.contains(taglet)) {
+ printError("Tag '" + tagSpec + "' has been added or moved before.");
+ }
+ else {
+ mentionedTags.add(taglet);
+
+ // re-append taglet
+ tagletMap.remove(tagSpec);
+ tagletMap.put(tagSpec, taglet);
+ }
+ }
+ }
+ else {
+ int ndx2 = tagSpec.indexOf(':', ndx1 + 1);
+ if (ndx2 > ndx1 && ndx2 < tagSpec.length() - 1) {
+ String tagName = tagSpec.substring(0, ndx1);
+ String tagHead = null;
+ if (tagSpec.charAt(ndx2 + 1) == '\"') {
+ if (tagSpec.charAt(tagSpec.length() - 1) == '\"') {
+ tagHead = tagSpec.substring(ndx2 + 2, tagSpec.length() - 1);
+ validTagSpec = true;
+ }
+ }
+ else {
+ tagHead = tagSpec.substring(ndx2 + 1);
+ validTagSpec = true;
+ }
+
+ boolean tagScopeOverview = false;
+ boolean tagScopePackages = false;
+ boolean tagScopeTypes = false;
+ boolean tagScopeConstructors = false;
+ boolean tagScopeMethods = false;
+ boolean tagScopeFields = false;
+ boolean tagDisabled = false;
+
+ tag_option_loop:
+ for (int n=ndx1+1; n<ndx2; ++n) {
+ switch (tagSpec.charAt(n)) {
+ case 'X':
+ tagDisabled = true;
+ break;
+ case 'a':
+ tagScopeOverview = true;
+ tagScopePackages = true;
+ tagScopeTypes = true;
+ tagScopeConstructors = true;
+ tagScopeMethods = true;
+ tagScopeFields = true;
+ break;
+ case 'o':
+ tagScopeOverview = true;
+ break;
+ case 'p':
+ tagScopePackages = true;
+ break;
+ case 't':
+ tagScopeTypes = true;
+ break;
+ case 'c':
+ tagScopeConstructors = true;
+ break;
+ case 'm':
+ tagScopeMethods = true;
+ break;
+ case 'f':
+ tagScopeFields = true;
+ break;
+ default:
+ validTagSpec = false;
+ break tag_option_loop;
+ }
+ }
+
+ if (validTagSpec) {
+ GenericTaglet taglet
+ = new GenericTaglet(tagName,
+ tagHead,
+ tagScopeOverview,
+ tagScopePackages,
+ tagScopeTypes,
+ tagScopeConstructors,
+ tagScopeMethods,
+ tagScopeFields);
+ taglet.setTagletEnabled(!tagDisabled);
+ taglet.register(tagletMap);
+ mentionedTags.add(taglet);
+ }
+ }
+ }
+ if (!validTagSpec) {
+ printError("Value for option -tag must be in format \"<tagname>:Xaoptcmf:<taghead>\".");
+ }
+ return validTagSpec;
+ }
+ }
+
+ private DocletOption[] commonOptions =
+ {
+ optionTargetDirectory,
+ optionAuthor,
+ optionVersion,
+ optionNoSince,
+ optionNoDeprecated,
+ optionGroup,
+ optionDocFilesSubDirs,
+ optionExcludeDocFilesSubDir,
+ optionTagletPath,
+ optionTaglet,
+ optionTag,
+ };
+
+ private void registerOptions()
+ {
+ if (!optionsRegistered) {
+ for (int i=0; i<commonOptions.length; ++i) {
+ DocletOption option = commonOptions[i];
+ registerOption(option);
+ }
+ DocletOption[] docletOptions = getOptions();
+ for (int i=0; i<docletOptions.length; ++i) {
+ DocletOption option = docletOptions[i];
+ registerOption(option);
+ }
+ optionsRegistered = true;
+ }
+ }
+
+ protected abstract DocletOption[] getOptions();
+
+ private boolean optionsRegistered = false;
+
+ private void registerOption(DocletOption option)
+ {
+ nameToOptionMap.put(option.getName(), option);
+ }
+
+ private Map nameToOptionMap = new HashMap();
+
+ private int getOptionLength(String optionName)
+ {
+ registerOptions();
+ DocletOption option = (DocletOption)nameToOptionMap.get(optionName.toLowerCase());
+ if (null != option) {
+ return option.getLength();
+ }
+ else {
+ return -1;
+ }
+ }
+
+ protected List getKnownDirectSubclasses(ClassDoc classDoc)
+ {
+ List result = new LinkedList();
+ if (!"java.lang.Object".equals(classDoc.qualifiedName())) {
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i=0; i<classes.length; ++i) {
+ if (classDoc == classes[i].superclass()) {
+ result.add(classes[i]);
+ }
+ }
+ }
+ return result;
+ }
+
+ protected static class IndexKey
+ implements Comparable
+ {
+ private String name;
+ private String lowerName;
+
+ public IndexKey(String name)
+ {
+ this.name = name;
+ this.lowerName = name.toLowerCase();
+ }
+
+ public boolean equals(Object other)
+ {
+ return this.lowerName.equals(((IndexKey)other).lowerName);
+ }
+
+ public int hashCode()
+ {
+ return lowerName.hashCode();
+ }
+
+ public int compareTo(Object other)
+ {
+ return lowerName.compareTo(((IndexKey)other).lowerName);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+ private Map categorizedIndex;
+
+ protected Map getCategorizedIndex()
+ {
+ if (null == categorizedIndex) {
+ categorizedIndex = new LinkedHashMap();
+
+ Map indexMap = getIndexByName();
+ LinkedList keys = new LinkedList(); //indexMap.keySet().size());
+ keys.addAll(indexMap.keySet());
+ Collections.sort(keys);
+ Iterator it = keys.iterator(); //indexMap.keySet().iterator();
+ char previousCategoryLetter = '\0';
+ Character keyLetter = null;
+ while (it.hasNext()) {
+ IndexKey key = (IndexKey)it.next();
+ char firstChar = Character.toUpperCase(key.getName().charAt(0));
+ if (firstChar != previousCategoryLetter) {
+ keyLetter = new Character(firstChar);
+ previousCategoryLetter = firstChar;
+ categorizedIndex.put(keyLetter, new LinkedList());
+ }
+ List letterList = (List)categorizedIndex.get(keyLetter);
+ letterList.add(indexMap.get(key));
+ }
+ }
+
+ return categorizedIndex;
+ }
+
+
+ private Map indexByName;
+
+ protected Map getIndexByName()
+ {
+ if (null == indexByName) {
+ // Create index
+
+ // Collect index
+
+ indexByName = new HashMap(); //TreeMap();
+
+ // Add packages to index
+
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i<ilim; ++i) {
+ PackageDoc c = packages[i];
+ if (c.name().length() > 0) {
+ indexByName.put(new IndexKey(c.name()), c);
+ }
+ }
+
+ // Add classes, fields and methods to index
+
+ ClassDoc[] sumclasses = rootDoc.classes();
+ for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
+ ClassDoc c = sumclasses[i];
+ if (null == c.containingClass()) {
+ indexByName.put(new IndexKey(c.name() + " " + c.containingPackage().name()), c);
+ }
+ else {
+ indexByName.put(new IndexKey(c.name().substring(c.containingClass().name().length() + 1)
+ + " " + c.containingClass().name() + " " + c.containingPackage().name()), c);
+ }
+ FieldDoc[] fields = c.fields();
+ for (int j=0, jlim=fields.length; j<jlim; ++j) {
+ indexByName.put(new IndexKey(fields[j].name() + " " + fields[j].containingClass().name() + " " + fields[j].containingPackage().name()), fields[j]);
+ }
+ MethodDoc[] methods = c.methods();
+ for (int j=0, jlim=methods.length; j<jlim; ++j) {
+ MethodDoc method = methods[j];
+ indexByName.put(new IndexKey(method.name() + method.signature() + " " + method.containingClass().name() + " " + method.containingPackage().name()), method);
+ }
+ ConstructorDoc[] constructors = c.constructors();
+ for (int j=0, jlim=constructors.length; j<jlim; ++j) {
+ ConstructorDoc constructor = constructors[j];
+ indexByName.put(new IndexKey(constructor.name() + constructor.signature() + " " + constructor.containingClass().name() + " " + constructor.containingPackage().name()), constructor);
+ }
+ }
+ }
+ return indexByName;
+ }
+
+ private void registerTaglet(Taglet taglet)
+ {
+ tagletMap.put(taglet.getName(), taglet);
+ }
+
+ protected void printTaglets(Tag[] tags, TagletContext context, TagletPrinter output, boolean inline)
+ {
+ for (Iterator it = tagletMap.keySet().iterator(); it.hasNext(); ) {
+ String tagName = (String)it.next();
+ Object o = tagletMap.get(tagName);
+ Taglet taglet = (Taglet)o;
+ Doc doc = context.getDoc();
+ if (inline == taglet.isInlineTag()
+ && ((doc == null
+ && taglet.inOverview())
+ || (doc != null
+ && ((doc.isConstructor() && taglet.inConstructor())
+ || (doc.isField() && taglet.inField())
+ || (doc.isMethod() && taglet.inMethod())
+ || (doc instanceof PackageDoc && taglet.inPackage())
+ || ((doc.isClass() || doc.isInterface()) && taglet.inType()))))) {
+
+ List tagsOfThisType = new LinkedList();
+ for (int i=0; i<tags.length; ++i) {
+ if (tags[i].name().substring(1).equals(tagName)) {
+ tagsOfThisType.add(tags[i]);
+ }
+ }
+
+ Tag[] tagletTags = (Tag[])tagsOfThisType.toArray(new Tag[tagsOfThisType.size()]);
+
+ String tagletString;
+ if (taglet instanceof StandardTaglet) {
+ tagletString = renderTag(tagName, tagletTags, context);
+ }
+ else if (taglet instanceof GnuExtendedTaglet) {
+ tagletString = ((GnuExtendedTaglet)taglet).toString(tagletTags, context);
+ }
+ else {
+ tagletString = taglet.toString(tagletTags);
+ }
+ if (null != tagletString) {
+ output.printTagletString(tagletString);
+ }
+ }
+ }
+ }
+
+ protected void printInlineTaglet(Tag tag, TagletContext context, TagletPrinter output)
+ {
+ Taglet taglet = (Taglet)tagletMap.get(tag.name().substring(1));
+ if (null != taglet) {
+ String tagletString;
+ if (taglet instanceof GnuExtendedTaglet) {
+ tagletString = ((GnuExtendedTaglet)taglet).toString(tag, context);
+ }
+ else {
+ tagletString = taglet.toString(tag);
+ }
+ if (null != tagletString) {
+ output.printTagletString(tagletString);
+ }
+ }
+ else {
+ printWarning("Unknown tag: " + tag.name());
+ }
+ }
+
+ protected void printMainTaglets(Tag[] tags, TagletContext context, TagletPrinter output)
+ {
+ printTaglets(tags, context, output, false);
+ }
+
+ /**
+ * @param usedClassToPackagesMap ClassDoc to (PackageDoc to (UsageType to (Set of Doc)))
+ */
+ private void addUsedBy(Map usedClassToPackagesMap,
+ ClassDoc usedClass, UsageType usageType, Doc user, PackageDoc userPackage)
+ {
+ Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(usedClass);
+ if (null == packageToUsageTypeMap) {
+ packageToUsageTypeMap = new HashMap();
+ usedClassToPackagesMap.put(usedClass, packageToUsageTypeMap);
+ }
+
+ Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(userPackage);
+ if (null == usageTypeToUsersMap) {
+ usageTypeToUsersMap = new TreeMap();
+ packageToUsageTypeMap.put(userPackage, usageTypeToUsersMap);
+ }
+
+ Set userSet = (Set)usageTypeToUsersMap.get(usageType);
+ if (null == userSet) {
+ userSet = new TreeSet(); // FIXME: we need the collator from Main here
+ usageTypeToUsersMap.put(usageType, userSet);
+ }
+ userSet.add(user);
+ }
+
+ /**
+ * Create the cross reference database.
+ */
+ private Map collectUsage() {
+
+ Map _usedClassToPackagesMap = new HashMap();
+
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
+ ClassDoc clazz = classes[i];
+
+ if (clazz.isInterface()) {
+ // classes implementing
+ InterfaceRelation relation
+ = (InterfaceRelation)getInterfaceRelations().get(clazz);
+ Iterator it = relation.implementingClasses.iterator();
+ while (it.hasNext()) {
+ ClassDoc implementor = (ClassDoc)it.next();
+ addUsedBy(_usedClassToPackagesMap,
+ clazz, UsageType.CLASS_IMPLEMENTING, implementor, implementor.containingPackage());
+ }
+ }
+ else {
+ // classes derived from
+ for (ClassDoc superclass = clazz.superclass(); superclass != null;
+ superclass = superclass.superclass()) {
+ addUsedBy(_usedClassToPackagesMap,
+ superclass, UsageType.CLASS_DERIVED_FROM, clazz, clazz.containingPackage());
+ }
+ }
+
+ FieldDoc[] fields = clazz.fields();
+ for (int j = 0, jlim = fields.length; j < jlim; ++ j) {
+ FieldDoc field = fields[j];
+
+ // fields of type
+ ClassDoc fieldType = field.type().asClassDoc();
+ if (null != fieldType) {
+ addUsedBy(_usedClassToPackagesMap,
+ fieldType, UsageType.FIELD_OF_TYPE,
+ field, clazz.containingPackage());
+ }
+ }
+
+ MethodDoc[] methods = clazz.methods();
+ for (int j = 0, jlim = methods.length; j < jlim; ++ j) {
+ MethodDoc method = methods[j];
+
+ // methods with return type
+
+ ClassDoc returnType = method.returnType().asClassDoc();
+ if (null != returnType) {
+ addUsedBy(_usedClassToPackagesMap,
+ returnType, UsageType.METHOD_WITH_RETURN_TYPE,
+ method, clazz.containingPackage());
+ }
+ Parameter[] parameters = method.parameters();
+ for (int k=0; k<parameters.length; ++k) {
+
+ // methods with parameter type
+
+ Parameter parameter = parameters[k];
+ ClassDoc parameterType = parameter.type().asClassDoc();
+ if (null != parameterType) {
+ addUsedBy(_usedClassToPackagesMap,
+ parameterType, UsageType.METHOD_WITH_PARAMETER_TYPE,
+ method, clazz.containingPackage());
+ }
+ }
+
+ // methods which throw
+
+ ClassDoc[] thrownExceptions = method.thrownExceptions();
+ for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
+ ClassDoc thrownException = thrownExceptions[k];
+ addUsedBy(_usedClassToPackagesMap,
+ thrownException, UsageType.METHOD_WITH_THROWN_TYPE,
+ method, clazz.containingPackage());
+ }
+ }
+
+ ConstructorDoc[] constructors = clazz.constructors();
+ for (int j = 0, jlim = constructors.length; j < jlim; ++ j) {
+
+ ConstructorDoc constructor = constructors[j];
+
+ Parameter[] parameters = constructor.parameters();
+ for (int k = 0, klim = parameters.length; k < klim; ++ k) {
+
+ // constructors with parameter type
+
+ Parameter parameter = parameters[k];
+ ClassDoc parameterType = parameter.type().asClassDoc();
+ if (null != parameterType) {
+ addUsedBy(_usedClassToPackagesMap,
+ parameterType, UsageType.CONSTRUCTOR_WITH_PARAMETER_TYPE,
+ constructor, clazz.containingPackage());
+ }
+ }
+
+ // constructors which throw
+
+ ClassDoc[] thrownExceptions = constructor.thrownExceptions();
+ for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
+ ClassDoc thrownException = thrownExceptions[k];
+ addUsedBy(_usedClassToPackagesMap,
+ thrownException, UsageType.CONSTRUCTOR_WITH_THROWN_TYPE,
+ constructor, clazz.containingPackage());
+ }
+ }
+ }
+ return _usedClassToPackagesMap;
+ }
+
+ private Map usedClassToPackagesMap = null;
+
+ protected Map getUsageOfClass(ClassDoc classDoc)
+ {
+ if (null == this.usedClassToPackagesMap) {
+ this.usedClassToPackagesMap = collectUsage();
+ }
+ return (Map)this.usedClassToPackagesMap.get(classDoc);
+ }
+
+ protected static class UsageType
+ implements Comparable
+ {
+ public static final UsageType CLASS_DERIVED_FROM = new UsageType("class-derived-from");
+ public static final UsageType CLASS_IMPLEMENTING = new UsageType("class-implementing");
+ public static final UsageType FIELD_OF_TYPE = new UsageType("field-of-type");
+ public static final UsageType METHOD_WITH_RETURN_TYPE = new UsageType("method-with-return-type");
+ public static final UsageType METHOD_WITH_PARAMETER_TYPE = new UsageType("method-with-parameter-type");
+ public static final UsageType METHOD_WITH_THROWN_TYPE = new UsageType("method-with-thrown-type");
+ public static final UsageType CONSTRUCTOR_WITH_PARAMETER_TYPE = new UsageType("constructor-with-parameter-type");
+ public static final UsageType CONSTRUCTOR_WITH_THROWN_TYPE = new UsageType("constructor-with-thrown-type");
+ private String id;
+
+ private UsageType(String id)
+ {
+ this.id = id;
+ }
+
+ public int compareTo(Object other)
+ {
+ return this.id.compareTo(((UsageType)other).id);
+ }
+
+ public String toString() {
+ return "UsageType{id=" + id + "}";
+ }
+
+ public String getId() {
+ return id;
+ }
+ }
+
+ private ResourceBundle resources;
+
+ protected String getString(String key)
+ {
+ if (null == resources) {
+ Locale currentLocale = Locale.getDefault();
+
+ resources
+ = ResourceBundle.getBundle("htmldoclet.HtmlDoclet", currentLocale);
+ }
+
+ return resources.getString(key);
+ }
+
+ protected String format(String key, String value1)
+ {
+ return MessageFormat.format(getString(key), new Object[] { value1 });
+ }
+
+ protected List getPackageGroups()
+ {
+ return packageGroups;
+ }
+
+ protected void copyDocFiles(File sourceDir, File targetDir)
+ throws IOException
+ {
+ File sourceDocFiles = new File(sourceDir, "doc-files");
+ File targetDocFiles = new File(targetDir, "doc-files");
+
+ if (sourceDocFiles.exists()) {
+ IOToolkit.copyDirectory(sourceDocFiles,
+ targetDocFiles,
+ optionDocFilesSubDirs.getValue(),
+ optionExcludeDocFilesSubDir.getComponents());
+ }
+ }
+
+ private Set sourcePaths;
+
+ /**
+ * Try to determine the source directory for the given package by
+ * looking at the path specified by -sourcepath, or the current
+ * directory if -sourcepath hasn't been specified.
+ *
+ * @throws IOException if the source directory couldn't be
+ * located.
+ *
+ * @return List of File
+ */
+ protected List getPackageSourceDirs(PackageDoc packageDoc)
+ throws IOException
+ {
+ if (null == sourcePaths) {
+ for (int i=0; i<rootDoc.options().length; ++i) {
+ if ("-sourcepath".equals(rootDoc.options()[i][0])
+ || "-s".equals(rootDoc.options()[i][0])) {
+ sourcePaths = new LinkedHashSet();
+ String sourcepathString = rootDoc.options()[i][1];
+ StringTokenizer st = new StringTokenizer(sourcepathString, File.pathSeparator);
+ while (st.hasMoreTokens()) {
+ sourcePaths.add(new File(st.nextToken()));
+ }
+ }
+ }
+ if (null == sourcePaths) {
+ sourcePaths = new LinkedHashSet();
+ sourcePaths.add(new File(System.getProperty("user.dir")));
+ }
+ }
+
+ String packageSubDir = packageDoc.name().replace('.', File.separatorChar);
+ Iterator it = sourcePaths.iterator();
+ List result = new LinkedList();
+ while (it.hasNext()) {
+ File pathComponent = (File)it.next();
+ File packageDir = new File(pathComponent, packageSubDir);
+ if (packageDir.exists()) {
+ result.add(packageDir);
+ }
+ }
+ if (result.isEmpty()) {
+ throw new IOException("Couldn't locate source directory for package " + packageDoc.name());
+ }
+ else {
+ return result;
+ }
+ }
+
+ protected File getSourceFile(ClassDoc classDoc)
+ throws IOException
+ {
+ List packageDirs = getPackageSourceDirs(classDoc.containingPackage());
+ Iterator it = packageDirs.iterator();
+ while (it.hasNext()) {
+ File packageDir = (File)it.next();
+ File sourceFile = new File(packageDir, getOuterClassDoc(classDoc).name() + ".java");
+ if (sourceFile.exists()) {
+ return sourceFile;
+ }
+ }
+
+ throw new IOException("Couldn't locate source file for class " + classDoc.qualifiedTypeName());
+ }
+
+ protected void printError(String error)
+ {
+ if (null != rootDoc) {
+ rootDoc.printError(error);
+ }
+ else {
+ System.err.println("ERROR: "+error);
+ }
+ }
+
+ protected void printWarning(String warning)
+ {
+ if (null != rootDoc) {
+ rootDoc.printWarning(warning);
+ }
+ else {
+ System.err.println("WARNING: "+warning);
+ }
+ }
+
+ protected void printNotice(String notice)
+ {
+ if (null != rootDoc) {
+ rootDoc.printNotice(notice);
+ }
+ else {
+ System.err.println(notice);
+ }
+ }
+
+ protected static ClassDoc getOuterClassDoc(ClassDoc classDoc)
+ {
+ while (null != classDoc.containingClass()) {
+ classDoc = classDoc.containingClass();
+ }
+ return classDoc;
+ }
+
+ private SortedSet allPackages;
+
+ protected Set getAllPackages()
+ {
+ if (null == this.allPackages) {
+ allPackages = new TreeSet();
+ PackageDoc[] specifiedPackages = rootDoc.specifiedPackages();
+ for (int i=0; i<specifiedPackages.length; ++i) {
+ allPackages.add(specifiedPackages[i]);
+ }
+ ClassDoc[] specifiedClasses = rootDoc.specifiedClasses();
+ for (int i=0; i<specifiedClasses.length; ++i) {
+ allPackages.add(specifiedClasses[i].containingPackage());
+ }
+ }
+ return this.allPackages;
+ }
+
+ protected boolean omitPackageQualifier(PackageDoc packageDoc)
+ {
+ if (!optionNoQualifier.isSpecified()) {
+ return false;
+ }
+ else {
+ return optionNoQualifier.match(packageDoc);
+ }
+ }
+
+ protected String possiblyQualifiedName(Type type)
+ {
+ if (null == type.asClassDoc()
+ || !omitPackageQualifier(type.asClassDoc().containingPackage())) {
+ return type.qualifiedTypeName();
+ }
+ else {
+ return type.typeName();
+ }
+ }
+
+ protected static class InterfaceRelation
+ {
+ public Set superInterfaces;
+ public Set subInterfaces;
+ public Set implementingClasses;
+
+ public InterfaceRelation()
+ {
+ superInterfaces = new TreeSet();
+ subInterfaces = new TreeSet();
+ implementingClasses = new TreeSet();
+ }
+ }
+
+ private void addAllInterfaces(ClassDoc classDoc, Set allInterfaces)
+ {
+ ClassDoc[] interfaces = classDoc.interfaces();
+ for (int i=0; i<interfaces.length; ++i) {
+ allInterfaces.add(interfaces[i]);
+ addAllInterfaces(interfaces[i], allInterfaces);
+ }
+ }
+
+ private Map allSubClasses;
+
+ protected Map getAllSubClasses()
+ {
+ if (null == allSubClasses) {
+ allSubClasses = new HashMap();
+
+ ClassDoc[] classDocs = getRootDoc().classes();
+ for (int i=0; i<classDocs.length; ++i) {
+ if (!classDocs[i].isInterface()) {
+ for (ClassDoc cd = classDocs[i].superclass();
+ null != cd;
+ cd = cd.superclass()) {
+
+ if (!cd.qualifiedTypeName().equals("java.lang.Object")) {
+ List subClasses = (List)allSubClasses.get(cd);
+ if (null == subClasses) {
+ subClasses = new LinkedList();
+ allSubClasses.put(cd, subClasses);
+ }
+ subClasses.add(classDocs[i]);
+ }
+ }
+ }
+ }
+ }
+ return allSubClasses;
+ }
+
+ private Map interfaceRelations;
+
+ private void addToInterfaces(ClassDoc classDoc, ClassDoc[] interfaces)
+ {
+ for (int i=0; i<interfaces.length; ++i) {
+ InterfaceRelation interfaceRelation
+ = (InterfaceRelation)interfaceRelations.get(interfaces[i]);
+ if (null == interfaceRelation) {
+ interfaceRelation = new InterfaceRelation();
+ interfaceRelations.put(interfaces[i], interfaceRelation);
+ }
+ interfaceRelation.implementingClasses.add(classDoc);
+ addToInterfaces(classDoc, interfaces[i].interfaces());
+ }
+ }
+
+ protected Map getInterfaceRelations()
+ {
+ if (null == interfaceRelations) {
+ interfaceRelations = new HashMap();
+
+ ClassDoc[] classDocs = getRootDoc().classes();
+ for (int i=0; i<classDocs.length; ++i) {
+ if (classDocs[i].isInterface()) {
+ InterfaceRelation relation = new InterfaceRelation();
+ addAllInterfaces(classDocs[i], relation.superInterfaces);
+ interfaceRelations.put(classDocs[i], relation);
+ }
+ }
+
+ Iterator it = interfaceRelations.keySet().iterator();
+ while (it.hasNext()) {
+ ClassDoc interfaceDoc = (ClassDoc)it.next();
+ InterfaceRelation relation
+ = (InterfaceRelation)interfaceRelations.get(interfaceDoc);
+ Iterator superIt = relation.superInterfaces.iterator();
+ while (superIt.hasNext()) {
+ ClassDoc superInterfaceDoc = (ClassDoc)superIt.next();
+ InterfaceRelation superRelation
+ = (InterfaceRelation)interfaceRelations.get(superInterfaceDoc);
+ if (null != superRelation) {
+ superRelation.subInterfaces.add(interfaceDoc);
+ }
+ }
+ }
+
+ for (int i=0; i<classDocs.length; ++i) {
+ if (!classDocs[i].isInterface()) {
+ for (ClassDoc cd = classDocs[i]; null != cd; cd = cd.superclass()) {
+ addToInterfaces(classDocs[i], cd.interfaces());
+ }
+ }
+ }
+ }
+
+ return interfaceRelations;
+ }
+
+ private Map sortedMethodMap = new HashMap();
+
+ protected MethodDoc[] getSortedMethods(ClassDoc classDoc)
+ {
+ MethodDoc[] result = (MethodDoc[])sortedMethodMap.get(classDoc);
+ if (null == result) {
+ MethodDoc[] methods = classDoc.methods();
+ result = (MethodDoc[])methods.clone();
+ Arrays.sort(result);
+ return result;
+ }
+ return result;
+ }
+
+ private Map sortedConstructorMap = new HashMap();
+
+ protected ConstructorDoc[] getSortedConstructors(ClassDoc classDoc)
+ {
+ ConstructorDoc[] result = (ConstructorDoc[])sortedConstructorMap.get(classDoc);
+ if (null == result) {
+ ConstructorDoc[] constructors = classDoc.constructors();
+ result = (ConstructorDoc[])constructors.clone();
+ Arrays.sort(result);
+ return result;
+ }
+ return result;
+ }
+
+ private Map sortedFieldMap = new HashMap();
+
+ protected FieldDoc[] getSortedFields(ClassDoc classDoc)
+ {
+ FieldDoc[] result = (FieldDoc[])sortedFieldMap.get(classDoc);
+ if (null == result) {
+ FieldDoc[] fields = classDoc.fields();
+ result = (FieldDoc[])fields.clone();
+ Arrays.sort(result);
+ return result;
+ }
+ return result;
+ }
+
+ private Map sortedInnerClassMap = new HashMap();
+
+ protected ClassDoc[] getSortedInnerClasses(ClassDoc classDoc)
+ {
+ ClassDoc[] result = (ClassDoc[])sortedInnerClassMap.get(classDoc);
+ if (null == result) {
+ ClassDoc[] innerClasses = classDoc.innerClasses();
+ result = (ClassDoc[])innerClasses.clone();
+ Arrays.sort(result);
+ return result;
+ }
+ return result;
+ }
+
+ protected abstract String renderTag(String tagName, Tag[] tags, TagletContext context);
+
+ protected abstract String getDocletVersion();
+
+ protected SortedSet getThrownExceptions(ExecutableMemberDoc execMemberDoc)
+ {
+ SortedSet result = new TreeSet();
+ ClassDoc[] thrownExceptions = execMemberDoc.thrownExceptions();
+ for (int j=0; j<thrownExceptions.length; ++j) {
+ result.add(thrownExceptions[j]);
+ }
+ return result;
+ }
+
+ protected boolean isUncheckedException(ClassDoc classDoc)
+ {
+ if (classDoc.isException()) {
+ while (null != classDoc) {
+ if (classDoc.qualifiedTypeName().equals("java.lang.RuntimeException")) {
+ return true;
+ }
+ classDoc = classDoc.superclass();
+ }
+ return false;
+ }
+ else {
+ return false;
+ }
+ }
+
+ protected FieldDoc findField(ClassDoc classDoc, String fieldName)
+ {
+ for (ClassDoc cd = classDoc; cd != null; cd = cd.superclass()) {
+ FieldDoc[] fields = cd.fields(false);
+ for (int i=0; i<fields.length; ++i) {
+ if (fields[i].name().equals(fieldName)) {
+ return fields[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ private Map implementedInterfacesCache = new HashMap();
+
+ protected Set getImplementedInterfaces(ClassDoc classDoc)
+ {
+ Set result = (Set)implementedInterfacesCache.get(classDoc);
+ if (null == result) {
+ result = new TreeSet();
+
+ for (ClassDoc cd = classDoc; cd != null; cd = cd.superclass()) {
+ ClassDoc[] interfaces = cd.interfaces();
+ for (int i=0; i<interfaces.length; ++i) {
+ result.add(interfaces[i]);
+ InterfaceRelation relation
+ = (InterfaceRelation)getInterfaceRelations().get(interfaces[i]);
+ if (null != relation) {
+ result.addAll(relation.superInterfaces);
+ }
+ }
+ }
+
+ implementedInterfacesCache.put(classDoc, result);
+ }
+
+ return result;
+ }
+
+ protected boolean isSinglePackage()
+ {
+ return getAllPackages().size() <= 1;
+ }
+
+ protected PackageDoc getSinglePackage()
+ {
+ return (PackageDoc)getAllPackages().iterator().next();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletConfigurationException.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletConfigurationException.java
new file mode 100644
index 000000000..0e29df928
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletConfigurationException.java
@@ -0,0 +1,54 @@
+/* gnu.classpath.tools.doclets.DocletConfigurationException
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+/**
+ * Thrown by <code>AbstractDoclet</code> members or members of
+ * <code>AbstractDoclet</code> subclasses when a problem caused by
+ * user-specified options is detected.
+ *
+ * @see AbstractDoclet
+ */
+public class DocletConfigurationException
+ extends Exception
+{
+ public DocletConfigurationException(String message)
+ {
+ super(message);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOption.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOption.java
new file mode 100644
index 000000000..fa67f5ec7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOption.java
@@ -0,0 +1,56 @@
+/* gnu.classpath.tools.doclets.DocletOption
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+public abstract class DocletOption
+{
+ private String optionName;
+
+ protected DocletOption(String optionName)
+ {
+ this.optionName = optionName;
+ }
+
+ public String getName()
+ {
+ return this.optionName;
+ }
+
+ public abstract int getLength();
+ public abstract boolean set(String[] optionArr);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionColonSeparated.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionColonSeparated.java
new file mode 100644
index 000000000..e02e1ebb4
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionColonSeparated.java
@@ -0,0 +1,76 @@
+/* gnu.classpath.tools.doclets.DocletOptionColonSeparated
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Processes a doclet option whose value consists of a
+ * colon-separated list of strings.
+ */
+public class DocletOptionColonSeparated
+ extends DocletOption
+{
+ private Set components = new LinkedHashSet();
+
+ DocletOptionColonSeparated(String optionName)
+ {
+ super(optionName);
+ }
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ StringTokenizer st = new StringTokenizer(":");
+ while (st.hasMoreTokens()) {
+ components.add(st.nextToken());
+ }
+ return true;
+ }
+
+ public Set getComponents()
+ {
+ return components;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFile.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFile.java
new file mode 100644
index 000000000..b83685755
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFile.java
@@ -0,0 +1,77 @@
+/* gnu.classpath.tools.doclets.DocletOptionFile
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import java.io.File;
+
+/**
+ * Processes a doclet option whose value denotes an existing or
+ * non-existing file in the local file system.
+ */
+public class DocletOptionFile
+ extends DocletOption
+{
+ private File value;
+
+ public DocletOptionFile(String optionName)
+ {
+ this(optionName, null);
+ }
+
+ public DocletOptionFile(String optionName, File defaultFile)
+ {
+ super(optionName);
+ this.value = defaultFile;
+ }
+
+ public File getValue()
+ {
+ return this.value;
+ }
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ this.value = new File(optionArr[1]);
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFlag.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFlag.java
new file mode 100644
index 000000000..13afe407f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFlag.java
@@ -0,0 +1,69 @@
+/* gnu.classpath.tools.doclets.DocletOptionFlag
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+/**
+ * Processes a doclet option without a value whose existance denotes
+ * that a specific feature should be enabled or disabled.
+ */
+public class DocletOptionFlag
+ extends DocletOption
+{
+ private boolean value = false;
+
+ public DocletOptionFlag(String optionName)
+ {
+ super(optionName);
+ }
+
+ public boolean getValue()
+ {
+ return this.value;
+ }
+
+ public int getLength()
+ {
+ return 1;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ value = true;
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.java
new file mode 100644
index 000000000..33a637db8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.java
@@ -0,0 +1,124 @@
+/* gnu.classpath.tools.doclets.DocletOptionPackageWildcard
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import com.sun.javadoc.PackageDoc;
+
+/**
+ * Processes a doclet option whose value consists of a
+ * colon-separated list of package wildcards, or - optionally -
+ * equals the string "all", denoting that all packages should match.
+ */
+public class DocletOptionPackageWildcard
+ extends DocletOption
+{
+ private PackageMatcher packageMatcher;
+ private boolean allowAll;
+ private boolean specified;
+
+ DocletOptionPackageWildcard(String optionName, boolean allowAll)
+ {
+ super(optionName);
+ this.allowAll = allowAll;
+ }
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean isSpecified()
+ {
+ return specified;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ this.specified = true;
+ try {
+ if (allowAll && "all".equals(optionArr[2])) {
+ packageMatcher = null;
+ }
+ else {
+ packageMatcher = new PackageMatcher();
+
+ StringTokenizer tokenizer = new StringTokenizer(optionArr[2], ":");
+ while (tokenizer.hasMoreTokens()) {
+ String packageWildcard = tokenizer.nextToken();
+ packageMatcher.addWildcard(packageWildcard);
+ }
+ }
+ return true;
+ }
+ catch (InvalidPackageWildcardException e) {
+ // FIXME: output problem description here, better throw
+ // DocletConfigurationException
+ return false;
+ }
+ }
+
+ public SortedSet filter(PackageDoc[] packages)
+ {
+ if (null != packageMatcher) {
+ return packageMatcher.filter(packages);
+ }
+ else {
+ SortedSet result = new TreeSet();
+ for (int i=0; i<packages.length; ++i) {
+ result.add(packages[i]);
+ }
+ return result;
+ }
+ }
+
+ public boolean match(PackageDoc packageDoc)
+ {
+ if (null != packageMatcher) {
+ return packageMatcher.match(packageDoc);
+ }
+ else {
+ return true;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionString.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionString.java
new file mode 100644
index 000000000..ecab86541
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionString.java
@@ -0,0 +1,68 @@
+/* gnu.classpath.tools.doclets.DocletOptionString
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+/**
+ * Processes a doclet option whose value is an arbitrary string.
+ */
+public class DocletOptionString
+ extends DocletOption
+{
+ private String value = null;
+
+ public DocletOptionString(String optionName)
+ {
+ super(optionName);
+ }
+
+ public String getValue()
+ {
+ return this.value;
+ }
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ value = optionArr[1];
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/InlineTagRenderer.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/InlineTagRenderer.java
new file mode 100644
index 000000000..f7d4ac573
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/InlineTagRenderer.java
@@ -0,0 +1,46 @@
+/* gnu.classpath.tools.doclets.InlineTagRenderer
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import com.sun.javadoc.Tag;
+import gnu.classpath.tools.taglets.TagletContext;
+
+public interface InlineTagRenderer
+{
+ public String renderInlineTags(Tag[] tags, TagletContext context);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/InvalidPackageWildcardException.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/InvalidPackageWildcardException.java
new file mode 100644
index 000000000..8f34288a3
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/InvalidPackageWildcardException.java
@@ -0,0 +1,51 @@
+/* gnu.classpath.tools.doclets.InvalidPackageWildcardException
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+/**
+ * Thrown when an invalid wildcard pattern is passed to {@link
+ * PackageMatcher.addWildcard(String)}.
+ */
+public class InvalidPackageWildcardException
+ extends Exception
+{
+ public InvalidPackageWildcardException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/PackageGroup.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/PackageGroup.java
new file mode 100644
index 000000000..4278ffb98
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/PackageGroup.java
@@ -0,0 +1,58 @@
+/* gnu.classpath.tools.doclets.PackageGroup
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import java.util.SortedSet;
+
+/**
+ * Stores a package group given on the command line.
+ */
+public class PackageGroup
+{
+ private String name;
+ private SortedSet packages; // contains PackageDoc
+
+ public PackageGroup(String name, SortedSet packages)
+ {
+ this.name = name;
+ this.packages = packages;
+ }
+
+ public String getName() { return name; }
+ public SortedSet getPackages() { return packages; }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/PackageMatcher.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/PackageMatcher.java
new file mode 100644
index 000000000..196b74c88
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/PackageMatcher.java
@@ -0,0 +1,152 @@
+/* gnu.classpath.tools.doclets.PackageMatcher
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.sun.javadoc.PackageDoc;
+
+/**
+ * Filters a set of packages according to a set of wildcards.
+ */
+public class PackageMatcher
+{
+ private Set patterns = new HashSet();
+
+ /**
+ * Add a wildcard to be matched. Wildcards can contain asterisk
+ * characters which match zero or more characters.
+ *
+ * @throw InvalidPackageWildcardException if the wildcard cannot
+ * match any valid package name.
+ */
+ public void addWildcard(String wildcard)
+ throws InvalidPackageWildcardException
+ {
+ final int STATE_ID_START = 0;
+ final int STATE_ID = 1;
+
+ int state = STATE_ID_START;
+
+ char[] wildcardChars = wildcard.toCharArray();
+ StringBuffer regexString = new StringBuffer();
+
+ for (int i=0; i<wildcardChars.length; ++i) {
+ char c = wildcardChars[i];
+ switch (state) {
+ case STATE_ID_START:
+ if ('*' == c) {
+ regexString.append(".*");
+ }
+ else if (Character.isJavaIdentifierStart(c)) {
+ regexString.append(c);
+ }
+ else {
+ throw new InvalidPackageWildcardException(wildcard);
+ }
+ state = STATE_ID;
+ break;
+
+ case STATE_ID:
+ if ('.' == c) {
+ regexString.append("\\.");
+ state = STATE_ID_START;
+ }
+ else if ('*' == c) {
+ regexString.append(".*");
+ }
+ else if (Character.isJavaIdentifierPart(c)) {
+ regexString.append(c);
+ }
+ else {
+ throw new InvalidPackageWildcardException(wildcard);
+ }
+ }
+ }
+ if (STATE_ID_START == state) {
+ throw new InvalidPackageWildcardException(wildcard);
+ }
+
+ patterns.add(Pattern.compile(regexString.toString()));
+ }
+
+ /**
+ * Return a sorted, filtered set of packages. A package from the
+ * array given will be put into the output list if it matches one
+ * or more of the wildcards added to this PackageMatcher before.
+ */
+ public SortedSet filter(PackageDoc[] packageDocs)
+ {
+ SortedSet result = new TreeSet();
+ for (int i=0; i<packageDocs.length; ++i) {
+ if (match(packageDocs[i])) {
+ result.add(packageDocs[i]);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return true when the given PackageDoc matches one or more of
+ * the wildcard added to this PackageMatcher before.
+ */
+ public boolean match(PackageDoc packageDoc)
+ {
+ Iterator it = patterns.iterator();
+ while (it.hasNext()) {
+ Pattern pattern = (Pattern)it.next();
+ Matcher matcher = pattern.matcher(packageDoc.name());
+ if (matcher.matches()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ return "PackageMatcher{patterns=" + patterns + "}";
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/StandardTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/StandardTaglet.java
new file mode 100644
index 000000000..f43f2a13c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/StandardTaglet.java
@@ -0,0 +1,100 @@
+/* gnu.classpath.tools.doclets.StandardTaglet
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+import com.sun.javadoc.Tag;
+import com.sun.tools.doclets.Taglet;
+
+/**
+ * Represents one of the built-in taglets. Used for specifying taglet
+ * order.
+ */
+public class StandardTaglet
+ implements Taglet
+{
+ private String name;
+
+ /**
+ * Initialize with one of the built-in taglet names.
+ */
+ public StandardTaglet(String name) {
+ this.name = name;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String toString(Tag tag) {
+ //assert(false);
+ return null;
+ }
+
+ public String toString(Tag[] tags) {
+ //assert(false);
+ return null;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/TagletPrinter.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/TagletPrinter.java
new file mode 100644
index 000000000..b59704a51
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/TagletPrinter.java
@@ -0,0 +1,46 @@
+/* gnu.classpath.tools.doclets.TagletPrinter
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets;
+
+/**
+ * Call-back interface for taglet string output.
+ */
+public interface TagletPrinter
+{
+ public void printTagletString(String s);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.java
new file mode 100644
index 000000000..18bf57950
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.java
@@ -0,0 +1,174 @@
+/* DebugDoclet.java - Doclet for debugging
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.debugdoclet;
+
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.FieldDoc;
+import com.sun.javadoc.MethodDoc;
+import com.sun.javadoc.PackageDoc;
+import com.sun.javadoc.RootDoc;
+import com.sun.javadoc.Tag;
+
+import java.io.PrintStream;
+
+import java.util.Arrays;
+
+public class DebugDoclet
+{
+ public static boolean start(RootDoc rootDoc)
+ {
+ new DebugDoclet().run(rootDoc);
+ return true;
+ }
+
+ private PrintStream out;
+
+ public DebugDoclet()
+ {
+ out = System.out;
+ }
+
+ private void printHeader(String header)
+ {
+ out.println();
+ out.println("******** " + header + " ********");
+ out.println();
+ }
+
+ private void printSubHeader(String header)
+ {
+ out.println();
+ out.println("======== " + header + " ========");
+ out.println();
+ }
+
+ private void printSub2Header(String header)
+ {
+ out.println();
+ out.println("-------- " + header + " --------");
+ out.println();
+ }
+
+ private void run(RootDoc rootDoc)
+ {
+ printHeader("Overview");
+
+ printSubHeader("Specified Packages");
+
+ PackageDoc[] specifiedPackages = rootDoc.specifiedPackages();
+ Arrays.sort(specifiedPackages);
+ for (int i=0; i<specifiedPackages.length; ++i) {
+ out.println(specifiedPackages[i].name());
+ }
+
+ printSubHeader("Specified Classes");
+
+ ClassDoc[] specifiedClasses = rootDoc.specifiedClasses();
+ Arrays.sort(specifiedClasses);
+ for (int i=0; i<specifiedClasses.length; ++i) {
+ out.println(specifiedClasses[i].qualifiedTypeName());
+ }
+ printSubHeader("Classes");
+
+ ClassDoc[] classes = rootDoc.classes();
+ Arrays.sort(classes);
+ for (int i=0; i<classes.length; ++i) {
+ out.println(classes[i].qualifiedTypeName());
+ }
+
+ printHeader("Class Detail");
+
+ for (int i=0; i<classes.length; ++i) {
+ printSubHeader(classes[i].qualifiedTypeName());
+
+ printTags(classes[i].firstSentenceTags());
+
+ printSub2Header("Methods");
+
+ MethodDoc[] methods = classes[i].methods();
+
+ for (int j=0; j<methods.length; ++j) {
+ out.println("name: \"" + methods[j].name() + "\"");
+ out.println("signature: \"" + methods[j].signature() + "\"");
+ out.println("modifiers: \"" + methods[j].modifiers() + "\"");
+ out.print("throws: ");
+ ClassDoc[] thrownExceptions = methods[j].thrownExceptions();
+ for (int k=0; k<thrownExceptions.length; ++k) {
+ if (k>0) { out.print(", "); }
+ out.print(thrownExceptions[k].qualifiedTypeName());
+ }
+ out.println();
+ }
+
+ printSub2Header("Fields");
+
+ FieldDoc[] fields = classes[i].fields();
+
+ for (int j=0; j<fields.length; ++j) {
+ out.println("name: \"" + fields[j].name() + "\"");
+ out.println("modifiers: \"" + fields[j].modifiers() + "\"");
+ out.println();
+ }
+
+ printSub2Header("Serializable Fields");
+
+ FieldDoc[] sfields = classes[i].serializableFields();
+
+ for (int j=0; j<sfields.length; ++j) {
+ out.println("name: \"" + sfields[j].name() + "\"");
+ out.println("modifiers: \"" + sfields[j].modifiers() + "\"");
+ out.println();
+ }
+ }
+ }
+
+ private void printTag(Tag tag)
+ {
+ if (null != tag.text()) {
+ System.out.println(tag.text());
+ }
+ }
+
+ private void printTags(Tag[] tags)
+ {
+ for (int i=0; i<tags.length; ++i) {
+ out.println("Tag #" + (i+1) + ":");
+ printTag(tags[i]);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/CssClass.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/CssClass.java
new file mode 100644
index 000000000..ba4c8b685
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/CssClass.java
@@ -0,0 +1,300 @@
+/* gnu.classpath.tools.doclets.htmldoclet.CssClass
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.htmldoclet;
+
+/**
+ * Represents a CSS (Cascading Stylesheet) class. Supports
+ * substituting <code>div</code> and <code>span</code> tags by more
+ * specialized HTML tags.
+ */
+public class CssClass
+{
+ public static final CssClass BODY_MENU_PACKAGES = new CssClass("menu packages");
+ public static final CssClass BODY_MENU_CLASSES = new CssClass("menu classes");
+ public static final CssClass BODY_CONTENT_CLASS = new CssClass("content class");
+ public static final CssClass BODY_CONTENT_DEPRECATED = new CssClass("content deprecated");
+ public static final CssClass BODY_CONTENT_PACKAGE = new CssClass("content package");
+ public static final CssClass BODY_CONTENT_OVERVIEW = new CssClass("content overview");
+ public static final CssClass BODY_CONTENT_ABOUT = new CssClass("content about");
+ public static final CssClass BODY_CONTENT_HELP = new CssClass("content help");
+ public static final CssClass BODY_CONTENT_PACKAGE_TREE = new CssClass("content packagetree");
+ public static final CssClass BODY_CONTENT_FULL_TREE = new CssClass("content fulltree");
+ public static final CssClass BODY_CONTENT_INDEX = new CssClass("content index");
+ public static final CssClass BODY_CONTENT_USES = new CssClass("content uses");
+ public static final CssClass BODY_CONTENT_SOURCE = new CssClass("content source");
+
+ public static final CssClass OVERVIEW_TITLE = new CssClass("overview title", "h1");
+ public static final CssClass OVERVIEW_SUMMARY = new CssClass("overview summary");
+ public static final CssClass OVERVIEW_SUMMARY_LEFT = new CssClass("left");
+ public static final CssClass OVERVIEW_SUMMARY_RIGHT = new CssClass("right");
+ public static final CssClass OVERVIEW_DESCRIPTION_TOP = new CssClass("overview description top");
+ public static final CssClass OVERVIEW_DESCRIPTION_FULL = new CssClass("overview description full");
+
+ public static final CssClass DEPRECATION_TITLE = new CssClass("deprecation title", "h1");
+ public static final CssClass DEPRECATION_SUMMARY = new CssClass("summary");
+ public static final CssClass DEPRECATION_SUMMARY_LEFT = new CssClass("left");
+ public static final CssClass DEPRECATION_SUMMARY_DESCRIPTION = new CssClass("description");
+ public static final CssClass DEPRECATION_TOC = new CssClass("dep-toc");
+ public static final CssClass DEPRECATION_TOC_HEADER = new CssClass("header", "h3");
+ public static final CssClass DEPRECATION_TOC_LIST = new CssClass("list", "ul");
+ public static final CssClass DEPRECATION_TOC_ENTRY = new CssClass("entry", "li");
+ public static final CssClass DEPRECATION_EMPTY = new CssClass("dep-empty", "p");
+ public static final CssClass DEPRECATION_LIST = new CssClass("dep-list", "div");
+
+ public static final CssClass SERIALIZED_TITLE = new CssClass("serialized title", "h1");
+ public static final CssClass SERIALIZED_PACKAGE_HEADER = new CssClass("serialized package header", "h2");
+ public static final CssClass SERIALIZED_CLASS_HEADER = new CssClass("serialized class header", "h3");
+ public static final CssClass SERIALIZED_SVUID_OUTER = new CssClass("serialized svuid outer", "p");
+ public static final CssClass SERIALIZED_SVUID_HEADER = new CssClass("serialized svuid header", "b");
+ public static final CssClass SERIALIZED_SVUID_VALUE = new CssClass("serialized svuid header");
+ public static final CssClass SERIALIZED_SECTION = new CssClass("serialized section");
+ public static final CssClass SERIALIZED_SECTION_HEADER = new CssClass("serialized section header", "h4");
+
+ public static final CssClass PACKAGE_TITLE = new CssClass("package title", "h1");
+ public static final CssClass PACKAGE_SUMMARY = new CssClass("package summary");
+ public static final CssClass PACKAGE_SUMMARY_LEFT = new CssClass("left");
+ public static final CssClass PACKAGE_SUMMARY_RIGHT = new CssClass("right");
+ public static final CssClass PACKAGE_DESCRIPTION_TOP = new CssClass("package description top");
+ public static final CssClass PACKAGE_DESCRIPTION_FULL = new CssClass("package description full");
+ public static final CssClass PACKAGE_TREE_TITLE = new CssClass("package tree title", "h1");
+ public static final CssClass PACKAGE_TREE_SECTION_TITLE = new CssClass("package tree section title", "h2");
+ public static final CssClass PACKAGE_TREE = new CssClass("tree", "ul");
+
+ public static final CssClass TREE_LINK = new CssClass("tree link", "b");
+
+ public static final CssClass FULL_TREE_PACKAGELIST = new CssClass("fulltree package list", "dl");
+ public static final CssClass FULL_TREE_PACKAGELIST_HEADER = new CssClass("fulltree package header", "dt", "b");
+ public static final CssClass FULL_TREE_PACKAGELIST_ITEM = new CssClass("fulltree package item", "dd");
+
+ public static final CssClass PACKAGE_MENU_LIST = new CssClass("package menu-list", "div");
+ public static final CssClass PACKAGE_MENU_ENTRY = new CssClass("package menu-entry");
+ public static final CssClass PACKAGE_MENU_TITLE = new CssClass("package menu-title", "h4");
+
+ public static final CssClass CLASS_MENU_LIST = new CssClass("classes menu-list", "div");
+ public static final CssClass CLASS_MENU_TITLE = new CssClass("classes menu-title", "h4");
+ public static final CssClass CLASS_MENU_SUBTITLE = new CssClass("classes menu-subtitle", "p");
+ public static final CssClass CLASS_MENU_ENTRY_CLASS = new CssClass("classes menu-entry class");
+ public static final CssClass CLASS_MENU_ENTRY_INTERFACE = new CssClass("classes menu-entry interface", "i");
+
+ public static final CssClass INDEX_TITLE = new CssClass("index title", "h1");
+ public static final CssClass INDEX_CATEGORY = new CssClass("index category");
+ public static final CssClass INDEX_CATEGORY_HEADER = new CssClass("index category header", "h2");
+ public static final CssClass INDEX_ENTRY = new CssClass("index entry");
+ public static final CssClass INDEX_ENTRY_DESCRIPTION = new CssClass("description");
+ public static final CssClass INDEX_ENTRY_KEY = new CssClass("key");
+ public static final CssClass INDEX_LETTERS = new CssClass("index letters");
+ public static final CssClass INDEX_LETTER = new CssClass("index letter");
+ public static final CssClass INDEX_LETTER_SPACER = new CssClass("index letter spacer");
+
+ public static final CssClass CLASS_TITLE = new CssClass("class title outer");
+ public static final CssClass CLASS_TITLE_PACKAGE = new CssClass("class title-package", "h3");
+ public static final CssClass CLASS_TITLE_CLASS = new CssClass("class title-class", "h1");
+ public static final CssClass CLASS_SUBCLASSES = new CssClass("class subclasses", "dl");
+ public static final CssClass CLASS_SUBCLASSES_HEADER = new CssClass("class subclasses header", "dt", "b");
+ public static final CssClass CLASS_SUBCLASSES_ITEM = new CssClass("class subclasses header", "dd");
+ public static final CssClass CLASS_ENCLOSINGCLASS = new CssClass("class enclosing", "dl");
+ public static final CssClass CLASS_ENCLOSINGCLASS_HEADER = new CssClass("class enclosing header", "dt", "b");
+ public static final CssClass CLASS_ENCLOSINGCLASS_ITEM = new CssClass("class enclosing item", "dd");
+ public static final CssClass CLASS_KNOWNIMPLEMENTING = new CssClass("class knownimplementing", "dl");
+ public static final CssClass CLASS_KNOWNIMPLEMENTING_HEADER = new CssClass("header", "dt", "b");
+ public static final CssClass CLASS_KNOWNIMPLEMENTING_ITEM = new CssClass("item", "dd");
+ public static final CssClass CLASS_INHERITANCETREE = new CssClass("class inheritance-tree");
+ public static final CssClass CLASS_SYNOPSIS = new CssClass("class synopsis outer");
+ public static final CssClass CLASS_SYNOPSIS_NAME = new CssClass("class synopsis name", "b");
+ public static final CssClass CLASS_SYNOPSIS_DECLARATION = new CssClass("class synopsis declaration", "div", "code");
+ public static final CssClass CLASS_SYNOPSIS_SUPERCLASS = new CssClass("class synopsis superclass", "div", "code");
+ public static final CssClass CLASS_SYNOPSIS_IMPLEMENTS = new CssClass("class synopsis implements", "div", "code");
+ public static final CssClass CLASS_DESCRIPTION = new CssClass("class description");
+ public static final CssClass CLASS_SUMMARY = new CssClass("class summary");
+ public static final CssClass CLASS_SUMMARY_LEFT = new CssClass("left", new String[] { "valign" }, new String[] { "top" });
+ public static final CssClass CLASS_SUMMARY_LEFT_SYNOPSIS = new CssClass("synopsis", "code");
+ public static final CssClass CLASS_SUMMARY_RIGHT = new CssClass("right");
+ public static final CssClass CLASS_SUMMARY_RIGHT_LIST = new CssClass("list", "dl");
+ public static final CssClass CLASS_SUMMARY_RIGHT_SYNOPSIS = new CssClass("synopsis", "dt", "code");
+ public static final CssClass CLASS_SUMMARY_RIGHT_DESCRIPTION = new CssClass("description", "dd");
+ public static final CssClass CLASS_SUMMARY_INHERITED = new CssClass("inherited");
+ public static final CssClass CLASS_SUMMARY_INHERITED_MEMBER = new CssClass("member", "code");
+ public static final CssClass CLASS_BOILERPLATE = new CssClass("boilerplate", "pre", new String[] { "style" }, new String[] { "font-size: x-small;" });
+
+ public static final CssClass USAGE_TITLE = new CssClass("usage title", "h1");
+ public static final CssClass USAGE_PACKAGE_TITLE = new CssClass("usage package title", "h2");
+ public static final CssClass USAGE_USAGE_TITLE = new CssClass("usage usage title", "h3");
+ public static final CssClass USAGE_SUMMARY = new CssClass("usage summary");
+ public static final CssClass USAGE_SUMMARY_LEFT = new CssClass("left");
+ public static final CssClass USAGE_SUMMARY_RIGHT = new CssClass("right");
+ public static final CssClass USAGE_SUMMARY_SYNOPSIS = new CssClass("synopsis");
+ public static final CssClass USAGE_SUMMARY_DESCRIPTION = new CssClass("description");
+ public static final CssClass USAGE_TABLE_HEADER = new CssClass("table header", "h3");
+ public static final CssClass USAGE_EMPTY = new CssClass("usage empty", "p");
+
+ public static final CssClass MEMBER_DETAIL = new CssClass("member detail outer");
+ public static final CssClass MEMBER_DETAIL_NAME = new CssClass("member detail name", "h3");
+ public static final CssClass MEMBER_DETAIL_BODY = new CssClass("member detail name", "blockquote");
+ public static final CssClass MEMBER_DETAIL_SYNOPSIS = new CssClass("member detail synopsis", "pre");
+ public static final CssClass MEMBER_DETAIL_DESCRIPTION = new CssClass("member detail description");
+ public static final CssClass MEMBER_DETAIL_SPECIFIED_BY_LIST = new CssClass("member detail specified by list", "dl");
+ public static final CssClass MEMBER_DETAIL_SPECIFIED_BY_HEADER = new CssClass("member detail specified by header", "dt", "b");
+ public static final CssClass MEMBER_DETAIL_SPECIFIED_BY_ITEM = new CssClass("member detail specified by item", "dd");
+ public static final CssClass MEMBER_DETAIL_OVERRIDDEN_LIST = new CssClass("member detail overridden list", "dl");
+ public static final CssClass MEMBER_DETAIL_OVERRIDDEN_HEADER = new CssClass("member detail overridden header", "dt", "b");
+ public static final CssClass MEMBER_DETAIL_OVERRIDDEN_ITEM = new CssClass("member detail overridden item", "dd");
+ public static final CssClass MEMBER_DETAIL_PARAMETER_LIST = new CssClass("parameter", "div", "dl");
+ public static final CssClass MEMBER_DETAIL_PARAMETER_HEADER = new CssClass("header", "dt", "b");
+ public static final CssClass MEMBER_DETAIL_PARAMETER_ITEM = new CssClass("item", "dd");
+ public static final CssClass MEMBER_DETAIL_PARAMETER_ITEM_NAME = new CssClass("name", "code");
+ public static final CssClass MEMBER_DETAIL_PARAMETER_ITEM_SEPARATOR = new CssClass("separator");
+ public static final CssClass MEMBER_DETAIL_PARAMETER_ITEM_DESCRIPTION = new CssClass("description");
+ public static final CssClass MEMBER_DETAIL_RETURN_LIST = new CssClass("member detail return list", "div", "dl");
+ public static final CssClass MEMBER_DETAIL_RETURN_HEADER = new CssClass("member detail return header", "dt", "b");
+ public static final CssClass MEMBER_DETAIL_RETURN_ITEM = new CssClass("member detail return item", "dd");
+ public static final CssClass MEMBER_DETAIL_THROWN_LIST = new CssClass("member detail thrown list", "div", "dl");
+ public static final CssClass MEMBER_DETAIL_THROWN_HEADER = new CssClass("member detail thrown header", "dt", "b");
+ public static final CssClass MEMBER_DETAIL_THROWN_ITEM = new CssClass("member detail thrown item", "dd");
+ public static final CssClass MEMBER_DETAIL_THROWN_ITEM_NAME = new CssClass("name", "code");
+ public static final CssClass MEMBER_DETAIL_THROWN_ITEM_SEPARATOR = new CssClass("separator");
+ public static final CssClass MEMBER_DETAIL_THROWN_ITEM_DESCRIPTION = new CssClass("description");
+
+ public static final CssClass TABLE_HEADER = new CssClass("table header", "h2");
+ public static final CssClass TABLE_SUB_HEADER = new CssClass("table sub header", "h3");
+ public static final CssClass TABLE_CONTAINER = new CssClass("table container", "dl", "dd");
+
+ public static final CssClass SECTION = new CssClass("section", "div");
+ public static final CssClass SECTION_HEADER = new CssClass("section header", "h2");
+
+ public static final CssClass NAVBAR_TOP = new CssClass("navbar div top");
+ public static final CssClass NAVBAR_TOP_NAVI = new CssClass("navi");
+ public static final CssClass NAVBAR_TOP_HEADER = new CssClass("header", new String[] { "rowspan" }, new String[] { "2" });
+ public static final CssClass NAVBAR_BOTTOM = new CssClass("navbar div bottom");
+ public static final CssClass NAVBAR_BOTTOM_SPACER = new CssClass("navbar bottom spacer", "p");
+ public static final CssClass NAVBAR_ITEM_ENABLED = new CssClass("navbar item enabled");
+ public static final CssClass NAVBAR_ITEM_DISABLED = new CssClass("navbar item disabled");
+ public static final CssClass NAVBAR_ITEM_ACTIVE = new CssClass("navbar item active");
+
+ public static final CssClass TAGLET = new CssClass("taglet", "div");
+
+ public static final CssClass ABOUT_TITLE = new CssClass("about title", "h1");
+ public static final CssClass ABOUT_GENERATOR = new CssClass("about generator", "p");
+
+ public static final CssClass SOURCE = new CssClass("source body");
+ public static final CssClass SOURCE_TITLE = new CssClass("source title", "h1");
+
+ public static final CssClass DEPRECATED = new CssClass("deprecated", "span");
+ public static final CssClass DEPRECATED_INLINE = new CssClass("deprecated", "p");
+ public static final CssClass DEPRECATED_HEADER = new CssClass("deprecated header", "b");
+ public static final CssClass DEPRECATED_BODY = new CssClass("deprecated", "i");
+
+ private String name;
+ private String elementName;
+ private String innerElementName;
+ private String[] attributeNames;
+ private String[] attributeValues;
+
+ private CssClass(String name)
+ {
+ this(name, null);
+ }
+
+ private CssClass(String name, String elementName)
+ {
+ this(name, elementName, null);
+ }
+
+ private CssClass(String name, String elementName, String innerElementName)
+ {
+ this(name, elementName, innerElementName, null, null);
+ }
+
+ private CssClass(String name, String elementName, String[] attributeNames, String[] attributeValues)
+ {
+ this(name, null, null, attributeNames, attributeValues);
+ }
+
+ private CssClass(String name, String[] attributeNames, String[] attributeValues)
+ {
+ this(name, null, null, attributeNames, attributeValues);
+ }
+
+ private CssClass(String name, String elementName, String innerElementName, String[] attributeNames, String[] attributeValues)
+ {
+ this.name = name;
+ this.elementName = elementName;
+ this.innerElementName = innerElementName;
+ this.attributeNames = attributeNames;
+ this.attributeValues = attributeValues;
+ }
+
+ public String getSpanElementName()
+ {
+ if (null != this.elementName) {
+ return this.elementName;
+ }
+ else {
+ return "span";
+ }
+ }
+
+ public String getDivElementName()
+ {
+ if (null != this.elementName) {
+ return this.elementName;
+ }
+ else {
+ return "div";
+ }
+ }
+
+ public String getInnerElementName()
+ {
+ return this.innerElementName;
+ }
+
+ public String[] getAttributeNames()
+ {
+ return this.attributeNames;
+ }
+
+ public String[] getAttributeValues()
+ {
+ return this.attributeValues;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.java
new file mode 100644
index 000000000..f3b2fa8ca
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.java
@@ -0,0 +1,187 @@
+/* gnu.classpath.tools.doclets.htmldoclet.ExternalDocSet
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.htmldoclet;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import com.sun.javadoc.ClassDoc;
+
+public class ExternalDocSet
+{
+ private String url;
+ private String packageListDir;
+ private URL docSetDirectoryURL;
+
+ public String getPackageListDir()
+ {
+ return packageListDir;
+ }
+
+ public ExternalDocSet(String url,
+ String packageListDir)
+ {
+ this.url = url;
+ this.packageListDir = packageListDir;
+ }
+
+ private Set packageNames = new HashSet();
+ private boolean javadocCompatible;
+
+ public void load(File targetDirectory)
+ throws IOException, MalformedURLException
+ {
+ if (!url.endsWith("/")) {
+ url += "/";
+ }
+
+ this.docSetDirectoryURL = new URL(targetDirectory.toURL(),
+ url);
+
+ URL packageListDirURL;
+ if (null != packageListDir) {
+ if (!packageListDir.endsWith("/")) {
+ packageListDir += "/";
+ }
+ packageListDirURL = new URL(new File(System.getProperty("user.dir")).toURL(),
+ packageListDir);
+ }
+ else {
+ packageListDirURL = docSetDirectoryURL;
+ }
+
+ URL packageListURL = new URL(packageListDirURL,
+ "package-list");
+ InputStream in = packageListURL.openStream();
+ if (null != in) {
+ readPackages(in);
+ in.close();
+ }
+ else {
+ throw new FileNotFoundException(packageListURL.toString());
+ }
+
+ URL gjdocPropertiesURL = new URL(packageListDirURL,
+ "gjdoc.properties");
+ try {
+ InputStream propertiesIn = gjdocPropertiesURL.openStream();
+ if (null != in) {
+ Properties properties = new Properties();
+ properties.load(propertiesIn);
+ propertiesIn.close();
+
+ String gjdocCompatProperty = properties.getProperty("gjdoc.compat");
+ if (null != gjdocCompatProperty) {
+ javadocCompatible = "true".equals(properties.getProperty("gjdoc.compat"));
+ }
+ else {
+ javadocCompatible = true;
+ }
+ }
+ else {
+ javadocCompatible = true;
+ }
+ }
+ catch (FileNotFoundException e) {
+ javadocCompatible = true;
+ }
+ }
+
+ public String getPackageDocURL(String packageName)
+ {
+ try {
+ URL packageURL = new URL(docSetDirectoryURL,
+ packageName.replace('.', '/'));
+ return packageURL.toString();
+ }
+ catch (MalformedURLException e) {
+ // This should not happen since we know that packageName is a
+ // proper Java identifiers, so the resulting URL can't be
+ // invalid
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getClassDocURL(String packageName, String typeName)
+ {
+ try {
+ URL fileURL = new URL(docSetDirectoryURL,
+ packageName.replace('.', '/') + "/" + typeName + ".html");
+ return fileURL.toString();
+ }
+ catch (MalformedURLException e) {
+ // This should not happen since we know that packageName and
+ // typeName are proper Java identifiers, so the resulting URL
+ // can't be invalid
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void readPackages(InputStream in)
+ throws IOException
+ {
+ BufferedReader reader
+ = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ packageNames.add(line);
+ }
+ }
+
+ public Set getPackageNames()
+ {
+ return packageNames;
+ }
+
+ public boolean isJavadocCompatible()
+ {
+ return javadocCompatible;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.java
new file mode 100644
index 000000000..5ec980634
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.java
@@ -0,0 +1,3887 @@
+/* gnu.classpath.tools.doclets.htmldoclet.HtmlDoclet
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.htmldoclet;
+
+import gnu.classpath.tools.IOToolkit;
+
+import gnu.classpath.tools.doclets.AbstractDoclet;
+import gnu.classpath.tools.doclets.DocletConfigurationException;
+import gnu.classpath.tools.doclets.DocletOption;
+import gnu.classpath.tools.doclets.DocletOptionFile;
+import gnu.classpath.tools.doclets.DocletOptionFlag;
+import gnu.classpath.tools.doclets.DocletOptionString;
+import gnu.classpath.tools.doclets.PackageGroup;
+import gnu.classpath.tools.doclets.TagletPrinter;
+import gnu.classpath.tools.doclets.InlineTagRenderer;
+
+import gnu.classpath.tools.doclets.xmldoclet.HtmlRepairer;
+
+import gnu.classpath.tools.taglets.GnuExtendedTaglet;
+import gnu.classpath.tools.taglets.TagletContext;
+
+import gnu.classpath.tools.java2xhtml.Java2xhtml;
+
+import gnu.classpath.tools.StringToolkit;
+
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.Taglet;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import java.net.MalformedURLException;
+
+import java.nio.charset.Charset;
+
+import java.text.DateFormat;
+import java.text.MessageFormat;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TimeZone;
+import java.util.TreeSet;
+
+public class HtmlDoclet
+ extends AbstractDoclet
+ implements InlineTagRenderer
+{
+ private static String filenameExtension = ".html";
+
+ /**
+ * Contains ExternalDocSet.
+ */
+ private List externalDocSets = new LinkedList();
+
+ /**
+ * Contains String->ExternalDocSet.
+ */
+ private Map packageNameToDocSet = new HashMap();
+
+ /**
+ * Cache for version string from resource /version.properties
+ */
+ private String docletVersion;
+
+ /**
+ * For now, do not output a help page.
+ */
+ private static final boolean outputHelpPage = false;
+
+ /**
+ * Stores the output encoding (either the one specified using
+ * -charset, or the platform default encoding).
+ */
+ private String outputCharset;
+
+ private void printNavBar(HtmlPage output, String currentPage, ClassDoc currentClass)
+ {
+ output.beginDiv(CssClass.NAVBAR_TOP);
+
+ boolean overviewLevel
+ = ("overview".equals(currentPage)
+ || "full-tree".equals(currentPage)
+ || "index".equals(currentPage)
+ || "split-index".equals(currentPage)
+ || "serialized".equals(currentPage)
+ || "deprecated".equals(currentPage)
+ || "about".equals(currentPage)
+ );
+
+ if (!isSinglePackage()) {
+ if ("overview".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Overview");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ output.beginAnchor(output.getPathToRoot() + "/overview-summary" + filenameExtension);
+ output.print("Overview");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+
+ output.print(" ");
+ }
+
+ if (!overviewLevel || isSinglePackage()) {
+ if ("package".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Package");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ String packageHref;
+ if (isSinglePackage()) {
+ packageHref = output.getPathToRoot() + "/" + getPackageURL(getSinglePackage()) + "package-summary" + filenameExtension;
+ }
+ else {
+ packageHref = "package-summary" + filenameExtension;
+ }
+ output.beginAnchor(packageHref);
+ output.print("Package");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ output.print("Package");
+ output.endSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ }
+
+ if (optionUse.getValue() || optionLinkSource.getValue()) {
+ output.print(" ");
+
+ if (null != currentClass) {
+ if ("class".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Class");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ output.beginAnchor(currentClass.name() + filenameExtension);
+ output.print("Class");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ output.print("Class");
+ output.endSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ }
+
+ if (optionUse.getValue()) {
+ output.print(" ");
+
+ if (null != currentClass) {
+ if ("uses".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Use");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ output.beginAnchor(currentClass.name() + "-uses" + filenameExtension);
+ output.print("Use");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ output.print("Use");
+ output.endSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ }
+ }
+
+ if (optionLinkSource.getValue()) {
+ output.print(" ");
+
+
+ if ("source".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Source");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+
+ if (null != currentClass) {
+
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ String targetClassName = currentClass.name();
+ String targetAnchor = "";
+ if (null != currentClass.containingClass()) {
+ targetClassName = getOuterClassDoc(currentClass).name();
+ targetAnchor = "#line." + currentClass.position().line();
+ }
+ output.beginAnchor(targetClassName + "-source" + filenameExtension + targetAnchor);
+ output.print("Source");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ output.print("Source");
+ output.endSpan(CssClass.NAVBAR_ITEM_DISABLED);
+ }
+ }
+ }
+ }
+
+
+ if (!optionNoTree.getValue()) {
+ output.print(" ");
+
+ if ("full-tree".equals(currentPage)
+ || "package-tree".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Tree");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ String treeHref;
+ if (isSinglePackage() && overviewLevel) {
+ treeHref = getPackageURL(getSinglePackage()) + "tree" + filenameExtension;
+ }
+ else {
+ treeHref = "tree" + filenameExtension;
+ }
+
+ output.beginAnchor(treeHref);
+ output.print("Tree");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+ }
+
+ output.print(" ");
+
+ String indexName;
+ if (optionSplitIndex.getValue()) {
+ indexName = "alphaindex-1";
+ }
+ else {
+ indexName = "alphaindex";
+ }
+
+ if ("index".equals(currentPage) || "split-index".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Index");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ output.beginAnchor(output.getPathToRoot() + "/" + indexName + filenameExtension);
+ output.print("Index");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+
+ if (!optionNoDeprecatedList.getValue()) {
+ output.print(" ");
+
+ if ("deprecated".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Deprecated");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ output.beginAnchor(output.getPathToRoot() + "/deprecated" + filenameExtension);
+ output.print("Deprecated");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+ }
+
+ if (outputHelpPage) {
+ if (!optionNoHelp.getValue()) {
+ output.print(" ");
+
+ if ("help".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("Help");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ output.beginAnchor(output.getPathToRoot() + "/help" + filenameExtension);
+ output.print("Help");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+ }
+ }
+
+ output.print(" ");
+
+ if ("about".equals(currentPage)) {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ output.print("About");
+ output.endSpan(CssClass.NAVBAR_ITEM_ACTIVE);
+ }
+ else {
+ output.beginSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ output.beginAnchor(output.getPathToRoot() + "/about" + filenameExtension);
+ output.print("About");
+ output.endAnchor();
+ output.endSpan(CssClass.NAVBAR_ITEM_ENABLED);
+ }
+
+ output.endDiv(CssClass.NAVBAR_TOP);
+ }
+
+ private void printNavBarTopRow(HtmlPage output, String currentPage, ClassDoc currentClass)
+ {
+ output.beginRow();
+ output.beginCell(CssClass.NAVBAR_TOP);
+ printNavBar(output, currentPage, currentClass);
+ output.endCell();
+ if (null != optionHeader.getValue()) {
+ output.beginCell(CssClass.NAVBAR_TOP_HEADER);
+ output.print(replaceDocRoot(output, optionHeader.getValue()));
+ output.endCell();
+ }
+ output.endRow();
+ }
+
+ private void printNavBarTopNaviCell(HtmlPage output)
+ {
+ output.beginCell(CssClass.NAVBAR_TOP_NAVI);
+ output.beginAnchor(output.getPathToRoot() + "/index" + filenameExtension, "Show in a frameset", "_top");
+ output.print("Frames");
+ output.endAnchor();
+ output.print(" | ");
+
+ output.beginAnchor(output.getFile().getName(), "Show without frames", "_top");
+ output.print("No Frames");
+ output.endAnchor();
+ output.print(" ");
+
+ output.endCell();
+ }
+
+ private void printNavBarTop(HtmlPage output, String currentPage)
+ {
+ printNavBarTop(output, currentPage, null, null, null);
+ }
+
+ private void printNavBarTop(HtmlPage output, String currentPage,
+ ClassDoc currentClass, Object prev, Object next)
+ {
+ if (!optionNoNavBar.getValue()) {
+ output.beginTable(CssClass.NAVBAR_TOP);
+ printNavBarTopRow(output, currentPage, currentClass);
+ output.beginRow();
+ if ("class".equals(currentPage)) {
+ output.beginCell(CssClass.NAVBAR_TOP_NAVI);
+ ClassDoc prevClass = (ClassDoc)prev;
+ ClassDoc nextClass = (ClassDoc)next;
+ if (null != prevClass) {
+ output.anchor(getClassDocURL(output, prevClass), "Prev Class");
+ }
+ else {
+ output.print("Prev Class");
+ }
+ output.print(" | ");
+ if (null != nextClass) {
+ output.anchor(getClassDocURL(output, nextClass), "Next Class");
+ }
+ else {
+ output.print("Next Class");
+ }
+ output.endCell();
+ }
+ else if ("split-index".equals(currentPage)) {
+ output.beginCell(CssClass.NAVBAR_TOP_NAVI);
+ Integer prevLetter = (Integer)prev;
+ Integer nextLetter = (Integer)next;
+ if (null != prevLetter) {
+ output.anchor("alphaindex-" + prevLetter + filenameExtension, "Prev Letter");
+ }
+ else {
+ output.print("Prev Letter");
+ }
+ output.print(" | ");
+ if (null != nextLetter) {
+ output.anchor("alphaindex-" + nextLetter + filenameExtension, "Next Letter");
+ }
+ else {
+ output.print("Next Letter");
+ }
+ output.endCell();
+ }
+ else {
+ output.beginCell(CssClass.NAVBAR_TOP_NAVI);
+ output.endCell();
+ }
+
+ printNavBarTopNaviCell(output);
+ output.endRow();
+
+ if ("class".equals(currentPage)) {
+ output.beginRow();
+
+ output.beginCell(CssClass.NAVBAR_TOP_NAVI);
+ output.print("Summary: ");
+
+ if (currentClass.innerClasses().length > 0) {
+ output.anchor("#summary-inner", "Nested");
+ }
+ else {
+ output.print("Nested");
+ }
+
+ output.print(" | ");
+
+ if (currentClass.fields().length > 0) {
+ output.anchor("#summary-fields", "Field");
+ }
+ else {
+ output.print("Field");
+ }
+
+ output.print(" | ");
+
+ if (currentClass.methods().length > 0) {
+ output.anchor("#summary-methods", "Method");
+ }
+ else {
+ output.print("Method");
+ }
+
+ output.print(" | ");
+
+ if (currentClass.constructors().length > 0) {
+ output.anchor("#summary-constructors", "Constr");
+ }
+ else {
+ output.print("Constr");
+ }
+
+ output.endCell();
+
+ output.beginCell(CssClass.NAVBAR_TOP_NAVI);
+ output.print("Detail: ");
+
+ if (currentClass.innerClasses().length > 0) {
+ output.anchor("#detail-inner", "Nested");
+ }
+ else {
+ output.print("Nested");
+ }
+
+ output.print(" | ");
+
+ if (currentClass.fields().length > 0) {
+ output.anchor("#detail-fields", "Field");
+ }
+ else {
+ output.print("Field");
+ }
+
+ output.print(" | ");
+
+ if (currentClass.methods().length > 0) {
+ output.anchor("#detail-methods", "Method");
+ }
+ else {
+ output.print("Method");
+ }
+
+ output.print(" | ");
+
+ if (currentClass.constructors().length > 0) {
+ output.anchor("#detail-constructors", "Constr");
+ }
+ else {
+ output.print("Constr");
+ }
+
+ output.endCell();
+ output.endRow();
+ }
+ output.endTable();
+ }
+ }
+
+ private void printNavBarTopPackage(HtmlPage output, String currentPage,
+ PackageDoc prevPackage, PackageDoc nextPackage)
+ {
+ if (!optionNoNavBar.getValue()) {
+ output.beginTable(CssClass.NAVBAR_TOP);
+ printNavBarTopRow(output, currentPage, null);
+
+ output.beginRow();
+ output.beginCell(CssClass.NAVBAR_TOP_NAVI);
+ if (null != prevPackage) {
+ output.anchor(output.getPathToRoot() + "/" + getPackageURL(prevPackage) + "package-summary" + filenameExtension, "Prev Package");
+ }
+ else {
+ output.print("Prev Package");
+ }
+ output.print(" | ");
+ if (null != nextPackage) {
+ output.anchor(output.getPathToRoot() + "/" + getPackageURL(nextPackage) + "package-summary" + filenameExtension, "Next Package");
+ }
+ else {
+ output.print("Next Package");
+ }
+ output.endCell();
+
+ printNavBarTopNaviCell(output);
+ output.endRow();
+
+ output.endTable();
+ }
+ }
+
+ private void printNavBarBottom(HtmlPage output, String currentPage)
+ {
+ printNavBarBottom(output, currentPage, null);
+ }
+
+ private void printNavBarBottom(HtmlPage output, String currentPage, ClassDoc currentClass)
+ {
+ if ("class".equals(currentPage)) {
+ String boilerplate = null;
+ Tag[] boilerplateTags = getOuterClassDoc(currentClass).tags("@boilerplate");
+ if (boilerplateTags.length > 0) {
+ boilerplate = boilerplateTags[0].text();
+ }
+ if (null != boilerplate) {
+ output.hr();
+ output.beginDiv(CssClass.CLASS_BOILERPLATE);
+ output.print(boilerplate);
+ output.endDiv(CssClass.CLASS_BOILERPLATE);
+ output.hr();
+ }
+ }
+
+ if (!optionNoNavBar.getValue()) {
+ output.beginDiv(CssClass.NAVBAR_BOTTOM_SPACER);
+ output.print(" ");
+ output.endDiv(CssClass.NAVBAR_BOTTOM_SPACER);
+ output.beginTable(CssClass.NAVBAR_BOTTOM);
+ output.beginRow();
+ output.beginCell();
+ printNavBar(output, currentPage, currentClass);
+ output.endCell();
+ if (null != optionFooter.getValue()) {
+ output.beginCell();
+ output.print(replaceDocRoot(output, optionFooter.getValue()));
+ output.endCell();
+ }
+ output.endRow();
+ output.endTable();
+ }
+
+ if (null != optionBottom.getValue()) {
+ output.hr();
+ output.print(replaceDocRoot(output, optionBottom.getValue()));
+ }
+ }
+
+ private void printPackagePageClasses(HtmlPage output, ClassDoc[] classDocs, String header)
+ {
+ if (classDocs.length > 0) {
+ output.beginDiv(CssClass.TABLE_CONTAINER);
+ output.beginTable(CssClass.PACKAGE_SUMMARY, new String[] { "border", "width" }, new String[] { "1", "100%" });
+ output.rowDiv(CssClass.TABLE_HEADER, header);
+
+ for (int i=0; i<classDocs.length; ++i) {
+ ClassDoc classDoc = classDocs[i];
+ if (classDoc.isIncluded()) {
+ output.beginRow();
+
+ output.beginCell(CssClass.PACKAGE_SUMMARY_LEFT);
+ printType(output, classDoc);
+ output.endCell();
+
+ output.beginCell(CssClass.PACKAGE_SUMMARY_RIGHT);
+ printTags(output, classDoc, classDoc.firstSentenceTags(), true);
+ output.endCell();
+ output.endRow();
+ }
+ }
+ output.endTable();
+ output.endDiv(CssClass.TABLE_CONTAINER);
+ output.print("\n");
+ }
+ }
+
+ private void printPackagesListFile()
+ throws IOException
+ {
+ PrintWriter out
+ = new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(getTargetDirectory(),
+ "package-list")),
+ "UTF-8"));
+
+ PackageDoc[] packages = getRootDoc().specifiedPackages();
+ for (int i=0; i<packages.length; ++i) {
+ String packageName = packages[i].name();
+ if (packageName.length() > 0) {
+ out.println(packageName);
+ }
+ }
+
+ out.close();
+ }
+
+ private void printPackagePage(File packageDir, String pathToRoot,
+ PackageDoc packageDoc,
+ PackageDoc prevPackageDoc,
+ PackageDoc nextPackageDoc)
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(packageDir, "package-summary" + filenameExtension),
+ pathToRoot);
+
+ Set keywords = new LinkedHashSet();
+ keywords.add(packageDoc.name() + " packages");
+
+ output.beginPage(getPageTitle(packageDoc.name()), getOutputCharset(),
+ keywords, getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_PACKAGE);
+ printNavBarTopPackage(output, "package", prevPackageDoc, nextPackageDoc);
+
+ output.beginDiv(CssClass.PACKAGE_TITLE);
+ output.print("Package ");
+ if (packageDoc.name().length() > 0) {
+ output.print(packageDoc.name());
+ }
+ else {
+ output.print("&lt;Unnamed&gt;");
+ }
+ output.endDiv(CssClass.PACKAGE_TITLE);
+
+ output.beginDiv(CssClass.PACKAGE_DESCRIPTION_TOP);
+ printTags(output, packageDoc, packageDoc.firstSentenceTags(), true);
+ output.endDiv(CssClass.PACKAGE_DESCRIPTION_TOP);
+
+ printPackagePageClasses(output, packageDoc.interfaces(),
+ "Interface Summary");
+ printPackagePageClasses(output, packageDoc.ordinaryClasses(),
+ "Class Summary");
+ printPackagePageClasses(output, packageDoc.exceptions(),
+ "Exception Summary");
+ printPackagePageClasses(output, packageDoc.errors(),
+ "Error Summary");
+
+ output.anchorName("description");
+ output.beginDiv(CssClass.PACKAGE_DESCRIPTION_FULL);
+ printTags(output, packageDoc, packageDoc.inlineTags(), false);
+ output.endDiv(CssClass.PACKAGE_DESCRIPTION_FULL);
+
+ printNavBarBottom(output, "package");
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ static class TreeNode
+ implements Comparable
+ {
+ ClassDoc classDoc;
+ SortedSet children = new TreeSet();
+
+ TreeNode(ClassDoc classDoc) {
+ TreeNode.this.classDoc = classDoc;
+ }
+
+ public boolean equals(Object other)
+ {
+ return classDoc.equals(((TreeNode)other).classDoc);
+ }
+
+ public int compareTo(Object other)
+ {
+ return classDoc.compareTo(((TreeNode)other).classDoc);
+ }
+
+ public int hashCode()
+ {
+ return classDoc.hashCode();
+ }
+ }
+
+ private TreeNode addClassTreeNode(Map treeMap, ClassDoc classDoc)
+ {
+ TreeNode node = (TreeNode)treeMap.get(classDoc.qualifiedName());
+ if (null == node) {
+ node = new TreeNode(classDoc);
+ treeMap.put(classDoc.qualifiedName(), node);
+
+ ClassDoc superClassDoc = (ClassDoc)classDoc.superclass();
+ if (null != superClassDoc) {
+ TreeNode parentNode = addClassTreeNode(treeMap, superClassDoc);
+ parentNode.children.add(node);
+ }
+ }
+ return node;
+ }
+
+ private TreeNode addInterfaceTreeNode(Map treeMap, ClassDoc classDoc)
+ {
+ TreeNode node = (TreeNode)treeMap.get(classDoc.qualifiedName());
+ if (null == node) {
+ node = new TreeNode(classDoc);
+ treeMap.put(classDoc.qualifiedName(), node);
+
+ ClassDoc[] superInterfaces = classDoc.interfaces();
+ if (null != superInterfaces && superInterfaces.length > 0) {
+ for (int i=0; i<superInterfaces.length; ++i) {
+ TreeNode parentNode = addInterfaceTreeNode(treeMap, superInterfaces[i]);
+ parentNode.children.add(node);
+ }
+ }
+ else {
+ TreeNode rootNode = (TreeNode)treeMap.get("<root>");
+ if (null == rootNode) {
+ rootNode = new TreeNode(null);
+ treeMap.put("<root>", rootNode);
+ }
+ rootNode.children.add(node);
+ }
+ }
+ return node;
+ }
+
+ private void printPackageTreeRec(HtmlPage output, TreeNode node, TreeNode parentNode)
+ {
+ output.beginElement("li", "class", "node");
+ output.beginElement("div");
+ if (node.classDoc.isIncluded()) {
+ String packageName = node.classDoc.containingPackage().name();
+ if (packageName.length() > 0) {
+ output.print(packageName);
+ output.print(".");
+ }
+ output.beginSpan(CssClass.TREE_LINK);
+ printType(output, node.classDoc);
+ output.endSpan(CssClass.TREE_LINK);
+ }
+ else {
+ output.print(possiblyQualifiedName(node.classDoc));
+ }
+ ClassDoc[] interfaces = node.classDoc.interfaces();
+ ClassDoc parentClassDoc = null;
+ if (null != parentNode) {
+ parentClassDoc = parentNode.classDoc;
+ }
+ if (interfaces.length > 0
+ && !(interfaces.length == 1 && interfaces[0].equals(parentClassDoc))) {
+ if (node.classDoc.isInterface()) {
+ output.print(" (also implements ");
+ }
+ else {
+ output.print(" (implements ");
+ }
+
+ boolean firstItem = true;
+ for (int i=0; i<interfaces.length; ++i) {
+ ClassDoc implemented = interfaces[i];
+ if (!implemented.equals(parentClassDoc)) {
+ if (!firstItem) {
+ output.print(", ");
+ }
+ firstItem = false;
+ if (implemented.isIncluded()) {
+ output.print(implemented.containingPackage().name());
+ output.print(".");
+ printType(output, implemented);
+ }
+ else {
+ output.print(possiblyQualifiedName(implemented));
+ }
+ }
+ }
+ output.print(")");
+ }
+
+ output.endElement("div");
+ output.endElement("li");
+ if (!node.children.isEmpty()) {
+ output.beginElement("li", "class", "level");
+ output.beginElement("ul");
+ Iterator it = node.children.iterator();
+ while (it.hasNext()) {
+ TreeNode child = (TreeNode)it.next();
+ printPackageTreeRec(output, child, node);
+ }
+ output.endElement("ul");
+ output.endElement("li");
+ }
+ }
+
+ private void printClassTree(HtmlPage output, ClassDoc[] classDocs)
+ {
+ Map classTreeMap = new HashMap();
+
+ for (int i=0; i<classDocs.length; ++i) {
+ ClassDoc classDoc = classDocs[i];
+ if (!classDoc.isInterface()) {
+ addClassTreeNode(classTreeMap, classDoc);
+ }
+ }
+
+ TreeNode root = (TreeNode)classTreeMap.get("java.lang.Object");
+ if (null != root) {
+ output.div(CssClass.PACKAGE_TREE_SECTION_TITLE, "Class Hierarchy");
+ output.beginDiv(CssClass.PACKAGE_TREE);
+ printPackageTreeRec(output, root, null);
+ output.endDiv(CssClass.PACKAGE_TREE);
+ }
+ }
+
+ private void printInterfaceTree(HtmlPage output, ClassDoc[] classDocs)
+ {
+ Map interfaceTreeMap = new HashMap();
+
+ for (int i=0; i<classDocs.length; ++i) {
+ ClassDoc classDoc = classDocs[i];
+ if (classDoc.isInterface()) {
+ addInterfaceTreeNode(interfaceTreeMap, classDoc);
+ }
+ }
+
+ TreeNode interfaceRoot = (TreeNode)interfaceTreeMap.get("<root>");
+ if (null != interfaceRoot) {
+ Iterator it = interfaceRoot.children.iterator();
+ if (it.hasNext()) {
+ output.div(CssClass.PACKAGE_TREE_SECTION_TITLE, "Interface Hierarchy");
+ output.beginDiv(CssClass.PACKAGE_TREE);
+ while (it.hasNext()) {
+ TreeNode node = (TreeNode)it.next();
+ printPackageTreeRec(output, node, null);
+ }
+ output.endDiv(CssClass.PACKAGE_TREE);
+ }
+ }
+
+ }
+
+ private void printPackageTreePage(File packageDir, String pathToRoot, PackageDoc packageDoc)
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(packageDir,
+ "tree" + filenameExtension),
+ pathToRoot);
+ output.beginPage(getPageTitle(packageDoc.name() + " Hierarchy"),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_PACKAGE_TREE);
+ printNavBarTop(output, "package-tree");
+
+ output.div(CssClass.PACKAGE_TREE_TITLE, "Hierarchy for Package " + packageDoc.name());
+
+ ClassDoc[] classDocs = packageDoc.allClasses();
+ printClassTree(output, classDocs);
+ printInterfaceTree(output, classDocs);
+
+ printNavBarBottom(output, "package-tree");
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printFullTreePage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "tree" + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("Hierarchy"),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_FULL_TREE);
+ printNavBarTop(output, "full-tree");
+
+ output.div(CssClass.PACKAGE_TREE_TITLE, "Hierarchy for All Packages");
+
+ output.beginDiv(CssClass.FULL_TREE_PACKAGELIST);
+ output.div(CssClass.FULL_TREE_PACKAGELIST_HEADER, "Package Hierarchies:");
+ output.beginDiv(CssClass.FULL_TREE_PACKAGELIST_ITEM);
+ Set allPackages = getAllPackages();
+ Iterator it = allPackages.iterator();
+ while (it.hasNext()) {
+ PackageDoc packageDoc = (PackageDoc)it.next();
+ output.beginAnchor(getPackageURL(packageDoc) + "tree" + filenameExtension);
+ output.print(packageDoc.name());
+ output.endAnchor();
+ if (it.hasNext()) {
+ output.print(", ");
+ }
+ }
+ output.endDiv(CssClass.FULL_TREE_PACKAGELIST_ITEM);
+ output.endDiv(CssClass.FULL_TREE_PACKAGELIST);
+
+ ClassDoc[] classDocs = getRootDoc().classes();
+ printClassTree(output, classDocs);
+ printInterfaceTree(output, classDocs);
+
+ printNavBarBottom(output, "full-tree");
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printIndexEntry(HtmlPage output, Doc entry)
+ {
+ output.beginDiv(CssClass.INDEX_ENTRY);
+ output.beginDiv(CssClass.INDEX_ENTRY_KEY);
+ String anchor = null;
+ String description = null;
+ if (entry instanceof PackageDoc) {
+ output.beginAnchor(getPackageURL((PackageDoc)entry) + "package-summary" + filenameExtension);
+ output.print(entry.name());
+ output.endAnchor();
+ output.print(" - package");
+ }
+ else if (entry instanceof ClassDoc) {
+ ClassDoc classDoc = (ClassDoc)entry;
+ output.beginAnchor(getClassURL(classDoc));
+ output.print(entry.name() + getTypeParameters(classDoc));
+ output.endAnchor();
+ output.print(" - ");
+ if (entry.isInterface()) {
+ output.print("interface ");
+ }
+ else if (entry.isException()) {
+ output.print("exception ");
+ }
+ else if (entry.isError()) {
+ output.print("error ");
+ }
+ else {
+ output.print("class ");
+ }
+ String packageName = classDoc.containingPackage().name();
+ if (packageName.length() > 0) {
+ output.print(packageName);
+ output.print(".");
+ }
+ printType(output, classDoc);
+ }
+ else {
+ ProgramElementDoc memberDoc = (ProgramElementDoc)entry;
+ output.beginAnchor(getMemberDocURL(output, memberDoc));
+ output.print(entry.name());
+ if (memberDoc instanceof ExecutableMemberDoc) {
+ output.print(((ExecutableMemberDoc)memberDoc).signature());
+ }
+ output.endAnchor();
+ output.print(" - ");
+
+ if (memberDoc.isStatic()) {
+ output.print("static ");
+ }
+
+ if (entry.isConstructor()) {
+ output.print("constructor for class ");
+ }
+ else if (entry.isMethod()) {
+ output.print("method in class ");
+ }
+ else if (entry.isField()) {
+ output.print("field in class ");
+ }
+ ClassDoc containingClass = memberDoc.containingClass();
+ String packageName = containingClass.containingPackage().name();
+ if (packageName.length() > 0) {
+ output.print(packageName);
+ output.print(".");
+ }
+ printType(output, containingClass);
+ }
+ output.endDiv(CssClass.INDEX_ENTRY_KEY);
+ output.beginDiv(CssClass.INDEX_ENTRY_DESCRIPTION);
+ printTags(output, entry, entry.firstSentenceTags(), true);
+ output.endDiv(CssClass.INDEX_ENTRY_DESCRIPTION);
+ output.endDiv(CssClass.INDEX_ENTRY);
+ }
+
+ private void printFrameSetPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "index" + filenameExtension),
+ ".",
+ HtmlPage.DOCTYPE_FRAMESET);
+
+ String title = getWindowTitle();
+ output.beginPage(title, getOutputCharset(), getStylesheets());
+ output.beginElement("frameset", "cols", "20%,80%");
+
+ String contentURL;
+ if (isSinglePackage()) {
+ output.atomicElement("frame",
+ new String[] { "src", "name" },
+ new String[] { getPackageURL(getSinglePackage()) + "classes" + filenameExtension, "classes" });
+ contentURL = getPackageURL(getSinglePackage()) + "package-summary.html";
+ }
+ else {
+ output.beginElement("frameset", "rows", "25%,75%");
+ output.atomicElement("frame",
+ new String[] { "src", "name" },
+ new String[] { "all-packages" + filenameExtension, "packages" });
+ output.atomicElement("frame",
+ new String[] { "src", "name" },
+ new String[] { "all-classes" + filenameExtension, "classes" });
+ output.endElement("frameset");
+ contentURL = "overview-summary" + filenameExtension;
+ }
+ output.atomicElement("frame",
+ new String[] { "src", "name" },
+ new String[] { contentURL, "content" });
+ output.endElement("frameset");
+ output.endPage();
+ output.close();
+ }
+
+ private void printPackagesMenuPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "all-packages" + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("Package Menu"), getOutputCharset(), getStylesheets());
+ output.beginBody(CssClass.BODY_MENU_PACKAGES, false);
+
+ output.beginSpan(CssClass.PACKAGE_MENU_ENTRY);
+ output.beginAnchor("all-classes" + filenameExtension,
+ null,
+ "classes");
+ output.print("All Classes");
+ output.endAnchor();
+ output.endSpan(CssClass.PACKAGE_MENU_ENTRY);
+
+ output.div(CssClass.PACKAGE_MENU_TITLE, "Packages");
+
+ output.beginDiv(CssClass.PACKAGE_MENU_LIST);
+
+ Set packageDocs = getAllPackages();
+ Iterator it = packageDocs.iterator();
+ while (it.hasNext()) {
+ PackageDoc packageDoc = (PackageDoc)it.next();
+ output.beginSpan(CssClass.PACKAGE_MENU_ENTRY);
+ output.beginAnchor(getPackageURL(packageDoc) + "classes" + filenameExtension,
+ null,
+ "classes");
+ if (packageDoc.name().length() > 0) {
+ output.print(packageDoc.name());
+ }
+ else {
+ output.print("&lt;unnamed package&gt;");
+ }
+ output.endAnchor();
+ output.endSpan(CssClass.PACKAGE_MENU_ENTRY);
+ output.br();
+ }
+
+ output.endDiv(CssClass.PACKAGE_MENU_LIST);
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printClassMenuEntry(HtmlPage output, ClassDoc classDoc)
+ {
+ CssClass entryClass;
+ if (classDoc.isInterface()) {
+ entryClass = CssClass.CLASS_MENU_ENTRY_INTERFACE;
+ }
+ else {
+ entryClass = CssClass.CLASS_MENU_ENTRY_CLASS;
+ }
+ output.beginSpan(entryClass);
+ output.beginAnchor(getClassDocURL(output, classDoc),
+ classDoc.qualifiedTypeName(),
+ "content");
+ output.print(classDoc.name());
+ output.endAnchor();
+ output.endSpan(entryClass);
+ output.br();
+ }
+
+ private void printClassMenuSection(HtmlPage output, Collection classDocs, String header)
+ {
+ if (!classDocs.isEmpty()) {
+ output.div(CssClass.CLASS_MENU_SUBTITLE, header);
+ Iterator it = classDocs.iterator();
+ while (it.hasNext()) {
+ ClassDoc classDoc = (ClassDoc)it.next();
+ printClassMenuEntry(output, classDoc);
+ }
+ }
+ }
+
+ private void printClassMenuList(HtmlPage output, ClassDoc[] classDocs, boolean categorized)
+ {
+ output.beginDiv(CssClass.CLASS_MENU_LIST);
+
+ if (categorized) {
+ Set classes = new TreeSet();
+ Set interfaces = new TreeSet();
+ Set exceptions = new TreeSet();
+ Set errors = new TreeSet();
+
+ for (int i=0; i<classDocs.length; ++i) {
+ ClassDoc classDoc = classDocs[i];
+ if (classDoc.isInterface()) {
+ interfaces.add(classDoc);
+ }
+ else if (classDoc.isException()) {
+ exceptions.add(classDoc);
+ }
+ else if (classDoc.isError()) {
+ errors.add(classDoc);
+ }
+ else {
+ classes.add(classDoc);
+ }
+ }
+ printClassMenuSection(output, interfaces, "Interfaces");
+ printClassMenuSection(output, classes, "Classes");
+ printClassMenuSection(output, exceptions, "Exceptions");
+ printClassMenuSection(output, errors, "Errors");
+ }
+ else {
+ for (int i=0; i<classDocs.length; ++i) {
+ ClassDoc classDoc = classDocs[i];
+ if (classDoc.isIncluded()) {
+ printClassMenuEntry(output, classDoc);
+ }
+ }
+ }
+
+ output.endDiv(CssClass.CLASS_MENU_LIST);
+ }
+
+ private void printAllClassesMenuPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "all-classes" + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("Class Menu"), getOutputCharset(), getStylesheets());
+ output.beginBody(CssClass.BODY_MENU_CLASSES, false);
+
+ output.div(CssClass.CLASS_MENU_TITLE, "All Classes");
+
+ printClassMenuList(output, getRootDoc().classes(), false);
+
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printPackageClassesMenuPage(File packageDir, String pathToRoot, PackageDoc packageDoc)
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(packageDir,
+ "classes" + filenameExtension),
+ pathToRoot);
+
+ output.beginPage(getPageTitle(packageDoc.name() + " Class Menu"),
+ getOutputCharset(), getStylesheets());
+ output.beginBody(CssClass.BODY_MENU_CLASSES, false);
+
+ output.beginDiv(CssClass.CLASS_MENU_TITLE);
+ output.beginAnchor("package-summary" + filenameExtension, "", "content");
+ if (packageDoc.name().length() > 0) {
+ output.print(packageDoc.name());
+ }
+ else {
+ output.print("&lt;Unnamed&gt;");
+ }
+ output.endAnchor();
+ output.endDiv(CssClass.CLASS_MENU_TITLE);
+
+ printClassMenuList(output, packageDoc.allClasses(), true);
+
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printSplitIndex()
+ throws IOException
+ {
+ Map categorizedIndex = getCategorizedIndex();
+ Iterator it = categorizedIndex.keySet().iterator();
+ int n = 1;
+ int count = categorizedIndex.size();
+ while (it.hasNext()) {
+ Character c = (Character)it.next();
+ List classList = (List)categorizedIndex.get(c);
+ printIndexPage(n++, count, c, classList);
+ }
+ }
+
+ private void printIndexPage()
+ throws IOException
+ {
+ printIndexPage(0, 0, null, null);
+ }
+
+ private void printIndexPage(int index, int maxIndex, Character letter, List classList)
+ throws IOException
+ {
+ String pageName = "alphaindex";
+ if (null != letter) {
+ pageName += "-" + index;
+ }
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ pageName + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("Alphabetical Index"),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_INDEX);
+ if (null == letter) {
+ printNavBarTop(output, "index");
+ }
+ else {
+ printNavBarTop(output, "split-index", null,
+ (index > 1) ? new Integer(index - 1) : null,
+ (index < maxIndex) ? new Integer(index + 1) : null);
+ }
+
+ {
+ String title;
+ if (null == letter) {
+ title = "Alphabetical Index";
+ }
+ else {
+ title = "Alphabetical Index: " + letter;
+ }
+ output.div(CssClass.INDEX_TITLE, title);
+
+ if (null != letter || getCategorizedIndex().keySet().size() > 1) {
+ output.beginDiv(CssClass.INDEX_LETTERS);
+
+ Iterator it = getCategorizedIndex().keySet().iterator();
+ int n = 1;
+ while (it.hasNext()) {
+ Character c = (Character)it.next();
+ output.beginSpan(CssClass.INDEX_LETTER);
+ if (letter != null) {
+ output.beginAnchor("alphaindex-" + n + filenameExtension);
+ }
+ else {
+ output.beginAnchor("#" + c);
+ }
+ output.print(c.toString());
+ output.endAnchor();
+ output.endSpan(CssClass.INDEX_LETTER);
+ output.beginSpan(CssClass.INDEX_LETTER_SPACER);
+ output.print(" ");
+ output.endSpan(CssClass.INDEX_LETTER_SPACER);
+ ++n;
+ }
+ }
+
+ output.endDiv(CssClass.INDEX_LETTERS);
+ }
+
+ if (null != letter) {
+ printIndexCategory(output, letter, classList);
+ }
+ else {
+ Map categorizedIndex = getCategorizedIndex();
+ Iterator categoryIt = categorizedIndex.keySet().iterator();
+
+ while (categoryIt.hasNext()) {
+ letter = (Character)categoryIt.next();
+ classList = (List)categorizedIndex.get(letter);
+ output.anchorName(letter.toString());
+ printIndexCategory(output, letter, classList);
+ }
+ }
+
+ printNavBarBottom(output, "index");
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printIndexCategory(HtmlPage output, Character letter, List classList)
+ {
+ Iterator it = classList.iterator();
+
+ output.div(CssClass.INDEX_CATEGORY_HEADER, letter.toString());
+ output.beginDiv(CssClass.INDEX_CATEGORY);
+ while (it.hasNext()) {
+ Doc entry = (Doc)it.next();
+ printIndexEntry(output, entry);
+ }
+ output.endDiv(CssClass.INDEX_CATEGORY);
+ }
+
+ private void printDeprecationSummary(HtmlPage output, List docs, String header)
+ {
+ if (!docs.isEmpty()) {
+ output.beginDiv(CssClass.TABLE_CONTAINER);
+ output.beginTable(CssClass.DEPRECATION_SUMMARY, new String[] { "border", "width" }, new String[] { "1", "100%" });
+ output.rowDiv(CssClass.TABLE_HEADER, header);
+
+ Iterator it = docs.iterator();
+ while (it.hasNext()) {
+ Doc doc = (Doc)it.next();
+ output.beginRow();
+
+ output.beginCell(CssClass.DEPRECATION_SUMMARY_LEFT);
+ if (doc instanceof Type) {
+ printType(output, (Type)doc);
+ }
+ else {
+ ProgramElementDoc memberDoc = (ProgramElementDoc)doc;
+ output.beginAnchor(getMemberDocURL(output, memberDoc));
+ output.print(memberDoc.containingClass().qualifiedName());
+ output.print(".");
+ output.print(memberDoc.name());
+ if (memberDoc instanceof ExecutableMemberDoc) {
+ output.print(((ExecutableMemberDoc)memberDoc).flatSignature());
+ }
+ output.endAnchor();
+ }
+ output.beginDiv(CssClass.DEPRECATION_SUMMARY_DESCRIPTION);
+ printTags(output, doc, doc.tags("deprecated")[0].firstSentenceTags(), true);
+ output.endDiv(CssClass.DEPRECATION_SUMMARY_DESCRIPTION);
+
+ output.endCell();
+
+ output.endRow();
+ }
+ output.endTable();
+ output.endDiv(CssClass.TABLE_CONTAINER);
+ output.print("\n");
+ }
+ }
+
+
+ private void printSerializationPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "serialized-form" + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("Serialized Form"),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_DEPRECATED);
+ printNavBarTop(output, "serialized");
+
+ output.div(CssClass.SERIALIZED_TITLE, "Serialized Form");
+
+ Iterator it = getAllPackages().iterator();
+
+ while (it.hasNext()) {
+
+ PackageDoc packageDoc = (PackageDoc)it.next();
+
+ List serializableClasses = new LinkedList();
+ ClassDoc[] classes = packageDoc.allClasses();
+ for (int i=0; i<classes.length; ++i) {
+ ClassDoc classDoc = classes[i];
+ if (classDoc.isSerializable() || classDoc.isExternalizable()) {
+ serializableClasses.add(classDoc);
+ }
+ }
+
+ if (!serializableClasses.isEmpty()) {
+ output.div(CssClass.SERIALIZED_PACKAGE_HEADER, "Package " + packageDoc.name());
+
+ Iterator cit = serializableClasses.iterator();
+ while (cit.hasNext()) {
+ ClassDoc classDoc = (ClassDoc)cit.next();
+
+ output.anchorName(classDoc.qualifiedTypeName());
+
+ output.beginDiv(CssClass.SERIALIZED_CLASS_HEADER);
+ output.print("Class ");
+ printType(output, classDoc, true);
+ output.print(" extends ");
+ printType(output, classDoc.superclass());
+ output.print(" implements Serializable");
+ output.endDiv(CssClass.SERIALIZED_CLASS_HEADER);
+
+ FieldDoc serialVersionUidField = findField(classDoc, "serialVersionUID");
+ if (null != serialVersionUidField
+ && serialVersionUidField.isFinal()
+ && serialVersionUidField.isStatic()
+ && serialVersionUidField.type().typeName().equals("long")) {
+
+ String fieldValue = serialVersionUidField.constantValueExpression();
+ if (null != fieldValue) {
+ output.beginDiv(CssClass.SERIALIZED_SVUID_OUTER);
+ output.span(CssClass.SERIALIZED_SVUID_HEADER, "serialVersionUID: ");
+ output.span(CssClass.SERIALIZED_SVUID_VALUE, fieldValue);
+ output.endDiv(CssClass.SERIALIZED_SVUID_OUTER);
+ }
+ }
+ printMemberDetails(output,
+ classDoc.serializationMethods(),
+ "Serialization Methods",
+ true, null);
+ printMemberDetails(output,
+ classDoc.serializableFields(),
+ "Serialized Fields",
+ true, null);
+ }
+ }
+ }
+
+ printNavBarBottom(output, "serialized");
+
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+
+ private void printDeprecationPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "deprecated" + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("Deprecated API"),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_DEPRECATED);
+ printNavBarTop(output, "deprecated");
+
+ output.div(CssClass.DEPRECATION_TITLE, "Deprecated API");
+
+ List deprecatedInterfaces = new LinkedList();
+ List deprecatedExceptions = new LinkedList();
+ List deprecatedErrors = new LinkedList();
+ List deprecatedClasses = new LinkedList();
+ List deprecatedFields = new LinkedList();
+ List deprecatedMethods = new LinkedList();
+ List deprecatedConstructors = new LinkedList();
+
+ ClassDoc[] classDocs = getRootDoc().classes();
+ for (int i=0; i<classDocs.length; ++i) {
+ ClassDoc classDoc = classDocs[i];
+ {
+ Tag[] deprecatedTags = classDoc.tags("deprecated");
+ if (null != deprecatedTags && deprecatedTags.length > 0) {
+ if (classDoc.isInterface()) {
+ deprecatedInterfaces.add(classDoc);
+ }
+ else if (classDoc.isException()) {
+ deprecatedExceptions.add(classDoc);
+ }
+ else if (classDoc.isError()) {
+ deprecatedErrors.add(classDoc);
+ }
+ else {
+ deprecatedClasses.add(classDoc);
+ }
+ }
+ }
+ ConstructorDoc[] constructors = classDoc.constructors();
+ for (int j=0; j<constructors.length; ++j) {
+ Tag[] deprecatedTags = constructors[j].tags("deprecated");
+ if (null != deprecatedTags && deprecatedTags.length > 0) {
+ deprecatedConstructors.add(constructors[j]);
+ }
+ }
+ MethodDoc[] methods = classDoc.methods();
+ for (int j=0; j<methods.length; ++j) {
+ Tag[] deprecatedTags = methods[j].tags("deprecated");
+ if (null != deprecatedTags && deprecatedTags.length > 0) {
+ deprecatedMethods.add(methods[j]);
+ }
+ }
+ FieldDoc[] fields = classDoc.fields();
+ for (int j=0; j<fields.length; ++j) {
+ Tag[] deprecatedTags = fields[j].tags("deprecated");
+ if (null != deprecatedTags && deprecatedTags.length > 0) {
+ deprecatedFields.add(fields[j]);
+ }
+ }
+ }
+
+ if (!deprecatedInterfaces.isEmpty()
+ || !deprecatedClasses.isEmpty()
+ || !deprecatedExceptions.isEmpty()
+ || !deprecatedErrors.isEmpty()
+ || !deprecatedFields.isEmpty()
+ || !deprecatedMethods.isEmpty()
+ || !deprecatedConstructors.isEmpty()) {
+
+ output.beginDiv(CssClass.DEPRECATION_TOC);
+ output.div(CssClass.DEPRECATION_TOC_HEADER, "Contents");
+ output.beginDiv(CssClass.DEPRECATION_TOC_LIST);
+ if (!deprecatedInterfaces.isEmpty()) {
+ output.beginDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ output.anchor("#interfaces", "Deprecated Interfaces");
+ output.endDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ }
+ if (!deprecatedClasses.isEmpty()) {
+ output.beginDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ output.anchor("#classes", "Deprecated Classes");
+ output.endDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ }
+ if (!deprecatedExceptions.isEmpty()) {
+ output.beginDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ output.anchor("#exceptions", "Deprecated Exceptions");
+ output.endDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ }
+ if (!deprecatedErrors.isEmpty()) {
+ output.beginDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ output.anchor("#errors", "Deprecated Errors");
+ output.endDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ }
+ if (!deprecatedFields.isEmpty()) {
+ output.beginDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ output.anchor("#fields", "Deprecated Fields");
+ output.endDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ }
+ if (!deprecatedMethods.isEmpty()) {
+ output.beginDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ output.anchor("#methods", "Deprecated Methods");
+ output.endDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ }
+ if (!deprecatedConstructors.isEmpty()) {
+ output.beginDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ output.anchor("#constructors", "Deprecated Constructors");
+ output.endDiv(CssClass.DEPRECATION_TOC_ENTRY);
+ }
+ output.endDiv(CssClass.DEPRECATION_TOC_LIST);
+ output.endDiv(CssClass.DEPRECATION_TOC);
+ output.beginDiv(CssClass.DEPRECATION_LIST);
+
+ output.anchorName("interfaces");
+ printDeprecationSummary(output, deprecatedInterfaces, "Deprecated Interfaces");
+
+ output.anchorName("classes");
+ printDeprecationSummary(output, deprecatedClasses, "Deprecated Classes");
+
+ output.anchorName("exceptions");
+ printDeprecationSummary(output, deprecatedExceptions, "Deprecated Exceptions");
+
+ output.anchorName("errors");
+ printDeprecationSummary(output, deprecatedErrors, "Deprecated Errors");
+
+ output.anchorName("fields");
+ printDeprecationSummary(output, deprecatedFields, "Deprecated Fields");
+
+ output.anchorName("methods");
+ printDeprecationSummary(output, deprecatedMethods, "Deprecated Methods");
+
+ output.anchorName("constructors");
+ printDeprecationSummary(output, deprecatedConstructors, "Deprecated Constructors");
+
+ output.endDiv(CssClass.DEPRECATION_LIST);
+ }
+ else {
+ output.beginDiv(CssClass.DEPRECATION_EMPTY);
+ output.print("No deprecated classes or class members in this API.");
+ output.endDiv(CssClass.DEPRECATION_EMPTY);
+
+ }
+
+ printNavBarBottom(output, "deprecated");
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printAboutPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "about" + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("About"),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_ABOUT);
+
+ printNavBarTop(output, "about");
+
+ output.div(CssClass.ABOUT_TITLE, "About");
+
+ output.beginDiv(CssClass.ABOUT_GENERATOR);
+ output.print("Generated by ");
+ output.print("Gjdoc");
+ output.print(" HtmlDoclet ");
+ output.print(getDocletVersion());
+ output.print(", part of ");
+ output.beginAnchor("http://www.gnu.org/software/classpath/cp-tools/", "", "_top");
+ output.print("GNU Classpath Tools");
+ output.endAnchor();
+ output.print(", on ");
+ DateFormat format = DateFormat.getDateTimeInstance(DateFormat.LONG,
+ DateFormat.LONG,
+ Locale.US);
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"),
+ Locale.US);
+ format.setCalendar(cal);
+ output.print(format.format(new Date()));
+ output.print(".");
+ output.endDiv(CssClass.ABOUT_GENERATOR);
+
+ printNavBarBottom(output, "about");
+
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printSourcePage(File packageDir, ClassDoc classDoc, String sourceXhtml)
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(packageDir,
+ classDoc.name() + "-source" + filenameExtension),
+ getPathToRoot(packageDir, getTargetDirectory()));
+ output.beginPage(getPageTitle("Source for " + classDoc.qualifiedTypeName()),
+ getOutputCharset(),
+ getStylesheets());
+
+ output.beginBody(CssClass.BODY_CONTENT_SOURCE);
+
+ printNavBarTop(output, "source", classDoc, null, null);
+
+ output.div(CssClass.SOURCE_TITLE, "Source for " + classDoc.qualifiedTypeName());
+ output.beginDiv(CssClass.SOURCE);
+ output.print(sourceXhtml);
+ output.endDiv(CssClass.SOURCE);
+
+ printNavBarBottom(output, "source", classDoc);
+
+ output.endBody();
+ output.endPage();
+
+ output.close();
+ }
+
+ private void printHelpPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "help" + filenameExtension),
+ ".");
+ output.beginPage(getPageTitle("Help"),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_HELP);
+
+ printNavBarTop(output, "help");
+
+ InputStream helpIn;
+ if (null != optionHelpFile.getValue()){
+ helpIn = new FileInputStream(optionHelpFile.getValue());
+ }
+ else {
+ helpIn = getClass().getResourceAsStream("/htmldoclet/help.xhtml");
+ }
+ output.insert(new InputStreamReader(helpIn, "utf-8"));
+ helpIn.close();
+
+ printNavBarBottom(output, "help");
+
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printOverviewPage()
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(getTargetDirectory(),
+ "overview-summary" + filenameExtension),
+ ".");
+ output.beginPage(getWindowTitle(),
+ getOutputCharset(),
+ getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_OVERVIEW);
+
+ printNavBarTop(output, "overview");
+
+ String overviewHeader;
+ if (null != optionDocTitle.getValue()) {
+ overviewHeader = optionDocTitle.getValue();
+ }
+ else if (null != optionTitle.getValue()) {
+ overviewHeader = optionTitle.getValue();
+ }
+ else {
+ overviewHeader = null;
+ }
+
+ if (null != overviewHeader) {
+ output.div(CssClass.OVERVIEW_TITLE, overviewHeader);
+ }
+
+ output.beginDiv(CssClass.OVERVIEW_DESCRIPTION_TOP);
+ printTags(output, getRootDoc(), getRootDoc().firstSentenceTags(), true);
+ output.endDiv(CssClass.OVERVIEW_DESCRIPTION_TOP);
+
+ List packageGroups = getPackageGroups();
+
+ if (packageGroups.isEmpty()) {
+
+ printOverviewPackages(output, getAllPackages(),
+ "All Packages");
+ }
+ else {
+ Set otherPackages = new LinkedHashSet();
+ otherPackages.addAll(getAllPackages());
+
+ Iterator it = packageGroups.iterator();
+ while (it.hasNext()) {
+ PackageGroup packageGroup = (PackageGroup)it.next();
+ printOverviewPackages(output,
+ packageGroup.getPackages(),
+ packageGroup.getName());
+ otherPackages.removeAll(packageGroup.getPackages());
+ }
+
+ if (!otherPackages.isEmpty()) {
+ printOverviewPackages(output,
+ otherPackages,
+ "Other Packages");
+ }
+ }
+
+ output.anchorName("description");
+ output.beginDiv(CssClass.OVERVIEW_DESCRIPTION_FULL);
+ printTags(output, getRootDoc(), getRootDoc().inlineTags(), false);
+ output.endDiv(CssClass.OVERVIEW_DESCRIPTION_FULL);
+
+ printNavBarBottom(output, "overview");
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printOverviewPackages(HtmlPage output, Collection packageDocs, String header)
+ {
+ output.beginDiv(CssClass.TABLE_CONTAINER);
+ output.beginTable(CssClass.OVERVIEW_SUMMARY, new String[] { "border", "width" }, new String[] { "1", "100%" });
+ output.rowDiv(CssClass.TABLE_HEADER, header);
+
+ Iterator it = packageDocs.iterator();
+ while (it.hasNext()) {
+ PackageDoc packageDoc = (PackageDoc)it.next();
+ output.beginRow();
+
+ output.beginCell(CssClass.OVERVIEW_SUMMARY_LEFT);
+ output.beginAnchor(getPackageURL(packageDoc) + "package-summary" + filenameExtension);
+ output.print(packageDoc.name());
+ output.endAnchor();
+ output.endCell();
+
+ output.beginCell(CssClass.OVERVIEW_SUMMARY_RIGHT);
+ printTags(output, packageDoc, packageDoc.firstSentenceTags(), true);
+ output.endCell();
+ output.endRow();
+ }
+ output.endTable();
+ output.endDiv(CssClass.TABLE_CONTAINER);
+ }
+
+ private void printClassUsagePage(File packageDir, String pathToRoot, ClassDoc classDoc)
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(packageDir,
+ classDoc.name() + "-uses" + filenameExtension),
+ pathToRoot);
+ output.beginPage(getPageTitle(classDoc.name()), getOutputCharset(), getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_USES);
+ printNavBarTop(output, "uses", classDoc, null, null);
+
+ output.div(CssClass.USAGE_TITLE,
+ "Uses of " + getClassTypeName(classDoc)
+ + " " + classDoc.qualifiedName());
+
+ Map packageToUsageTypeMap = getUsageOfClass(classDoc);
+ if (null != packageToUsageTypeMap && !packageToUsageTypeMap.isEmpty()) {
+
+ Iterator packagesIterator = packageToUsageTypeMap.keySet().iterator();
+ while (packagesIterator.hasNext()) {
+ PackageDoc packageDoc = (PackageDoc)packagesIterator.next();
+
+ output.div(CssClass.USAGE_PACKAGE_TITLE, "Uses in package " + packageDoc.name());
+
+ Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(packageDoc);
+ Iterator usageTypeIterator = usageTypeToUsersMap.keySet().iterator();
+ while (usageTypeIterator.hasNext()) {
+ UsageType usageType = (UsageType)usageTypeIterator.next();
+
+ output.beginTable(CssClass.USAGE_SUMMARY, new String[] { "border", "width" }, new String[] { "1", "100%" });
+ output.rowDiv(CssClass.USAGE_TABLE_HEADER, format("usagetype." + usageType.getId(),
+ classDoc.qualifiedName()));
+
+ Set users = (Set)usageTypeToUsersMap.get(usageType);
+ Iterator userIterator = users.iterator();
+ while (userIterator.hasNext()) {
+ Doc user = (Doc)userIterator.next();
+
+ output.beginRow();
+
+ if (user instanceof ClassDoc) {
+ output.beginCell(CssClass.USAGE_SUMMARY_LEFT);
+ output.print("class");
+ output.endCell();
+
+ output.beginCell(CssClass.USAGE_SUMMARY_RIGHT);
+ output.beginDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ printType(output, ((ClassDoc)user));
+ output.endDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ output.beginDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ printTags(output, ((ClassDoc)user), ((ClassDoc)user).firstSentenceTags(), true);
+ output.endDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ output.endCell();
+ }
+ else if (user instanceof FieldDoc) {
+ FieldDoc fieldDoc = (FieldDoc)user;
+
+ output.beginCell(CssClass.USAGE_SUMMARY_LEFT);
+ printType(output, ((FieldDoc)user).type());
+ output.endCell();
+
+ output.beginCell(CssClass.USAGE_SUMMARY_RIGHT);
+ output.beginDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ printType(output, ((FieldDoc)user).containingClass());
+ output.print(".");
+ output.beginAnchor(getMemberDocURL(output, (FieldDoc)user));
+ output.print(((FieldDoc)user).name());
+ output.endAnchor();
+ output.endDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ output.beginDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ printTags(output, ((FieldDoc)user), ((FieldDoc)user).firstSentenceTags(), true);
+ output.endDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ output.endCell();
+ }
+ else if (user instanceof MethodDoc) {
+ MethodDoc methodDoc = (MethodDoc)user;
+
+ output.beginCell(CssClass.USAGE_SUMMARY_LEFT);
+ printType(output, ((MethodDoc)user).returnType());
+ output.endCell();
+
+ output.beginCell(CssClass.USAGE_SUMMARY_RIGHT);
+ output.beginDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ printType(output, ((MethodDoc)user).containingClass());
+ output.print(".");
+ output.beginAnchor(getMemberDocURL(output, (MethodDoc)user));
+ output.print(((MethodDoc)user).name());
+ output.endAnchor();
+ printParameters(output, (ExecutableMemberDoc)user);
+ output.endDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ output.beginDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ printTags(output, ((MethodDoc)user), ((MethodDoc)user).firstSentenceTags(), true);
+ output.endDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ output.endCell();
+ }
+ else if (user instanceof ConstructorDoc) {
+ ConstructorDoc constructorDoc = (ConstructorDoc)user;
+
+ output.beginCell(CssClass.USAGE_SUMMARY_RIGHT);
+ output.beginDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ printType(output, ((ConstructorDoc)user).containingClass());
+ output.print(".");
+ output.beginAnchor(getMemberDocURL(output, (ConstructorDoc)user));
+ output.print(((ConstructorDoc)user).name());
+ output.endAnchor();
+ printParameters(output, (ExecutableMemberDoc)user);
+ output.endDiv(CssClass.USAGE_SUMMARY_SYNOPSIS);
+ output.beginDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ printTags(output, ((ConstructorDoc)user),
+ ((ConstructorDoc)user).firstSentenceTags(), true);
+ output.endDiv(CssClass.USAGE_SUMMARY_DESCRIPTION);
+ output.endCell();
+ }
+
+ output.endRow();
+ }
+ output.endTable();
+ }
+ }
+ }
+ else {
+ output.div(CssClass.USAGE_EMPTY,
+ getClassTypeName(classDoc)
+ + " " + classDoc.qualifiedName() + " is not used by any class in this documentation set.");
+ }
+ printNavBarBottom(output, "uses", classDoc);
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printSuperTreeRec(HtmlPage output, ListIterator it, int level)
+ {
+ if (it.hasPrevious()) {
+ ClassDoc cd = (ClassDoc)it.previous();
+ output.beginElement("li", new String[] { "class" }, new String[] { "inheritance " + level });
+ output.beginElement("code");
+ if (it.hasPrevious()) {
+ printType(output, cd, true);
+ }
+ else {
+ output.print(cd.qualifiedName() + getTypeParameters(cd));
+ }
+ output.endElement("code");
+ output.endElement("li");
+
+ output.beginElement("li");
+
+ if (it.hasPrevious()) {
+ output.beginElement("ul", new String[] { "class" }, new String[] { "inheritance " + (level + 1) });
+ printSuperTreeRec(output, it, level + 1);
+ output.endElement("ul");
+ }
+
+ output.endElement("li");
+ }
+ }
+
+ private static boolean isSubInterface(ClassDoc classDoc, ClassDoc otherClassDoc)
+ {
+ ClassDoc[] interfaces = otherClassDoc.interfaces();
+ for (int i=0; i<interfaces.length; ++i) {
+ if (classDoc == interfaces[i]) {
+ return true;
+ }
+ else if (isSubInterface(classDoc, interfaces[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void printCommaSeparatedTypes(HtmlPage output,
+ Collection list,
+ String header,
+ CssClass cssClass)
+ {
+ if (!list.isEmpty()) {
+ output.beginDiv(cssClass);
+ output.div(CssClass.CLASS_KNOWNIMPLEMENTING_HEADER, header);
+ output.beginDiv(CssClass.CLASS_KNOWNIMPLEMENTING_ITEM);
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ Type type = (Type)it.next();
+ printType(output, type);
+ if (it.hasNext()) {
+ output.print(", ");
+ }
+ }
+ output.endDiv(CssClass.CLASS_KNOWNIMPLEMENTING_ITEM);
+ output.endDiv(cssClass);
+ }
+ }
+
+ private void printClassPage(File packageDir, String pathToRoot,
+ ClassDoc classDoc, ClassDoc prevClassDoc, ClassDoc nextClassDoc)
+ throws IOException
+ {
+ HtmlPage output = newHtmlPage(new File(packageDir,
+ classDoc.name() + filenameExtension),
+ pathToRoot);
+ Set keywords = new LinkedHashSet();
+ {
+ keywords.add(classDoc.qualifiedName() + " class");
+ FieldDoc[] fieldDocs = classDoc.fields();
+ for (int i=0; i<fieldDocs.length; ++i) {
+ FieldDoc fieldDoc = fieldDocs[i];
+ keywords.add(fieldDoc.name());
+ }
+
+ MethodDoc[] methodDocs = classDoc.methods();
+ for (int i=0; i<methodDocs.length; ++i) {
+ MethodDoc methodDoc = methodDocs[i];
+ keywords.add(methodDoc.name() + "()");
+ }
+ }
+ String parameters = getTypeParameters(classDoc);
+
+ output.beginPage(getPageTitle(classDoc.name()), getOutputCharset(),
+ keywords, getStylesheets());
+ output.beginBody(CssClass.BODY_CONTENT_CLASS);
+ printNavBarTop(output, "class", classDoc, prevClassDoc, nextClassDoc);
+
+ output.beginDiv(CssClass.CLASS_TITLE);
+ output.div(CssClass.CLASS_TITLE_PACKAGE,
+ classDoc.containingPackage().name());
+ output.div(CssClass.CLASS_TITLE_CLASS,
+ getClassTypeName(classDoc)
+ + " " + classDoc.name()
+ + parameters);
+ output.endDiv(CssClass.CLASS_TITLE);
+
+ boolean needSep = false;
+
+ if (classDoc.isInterface()) {
+
+ InterfaceRelation relation
+ = (InterfaceRelation)getInterfaceRelations().get(classDoc);
+
+ printCommaSeparatedTypes(output,
+ relation.superInterfaces,
+ "All Superinterfaces:",
+ CssClass.CLASS_KNOWNIMPLEMENTING);
+
+ printCommaSeparatedTypes(output,
+ relation.subInterfaces,
+ "Known Subinterfaces:",
+ CssClass.CLASS_KNOWNIMPLEMENTING);
+
+ printCommaSeparatedTypes(output,
+ relation.implementingClasses,
+ "Known Implementing Classes:",
+ CssClass.CLASS_KNOWNIMPLEMENTING);
+
+ needSep = !relation.superInterfaces.isEmpty()
+ || !relation.subInterfaces.isEmpty()
+ || !relation.implementingClasses.isEmpty();
+ }
+ else {
+ needSep = true;
+
+ if (!"java.lang.Object".equals(classDoc.qualifiedName())) {
+ LinkedList superClasses = new LinkedList();
+ for (ClassDoc cd = classDoc; cd != null; cd = cd.superclass()) {
+ superClasses.add(cd);
+ }
+ output.beginDiv(CssClass.CLASS_INHERITANCETREE);
+ output.beginElement("ul", new String[] { "class" }, new String[] { "inheritance 0" });
+ printSuperTreeRec(output, superClasses.listIterator(superClasses.size()), 0);
+ output.endElement("ul");
+ output.endDiv(CssClass.CLASS_INHERITANCETREE);
+
+ if (null != classDoc.containingClass()) {
+ output.beginDiv(CssClass.CLASS_ENCLOSINGCLASS);
+ output.div(CssClass.CLASS_ENCLOSINGCLASS_HEADER, "Enclosing Class:");
+ output.beginDiv(CssClass.CLASS_ENCLOSINGCLASS_ITEM);
+ printType(output, classDoc.containingClass());
+ output.endDiv(CssClass.CLASS_ENCLOSINGCLASS_ITEM);
+ output.endDiv(CssClass.CLASS_ENCLOSINGCLASS);
+ }
+
+ Set implementedInterfaces = getImplementedInterfaces(classDoc);
+
+ printCommaSeparatedTypes(output,
+ implementedInterfaces,
+ "Implemented Interfaces:",
+ CssClass.CLASS_KNOWNIMPLEMENTING);
+
+ List knownDirectSubclasses = getKnownDirectSubclasses(classDoc);
+ if (!knownDirectSubclasses.isEmpty()) {
+ output.beginDiv(CssClass.CLASS_SUBCLASSES);
+ output.div(CssClass.CLASS_SUBCLASSES_HEADER, "Known Direct Subclasses:");
+ output.beginDiv(CssClass.CLASS_SUBCLASSES_ITEM);
+ Iterator it = knownDirectSubclasses.iterator();
+ while (it.hasNext()) {
+ printType(output, (ClassDoc)it.next());
+ if (it.hasNext()) {
+ output.print(", ");
+ }
+ }
+
+ output.endDiv(CssClass.CLASS_SUBCLASSES_ITEM);
+ output.endDiv(CssClass.CLASS_SUBCLASSES_HEADER);
+ output.endDiv(CssClass.CLASS_SUBCLASSES);
+ }
+ }
+ }
+
+ if (needSep) {
+ output.hr();
+ }
+
+ output.beginDiv(CssClass.CLASS_SYNOPSIS);
+ output.beginDiv(CssClass.CLASS_SYNOPSIS_DECLARATION);
+ output.print(getFullModifiers(classDoc) + ' ' + getClassTypeKeyword(classDoc)
+ + ' ');
+ output.beginSpan(CssClass.CLASS_SYNOPSIS_NAME);
+ if (optionLinkSource.getValue() && null != classDoc.position()) {
+ output.beginAnchor(getOuterClassDoc(classDoc).name() + "-source" + filenameExtension + "#line." + classDoc.position());
+ output.print(classDoc.name() + parameters);
+ output.endAnchor();
+ }
+ else {
+ output.print(classDoc.name() + parameters);
+ }
+ output.endSpan(CssClass.CLASS_SYNOPSIS_NAME);
+ output.endDiv(CssClass.CLASS_SYNOPSIS_DECLARATION);
+
+ if (!classDoc.isInterface()) {
+ if (null != classDoc.superclass()) {
+ output.beginDiv(CssClass.CLASS_SYNOPSIS_SUPERCLASS);
+ output.print("extends ");
+ printType(output, classDoc.superclass());
+ output.endDiv(CssClass.CLASS_SYNOPSIS_SUPERCLASS);
+ }
+ }
+
+ ClassDoc[] interfaces = classDoc.interfaces();
+ if (interfaces.length > 0) {
+ output.beginDiv(CssClass.CLASS_SYNOPSIS_IMPLEMENTS);
+ if (!classDoc.isInterface()) {
+ output.print("implements ");
+ }
+ else {
+ output.print("extends ");
+ }
+ for (int i=0; i<interfaces.length; ++i) {
+ if (i>0) {
+ output.print(", ");
+ }
+ printType(output, interfaces[i]);
+ }
+ output.endDiv(CssClass.CLASS_SYNOPSIS_IMPLEMENTS);
+ }
+ output.endDiv(CssClass.CLASS_SYNOPSIS);
+
+ output.hr();
+
+ if (!optionNoComment.getValue()) {
+ output.beginDiv(CssClass.CLASS_DESCRIPTION);
+ printTags(output, classDoc, classDoc.inlineTags(), false);
+ output.endDiv(CssClass.CLASS_DESCRIPTION);
+
+ printTaglets(output, classDoc.tags(), new HtmlTagletContext(classDoc, output, false));
+ }
+
+
+ Set implementedInterfaces = getImplementedInterfaces(classDoc);
+
+ boolean haveInheritedFields = false;
+ boolean haveInheritedMethods = false;
+ boolean haveInheritedClasses = false;
+ {
+ if (!classDoc.isInterface()) {
+ ClassDoc superClassDoc = classDoc.superclass();
+ while (null != superClassDoc
+ && (!haveInheritedFields
+ || !haveInheritedMethods
+ || !haveInheritedClasses)) {
+ if (superClassDoc.fields().length > 0) {
+ haveInheritedFields = true;
+ }
+ if (superClassDoc.methods().length > 0) {
+ haveInheritedMethods = true;
+ }
+ if (superClassDoc.innerClasses().length > 0) {
+ haveInheritedClasses = true;
+ }
+ superClassDoc = superClassDoc.superclass();
+ }
+ }
+ }
+
+ printProgramElementDocs(output, getSortedInnerClasses(classDoc),
+ "Nested Class Summary", haveInheritedClasses,
+ "summary-inner");
+
+ {
+ ClassDoc superClassDoc = classDoc.superclass();
+ while (null != superClassDoc) {
+ printInheritedMembers(output, getSortedInnerClasses(superClassDoc),
+ "Nested classes/interfaces inherited from class {0}",
+ superClassDoc);
+ superClassDoc = superClassDoc.superclass();
+ }
+ }
+
+ printProgramElementDocs(output, getSortedFields(classDoc),
+ "Field Summary", haveInheritedFields,
+ "summary-fields");
+
+ {
+ ClassDoc superClassDoc = classDoc.superclass();
+ while (null != superClassDoc) {
+ printInheritedMembers(output, getSortedFields(superClassDoc),
+ "Fields inherited from class {0}",
+ superClassDoc);
+ superClassDoc = superClassDoc.superclass();
+ }
+ }
+
+ {
+ Iterator it = implementedInterfaces.iterator();
+ while (it.hasNext()) {
+ ClassDoc implementedInterface
+ = (ClassDoc)it.next();
+ if (!"java.io.Serializable".equals(implementedInterface.qualifiedName())
+ && !"java.io.Externalizable".equals(implementedInterface.qualifiedName())) {
+ printInheritedMembers(output, getSortedFields(implementedInterface),
+ "Fields inherited from interface {0}",
+ implementedInterface);
+ }
+ }
+ }
+
+ printProgramElementDocs(output, getSortedConstructors(classDoc),
+ "Constructor Summary", false,
+ "summary-constructors");
+ printProgramElementDocs(output, getSortedMethods(classDoc),
+ "Method Summary", haveInheritedMethods,
+ "summary-methods");
+
+ if (classDoc.isInterface()) {
+ InterfaceRelation relation
+ = (InterfaceRelation)getInterfaceRelations().get(classDoc);
+ Iterator it = relation.superInterfaces.iterator();
+ while (it.hasNext()) {
+ ClassDoc superClassDoc = (ClassDoc)it.next();
+ printInheritedMembers(output, getSortedMethods(superClassDoc),
+ "Methods inherited from interface {0}",
+ superClassDoc);
+ }
+ }
+ else {
+ ClassDoc superClassDoc = classDoc.superclass();
+ while (null != superClassDoc) {
+ printInheritedMembers(output, getSortedMethods(superClassDoc),
+ "Methods inherited from class {0}",
+ superClassDoc);
+ superClassDoc = superClassDoc.superclass();
+ }
+ }
+
+ printMemberDetails(output, getSortedFields(classDoc),
+ "Field Details", false, "detail-fields");
+ printMemberDetails(output, getSortedConstructors(classDoc),
+ "Constructor Details", false, "detail-constructors");
+ printMemberDetails(output, getSortedMethods(classDoc),
+ "Method Details", false, "detail-methods");
+
+ printNavBarBottom(output, "class", classDoc);
+
+ output.endBody();
+ output.endPage();
+ output.close();
+ }
+
+ private void printInheritedMembers(HtmlPage output,
+ ProgramElementDoc[] memberDocs,
+ String headerFormat,
+ ClassDoc superclass)
+ {
+ if (memberDocs.length > 0) {
+
+ output.beginDiv(CssClass.TABLE_CONTAINER);
+ output.beginTable(CssClass.CLASS_SUMMARY, new String[] { "border", "width" }, new String[] { "1", "100%" });
+ String superclassLink;
+ if (superclass.isIncluded()) {
+ superclassLink = superclass.containingPackage().name()
+ + "." + createTypeHref(output, superclass, false);
+ }
+ else {
+ superclassLink = createTypeHref(output, superclass, true);
+ }
+ output.rowDiv(CssClass.TABLE_SUB_HEADER,
+ new MessageFormat(headerFormat).format(new Object[] {
+ superclassLink
+ }));
+
+ output.beginRow();
+ output.beginCell(CssClass.CLASS_SUMMARY_INHERITED);
+ for (int i=0; i<memberDocs.length; ++i) {
+ ProgramElementDoc memberDoc = memberDocs[i];
+ if (i > 0) {
+ output.print(", ");
+ }
+ String title = null;
+ if (memberDoc.isMethod()) {
+ title = memberDoc.name() + ((MethodDoc)memberDoc).flatSignature();
+ }
+ else if (memberDoc.isInterface()) {
+ title = "interface " + ((ClassDoc)memberDoc).qualifiedName();
+ }
+ else if (memberDoc.isClass()) {
+ title = "class " + ((ClassDoc)memberDoc).qualifiedName();
+ }
+ output.beginAnchor(getMemberDocURL(output, memberDoc), title);
+ output.beginSpan(CssClass.CLASS_SUMMARY_INHERITED_MEMBER);
+ output.print(memberDoc.name());
+ output.endSpan(CssClass.CLASS_SUMMARY_INHERITED_MEMBER);
+ output.endAnchor();
+ }
+ output.endCell();
+ output.endRow();
+ output.endTable();
+ output.endDiv(CssClass.TABLE_CONTAINER);
+ }
+ }
+
+ private void collectSpecifiedByRecursive(Set specifyingInterfaces,
+ ClassDoc classDoc,
+ MethodDoc methodDoc)
+ {
+ ClassDoc[] interfaces = classDoc.interfaces();
+ for (int i=0; i<interfaces.length; ++i) {
+ MethodDoc[] methods = interfaces[i].methods();
+ for (int j=0; j<methods.length; ++j) {
+ if (methods[j].name().equals(methodDoc.name())
+ && methods[j].signature().equals(methodDoc.signature())) {
+ specifyingInterfaces.add(methods[j]);
+ break;
+ }
+ }
+ collectSpecifiedByRecursive(specifyingInterfaces,
+ interfaces[i],
+ methodDoc);
+ }
+ }
+
+ private void printMemberDetails(HtmlPage output,
+ ProgramElementDoc[] memberDocs, String header,
+ boolean isOnSerializedPage,
+ String anchor)
+ {
+ if (memberDocs.length > 0) {
+
+ if (null != anchor) {
+ output.anchorName(anchor);
+ }
+
+ CssClass sectionClass;
+ CssClass headerClass;
+ if (isOnSerializedPage) {
+ sectionClass = CssClass.SERIALIZED_SECTION;
+ headerClass = CssClass.SERIALIZED_SECTION_HEADER;
+ }
+ else {
+ sectionClass = CssClass.SECTION;
+ headerClass = CssClass.SECTION_HEADER;
+ }
+ output.div(headerClass, header);
+ output.beginDiv(sectionClass);
+
+ for (int i=0; i<memberDocs.length; ++i) {
+ if (i>0) {
+ output.hr();
+ }
+
+ ProgramElementDoc memberDoc = memberDocs[i];
+
+ output.anchorName(getMemberAnchor(memberDoc));
+
+ output.beginDiv(CssClass.MEMBER_DETAIL);
+ output.div(CssClass.MEMBER_DETAIL_NAME, memberDoc.name());
+
+ StringBuffer synopsis = new StringBuffer();
+ int synopsisLength = 0;
+
+ if (!isOnSerializedPage || !memberDoc.isField()) {
+ String fullModifiers = getFullModifiers(memberDoc);
+ synopsis.append(fullModifiers);
+ synopsisLength += fullModifiers.length();
+
+ }
+ if (memberDoc.isMethod() || memberDoc.isField()) {
+ Type type;
+ if (memberDoc.isMethod()) {
+ type = ((MethodDoc)memberDoc).returnType();
+ }
+ else {
+ type = ((FieldDoc)memberDoc).type();
+ }
+
+ synopsis.append(" ");
+ synopsisLength ++;
+ synopsis.append(createTypeHref(output, type, false));
+ if (null != type.asClassDoc() && type.asClassDoc().isIncluded()) {
+ synopsisLength += type.asClassDoc().name().length();
+ }
+ else {
+ synopsisLength += type.qualifiedTypeName().length();
+ }
+ synopsisLength += type.dimension().length();
+ }
+
+ synopsis.append(" ");
+ synopsisLength ++;
+
+ if (optionLinkSource.getValue() && null != memberDoc.position()) {
+ ClassDoc containingClass = memberDoc.containingClass();
+ while (null != containingClass.containingClass()) {
+ containingClass = containingClass.containingClass();
+ }
+ String href = containingClass.name() + "-source" + filenameExtension + "#line." + memberDoc.position().line();
+ synopsis.append(output.createHrefString(href, memberDoc.name()));
+ }
+ else {
+ synopsis.append(memberDoc.name());
+ }
+ synopsisLength += memberDoc.name().length();
+
+ if (memberDoc.isConstructor() || memberDoc.isMethod()) {
+ //printParameters(output, (ExecutableMemberDoc)memberDoc);
+ synopsis.append("(");
+ ++ synopsisLength;
+ StringBuffer paddingLeft = new StringBuffer();
+ for (int j=0; j<synopsisLength; ++j) {
+ paddingLeft.append(' ');
+ }
+ Parameter[] parameters = ((ExecutableMemberDoc)memberDoc).parameters();
+ for (int j=0; j<parameters.length; ++j) {
+ Parameter parameter = parameters[j];
+ synopsis.append(createTypeHref(output, parameter.type(), false));
+ synopsis.append(" ");
+ synopsis.append(parameter.name());
+ if (j < parameters.length - 1) {
+ synopsis.append(",\n");
+ synopsis.append(paddingLeft);
+ }
+ }
+ synopsis.append(")");
+ ClassDoc[] exceptions = ((ExecutableMemberDoc)memberDoc).thrownExceptions();
+ if (exceptions.length > 0) {
+ synopsis.append("\n throws ");
+ for (int j=0; j<exceptions.length; ++j) {
+ ClassDoc exception = exceptions[j];
+ synopsis.append(createTypeHref(output, exception, false));
+ if (j < exceptions.length - 1) {
+ synopsis.append(",\n ");
+ }
+ }
+ }
+ }
+
+ output.beginDiv(CssClass.MEMBER_DETAIL_SYNOPSIS);
+ output.print(synopsis.toString());
+ output.endDiv(CssClass.MEMBER_DETAIL_SYNOPSIS);
+
+ output.beginDiv(CssClass.MEMBER_DETAIL_BODY);
+
+ Tag[] deprecatedTags = memberDoc.tags("deprecated");
+ if (deprecatedTags.length > 0) {
+ output.beginDiv(CssClass.DEPRECATED_INLINE);
+ output.beginSpan(CssClass.DEPRECATED_HEADER);
+ output.print("Deprecated. ");
+ output.endSpan(CssClass.DEPRECATED_HEADER);
+ output.beginSpan(CssClass.DEPRECATED_BODY);
+ }
+ for (int j=0; j<deprecatedTags.length; ++j) {
+ printTags(output, memberDoc, deprecatedTags[j].inlineTags(), true);
+ }
+ if (deprecatedTags.length > 0) {
+ output.endSpan(CssClass.DEPRECATED_BODY);
+ output.beginDiv(CssClass.DEPRECATED_INLINE);
+ }
+
+ output.beginDiv(CssClass.MEMBER_DETAIL_DESCRIPTION);
+ printTags(output, memberDoc, memberDoc.inlineTags(), false);
+ output.endDiv(CssClass.MEMBER_DETAIL_DESCRIPTION);
+
+ if (memberDoc.isConstructor() || memberDoc.isMethod()) {
+
+ if (memberDoc.isMethod()) {
+ Set specifyingInterfaces = new LinkedHashSet();
+ if (memberDoc.containingClass().isInterface()) {
+ collectSpecifiedByRecursive(specifyingInterfaces,
+ memberDoc.containingClass(),
+ (MethodDoc)memberDoc);
+ }
+ else {
+ for (ClassDoc cd = memberDoc.containingClass();
+ null != cd; cd = cd.superclass()) {
+ collectSpecifiedByRecursive(specifyingInterfaces,
+ cd,
+ (MethodDoc)memberDoc);
+ }
+ }
+
+ if (!specifyingInterfaces.isEmpty()
+ && !isOnSerializedPage) {
+ output.beginDiv(CssClass.MEMBER_DETAIL_SPECIFIED_BY_LIST);
+ output.div(CssClass.MEMBER_DETAIL_SPECIFIED_BY_HEADER, "Specified by:");
+ Iterator it = specifyingInterfaces.iterator();
+ while (it.hasNext()) {
+ MethodDoc specifyingInterfaceMethod = (MethodDoc)it.next();
+ output.beginDiv(CssClass.MEMBER_DETAIL_SPECIFIED_BY_ITEM);
+ output.beginAnchor(getMemberDocURL(output,
+ specifyingInterfaceMethod));
+ output.print(memberDoc.name());
+ output.endAnchor();
+ output.print(" in interface ");
+ printType(output, specifyingInterfaceMethod.containingClass());
+ output.endDiv(CssClass.MEMBER_DETAIL_SPECIFIED_BY_ITEM);
+ }
+ output.endDiv(CssClass.MEMBER_DETAIL_SPECIFIED_BY_LIST);
+ }
+
+ ClassDoc overriddenClassDoc = null;
+ MemberDoc specifyingSuperMethod = null;
+
+ for (ClassDoc superclassDoc = memberDoc.containingClass().superclass();
+ null != superclassDoc && null == overriddenClassDoc;
+ superclassDoc = superclassDoc.superclass()) {
+
+ MethodDoc[] methods = superclassDoc.methods();
+ for (int j=0; j<methods.length; ++j) {
+ if (methods[j].name().equals(memberDoc.name())
+ && methods[j].signature().equals(((MethodDoc)memberDoc).signature())) {
+ overriddenClassDoc = superclassDoc;
+ specifyingSuperMethod = methods[j];
+ break;
+ }
+ }
+ }
+
+ if (null != overriddenClassDoc) {
+ output.beginDiv(CssClass.MEMBER_DETAIL_OVERRIDDEN_LIST);
+ output.div(CssClass.MEMBER_DETAIL_OVERRIDDEN_HEADER, "Overrides:");
+ output.beginDiv(CssClass.MEMBER_DETAIL_OVERRIDDEN_ITEM);
+
+ output.beginAnchor(getMemberDocURL(output,
+ specifyingSuperMethod));
+ output.print(memberDoc.name());
+ output.endAnchor();
+ output.print(" in interface ");
+ printType(output, overriddenClassDoc);
+
+ output.endDiv(CssClass.MEMBER_DETAIL_OVERRIDDEN_ITEM);
+ output.endDiv(CssClass.MEMBER_DETAIL_OVERRIDDEN_LIST);
+ }
+ }
+
+ if (!optionNoComment.getValue()) {
+
+ ExecutableMemberDoc execMemberDoc
+ = (ExecutableMemberDoc)memberDoc;
+
+ if (execMemberDoc.paramTags().length > 0) {
+ output.beginDiv(CssClass.MEMBER_DETAIL_PARAMETER_LIST);
+ output.div(CssClass.MEMBER_DETAIL_PARAMETER_HEADER, "Parameters:");
+ Parameter[] parameters = execMemberDoc.parameters();
+ for (int j=0; j<parameters.length; ++j) {
+ Parameter parameter = parameters[j];
+ ParamTag[] paramTags = execMemberDoc.paramTags();
+ ParamTag paramTag = null;
+ for (int k=0; k<paramTags.length; ++k) {
+ if (paramTags[k].parameterName().equals(parameter.name())) {
+ paramTag = paramTags[k];
+ break;
+ }
+ }
+
+ if (null != paramTag) {
+ output.beginDiv(CssClass.MEMBER_DETAIL_PARAMETER_ITEM);
+ output.beginSpan(CssClass.MEMBER_DETAIL_PARAMETER_ITEM_NAME);
+ output.print(parameter.name());
+ output.endSpan(CssClass.MEMBER_DETAIL_PARAMETER_ITEM_NAME);
+ output.beginSpan(CssClass.MEMBER_DETAIL_PARAMETER_ITEM_SEPARATOR);
+ output.print(" - ");
+ output.endSpan(CssClass.MEMBER_DETAIL_PARAMETER_ITEM_SEPARATOR);
+ output.beginSpan(CssClass.MEMBER_DETAIL_PARAMETER_ITEM_DESCRIPTION);
+ printTags(output, execMemberDoc, paramTag.inlineTags(), false);
+ output.endSpan(CssClass.MEMBER_DETAIL_PARAMETER_ITEM_DESCRIPTION);
+ output.endDiv(CssClass.MEMBER_DETAIL_PARAMETER_ITEM);
+ }
+ }
+ output.endDiv(CssClass.MEMBER_DETAIL_PARAMETER_LIST);
+ }
+
+ if (execMemberDoc.isMethod()
+ && !"void".equals(((MethodDoc)execMemberDoc).returnType().typeName())) {
+
+ Tag[] returnTags = execMemberDoc.tags("return");
+ if (returnTags.length > 0) {
+ Tag returnTag = returnTags[0];
+
+ output.beginDiv(CssClass.MEMBER_DETAIL_RETURN_LIST);
+ output.div(CssClass.MEMBER_DETAIL_RETURN_HEADER, "Returns:");
+ output.beginDiv(CssClass.MEMBER_DETAIL_RETURN_ITEM);
+
+ printTags(output, execMemberDoc, returnTag.inlineTags(), false);
+
+ output.endDiv(CssClass.MEMBER_DETAIL_RETURN_ITEM);
+ output.endDiv(CssClass.MEMBER_DETAIL_RETURN_LIST);
+ }
+ }
+
+ Set thrownExceptions = getThrownExceptions(execMemberDoc);
+ boolean haveThrowsInfo = false;
+ ThrowsTag[] throwsTags = execMemberDoc.throwsTags();
+ for (int k=0; k<throwsTags.length; ++k) {
+ ThrowsTag throwsTag = throwsTags[k];
+ if (null != throwsTags[k].exception()
+ && (isUncheckedException(throwsTags[k].exception())
+ || thrownExceptions.contains(throwsTag.exception()))) {
+ haveThrowsInfo = true;
+ break;
+ }
+ }
+
+ if (haveThrowsInfo) {
+ output.beginDiv(CssClass.MEMBER_DETAIL_THROWN_LIST);
+ output.div(CssClass.MEMBER_DETAIL_THROWN_HEADER, "Throws:");
+
+ for (int k=0; k<throwsTags.length; ++k) {
+ ThrowsTag throwsTag = throwsTags[k];
+ if (null != throwsTag.exception()
+ && (isUncheckedException(throwsTag.exception())
+ || thrownExceptions.contains(throwsTag.exception()))) {
+ output.beginDiv(CssClass.MEMBER_DETAIL_THROWN_ITEM);
+ output.beginSpan(CssClass.MEMBER_DETAIL_THROWN_ITEM_NAME);
+ printType(output, throwsTags[k].exception());
+ output.endSpan(CssClass.MEMBER_DETAIL_THROWN_ITEM_NAME);
+ if (null != throwsTag) {
+ output.beginSpan(CssClass.MEMBER_DETAIL_THROWN_ITEM_SEPARATOR);
+ output.print(" - ");
+ output.endSpan(CssClass.MEMBER_DETAIL_THROWN_ITEM_SEPARATOR);
+ output.beginSpan(CssClass.MEMBER_DETAIL_THROWN_ITEM_DESCRIPTION);
+ printTags(output, execMemberDoc, throwsTag.inlineTags(), false);
+ output.endSpan(CssClass.MEMBER_DETAIL_THROWN_ITEM_DESCRIPTION);
+ }
+ output.endDiv(CssClass.MEMBER_DETAIL_THROWN_ITEM);
+ }
+ }
+ output.endDiv(CssClass.MEMBER_DETAIL_THROWN_LIST);
+ }
+ }
+ }
+
+ if (!optionNoComment.getValue()) {
+
+ if (memberDoc.isField()) {
+ FieldDoc fieldDoc = ((FieldDoc)memberDoc);
+ if (null != fieldDoc.constantValue()) {
+ output.beginDiv(CssClass.MEMBER_DETAIL_THROWN_LIST);
+ output.div(CssClass.MEMBER_DETAIL_THROWN_HEADER, "Field Value:");
+ output.div(CssClass.MEMBER_DETAIL_THROWN_ITEM,
+ fieldDoc.constantValueExpression().toString());
+ output.endDiv(CssClass.MEMBER_DETAIL_THROWN_LIST);
+ }
+ }
+
+ TagletContext context = new HtmlTagletContext(memberDoc, output, isOnSerializedPage);
+ printTaglets(output, memberDoc.tags(), context);
+ }
+
+ output.endDiv(CssClass.MEMBER_DETAIL_BODY);
+ output.endDiv(CssClass.MEMBER_DETAIL);
+ }
+ output.endDiv(sectionClass);
+ }
+ }
+
+
+ private void printParameters(HtmlPage output, ExecutableMemberDoc memberDoc)
+ {
+ Parameter[] parameters = memberDoc.parameters();
+ output.print("(");
+ for (int j=0; j<parameters.length; ++j) {
+ if (j > 0) {
+ output.print(", ");
+ }
+ printType(output, parameters[j].type());
+ output.print("&nbsp;");
+ output.print(parameters[j].name());
+ }
+ output.print(")");
+ }
+
+ private void printProgramElementDocs(HtmlPage output,
+ ProgramElementDoc[] memberDocs,
+ String header,
+ boolean forceOutputHeader,
+ String anchor)
+ {
+ if (memberDocs.length > 0 || forceOutputHeader) {
+ output.anchorName(anchor);
+ output.beginDiv(CssClass.TABLE_CONTAINER);
+ output.beginTable(CssClass.CLASS_SUMMARY, new String[] { "border", "width" }, new String[] { "1", "100%" });
+ output.rowDiv(CssClass.TABLE_HEADER, header);
+
+ for (int i=0; i<memberDocs.length; ++i) {
+ ProgramElementDoc memberDoc = memberDocs[i];
+ output.beginRow();
+
+ if (!memberDoc.isConstructor()) {
+ output.beginCell(CssClass.CLASS_SUMMARY_LEFT);
+ output.beginDiv(CssClass.CLASS_SUMMARY_LEFT_SYNOPSIS);
+ output.print(getSummaryModifiers(memberDoc) + " ");
+ if (memberDoc.isMethod()) {
+ printType(output, ((MethodDoc)memberDoc).returnType());
+ }
+ else if (memberDoc.isField()) {
+ printType(output, ((FieldDoc)memberDoc).type());
+ }
+ else if (memberDoc.isInterface()) {
+ output.print(" interface");
+ }
+ else if (memberDoc.isClass()) {
+ output.print(" class");
+ }
+ output.endDiv(CssClass.CLASS_SUMMARY_LEFT_SYNOPSIS);
+ output.endCell();
+ }
+
+ output.beginCell(CssClass.CLASS_SUMMARY_RIGHT);
+ output.beginDiv(CssClass.CLASS_SUMMARY_RIGHT_LIST);
+ output.beginDiv(CssClass.CLASS_SUMMARY_RIGHT_SYNOPSIS);
+ if (memberDoc.isClass() || memberDoc.isInterface()) {
+ output.beginAnchor(getClassDocURL(output, (ClassDoc)memberDoc));
+ }
+ else {
+ output.beginAnchor("#" + getMemberAnchor(memberDoc));
+ }
+ output.print(memberDoc.name());
+ output.endAnchor();
+ if (memberDoc.isConstructor() || memberDoc.isMethod()) {
+ printParameters(output, (ExecutableMemberDoc)memberDoc);
+ }
+ output.endDiv(CssClass.CLASS_SUMMARY_RIGHT_SYNOPSIS);
+ Tag[] firstSentenceTags;
+ Tag[] deprecatedTags = memberDoc.tags("deprecated");
+ if (deprecatedTags.length > 0) {
+ firstSentenceTags = deprecatedTags[0].firstSentenceTags();
+ }
+ else {
+ firstSentenceTags = memberDoc.firstSentenceTags();
+ }
+
+ if (null != firstSentenceTags && firstSentenceTags.length > 0) {
+ output.beginDiv(CssClass.CLASS_SUMMARY_RIGHT_DESCRIPTION);
+ if (deprecatedTags.length > 0) {
+ output.beginDiv(CssClass.DEPRECATED);
+ output.beginSpan(CssClass.DEPRECATED_HEADER);
+ output.print("Deprecated. ");
+ output.endSpan(CssClass.DEPRECATED_HEADER);
+ output.beginSpan(CssClass.DEPRECATED_BODY);
+ }
+ printTags(output, memberDoc, firstSentenceTags, true);
+ if (deprecatedTags.length > 0) {
+ output.endSpan(CssClass.DEPRECATED_BODY);
+ output.beginDiv(CssClass.DEPRECATED);
+ }
+ output.endDiv(CssClass.CLASS_SUMMARY_RIGHT_DESCRIPTION);
+ }
+ output.endDiv(CssClass.CLASS_SUMMARY_RIGHT_LIST);
+ output.endCell();
+ output.endRow();
+ }
+ output.endTable();
+ output.endDiv(CssClass.TABLE_CONTAINER);
+ }
+ }
+
+ private void printTag(final HtmlPage output,
+ HtmlRepairer repairer,
+ Tag tag, boolean firstSentence,
+ boolean inline,
+ Doc contextDoc)
+ {
+ TagletContext context = new HtmlTagletContext(contextDoc, output, false);
+ if (firstSentence) {
+ output.print(renderInlineTags(tag.firstSentenceTags(), context));
+ }
+ else {
+ output.print(renderInlineTags(tag.inlineTags(), context));
+ }
+ }
+
+ private void printTags(HtmlPage output, Doc contextDoc, Tag[] tags, boolean firstSentence)
+ {
+ printTags(output, contextDoc, tags, firstSentence, false);
+ }
+
+ private void printTags(HtmlPage output, Doc contextDoc, Tag[] tags, boolean firstSentence, boolean inline)
+ {
+ if (!optionNoComment.getValue()) {
+ output.print(renderInlineTags(tags, new HtmlTagletContext(contextDoc, output, false)));
+ }
+
+ /*
+ if (!optionNoComment.getValue()) {
+ output.print(renderInlineTags(tag.firstSentenceTags(), output));
+ HtmlRepairer repairer = new HtmlRepairer(getRootDoc(),
+ true, false,
+ null, null,
+ true);
+ for (int i=0; i<tags.length; ++i) {
+ printTag(output, repairer, tags[i], firstSentence, inline);
+ }
+ output.print(repairer.terminateText());
+ }
+ */
+ }
+
+ private String getClassDocURL(HtmlPage output, ClassDoc classDoc)
+ {
+ return output.getPathToRoot()
+ + "/"
+ + getPackageURL(classDoc.containingPackage())
+ + classDoc.name() + filenameExtension;
+ }
+
+ private String getMemberDocURL(HtmlPage output, ProgramElementDoc memberDoc)
+ {
+ ClassDoc classDoc = memberDoc.containingClass();
+ PackageDoc packageDoc = classDoc.containingPackage();
+ ExternalDocSet externalDocSet = null;
+ if (classDoc.containingPackage().name().length() > 0) {
+ externalDocSet = (ExternalDocSet)packageNameToDocSet.get(packageDoc.name());
+ }
+ StringBuffer result = new StringBuffer();
+ result.append(getClassDocURL(output, classDoc));
+ result.append('#');
+ if (null == externalDocSet) {
+ result.append(getMemberAnchor(memberDoc));
+ }
+ else {
+ result.append(getMemberAnchor(memberDoc, externalDocSet.isJavadocCompatible()));
+ }
+ return result.toString();
+ }
+
+ private void printType(HtmlPage output, Type type)
+ {
+ printType(output, type, false);
+ }
+
+ private void printType(HtmlPage output, Type type, boolean fullyQualified)
+ {
+ output.print(createTypeHref(output, type, fullyQualified));
+ }
+
+ private String createTypeHref(HtmlPage output, Type type, boolean fullyQualified)
+ {
+ ClassDoc asClassDoc = type.asClassDoc();
+ String url = null;
+ if (null != asClassDoc && asClassDoc.isIncluded()) {
+ url = getClassDocURL(output, asClassDoc);
+ }
+ else if (!type.isPrimitive()) {
+ if (type.qualifiedTypeName().length() > type.typeName().length()) {
+ String packageName = type.qualifiedTypeName();
+ packageName = packageName.substring(0, packageName.length() - type.typeName().length() - 1);
+
+ ExternalDocSet externalDocSet
+ = (ExternalDocSet)packageNameToDocSet.get(packageName);
+ if (null != externalDocSet) {
+ url = externalDocSet.getClassDocURL(packageName, type.typeName());
+ }
+ }
+ }
+
+ StringBuffer result = new StringBuffer();
+
+ if (null != url && null != asClassDoc) {
+ String parameters = getTypeParameters(asClassDoc);
+ if (fullyQualified) {
+ result.append(output.createHrefString(url,possiblyQualifiedName(asClassDoc) + parameters));
+ }
+ else {
+ StringBuffer title = new StringBuffer();
+ title.append(getClassTypeName(asClassDoc));
+ title.append(" in ");
+ title.append(asClassDoc.containingPackage().name());
+ result.append(output.createHrefString(url, asClassDoc.name() + parameters, title.toString()));
+ }
+ }
+ else {
+ result.append(possiblyQualifiedName(type));
+ }
+ result.append(type.dimension());
+ return result.toString();
+ }
+
+ private void printTaglets(final HtmlPage output, Tag[] tags, TagletContext context)
+ {
+ super.printMainTaglets(tags, context, new TagletPrinter() {
+ public void printTagletString(String tagletString) {
+ output.beginDiv(CssClass.TAGLET);
+ output.print(tagletString);
+ output.endDiv(CssClass.TAGLET);
+ }
+ });
+ }
+
+ private String getPackageURL(PackageDoc packageDoc)
+ {
+ if (packageDoc.name().length() > 0) {
+ ExternalDocSet externalDocSet = (ExternalDocSet)packageNameToDocSet.get(packageDoc.name());
+ String url;
+ if (null != externalDocSet) {
+ url = externalDocSet.getPackageDocURL(packageDoc.name());
+ }
+ else {
+ url = packageDoc.name().replace('.', '/');
+ }
+ if (!url.endsWith("/")) {
+ return url + '/';
+ }
+ else {
+ return url;
+ }
+ }
+ else {
+ return "";
+ }
+ }
+
+ private String getClassURL(ClassDoc classDoc)
+ {
+ ExternalDocSet externalDocSet = null;
+ if (classDoc.containingPackage().name().length() > 0) {
+ externalDocSet = (ExternalDocSet)packageNameToDocSet.get(classDoc.containingPackage().name());
+ }
+ if (null != externalDocSet) {
+ return externalDocSet.getClassDocURL(classDoc.containingPackage().name(),
+ classDoc.name());
+ }
+ else {
+ return getPackageURL(classDoc.containingPackage()) + classDoc.name() + filenameExtension;
+ }
+ }
+
+ protected void run()
+ throws DocletConfigurationException, IOException
+ {
+ if (optionSerialWarn.getValue()) {
+ printWarning("Option -serialwarn is currently ignored.");
+ }
+
+ if (null != optionTitle.getValue()) {
+ printWarning("Option -title is deprecated.");
+ }
+
+ if (!optionValidHtml.getValue()) {
+ printWarning("Option -validhtml hasn't been specified. Generated HTML will not validate.");
+ }
+
+
+ {
+ boolean warningEmitted = false;
+ Iterator it = externalDocSets.iterator();
+ while (it.hasNext()) {
+ ExternalDocSet externalDocSet = (ExternalDocSet)it.next();
+ printNotice("Fetching package list for external documentation set.");
+ try {
+ externalDocSet.load(getTargetDirectory());
+ if (!isJavadocCompatibleNames() && externalDocSet.isJavadocCompatible()
+ && !warningEmitted) {
+ printWarning("Linking to javadoc-compatible documentation. Generated HTML will not validate ");
+ warningEmitted = true;
+ }
+ }
+ catch (FileNotFoundException e) {
+ printWarning("Cannot fetch package list from " + externalDocSet.getPackageListDir());
+ }
+ Iterator pit = externalDocSet.getPackageNames().iterator();
+ while (pit.hasNext()) {
+ String packageName = (String)pit.next();
+ packageNameToDocSet.put(packageName, externalDocSet);
+ }
+ }
+ }
+ printNotice("Building cross-reference information...");
+ getInterfaceRelations();
+ getAllSubClasses();
+
+ printNotice("Writing overview files...");
+ printFrameSetPage();
+ if (!isSinglePackage()) {
+ printPackagesMenuPage();
+ printAllClassesMenuPage();
+ printOverviewPage();
+ if (!optionNoTree.getValue()) {
+ printNotice("Writing full tree...");
+ printFullTreePage();
+ }
+ }
+ printPackagesListFile();
+ printAboutPage();
+ if (!optionNoIndex.getValue()) {
+ printNotice("Writing index...");
+ if (!optionSplitIndex.getValue()) {
+ printIndexPage();
+ }
+ else {
+ printSplitIndex();
+ }
+ }
+ if (outputHelpPage && !optionNoHelp.getValue()) {
+ printHelpPage();
+ }
+
+ // Copy resources
+
+ File resourcesDir = new File(getTargetDirectory(),
+ "resources");
+
+ if ((resourcesDir.exists() && !resourcesDir.isDirectory())
+ || (!resourcesDir.exists() && !resourcesDir.mkdirs())) {
+ throw new IOException("Cannot create directory " + resourcesDir);
+ }
+
+ // Copy resources
+
+ String[] resourceNames = {
+ "gjdoc.js",
+ "gjdochtml-clean-layout.css",
+ "gjdochtml-clean-color1.css",
+ "inherit.png",
+ "xhtml11-target10.dtd",
+ };
+
+ for (int i=0; i<resourceNames.length; ++i) {
+ String resourceName = resourceNames[i];
+ File targetFile = new File(resourcesDir,
+ resourceName);
+ InputStream in = getClass().getResourceAsStream("/htmldoclet/" + resourceName);
+ if (in == null) {
+ in = new FileInputStream("src/resources/htmldoclet/" + resourceName);
+ }
+ FileOutputStream out = new FileOutputStream(targetFile);
+ IOToolkit.copyStream(in, out);
+ in.close();
+ out.close();
+ }
+
+ // Copy stylesheets
+
+ if (null != optionAddStylesheet.getValue()) {
+ File addStylesheetTargetFile = new File(resourcesDir,
+ "user.css");
+
+ IOToolkit.copyFile(optionAddStylesheet.getValue(),
+ addStylesheetTargetFile);
+ }
+
+ if (null != optionStylesheetFile.getValue()) {
+ File stylesheetTargetFile = new File(resourcesDir,
+ "user.css");
+
+ IOToolkit.copyFile(optionStylesheetFile.getValue(),
+ stylesheetTargetFile);
+ }
+
+ // Write gjdoc.properties
+
+ File gjdocPropertiesTargetFile = new File(getTargetDirectory(),
+ "gjdoc.properties");
+ writeGjdocProperties(gjdocPropertiesTargetFile);
+
+ /*
+ else {
+ InputStream cssIn = getClass().getResourceAsStream("/htmldoclet/gjdochtml-vanilla.css");
+ FileOutputStream cssOut = new FileOutputStream(stylesheetTargetFile);
+ IOToolkit.copyStream(cssIn, cssOut);
+ cssIn.close();
+ cssOut.close();
+ }
+ */
+
+ if (!optionNoDeprecatedList.getValue()) {
+ printDeprecationPage();
+ }
+
+ printSerializationPage();
+
+ Collection packageDocsCollection = getAllPackages();
+ PackageDoc[] packageDocs
+ = (PackageDoc[])packageDocsCollection.toArray(new PackageDoc[0]);
+
+ for (int i=0; i<packageDocs.length; ++i) {
+ PackageDoc packageDoc = packageDocs[i];
+ File packageDir = new File(getTargetDirectory(),
+ packageDoc.name().replace('.', File.separatorChar));
+ if (!packageDir.exists() && !packageDir.mkdirs()) {
+ throw new IOException("Couldn't create directory " + packageDir);
+ }
+ try {
+ List packageSourceDirs = getPackageSourceDirs(packageDoc);
+ Iterator pdIt = packageSourceDirs.iterator();
+ while (pdIt.hasNext()) {
+ File sourcePackageDir = (File)pdIt.next();
+ copyDocFiles(sourcePackageDir, packageDir);
+ }
+ }
+ catch (IOException ignore) {
+ }
+ String pathToRoot = getPathToRoot(packageDir, getTargetDirectory());
+ String packageName = packageDoc.name();
+ if (0 == packageName.length()) {
+ packageName = "<unnamed>";
+ }
+ printNotice("Writing HTML files for package " + packageName);
+ printPackagePage(packageDir, pathToRoot, packageDoc,
+ (i > 0) ? packageDocs[i - 1] : null,
+ (i < packageDocs.length - 1) ? packageDocs[i + 1] : null);
+ if (!optionNoTree.getValue()) {
+ printPackageTreePage(packageDir, pathToRoot, packageDoc);
+ }
+ printPackageClassesMenuPage(packageDir, pathToRoot, packageDoc);
+ ClassDoc[] classDocs = packageDoc.allClasses();
+ for (int j=0; j<classDocs.length; ++j) {
+ ClassDoc classDoc = classDocs[j];
+ if (classDoc.isIncluded()) {
+ printClassPage(packageDir, pathToRoot,
+ classDocs[j],
+ (j > 0) ? classDocs[j - 1] : null,
+ (j < classDocs.length - 1) ? classDocs[j + 1] : null
+ );
+ if (optionUse.getValue()) {
+ printClassUsagePage(packageDir, pathToRoot, classDocs[j]);
+ }
+ if (optionLinkSource.getValue() && null == classDoc.containingClass()) {
+ try {
+ File sourceFile = getSourceFile(classDoc);
+
+ Java2xhtml java2xhtml = new Java2xhtml();
+ Properties properties = new Properties();
+ properties.setProperty("isCodeSnippet", "true");
+ properties.setProperty("hasLineNumbers", "true");
+ java2xhtml.setProperties(properties);
+
+ StringWriter sourceBuffer = new StringWriter();
+ FileReader sourceReader = new FileReader(sourceFile);
+ IOToolkit.copyStream(sourceReader, sourceBuffer);
+ sourceReader.close();
+ String result = java2xhtml.makeHTML(sourceBuffer.getBuffer(), sourceFile.getName());
+
+ printSourcePage(packageDir,
+ classDoc,
+ result);
+ }
+ catch (IOException e) {
+ printWarning("Cannot locate source file for class " + classDoc.qualifiedTypeName());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private String getPathToRoot(File subDir, File rootDir)
+ {
+ StringBuffer result = new StringBuffer();
+ while (!subDir.equals(rootDir)) {
+ if (result.length() > 0) {
+ result.append("/");
+ }
+ subDir = subDir.getParentFile();
+ result.append("..");
+ }
+ if (0 == result.length()) {
+ result.append(".");
+ }
+ return result.toString();
+ }
+
+ private String getClassTypeName(ClassDoc classDoc)
+ {
+ if (classDoc.isInterface()) {
+ return "Interface";
+ }
+ else {
+ return "Class";
+ }
+ }
+
+ private String getClassTypeKeyword(ClassDoc classDoc)
+ {
+ if (classDoc.isInterface()) {
+ return "interface";
+ }
+ else {
+ return "class";
+ }
+ }
+
+ private String getMemberAnchor(ProgramElementDoc memberDoc)
+ {
+ return getMemberAnchor(memberDoc, isJavadocCompatibleNames());
+ }
+
+ private String getMemberAnchor(ProgramElementDoc memberDoc, boolean javadocCompatibility)
+ {
+ StringBuffer anchor = new StringBuffer();
+ anchor.append(memberDoc.name());
+ if (memberDoc.isConstructor() || memberDoc.isMethod()) {
+ if (javadocCompatibility) {
+ anchor.append(((ExecutableMemberDoc)memberDoc).signature());
+ }
+ else {
+ anchor.append(':');
+ Parameter[] parameters = ((ExecutableMemberDoc)memberDoc).parameters();
+ for (int i=0; i<parameters.length; ++i) {
+ anchor.append(parameters[i].type().typeName());
+ for (int j=0; j<parameters[i].type().dimension().length()/2; ++j) {
+ anchor.append('-');
+ }
+ if (i < parameters.length - 1) {
+ anchor.append(':');
+ }
+ }
+ }
+ }
+ return anchor.toString();
+ }
+
+ private String getFullModifiers(ProgramElementDoc memberDoc)
+ {
+ StringBuffer result = new StringBuffer();
+ if (memberDoc.isPackagePrivate()) {
+ result.append("(package private) ");
+ }
+ result.append(memberDoc.modifiers());
+ if ((memberDoc.isClass() && ((ClassDoc)memberDoc).isAbstract())
+ || (memberDoc.isMethod() && ((MethodDoc)memberDoc).isAbstract())) {
+ result.append(" abstract");
+ }
+ return result.toString();
+ }
+
+ private String getSummaryModifiers(ProgramElementDoc memberDoc)
+ {
+ StringBuffer result = new StringBuffer();
+ if (memberDoc.isPackagePrivate()) {
+ result.append("(package private) ");
+ }
+ else if (memberDoc.isPrivate()) {
+ result.append("private ");
+ }
+ else if (memberDoc.isProtected()) {
+ result.append("protected ");
+ }
+ if (memberDoc.isStatic()) {
+ result.append("static");
+ }
+ else if ((memberDoc.isClass() && ((ClassDoc)memberDoc).isAbstract())
+ || (memberDoc.isMethod() && ((MethodDoc)memberDoc).isAbstract())) {
+ result.append("abstract");
+ }
+ return result.toString();
+ }
+
+ protected DocletOption[] getOptions()
+ {
+ return options;
+ }
+
+ private DocletOptionFlag optionNoNavBar =
+ new DocletOptionFlag("-nonavbar");
+
+ private DocletOptionFlag optionNoTree =
+ new DocletOptionFlag("-notree");
+
+ private DocletOptionFlag optionNoDeprecatedList =
+ new DocletOptionFlag("-nodeprecatedlist");
+
+ private DocletOptionFlag optionNoIndex =
+ new DocletOptionFlag("-noindex");
+
+ private DocletOptionFlag optionUse =
+ new DocletOptionFlag("-use");
+
+ private DocletOptionFlag optionNoHelp =
+ new DocletOptionFlag("-nohelp");
+
+ private DocletOptionFlag optionNoComment =
+ new DocletOptionFlag("-nocomment");
+
+ private DocletOptionFlag optionSerialWarn =
+ new DocletOptionFlag("-serialwarn");
+
+ private DocletOptionFlag optionSplitIndex =
+ new DocletOptionFlag("-splitindex");
+
+ private DocletOptionString optionHeader =
+ new DocletOptionString("-header");
+
+ private DocletOptionString optionFooter =
+ new DocletOptionString("-footer");
+
+ private DocletOptionString optionBottom =
+ new DocletOptionString("-bottom");
+
+ private DocletOptionString optionWindowTitle =
+ new DocletOptionString("-windowtitle");
+
+ private DocletOptionString optionDocTitle =
+ new DocletOptionString("-doctitle");
+
+ private DocletOptionString optionTitle =
+ new DocletOptionString("-title");
+
+ private DocletOptionFile optionHelpFile =
+ new DocletOptionFile("-helpfile");
+
+ private DocletOptionFile optionStylesheetFile =
+ new DocletOptionFile("-stylesheetfile");
+
+ private DocletOptionFlag optionLinkSource =
+ new DocletOptionFlag("-linksource");
+
+ private DocletOption optionLink =
+ new DocletOption("-link") {
+
+ public int getLength()
+ {
+ return 2;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ externalDocSets.add(new ExternalDocSet(optionArr[1], null));
+ return true;
+ }
+ };
+
+ private DocletOption optionLinkOffline =
+ new DocletOption("-linkoffline") {
+
+ public int getLength()
+ {
+ return 3;
+ }
+
+ public boolean set(String[] optionArr)
+ {
+ externalDocSets.add(new ExternalDocSet(optionArr[1], optionArr[2]));
+ return true;
+ }
+ };
+
+ private DocletOptionString optionDocEncoding =
+ new DocletOptionString("-docencoding");
+
+ private DocletOptionString optionEncoding =
+ new DocletOptionString("-encoding");
+
+ private DocletOptionString optionCharset =
+ new DocletOptionString("-charset");
+
+ private DocletOptionFile optionAddStylesheet =
+ new DocletOptionFile("-addstylesheet");
+
+ private DocletOptionFlag optionValidHtml =
+ new DocletOptionFlag("-validhtml");
+
+ private DocletOptionString optionBaseUrl =
+ new DocletOptionString("-baseurl");
+
+ private DocletOption[] options =
+ {
+ optionNoNavBar,
+ optionNoTree,
+ optionNoDeprecatedList,
+ optionNoIndex,
+ optionNoHelp,
+ optionNoComment,
+ optionUse,
+ optionSplitIndex,
+ optionHeader,
+ optionFooter,
+ optionBottom,
+ optionHelpFile,
+ optionStylesheetFile,
+ optionWindowTitle,
+ optionDocTitle,
+ optionTitle,
+ optionLinkSource,
+ optionLink,
+ optionLinkOffline,
+ optionDocEncoding,
+ optionEncoding,
+ optionCharset,
+ optionAddStylesheet,
+ optionValidHtml,
+ optionBaseUrl,
+ };
+
+ static {
+ setInstance(new HtmlDoclet());
+ }
+
+ private static String replaceDocRoot(HtmlPage output, String str)
+ {
+ return StringToolkit.replace(str, "{@docRoot}", output.getPathToRoot());
+ }
+
+ private String getOutputDocEncoding()
+ {
+ String encoding = optionDocEncoding.getValue();
+
+ if (null == encoding) {
+ encoding = optionEncoding.getValue();
+ }
+
+ return encoding;
+ }
+
+ private String getOutputCharset()
+ {
+ if (null == outputCharset) {
+
+ if (null != optionCharset.getValue()) {
+ outputCharset = optionCharset.getValue();
+ }
+ else {
+ String fileEncoding = System.getProperty("file.encoding");
+ if (null != fileEncoding) {
+ try {
+ outputCharset = Charset.forName(fileEncoding).name();
+ }
+ catch (Exception ignore) {
+ }
+ }
+
+ if (null == outputCharset) {
+ printWarning("Cannot determine platform default charset, falling back to ISO-8859-1.");
+ outputCharset = "ISO-8859-1";
+ }
+ }
+ }
+ return outputCharset;
+ }
+
+ public InlineTagRenderer getInlineTagRenderer()
+ {
+ return this;
+ }
+
+ public String renderInlineTags(Tag[] tags, TagletContext context)
+ {
+ StringBuffer result = new StringBuffer();
+
+ HtmlRepairer repairer = new HtmlRepairer(getRootDoc(),
+ true, false,
+ null, null,
+ true);
+
+ for (int i=0; i<tags.length; ++i) {
+
+ Tag tag = tags[i];
+
+ if ("Text".equals(tag.name())) {
+ result.append(repairer.getWellformedHTML(tag.text()));
+ }
+ else if ("@link".equals(tag.name())) {
+ result.append(renderSeeTag((SeeTag)tag, context, false));
+ }
+ else if ("@linkplain".equals(tag.name())) {
+ result.append(renderSeeTag((SeeTag)tag, context, true));
+ }
+ else if ("@docRoot".equals(tag.name())) {
+ result.append(((HtmlTagletContext)context).getOutput().getPathToRoot());
+ }
+ else {
+ //TagletContext context = TagletContext.OVERVIEW; // FIXME
+ Taglet taglet = (Taglet)tagletMap.get(tag.name().substring(1));
+ if (null != taglet) {
+ if (taglet instanceof GnuExtendedTaglet) {
+ result.append(((GnuExtendedTaglet)taglet).toString(tag, context));
+ }
+ else {
+ result.append(taglet.toString(tag));
+ }
+ }
+ }
+ }
+ result.append(repairer.terminateText());
+ return result.toString();
+ }
+
+ public String renderSeeTag(SeeTag seeTag, TagletContext context, boolean plainFont)
+ {
+ StringBuffer result = new StringBuffer();
+
+ String href = null;
+ String label = null;
+ MemberDoc referencedMember = seeTag.referencedMember();
+ if (null != seeTag.referencedClass()) {
+
+ href = getClassDocURL(((HtmlTagletContext)context).getOutput(), seeTag.referencedClass());
+
+ Doc doc = context.getDoc();
+ ClassDoc classDoc = null;
+ if (doc.isClass() || doc.isInterface()) {
+ classDoc = (ClassDoc)doc;
+ }
+ else if (doc.isField() || doc.isMethod() || doc.isConstructor()) {
+ classDoc = ((MemberDoc)doc).containingClass();
+ }
+
+ if (null == referencedMember
+ || seeTag.referencedClass() != classDoc
+ || ((HtmlTagletContext)context).isOnSerializedPage()) {
+
+ if (!seeTag.referencedClass().isIncluded()) {
+ label = possiblyQualifiedName(seeTag.referencedClass());
+ }
+ else {
+ label = seeTag.referencedClass().typeName();
+ }
+ if (null != referencedMember) {
+ label += '.';
+ }
+ }
+ else {
+ label = "";
+ }
+
+ if (null != referencedMember) {
+ label += referencedMember.name();
+ if (referencedMember.isMethod() || referencedMember.isConstructor()) {
+ label += ((ExecutableMemberDoc)referencedMember).flatSignature();
+ }
+ href += '#' + getMemberAnchor(referencedMember);
+ }
+ else if (null != seeTag.referencedMemberName()) {
+ href = null;
+ }
+ }
+ else {
+ String referencedClassName = seeTag.referencedClassName();
+
+ if (null != referencedClassName) {
+
+ String referencedPackageName = null;
+
+ Iterator it = packageNameToDocSet.keySet().iterator();
+ while (it.hasNext()) {
+ String packageName = (String)it.next();
+ if ((null == referencedPackageName
+ || packageName.length() > referencedPackageName.length())
+ && referencedClassName.startsWith(packageName + '.')) {
+ referencedPackageName = packageName;
+ }
+ }
+
+ if (null != referencedPackageName) {
+ ExternalDocSet externalDocSet
+ = (ExternalDocSet)packageNameToDocSet.get(referencedPackageName);
+
+ String className = referencedClassName.substring(referencedPackageName.length() + 1);
+ href = externalDocSet.getClassDocURL(referencedPackageName,
+ className);
+ label = className;
+
+ String referencedMemberName = seeTag.referencedMemberName();
+
+ if (null != referencedMemberName) {
+ label += '.';
+ label += referencedMemberName;
+ href += '#' + transformReferencedMemberName(referencedMemberName,
+ externalDocSet.isJavadocCompatible());
+ }
+ else if (null != seeTag.referencedMemberName()) {
+ href = null;
+ }
+ }
+ }
+ }
+
+ if (null != seeTag.label()
+ && seeTag.label().length() > 0) {
+ label = seeTag.label();
+ }
+
+ if (null == label) {
+ label = seeTag.text();
+ if (label.startsWith("#")) {
+ label = label.substring(1);
+ }
+ else {
+ label = label.replace('#', '.');
+ }
+ label.trim();
+ }
+
+ if (null != href) {
+ result.append("<a href=\"");
+ result.append(href);
+ result.append("\">");
+ if (!plainFont) {
+ result.append("<code>");
+ }
+ result.append(label);
+ if (!plainFont) {
+ result.append("</code>");
+ }
+ result.append("</a>");
+ }
+ else {
+ if (!plainFont) {
+ result.append("<code>");
+ }
+ result.append(label);
+ if (!plainFont) {
+ result.append("</code>");
+ }
+ }
+
+ return result.toString();
+ }
+
+ protected String renderTag(String tagName, Tag[] tags, TagletContext context)
+ {
+ Doc doc = context.getDoc();
+
+ if ("see".equals(tagName)
+ && ((tags.length > 0)
+ || (doc.isClass()
+ && (((ClassDoc)doc).isSerializable()
+ || ((ClassDoc)doc).isExternalizable())))) {
+
+ StringBuffer result = new StringBuffer();
+ result.append("<dl class=\"tag list\">");
+ result.append("<dt class=\"tag section header\"><b>");
+ result.append("See Also:");
+ result.append("</b></dt>");
+
+ boolean oneLine = true;
+
+ if (oneLine) {
+ result.append("<dd>");
+ }
+
+ for (int i = 0; i < tags.length; ++i) {
+ if (oneLine) {
+ if (i > 0) {
+ result.append(", ");
+ }
+ }
+ else {
+ result.append("<dd>");
+ }
+ result.append(renderSeeTag((SeeTag)tags[i], context, false));
+ if (!oneLine) {
+ result.append("</dd>");
+ }
+ }
+
+ if ((doc instanceof ClassDoc)
+ && (((ClassDoc)doc).isSerializable() || ((ClassDoc)doc).isExternalizable())) {
+ if (tags.length > 0) {
+ result.append(", ");
+ }
+ HtmlPage output = ((HtmlTagletContext)context).getOutput();
+ result.append("<a href=\"" + output.getPathToRoot() + "/serialized-form" + filenameExtension + "#" + ((ClassDoc)doc).qualifiedName() + "\">Serialized Form</a>");
+ }
+
+ if (oneLine) {
+ result.append("</dd>");
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ else if (tags.length > 0
+ && "serial".equals(tagName)
+ && ((HtmlTagletContext)context).isOnSerializedPage()) {
+
+ return renderInlineTags(tags[0].inlineTags(), context);
+ }
+ else {
+ return "";
+ }
+ }
+
+ private String getWindowTitle()
+ {
+ if (null == optionWindowTitle.getValue()) {
+ return "Generated API Documentation";
+ }
+ else {
+ return optionWindowTitle.getValue();
+ }
+ }
+
+ private String getPageTitle(String title)
+ {
+ if (null == optionWindowTitle.getValue()) {
+ return title;
+ }
+ else {
+ return title + " (" + optionWindowTitle.getValue() + ")";
+ }
+ }
+
+ protected String getDocletVersion()
+ {
+ if (null == docletVersion) {
+ docletVersion = gnu.classpath.Configuration.CLASSPATH_VERSION;
+ }
+ return docletVersion;
+ }
+
+ private Map getStylesheets()
+ {
+ Map sheets = new HashMap();
+ if (null != optionStylesheetFile.getValue()) {
+ sheets.put("User-specified", new String[] {
+ "resources/user.css"
+ });
+ }
+ else {
+ List cleanSheets = new LinkedList();
+ cleanSheets.add("resources/gjdochtml-clean-layout.css");
+ cleanSheets.add("resources/gjdochtml-clean-color1.css");
+ if (null != optionAddStylesheet.getValue()) {
+ cleanSheets.add("resources/user.css");
+ }
+ sheets.put("GNU Clean", cleanSheets.toArray(new String[0]));
+ }
+ return sheets;
+ }
+
+ protected boolean isSinglePackage()
+ {
+ if (getRootDoc().firstSentenceTags().length > 0) {
+ return false;
+ }
+ else if (null != optionDocTitle.getValue()
+ || null != optionTitle.getValue()) {
+ return false;
+ }
+ else {
+ return super.isSinglePackage();
+ }
+ }
+
+ private String getTypeParameters(ClassDoc classDoc)
+ {
+ String parameters = "";
+ TypeVariable[] params = classDoc.typeParameters();
+ if (params != null && params.length > 0)
+ {
+ parameters = "&lt;";
+ for (int a = 0; a < params.length; ++a)
+ {
+ parameters += params[a].typeName();
+ Type[] bounds = params[a].bounds();
+ if (bounds != null)
+ {
+ parameters += " extends ";
+ for (int b = 0; a < bounds.length; ++b)
+ {
+ parameters += bounds[a];
+ if (b != bounds.length - 1)
+ parameters += " & ";
+ }
+ }
+ if (a != params.length - 1)
+ parameters += ",";
+ }
+ parameters += "&gt;";
+ }
+ return parameters;
+ }
+
+ private String transformReferencedMemberName(String referencedMemberName,
+ boolean javadocCompatibility)
+ {
+ if (!javadocCompatibility) {
+ StringBuffer result = new StringBuffer();
+ for (int i=0; i<referencedMemberName.length(); ++i) {
+ char c = referencedMemberName.charAt(i);
+ switch (c) {
+ case '(': result.append(':'); break;
+ case ')': break;
+ case ',': result.append(':'); break;
+ case '[': result.append('-'); break;
+ case ']': break;
+ default: result.append(c); break;
+ }
+ }
+ return result.toString();
+ }
+ else {
+ return referencedMemberName;
+ }
+ }
+
+ public void writeGjdocProperties(File outputFile)
+ throws IOException
+ {
+ Properties properties = new Properties();
+ properties.setProperty("gjdoc.version", getDocletVersion());
+ properties.setProperty("gjdoc.compat", Boolean.toString(isJavadocCompatibleNames()));
+
+ FileOutputStream out = new FileOutputStream(outputFile);
+ properties.store(out, "GNU Gjdoc API Documentation Set Descriptor");
+ out.close();
+ }
+
+ public boolean isJavadocCompatibleNames()
+ {
+ return !optionValidHtml.getValue();
+ }
+
+ private HtmlPage newHtmlPage(File file,
+ String pathToRoot)
+ throws IOException
+ {
+ return new HtmlPage(file,
+ pathToRoot,
+ getOutputDocEncoding(),
+ optionBaseUrl.getValue(),
+ getTargetDirectory());
+ }
+
+ private HtmlPage newHtmlPage(File file,
+ String pathToRoot,
+ String docType)
+ throws IOException
+ {
+ return new HtmlPage(file,
+ pathToRoot,
+ getOutputDocEncoding(),
+ optionBaseUrl.getValue(),
+ getTargetDirectory(),
+ docType);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.java
new file mode 100644
index 000000000..0315cb5df
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.java
@@ -0,0 +1,535 @@
+/* gnu.classpath.tools.doclets.htmldoclet.HtmlPage
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.htmldoclet;
+
+import gnu.classpath.tools.IOToolkit;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * Allows outputting an HTML document without having to build the
+ * document tree in-memory.
+ */
+public class HtmlPage
+{
+ private File file;
+ private PrintWriter out;
+ private String pathToRoot;
+ private String docType;
+ private String baseUrl;
+ private File rootDir;
+
+ public static final String DOCTYPE_FRAMESET = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">";
+
+ public HtmlPage(File file, String pathToRoot, String encoding, String baseUrl, File rootDir)
+ throws IOException
+ {
+ this(file, pathToRoot, encoding, baseUrl, rootDir, "<!DOCTYPE html PUBLIC \"-//gnu.org///DTD XHTML 1.1 plus Target 1.0//EN\" \"" + pathToRoot + "/resources/xhtml11-target10.dtd\">");
+ }
+
+ public HtmlPage(File file, String pathToRoot, String encoding, String baseUrl, File rootDir, String docType)
+ throws IOException
+ {
+ this.file = file;
+ OutputStream fileOut = new FileOutputStream(file);
+ Writer writer;
+ if (null != encoding) {
+ writer = new OutputStreamWriter(fileOut,
+ encoding);
+ }
+ else {
+ writer = new OutputStreamWriter(fileOut);
+ }
+ this.out = new PrintWriter(new BufferedWriter(writer));
+ this.pathToRoot = pathToRoot;
+ this.docType = docType;
+ this.baseUrl = baseUrl;
+ this.rootDir = rootDir;
+ }
+
+ public void beginElement(String elementName)
+ {
+ print('<');
+ print(elementName);
+ print('>');
+ }
+
+ public void beginElement(String elementName, String attributeName, String attributeValue)
+ {
+ print('<');
+ print(elementName);
+ print(' ');
+ print(attributeName);
+ print('=');
+ print('\"');
+ print(attributeValue);
+ print('\"');
+ print('>');
+ }
+
+ public void beginElement(String elementName, String[] attributeNames, String[] attributeValues)
+ {
+ print('<');
+ print(elementName);
+ for (int i=0; i<attributeNames.length; ++i) {
+ if (null != attributeValues[i]) {
+ print(' ');
+ print(attributeNames[i]);
+ print('=');
+ print('\"');
+ print(attributeValues[i]);
+ print('\"');
+ }
+ }
+ print('>');
+ }
+
+ public void beginElement(String elementName, String attributeName, String attributeValue, String[] attributeNames, String[] attributeValues)
+ {
+ print('<');
+ print(elementName);
+ print(' ');
+ print(attributeName);
+ print('=');
+ print('\"');
+ print(attributeValue);
+ print('\"');
+ if (null != attributeNames) {
+ for (int i=0; i<attributeNames.length; ++i) {
+ if (null != attributeValues[i]) {
+ print(' ');
+ print(attributeNames[i]);
+ print('=');
+ print('\"');
+ print(attributeValues[i]);
+ print('\"');
+ }
+ }
+ }
+ print('>');
+ }
+
+ public void atomicElement(String elementName)
+ {
+ print('<');
+ print(elementName);
+ print("/>");
+ }
+
+ public void atomicElement(String elementName, String attributeName, String attributeValue)
+ {
+ print('<');
+ print(elementName);
+ print(' ');
+ print(attributeName);
+ print('=');
+ print('\"');
+ print(attributeValue);
+ print('\"');
+ print("/>");
+ }
+
+ public void atomicElement(String elementName, String[] attributeNames, String[] attributeValues)
+ {
+ print('<');
+ print(elementName);
+ for (int i=0; i<attributeNames.length; ++i) {
+ if (null != attributeValues[i]) {
+ print(' ');
+ print(attributeNames[i]);
+ print('=');
+ print('\"');
+ print(attributeValues[i]);
+ print('\"');
+ }
+ }
+ print("/>");
+ }
+
+
+ public void endElement(String elementName)
+ {
+ print("</");
+ print(elementName);
+ print('>');
+ }
+
+
+ public void beginDiv(CssClass cssClass)
+ {
+ String[] divAttributeNames = cssClass.getAttributeNames();
+ String[] divAttributeValues = cssClass.getAttributeValues();
+ if (null == divAttributeNames) {
+ divAttributeNames = new String[0];
+ }
+ if (null == divAttributeValues) {
+ divAttributeValues = new String[0];
+ }
+
+ String[] attributeNames = new String[1 + divAttributeNames.length];
+ String[] attributeValues = new String[1 + divAttributeValues.length];
+
+ System.arraycopy(divAttributeNames, 0, attributeNames, 1, divAttributeNames.length);
+ System.arraycopy(divAttributeValues, 0, attributeValues, 1, divAttributeNames.length);
+
+ attributeNames[0] = "class";
+ attributeValues[0] = cssClass.getName();
+
+ beginElement(cssClass.getDivElementName(), attributeNames, attributeValues);
+ if (null != cssClass.getInnerElementName()) {
+ beginElement(cssClass.getInnerElementName());
+ }
+ }
+
+ public void endDiv(CssClass cssClass)
+ {
+ if (null != cssClass.getInnerElementName()) {
+ endElement(cssClass.getInnerElementName());
+ }
+ endElement(cssClass.getDivElementName());
+ }
+
+ public void beginSpan(CssClass cssClass)
+ {
+ beginElement(cssClass.getSpanElementName(), "class", cssClass.getName());
+ }
+
+ public void endSpan(CssClass cssClass)
+ {
+ endElement(cssClass.getSpanElementName());
+ }
+
+ public void hr()
+ {
+ atomicElement("hr");
+ }
+
+ public void br()
+ {
+ atomicElement("br");
+ }
+
+ public void print(String text)
+ {
+ out.print(text);
+ }
+
+ public void print(char c)
+ {
+ out.print(c);
+ }
+
+ public void div(CssClass cssClass, String contents)
+ {
+ beginDiv(cssClass);
+ print(contents);
+ endDiv(cssClass);
+ }
+
+ public void span(CssClass cssClass, String contents)
+ {
+ beginSpan(cssClass);
+ print(contents);
+ endSpan(cssClass);
+ }
+
+ public void beginPage(String title, String charset, Map stylesheets)
+ throws IOException
+ {
+ beginPage(title, charset, Collections.EMPTY_SET, stylesheets);
+ }
+
+ public void beginPage(String title, String charset,
+ Collection keywords, Map stylesheets)
+ throws IOException
+ {
+ print("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\n");
+ print(docType);
+ print("<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">");
+ beginElement("head");
+ beginElement("title");
+ print(title);
+ endElement("title");
+ if (null != baseUrl && baseUrl.length() > 0) {
+ StringBuffer url = new StringBuffer();
+ url.append(baseUrl);
+ if ('/' == url.charAt(url.length() - 1)) {
+ url.delete(url.length() - 1, url.length());
+ }
+ url.append(file.getCanonicalPath().substring(rootDir.getCanonicalPath().length()));
+ atomicElement("base",
+ new String[] { "href" },
+ new String[] { url.toString() });
+ }
+ beginElement("script",
+ new String[] { "src", "type" },
+ new String[] { pathToRoot + "/resources/gjdoc.js", "text/javascript" });
+ print("<!-- this comment required for konqueror 3.2.2 -->");
+ endElement("script");
+ atomicElement("meta",
+ new String[] { "http-equiv", "content" },
+ new String[] { "Content-Type", "text/html; charset=" + charset });
+ atomicElement("meta",
+ new String[] { "name", "content" },
+ new String[] { "generator", "GNU Gjdoc Standard Doclet" });
+ Iterator keywordIt = keywords.iterator();
+ while (keywordIt.hasNext()) {
+ String keyword = (String)keywordIt.next();
+ atomicElement("meta",
+ new String[] { "name", "content" },
+ new String[] { "keywords", keyword });
+ }
+
+ Iterator cssIt = stylesheets.keySet().iterator();
+ while (cssIt.hasNext()) {
+ String sheetName = (String)cssIt.next();
+ String[] sheetFiles = (String[])stylesheets.get(sheetName);
+
+ for (int i=0; i<sheetFiles.length; ++i) {
+ String sheetFile = sheetFiles[i];
+ atomicElement("link",
+ new String[] { "rel", "type", "href", "title" },
+ new String[] { "stylesheet", "text/css",
+ pathToRoot + "/" + sheetFile, sheetName });
+ }
+ }
+
+ endElement("head");
+ }
+
+ public void endPage()
+ {
+ endElement("html");
+ }
+
+ public void close()
+ {
+ out.close();
+ }
+
+ public void beginTable(CssClass cssClass)
+ {
+ beginElement("table", "class", cssClass.getName());
+ }
+
+ public void beginTable(CssClass cssClass, String[] attributeNames, String[] attributeValues)
+ {
+ beginElement("table", "class", cssClass.getName(), attributeNames, attributeValues);
+ }
+
+ public void beginRow()
+ {
+ beginElement("tr");
+ }
+
+ public void beginRow(CssClass cssClass)
+ {
+ beginElement("tr", "class", cssClass.getName(), cssClass.getAttributeNames(), cssClass.getAttributeValues());
+ }
+
+ public void beginRow(String attribute, String value)
+ {
+ beginElement("tr", attribute, value);
+ }
+
+ public void beginCell()
+ {
+ beginElement("td");
+ }
+
+ public void beginCell(String attribute, String value)
+ {
+ beginElement("td", attribute, value);
+ }
+
+ public void beginCell(CssClass cssClass)
+ {
+ beginElement("td", "class", cssClass.getName(), cssClass.getAttributeNames(), cssClass.getAttributeValues());
+ }
+
+ public void endCell()
+ {
+ endElement("td");
+ }
+
+ public void cell(CssClass cssClass, String contents)
+ {
+ beginCell(cssClass);
+ print(contents);
+ endCell();
+ }
+
+ public void endRow()
+ {
+ endElement("tr");
+ }
+
+ public void rowDiv(CssClass cssClass, String contents)
+ {
+ beginRow(cssClass);
+ beginCell("colspan", "2");
+ beginDiv(cssClass);
+ print(contents);
+ endDiv(cssClass);
+ endCell();
+ endRow();
+ }
+
+ public void endTable()
+ {
+ endElement("table");
+ }
+
+ public void beginAnchor(String href)
+ {
+ beginElement("a", "href", href);
+ }
+
+ public void beginAnchor(String href, String title)
+ {
+ beginElement("a",
+ new String[] { "href", "title" },
+ new String[] { href, title });
+ }
+
+ public void beginAnchor(String href, String title, String target)
+ {
+ beginElement("a",
+ new String[] { "href", "title", "target" },
+ new String[] { href, title, target });
+ }
+
+ public void endAnchor()
+ {
+ endElement("a");
+ }
+
+ public void anchor(String href, String label)
+ {
+ beginAnchor(href);
+ print(label);
+ endAnchor();
+ }
+
+ public void anchorName(String name)
+ {
+ atomicElement("a", new String[] { "name", "id" }, new String[] { name, name });
+ }
+
+ public String getPathToRoot()
+ {
+ return pathToRoot;
+ }
+
+ public void beginBody(CssClass cssClass)
+ {
+ beginBody(cssClass, true);
+ }
+
+ public void beginBody(CssClass cssClass, boolean setTitle)
+ {
+ if (setTitle) {
+ beginElement("body",
+ new String[] { "class", "onload" },
+ new String[] { cssClass.getName(), "if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)" }
+ );
+ }
+ else {
+ beginElement("body",
+ new String[] { "class", "onload" },
+ new String[] { cssClass.getName(), "if(parent.contentPageLoaded)parent.contentPageLoaded()" }
+ );
+ }
+ }
+
+ public void endBody()
+ {
+ endElement("body");
+ }
+
+ public void insert(Reader in)
+ throws IOException
+ {
+ IOToolkit.copyStream(in, out);
+ }
+
+ public String createHrefString(String url, String content)
+ {
+ return createHrefString(url, content, null);
+ }
+
+ public String createHrefString(String url, String content, String title)
+ {
+ StringBuffer result = new StringBuffer();
+ result.append("<a href=\"");
+ result.append(url);
+ result.append("\"");
+ if (null != title) {
+ result.append(" title=\"");
+ result.append(title);
+ result.append("\"");
+ }
+ result.append(">");
+ result.append(content);
+ result.append("</a>");
+ return result.toString();
+ }
+
+ public File getFile()
+ {
+ return this.file;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.java
new file mode 100644
index 000000000..7b8961361
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.java
@@ -0,0 +1,65 @@
+/* gnu.classpath.tools.doclets.htmldoclet.HtmlTagletContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.htmldoclet;
+
+import com.sun.javadoc.Doc;
+import gnu.classpath.tools.taglets.TagletContext;
+
+public class HtmlTagletContext
+ extends TagletContext
+{
+ private HtmlPage output;
+ private boolean isOnSerializedPage;
+
+ public HtmlTagletContext(Doc doc, HtmlPage output, boolean isOnSerializedPage)
+ {
+ super(doc);
+ this.output = output;
+ this.isOnSerializedPage = isOnSerializedPage;
+ }
+
+ public HtmlPage getOutput()
+ {
+ return output;
+ }
+
+ public boolean isOnSerializedPage()
+ {
+ return isOnSerializedPage;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java
new file mode 100644
index 000000000..29a9e0906
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java
@@ -0,0 +1,2451 @@
+/* gnu.classpath.tools.doclets.xmldoclet.Driver
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import com.sun.javadoc.*;
+import java.io.*;
+
+import com.sun.tools.doclets.Taglet;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import java.text.DateFormat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.TreeSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+import gnu.classpath.tools.gjdoc.TemporaryStore;
+import gnu.classpath.tools.gjdoc.GjdocPackageDoc;
+
+import gnu.classpath.tools.doclets.PackageGroup;
+import gnu.classpath.tools.doclets.PackageMatcher;
+import gnu.classpath.tools.doclets.InvalidPackageWildcardException;
+
+import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet;
+import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTransletOptions;
+
+import gnu.classpath.tools.taglets.AuthorTaglet;
+import gnu.classpath.tools.taglets.VersionTaglet;
+import gnu.classpath.tools.taglets.SinceTaglet;
+import gnu.classpath.tools.taglets.DeprecatedTaglet;
+import gnu.classpath.tools.taglets.GenericTaglet;
+import gnu.classpath.tools.doclets.StandardTaglet;
+
+import gnu.classpath.tools.java2xhtml.Java2xhtml;
+
+import gnu.classpath.tools.IOToolkit;
+import gnu.classpath.tools.FileSystemClassLoader;
+
+/**
+ * A Doclet which retrieves all information presented by the Doclet
+ * API, dumping it to stdout in XML format.
+ *
+ * @author Julian Scheid
+ */
+public class Driver {
+
+ public static final String XMLDOCLET_VERSION = "0.6.1";
+
+ /**
+ * Used for redirecting error messages to <code>/dev/null</code>.
+ */
+ private static class NullErrorReporter implements DocErrorReporter {
+ public void printError(String ignore) {}
+ public void printWarning(String ignore) {}
+ public void printNotice(String ignore) {}
+ }
+
+ /*
+ * Taglet context constants.
+ */
+ private static final int CONTEXT_CONSTRUCTOR = 1;
+ private static final int CONTEXT_FIELD = 2;
+ private static final int CONTEXT_METHOD = 3;
+ private static final int CONTEXT_OVERVIEW = 4;
+ private static final int CONTEXT_PACKAGE = 5;
+ private static final int CONTEXT_TYPE = 6;
+
+ /**
+ * All XML output will go to this stream.
+ */
+ private PrintWriter out;
+
+ /**
+ * How many spaces to indent each XML node level,
+ * i.e. Tab size for output.
+ */
+ private static int indentStep = 1;
+
+ /**
+ * Won't output superfluous spaces if set to true.
+ * If set to false, output will be more legible.
+ */
+ private boolean compress = false;
+
+ /**
+ * Won't output warning messages while fixing
+ * HTML code if set to true.
+ */
+ private boolean noHTMLWarn = false;
+
+ /**
+ * Won't output warning messages when encountering tags
+ * that look like an email address if set to true.
+ */
+ private boolean noEmailWarn = false;
+
+ /**
+ * Will fix HTML if necessary so that each comment
+ * contains valid XML code if set to true. If set
+ * to false, HTML code will not be modified and
+ * instead encapsulated in a CDATA section.
+ */
+ private boolean fixHTML = true;
+
+ /**
+ * User-specified name of the directory where the final version of
+ * the generated files will be written to.
+ *
+ * If no XSLT sheet is given, the XML output will go directly into
+ * this directory. Otherwise, XML output will go to a temporary
+ * directory and XSLT output will go to this directory.
+ */
+ private File targetDirectory = null;
+
+ /**
+ * Directory where XML output will be written to. If no XSLT
+ * sheet was given, this is the target directory specified
+ * by the user. Otherwise, this is a temporary directory.
+ */
+ private File xmlTargetDirectory;
+
+ /**
+ * Contains a number of TargetContexts which describe which XSLT
+ * sheet to apply to the output of this doclet, to what directory
+ * the XSLT output is written, and which postprocess driver to use
+ * to process XSLT output.
+ */
+ private List targets = new ArrayList();
+
+ /**
+ * XML text to include at the end of every generated page. Read
+ * from the file specified on the command line using -bottomnote.
+ * If present, this will be written to the main output file
+ * (index.xml) in node /gjdoc:rootDoc/gjdoc:bottomnote.
+ */
+ private String bottomNote;
+
+ /**
+ * Brief description of the package set. Can be specified on the
+ * command line using -title. This will be written to the main
+ * output file (index.xml) in node
+ * /gjdoc:rootDoc/gjdoc:title. The HTML generating XSLT sheet
+ * uses this for example in window titles.
+ */
+ private String title;
+
+ /**
+ * Path to the directory where temporary files should be stored.
+ * Defaults to system tempdir, but can be overridden by user
+ * with -workpath.
+ */
+ private String workingPath = System.getProperty("java.io.tmpdir");
+
+ /**
+ * Temporary directory created by this doclet where all
+ * temporary files will be stored in. If no temporary
+ * files are needed (i.e. no XSLT postprocessing stage
+ * specified by user), this is <code>null</code>.
+ */
+ private File workingDirectory;
+
+ /**
+ * Whether to deep-copy the doc-files subdirectory.
+ */
+ private boolean docFilesSubdirsEnabled = false;
+
+ /**
+ * Which direct subdirectories of the doc-files directories to exclude.
+ * Set of String.
+ */
+ private Set excludeDocFilesSubDirs = new HashSet();
+
+ /**
+ * Stores the Doclet API RootDoc we are operating on.
+ */
+ private RootDoc rootDoc;
+
+ /**
+ * XML namespace prefix used for all tags, except for HTML
+ * tags copied from Javadoc comments. Excluding colon.
+ */
+ public static final String tagPrefix = "gjdoc";
+
+ /**
+ * Classpath for loading Taglet classes.
+ */
+ private String tagletPath = null;
+
+ /**
+ * The current class that is being processed.
+ * Set in outputClassDoc().
+ */
+ private ClassDoc currentClass;
+
+ /**
+ * The current member that is being processed.
+ * Set in outputMemberDoc().
+ */
+ private MemberDoc currentMember;
+
+ /**
+ * The current constructor/method that is being processed.
+ * Set in outputExecutableMemberDoc().
+ */
+ private ExecutableMemberDoc currentExecMember;
+
+ /**
+ * Mapping from tag type to Taglet for user Taglets specified on
+ * the command line.
+ */
+ private Map tagletMap = new LinkedHashMap();
+
+ /**
+ * Keeps track of the tags mentioned by the user during option
+ * processiong so that an error can be emitted if a tag is
+ * mentioned more than once.
+ */
+ private List mentionedTags = new LinkedList();
+
+ /**
+ * Stores options to be passed to the DocTranslet.
+ */
+ private DocTransletOptions docTransletOptions = new DocTransletOptions();
+
+ /**
+ * Stores the package groups specified in the user
+ * options. Contains objects of type PackageGroup.
+ */
+ private List packageGroups = new LinkedList();
+
+ private HtmlRepairer htmlRepairer;
+
+ public static boolean start(TemporaryStore _rootDocWrapper) {
+ return new Driver().instanceStart((RootDoc)_rootDocWrapper.getAndClear());
+ }
+
+ /**
+ * Official Doclet entry point.
+ */
+ public static boolean start(RootDoc _rootDoc) {
+
+ // Create a new XmlDoclet instance and delegate control.
+ TemporaryStore tstore = new TemporaryStore(_rootDoc);
+ _rootDoc = null;
+ return new Driver().instanceStart((RootDoc)tstore.getAndClear());
+ }
+
+ /**
+ * Output an XML tag describing a com.sun.javadoc.Type object.
+ * Assumes that the tag does not have subtags.
+ *
+ * @param level Level of indentation. Will be multiplied by
+ * <code>indentStep</code> to yield actual amount
+ * of whitespace inserted at start of line.
+ * @param tag Identifier for the XML tag being output.
+ * @param type The Javadoc Type to be output.
+ */
+ protected void outputType(int level, String tag, Type type) {
+ outputType(level, tag, type, true);
+ }
+
+ protected void outputType(int level, String tag, Type type, boolean atomic) {
+
+ boolean isIncluded = false;
+ ClassDoc typeAsClassDoc = type.asClassDoc();
+ String packageName = null;
+ if (null != typeAsClassDoc) {
+ isIncluded = typeAsClassDoc.isIncluded();
+ packageName = typeAsClassDoc.containingPackage().name();
+ }
+ println(level, "<"+tagPrefix+":"+tag + " typename=\""+type.typeName()+"\""+
+ " qualifiedtypename=\""+type.qualifiedTypeName()+"\""
+ +(type.dimension().length()==0?"":" dimension=\""+type.dimension()+"\"")
+ +(isIncluded?" isIncluded=\"true\"" : "")
+ +((null != packageName)?" package=\"" + packageName + "\"" : "")
+ +(atomic?"/":"")+">");
+ }
+
+ protected void outputExecutableMemberDocBody(int level, ExecutableMemberDoc memberDoc) {
+
+ currentExecMember = memberDoc;
+
+ outputMemberDocBody(level, memberDoc);
+
+ Parameter[] parameters = memberDoc.parameters();
+ for (int i=0, ilim=parameters.length; i<ilim; ++i) {
+ Parameter parameter = parameters[i];
+ outputType(level, "parameter name=\""+parameter.name()+"\"", parameter.type());
+ }
+
+ ClassDoc[] exceptions = memberDoc.thrownExceptions();
+ for (int i=0, ilim=exceptions.length; i<ilim; ++i) {
+ ClassDoc exception = exceptions[i];
+ outputType(level, "thrownException", exception);
+ }
+
+ printAtomTag(level, "signature full=\""+memberDoc.signature()+"\" flat=\""+memberDoc.flatSignature()+"\"");
+
+ if (memberDoc.isNative()) {
+ printAtomTag(level, "isNative");
+ }
+
+ if (memberDoc.isSynchronized()) {
+ printAtomTag(level, "isSynchronized");
+ }
+ }
+
+ protected void outputMethodDoc(int level, MethodDoc methodDoc) {
+ println();
+ printOpenTag(level, "methoddoc name=\""+methodDoc.name()+"\"");
+ outputExecutableMemberDocBody(level+1, methodDoc);
+ outputType(level+1, "returns", methodDoc.returnType());
+ printCloseTag(level, "methoddoc");
+ }
+
+ protected void outputMemberDocBody(int level, MemberDoc memberDoc) {
+ currentMember = memberDoc;
+ outputProgramElementDocBody(level, memberDoc);
+ }
+
+ protected void outputFieldDocBody(int level, FieldDoc fieldDoc) {
+ outputType(level, "type", fieldDoc.type());
+ if (fieldDoc.isTransient()) {
+ printAtomTag(level, "isTransient");
+ }
+ if (fieldDoc.isVolatile()) {
+ printAtomTag(level, "isVolatile");
+ }
+ }
+
+ private void outputFieldDoc(int level, FieldDoc fieldDoc) {
+ println();
+ printOpenTag(level, "fielddoc name=\""+fieldDoc.name()+"\"");
+ outputMemberDocBody(level+1, fieldDoc);
+ outputFieldDocBody(level+1, fieldDoc);
+ printCloseTag(level, "fielddoc");
+ }
+
+ protected void outputConstructorDoc(int level, ConstructorDoc constructorDoc) {
+ println();
+ printOpenTag(level, "constructordoc name=\""+constructorDoc.name()+"\"");
+ outputExecutableMemberDocBody(level+1, constructorDoc);
+ printCloseTag(level, "constructordoc");
+ }
+
+ protected void outputSuperInterfacesRec(int level, ClassDoc classDoc) {
+ if (null!=classDoc) {
+ ClassDoc[] interfaces = classDoc.interfaces();
+ if (null != interfaces) {
+ for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
+ outputType(level, "superimplements", interfaces[i]);
+ }
+ }
+ outputSuperInterfacesRec(level, classDoc.superclass());
+ }
+ }
+
+ protected void outputClassDocSummary(ClassDoc classDoc) {
+ println();
+ printOpenTag(1, "classdoc name=\""+classDoc.name()+"\" qualifiedtypename=\""+classDoc.qualifiedName()+"\" isIncluded=\"true\"");
+ if (null!=classDoc.superclass()) {
+ outputType(2, "superclass", classDoc.superclass());
+ }
+
+ ClassDoc[] interfaces = classDoc.interfaces();
+ for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
+ outputType(2, "implements", interfaces[i]);
+ }
+ outputSuperInterfacesRec(2, classDoc.superclass());
+
+ printAtomTag(2, "containingPackage name=\""+classDoc.containingPackage().name()+"\"");
+ if (classDoc.isError()) {
+ printAtomTag(2, "isError");
+ }
+ if (classDoc.isException()) {
+ printAtomTag(2, "isException");
+ }
+ if (classDoc.isInterface()) {
+ printAtomTag(2, "isInterface");
+ }
+ if (classDoc.isOrdinaryClass()) {
+ printAtomTag(2, "isOrdinaryClass");
+ }
+
+ printCloseTag(1, "classdoc");
+ }
+
+ protected void outputPackageDoc(PackageDoc packageDoc) {
+ println();
+ printOpenTag(1, "packagedoc name=\""+packageDoc.name()+"\"");
+ if (packageDoc.firstSentenceTags().length > 0) {
+ printOpenTag(2, "firstSentenceTags", false);
+ outputTags(3, packageDoc.firstSentenceTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(0, "firstSentenceTags");
+ printOpenTag(2, "inlineTags", false);
+ outputTags(3, packageDoc.inlineTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(0, "inlineTags");
+ }
+
+ if (packageDoc.tags().length > 0) {
+ printOpenTag(2, "tags");
+ outputTags(3, packageDoc.tags(), true, CONTEXT_PACKAGE);
+ printCloseTag(2, "tags");
+ }
+
+ if (packageDoc.seeTags().length > 0) {
+ printOpenTag(2, "seeTags");
+ outputTags(3, packageDoc.seeTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(2, "seeTags");
+ }
+
+ ClassDoc[] allClasses = (ClassDoc[]) packageDoc.allClasses().clone();
+ Arrays.sort(allClasses);
+
+ if (false) {
+ for (int i = 0, ilim = allClasses.length; i < ilim; ++ i) {
+ printAtomTag(2, "containsClass qualifiedtypename=\""+allClasses[i].qualifiedTypeName()+"\"");
+ }
+ }
+
+ printCloseTag(1, "packagedoc");
+ }
+
+ protected void outputClassDoc(ClassDoc classDoc) throws IOException {
+
+ currentClass = classDoc;
+
+ println();
+ printOpenTag(1, "classdoc xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:"+tagPrefix+"=\"http://www.gnu.org/software/cp-tools/gjdocxml\" name=\""+classDoc.name()+"\" qualifiedtypename=\""+classDoc.qualifiedName()+"\"");
+
+ ClassDoc[] interfaces = classDoc.interfaces();
+ for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
+ outputType(2, "implements", interfaces[i]);
+ }
+ outputSuperInterfacesRec(2, classDoc.superclass());
+
+ outputProgramElementDocBody(2, classDoc);
+ if (classDoc.isAbstract())
+ printAtomTag(2, "isAbstract");
+ if (classDoc.isSerializable())
+ printAtomTag(2, "isSerializable");
+ if (classDoc.isExternalizable())
+ printAtomTag(2, "isExternalizable");
+ if (classDoc.definesSerializableFields()) {
+ printAtomTag(2, "definesSerializableFields");
+ }
+
+ ConstructorDoc[] constructors = classDoc.constructors();
+ for (int i=0, ilim=constructors.length; i<ilim; ++i) {
+ outputConstructorDoc(2, constructors[i]);
+ }
+
+ MethodDoc[] methods = classDoc.methods();
+ for (int i=0, ilim=methods.length; i<ilim; ++i) {
+ outputMethodDoc(2, methods[i]);
+ }
+
+ FieldDoc[] fields = classDoc.fields();
+ for (int i=0, ilim=fields.length; i<ilim; ++i) {
+ outputFieldDoc(2, fields[i]);
+ }
+
+ if (classDoc.serializableFields().length > 0) {
+ printOpenTag(2, "serializableFields");
+
+ FieldDoc[] sfields = classDoc.serializableFields();
+ for (int i=0, ilim=sfields.length; i<ilim; ++i) {
+ outputFieldDoc(2, sfields[i]);
+ }
+ printCloseTag(2, "serializableFields");
+ }
+
+ Java2xhtml java2xhtml = new Java2xhtml();
+ Properties properties = new Properties();
+ properties.setProperty("isCodeSnippet", "true");
+ properties.setProperty("hasLineNumbers", "true");
+ java2xhtml.setProperties(properties);
+
+ if (null == classDoc.containingClass() && docTransletOptions.linksource) {
+ printOpenTag(2, "source");
+ StringWriter sourceBuffer = new StringWriter();
+ File sourceFile = new File(((GjdocPackageDoc)classDoc.containingPackage()).packageDirectory(),
+ classDoc.name() + ".java");
+ FileReader sourceReader = new FileReader(sourceFile);
+ IOToolkit.copyStream(sourceReader, sourceBuffer);
+ print(java2xhtml.makeHTML(sourceBuffer.getBuffer(), sourceFile.getName()));
+ printCloseTag(2, "source");
+ }
+
+ ClassDoc superclassDoc = classDoc.superclass();
+ while (superclassDoc != null) {
+ outputType(2, "superclass", superclassDoc, false);
+
+ // FIXME: remove the following after adjusting the XSLT sheets:
+ printAtomTag(3, "containingPackage name=\"" + superclassDoc.containingPackage().name() + "\"");
+
+ MethodDoc[] superMethods = superclassDoc.methods();
+ if (null != superMethods) {
+ for (int i=0, ilim=superMethods.length; i<ilim; ++i) {
+ printAtomTag(3, "methoddoc name=\"" + superMethods[i].name() + "\" signature=\"" + superMethods[i].signature() + "\"");
+ }
+ }
+
+ FieldDoc[] superFields = superclassDoc.fields();
+ if (null != superFields) {
+ for (int i=0, ilim=superFields.length; i<ilim; ++i) {
+ printAtomTag(3, "fielddoc name=\"" + superFields[i].name() + "\"");
+ }
+ }
+ printCloseTag(2, "superclass");
+
+ superclassDoc = superclassDoc.superclass();
+ }
+
+ outputUsage(classDoc, 2);
+
+ printCloseTag(1, "classdoc");
+
+ currentClass = null;
+ currentMember = null;
+ currentExecMember = null;
+ }
+
+ protected int outputHeritageOpen(int level, ClassDoc classDoc) {
+
+ ClassDoc superClassDoc = classDoc.superclass();
+ if (null != superClassDoc) {
+ level = outputHeritageOpen(level, superClassDoc);
+ ++ level;
+ }
+ outputType(level, "heritage", classDoc, false);
+ return level;
+ }
+
+ protected void outputHeritageClose(int level, ClassDoc classDoc) {
+
+ ClassDoc superClassDoc = classDoc.superclass();
+ if (null != superClassDoc) {
+ outputHeritageClose(level + 1, superClassDoc);
+ }
+ printCloseTag(level, "heritage");
+ }
+
+ protected void outputDocBody(int level, Doc doc) {
+
+ int context = CONTEXT_TYPE;
+
+ if (doc.isClass()) {
+ printAtomTag(level, "isClass");
+
+ ClassDoc classDoc = (ClassDoc)doc;
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i=0, ilim=classes.length; i<ilim; ++i) {
+ if (classes[i].superclass() == classDoc) {
+ outputType(level, "extended-by", classes[i]);
+ }
+ }
+
+ outputHeritageOpen(level, classDoc);
+ outputHeritageClose(level, classDoc);
+ }
+ if (doc.isConstructor()) {
+ printAtomTag(level, "isConstructor");
+ context = CONTEXT_CONSTRUCTOR;
+ }
+ if (doc.isError()) {
+ printAtomTag(level, "isError");
+ }
+ if (doc.isException()) {
+ printAtomTag(level, "isException");
+ }
+ if (doc.isField()) {
+ printAtomTag(level, "isField");
+ context = CONTEXT_FIELD;
+ }
+ if (doc.isIncluded()) {
+ printAtomTag(level, "isIncluded");
+ }
+ if (doc.isInterface()) {
+ printAtomTag(level, "isInterface");
+
+ ClassDoc classDoc = (ClassDoc)doc;
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i=0, ilim=classes.length; i<ilim; ++i) {
+ ClassDoc[] implementedInterfaces = classes[i].interfaces();
+ for (int j=0; j<implementedInterfaces.length; ++j) {
+ if (implementedInterfaces[j] == classDoc) {
+ if (classDoc.isInterface()) {
+ outputType(level, "subinterface", classes[i]);
+ }
+ else {
+ outputType(level, "implemented-by", classes[i]);
+ }
+ break;
+ }
+ }
+ }
+ }
+ if (doc.isMethod()) {
+ printAtomTag(level, "isMethod");
+ context = CONTEXT_METHOD;
+ }
+ if (doc.isOrdinaryClass()) {
+ printAtomTag(level, "isOrdinaryClass");
+ }
+
+ if (doc.inlineTags().length > 0) {
+ printOpenTag(level, "inlineTags", false);
+ outputTags(level+1, doc.inlineTags(), true, context);
+ printCloseTag(0, "inlineTags");
+ }
+
+ if (doc.firstSentenceTags().length > 0) {
+ printOpenTag(level, "firstSentenceTags", false);
+ outputTags(level+1, doc.firstSentenceTags(), true, context);
+ printCloseTag(0, "firstSentenceTags");
+ }
+
+ if (doc.tags().length > 0) {
+ printOpenTag(level, "tags");
+ outputTaglets(level+1, doc.tags(), true, context);
+ printCloseTag(level, "tags");
+ }
+
+ if (doc.seeTags().length > 0) {
+ printOpenTag(level, "seeTags");
+ outputTags(level+1, doc.seeTags(), true, context);
+ printCloseTag(level, "seeTags");
+ }
+
+ SourcePosition position = doc.position();
+ if (null != position) {
+ printAtomTag(level, "position file=\"" + position.file().getAbsolutePath() + "\" line=\"" + position.line() + "\" column=\"" + position.column() + "\"");
+ }
+ }
+
+ protected void outputProgramElementDocBody(int level, ProgramElementDoc programElementDoc) {
+ outputDocBody(level, programElementDoc);
+ printAtomTag(level, "containingPackage name=\""+programElementDoc.containingPackage().name()+"\"");
+ if (null!=programElementDoc.containingClass()) {
+ outputType(level, "containingClass", programElementDoc.containingClass());
+ }
+ String access;
+ if (programElementDoc.isPublic())
+ access="public";
+ else if (programElementDoc.isProtected())
+ access="protected";
+ else if (programElementDoc.isPrivate())
+ access="private";
+ else if (programElementDoc.isPackagePrivate())
+ access="package";
+ else
+ throw new RuntimeException("Huh? "+programElementDoc+" is neither public, protected, private nor package protected.");
+ printAtomTag(level, "access scope=\""+access+"\"");
+ if (programElementDoc.isFinal())
+ printAtomTag(level, "isFinal");
+ if (programElementDoc.isStatic())
+ printAtomTag(level, "isStatic");
+ }
+
+ protected void outputTags(int level, Tag[] tags, boolean descend, int context) {
+
+ for (int i=0; i<tags.length; ++i) {
+ outputTag(tags[i], level, descend, context, i == tags.length-1);
+ }
+ }
+
+ protected void outputTag(Tag tag, int level, boolean descend, int context, boolean lastTag) {
+
+ if (!"Text".equals(tag.name())) {
+ printOpenTag(0 /* don't introduce additional whitespace */,
+ "tag kind=\""+tag.kind()+"\" name=\""+tag.name()+"\"", false);
+ }
+ if (tag instanceof ThrowsTag) {
+ ThrowsTag throwsTag = (ThrowsTag)tag;
+ if (null!=throwsTag.exception()) {
+ outputType(level+1, "exception", throwsTag.exception());
+ }
+ else {
+ StringBuffer sb = new StringBuffer("Exception ");
+ sb.append(throwsTag.exceptionName());
+ sb.append(" not found in ");
+ if (currentExecMember instanceof MethodDoc) {
+ MethodDoc m = (MethodDoc)currentExecMember;
+ sb.append(m.returnType().typeName());
+ sb.append(m.returnType().dimension());
+ sb.append(' ');
+ }
+ sb.append(currentClass.qualifiedName());
+ sb.append('.');
+ sb.append(currentExecMember.name());
+ sb.append('(');
+ Parameter[] params = currentExecMember.parameters();
+ for (int j=0; j < params.length; j++) {
+ sb.append(params[j].type().typeName());
+ sb.append(params[j].type().dimension());
+ sb.append(' ');
+ sb.append(params[j].name());
+ if (j != params.length-1)
+ sb.append(", ");
+ }
+ sb.append(')');
+ printWarning(sb.toString());
+
+ printAtomTag(level+1, "exception typename=\""+throwsTag.exceptionName()+"\"");
+ }
+ }
+ else if (tag instanceof ParamTag) {
+ ParamTag paramTag = (ParamTag)tag;
+ printAtomTag(level+1, "parameter name=\""+paramTag.parameterName()+"\"");
+ }
+
+ if (null != tag.text()) {
+ //printOpenTag(level+1, "text", false);
+ if (fixHTML) {
+ print(htmlRepairer.getWellformedHTML(tag.text()));
+ }
+ else {
+ print("<![CDATA["+cdata(tag.text())+"]]>");
+ }
+ //printCloseTag(0 /* don't introduce additional whitespace */, "text");
+ }
+ else {
+ printWarning("Tag got null text: "+tag);
+ }
+
+ if ((descend && ("@throws".equals(tag.name()) || "@param".equals(tag.name()))) || "@deprecated".equals(tag.name())) {
+ if (tag.firstSentenceTags().length>0) {
+ printOpenTag(level+1, "firstSentenceTags", false);
+ outputTags(level+2, tag.firstSentenceTags(), false, context);
+ printCloseTag(0, "firstSentenceTags");
+ }
+
+ if (tag.inlineTags().length>0) {
+ printOpenTag(level+1, "inlineTags", false);
+ outputTags(level+2, tag.firstSentenceTags(), false, context);
+ printCloseTag(0, "inlineTags");
+ }
+ }
+
+ if (fixHTML && lastTag) {
+ String terminateText = htmlRepairer.terminateText();
+ if (null != terminateText && terminateText.length() > 0) {
+ print(terminateText);
+ }
+ }
+
+ if (!"Text".equals(tag.name())) {
+
+ Taglet inlineTaglet = (Taglet)tagletMap.get(tag.name().substring(1));
+ if (null != inlineTaglet && inlineTaglet.isInlineTag()) {
+ printOpenTag(0, "inlineTagletText", false);
+ print(inlineTaglet.toString(tag));
+ printCloseTag(0, "inlineTagletText");
+ }
+
+ printCloseTag(0, "tag", false);
+ }
+ }
+
+ void outputTaglets(int level, Tag[] tags, boolean descend, int context)
+ {
+ for (Iterator it = tagletMap.keySet().iterator(); it.hasNext(); ) {
+ String tagName = (String)it.next();
+ Object o = tagletMap.get(tagName);
+ Taglet taglet = (Taglet)o;
+
+ if (!taglet.isInlineTag()
+ && ((context != CONTEXT_CONSTRUCTOR || taglet.inConstructor())
+ || (context != CONTEXT_FIELD || taglet.inField())
+ || (context != CONTEXT_METHOD || taglet.inMethod())
+ || (context != CONTEXT_OVERVIEW || taglet.inOverview())
+ || (context != CONTEXT_PACKAGE || taglet.inPackage())
+ || (context != CONTEXT_TYPE || taglet.inType()))) {
+
+ List tagsOfThisType = new ArrayList();
+ for (int i=0, ilim=tags.length; i<ilim; ++i) {
+ if (tags[i].name().substring(1).equals(tagName)) {
+ tagsOfThisType.add(tags[i]);
+ }
+ }
+
+ if (!tagsOfThisType.isEmpty()) {
+ Tag[] tagletTags = (Tag[])tagsOfThisType.toArray(new Tag[tagsOfThisType.size()]);
+ if (taglet instanceof StandardTaglet) {
+ Iterator tagIterator = tagsOfThisType.iterator();
+ while (tagIterator.hasNext()) {
+ Tag tag = (Tag)tagIterator.next();
+ outputTag(tag, level, descend, context, !tagIterator.hasNext());
+ }
+ }
+ else {
+ String tagletString = taglet.toString(tagletTags);
+ if (null != tagletString) {
+ printOpenTag(0, "tag name=\"" + tagName + "\" taglet-generated=\"true\"");
+ if (fixHTML) {
+ print(htmlRepairer.getWellformedHTML(tagletString));
+ print(htmlRepairer.terminateText());
+ }
+ else {
+ print("<![CDATA["+cdata(tagletString)+"]]>");
+ }
+ printCloseTag(0, "tag", false);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Inofficial entry point. We got an instance here.
+ */
+ protected boolean instanceStart(RootDoc _rootDoc) {
+
+ this.rootDoc = _rootDoc;
+ _rootDoc = null;
+
+ boolean xmlOnly = true;
+
+ // Set the default Taglet order
+
+ registerTaglet(new VersionTaglet());
+ registerTaglet(new AuthorTaglet());
+ //registerTaglet(new SinceTaglet());
+ registerTaglet(new StandardTaglet("deprecated"));
+ registerTaglet(new StandardTaglet("see"));
+ registerTaglet(new StandardTaglet("param"));
+
+ // Set the built-in Taglet filter
+
+ AuthorTaglet.setTagletEnabled(false);
+ VersionTaglet.setTagletEnabled(false);
+ SinceTaglet.setTagletEnabled(true);
+ DeprecatedTaglet.setTagletEnabled(true);
+
+ try {
+ {
+
+ // Process command line options passed through to this doclet
+
+ TargetContext targetContext = null;
+
+ TargetContext htmlTargetContext
+ = new TargetContext(DocTranslet.fromClasspath("/doctranslets/html/gjdoc.xsl"),
+ targetDirectory);
+
+ for (int i=0, ilim=rootDoc.options().length; i<ilim; ++i) {
+
+ String[] option = rootDoc.options()[i];
+ String optionTag = option[0];
+
+ if ("-d".equals(optionTag)) {
+ if (null == targetDirectory) {
+ targetDirectory = new File(option[1]);
+ }
+ if (null != targetContext) {
+ targetContext.setTargetDirectory(targetDirectory);
+ }
+ }
+
+ else if ("-nofixhtml".equals(optionTag)) {
+ fixHTML = false;
+ printError("-nofixhtml currently not supported.");
+ return false;
+ }
+ else if ("-compress".equals(optionTag)) {
+ compress = true;
+ }
+ else if ("-nohtmlwarn".equals(optionTag)) {
+ noHTMLWarn = true;
+ }
+ else if ("-noemailwarn".equals(optionTag)) {
+ noEmailWarn = true;
+ }
+ else if ("-indentstep".equals(optionTag)) {
+ indentStep = Integer.parseInt(option[1]);
+ }
+ else if ("-doctranslet".equals(optionTag)) {
+ targets.add(targetContext = new TargetContext(DocTranslet.fromJarFile(new File(option[1])),
+ targetDirectory));
+ }
+ else if ("-genhtml".equals(optionTag)) {
+ htmlTargetContext.setTargetDirectory(targetDirectory);
+ targets.add(targetContext = htmlTargetContext);
+ xmlOnly = false;
+ }
+ else if ("-geninfo".equals(optionTag)) {
+ targetContext
+ = new TargetContext(DocTranslet.fromClasspath("/doctranslets/info/gengj.xsl"),
+ targetDirectory);
+ targets.add(targetContext);
+ if (!fixHTML) {
+ printNotice("NOTE: -geninfo implies -fixhtml.");
+ fixHTML = true;
+ }
+ xmlOnly = false;
+ }
+ else if ("-gendocbook".equals(optionTag)) {
+ targetContext = new TargetContext(DocTranslet.fromClasspath("/doctranslets/docbook/gengj.xsl"),
+ targetDirectory);
+ targets.add(targetContext);
+ if (!fixHTML) {
+ printNotice("NOTE: -gendocbook implies -fixhtml.");
+ fixHTML = true;
+ }
+ }
+ else if ("-genpdf".equals(optionTag)) {
+ targetContext
+ = new TargetContext(DocTranslet.fromClasspath("/doctranslets/docbook/gengj.xsl"),
+ targetDirectory);
+ /** "gnu.classpath.tools.doclets.xmldoclet.DocBookPostprocessor") **/
+ targets.add(targetContext);
+ if (!fixHTML) {
+ printNotice("NOTE: -genpdf implies -fixhtml.");
+ fixHTML = true;
+ }
+ }
+ else if ("-xmlonly".equals(optionTag)) {
+ xmlOnly = true;
+ }
+ else if ("-bottomnote".equals(optionTag)) {
+
+ FileReader reader = new FileReader(option[1]);
+ StringWriter writer = new StringWriter();
+ char[] buf = new char[256];
+ int nread;
+ while ((nread = reader.read(buf)) >= 0) {
+ writer.write(buf, 0, nread);
+ }
+ writer.flush();
+ bottomNote = writer.toString();
+ writer.close();
+ reader.close();
+ }
+ else if ("-title".equals(optionTag)) {
+
+ title = option[1];
+ }
+ else if ("-workpath".equals(optionTag)) {
+
+ workingPath = option[1];
+ }
+ else if ("-tagletpath".equals(optionTag)) {
+
+ if (null == tagletPath) {
+ tagletPath = option[1];
+ }
+ else {
+ tagletPath = tagletPath + File.pathSeparator + option[1];
+ }
+ }
+ else if ("-taglet".equals(optionTag)) {
+
+ boolean tagletLoaded = false;
+
+ String useTagletPath = this.tagletPath;
+ if (null == useTagletPath) {
+ useTagletPath = System.getProperty("java.class.path");
+ }
+
+ try {
+ Class tagletClass;
+ try {
+ tagletClass
+ = new FileSystemClassLoader(useTagletPath).loadClass(option[1]);
+ }
+ catch (ClassNotFoundException e) {
+ // If not found on specified tagletpath, try default classloader
+ tagletClass
+ = Class.forName(option[1]);
+ }
+ Method registerTagletMethod
+ = tagletClass.getDeclaredMethod("register", new Class[] { java.util.Map.class });
+
+ if (!registerTagletMethod.getReturnType().equals(Void.TYPE)) {
+ printError("Taglet class '" + option[1] + "' found, but register method doesn't return void.");
+ }
+ else if (registerTagletMethod.getExceptionTypes().length > 0) {
+ printError("Taglet class '" + option[1] + "' found, but register method contains throws clause.");
+ }
+ else if ((registerTagletMethod.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC | Modifier.ABSTRACT)) != (Modifier.STATIC | Modifier.PUBLIC)) {
+ printError("Taglet class '" + option[1] + "' found, but register method isn't public static, or is abstract..");
+ }
+ else {
+ Map tempMap = new HashMap();
+ registerTagletMethod.invoke(null, new Object[] { tempMap });
+ tagletLoaded = true;
+ String name = (String)tempMap.keySet().iterator().next();
+ Taglet taglet = (Taglet)tempMap.get(name);
+ tagletMap.put(name, taglet);
+ mentionedTags.add(taglet);
+ }
+ }
+ catch (NoSuchMethodException e) {
+ printError("Taglet class '" + option[1] + "' found, but doesn't contain the register method.");
+ }
+ catch (SecurityException e) {
+ printError("Taglet class '" + option[1] + "' cannot be loaded: " + e.getMessage());
+ }
+ catch (InvocationTargetException e) {
+ printError("Taglet class '" + option[1] + "' found, but register method throws exception: " + e.toString());
+ }
+ catch (IllegalAccessException e) {
+ printError("Taglet class '" + option[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
+ }
+ catch (IllegalArgumentException e) {
+ printError("Taglet class '" + option[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
+ }
+ catch (ClassNotFoundException e) {
+ printError("Taglet class '" + option[1] + "' cannot be found.");
+ }
+ if (!tagletLoaded) {
+ return false;
+ }
+ }
+ else if ("-author".equals(optionTag)) {
+ AuthorTaglet.setTagletEnabled(true);
+ }
+ else if ("-version".equals(optionTag)) {
+ VersionTaglet.setTagletEnabled(true);
+ }
+ else if ("-nosince".equals(optionTag)) {
+ SinceTaglet.setTagletEnabled(false);
+ }
+ else if ("-nodeprecated".equals(optionTag)) {
+ DeprecatedTaglet.setTagletEnabled(false);
+ }
+ else if ("-authormail".equals(optionTag)) {
+
+ if ("no-replace".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NO_REPLACEMENT);
+ }
+ else if ("mailto-name".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.MAILTO_NAME);
+ }
+ else if ("name-mailto-address".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NAME_MAILTO_ADDRESS);
+ }
+ else if ("name-mangled-address".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NAME_MANGLED_ADDRESS);
+ }
+ else {
+ printError("Invalid value for option '-authortag-email'. Allowed values are:"
+ + " no-replace, mailto-name, name-mailto-address, name-mangled-address.");
+ return false;
+ }
+ }
+ else if ("-mailmangledot".equals(optionTag)) {
+ AuthorTaglet.setDotReplacement(option[1]);
+ }
+ else if ("-mailmangleat".equals(optionTag)) {
+ AuthorTaglet.setAtReplacement(option[1]);
+ }
+ else if ("-docfilessubdirs".equals(optionTag)) {
+ docFilesSubdirsEnabled = true;
+ }
+ else if ("-excludedocfilessubdir".equals(optionTag)) {
+ StringTokenizer st = new StringTokenizer(option[1]);
+ while (st.hasMoreTokens()) {
+ excludeDocFilesSubDirs.add(st.nextToken());
+ }
+ }
+ else if ("-nonavbar".equals(optionTag)) {
+ docTransletOptions.nonavbar = true;
+ }
+ else if ("-noindex".equals(optionTag)) {
+ docTransletOptions.noindex = true;
+ }
+ else if ("-notree".equals(optionTag)) {
+ docTransletOptions.notree = true;
+ }
+ else if ("-nocomment".equals(optionTag)) {
+ docTransletOptions.nocomment = true;
+ }
+ else if ("-nohelp".equals(optionTag)) {
+ docTransletOptions.nohelp = true;
+ }
+ else if ("-splitindex".equals(optionTag)) {
+ docTransletOptions.splitindex = true;
+ }
+ else if ("-linksource".equals(optionTag)) {
+ docTransletOptions.linksource = true;
+ }
+ else if ("-windowtitle".equals(optionTag)) {
+ docTransletOptions.windowtitle = option[1];
+ }
+ else if ("-helpfile".equals(optionTag)) {
+ docTransletOptions.helpfile = new File(option[1]).toURL().toString();
+ }
+ else if ("-stylesheetfile".equals(optionTag)) {
+ docTransletOptions.stylesheetfile = new File(option[1]).toURL().toString();
+ }
+ else if ("-header".equals(optionTag)) {
+ docTransletOptions.header = option[1];
+ }
+ else if ("-footer".equals(optionTag)) {
+ docTransletOptions.footer = option[1];
+ }
+ else if ("-bottom".equals(optionTag)) {
+ docTransletOptions.bottom = option[1];
+ }
+ else if ("-doctitle".equals(optionTag)) {
+ docTransletOptions.doctitle = option[1];
+ }
+ else if ("-nodeprecatedlist".equals(optionTag)) {
+ docTransletOptions.nodeprecatedlist = true;
+ }
+ else if ("-uses".equals(optionTag)) {
+ docTransletOptions.uses = true;
+ }
+ else if ("-group".equals(optionTag)) {
+ if (!processGroupOption(option[1], option[2])) {
+ printError("Invalid package wildcard list in -group option \"" + option[1] + "\" " + option[2]);
+ return false;
+ }
+ }
+ else if ("-tag".equals(optionTag)) {
+ String tagSpec = option[1];
+ boolean validTagSpec = false;
+ int ndx1 = tagSpec.indexOf(':');
+ if (ndx1 < 0) {
+ Taglet taglet = (Taglet)tagletMap.get(tagSpec);
+ if (null == taglet) {
+ printError("There is no standard tag '" + tagSpec + "'.");
+ }
+ else {
+ if (mentionedTags.contains(taglet)) {
+ printError("Tag '" + tagSpec + "' has been added or moved before.");
+ }
+ else {
+ mentionedTags.add(taglet);
+
+ // re-append taglet
+ tagletMap.remove(tagSpec);
+ tagletMap.put(tagSpec, taglet);
+ }
+ }
+ }
+ else {
+ int ndx2 = tagSpec.indexOf(':', ndx1 + 1);
+ if (ndx2 > ndx1 && ndx2 < tagSpec.length() - 1) {
+ String tagName = tagSpec.substring(0, ndx1);
+ String tagHead = null;
+ if (tagSpec.charAt(ndx2 + 1) == '\"') {
+ if (tagSpec.charAt(tagSpec.length() - 1) == '\"') {
+ tagHead = tagSpec.substring(ndx2 + 2, tagSpec.length() - 1);
+ validTagSpec = true;
+ }
+ }
+ else {
+ tagHead = tagSpec.substring(ndx2 + 1);
+ validTagSpec = true;
+ }
+
+ boolean tagScopeOverview = false;
+ boolean tagScopePackages = false;
+ boolean tagScopeTypes = false;
+ boolean tagScopeConstructors = false;
+ boolean tagScopeMethods = false;
+ boolean tagScopeFields = false;
+ boolean tagDisabled = false;
+
+ tag_option_loop:
+ for (int n=ndx1+1; n<ndx2; ++n) {
+ switch (tagSpec.charAt(n)) {
+ case 'X':
+ tagDisabled = true;
+ break;
+ case 'a':
+ tagScopeOverview = true;
+ tagScopePackages = true;
+ tagScopeTypes = true;
+ tagScopeConstructors = true;
+ tagScopeMethods = true;
+ tagScopeFields = true;
+ break;
+ case 'o':
+ tagScopeOverview = true;
+ break;
+ case 'p':
+ tagScopePackages = true;
+ break;
+ case 't':
+ tagScopeTypes = true;
+ break;
+ case 'c':
+ tagScopeConstructors = true;
+ break;
+ case 'm':
+ tagScopeMethods = true;
+ break;
+ case 'f':
+ tagScopeFields = true;
+ break;
+ default:
+ validTagSpec = false;
+ break tag_option_loop;
+ }
+ }
+
+ if (validTagSpec) {
+ GenericTaglet taglet
+ = new GenericTaglet(tagName,
+ tagHead,
+ tagScopeOverview,
+ tagScopePackages,
+ tagScopeTypes,
+ tagScopeConstructors,
+ tagScopeMethods,
+ tagScopeFields);
+ taglet.setTagletEnabled(!tagDisabled);
+ taglet.register(tagletMap);
+ mentionedTags.add(taglet);
+ }
+ }
+ }
+ if (!validTagSpec) {
+ printError("Value for option -tag must be in format \"<tagname>:Xaoptcmf:<taghead>\".");
+ }
+ }
+ }
+
+ // Use current directory if target directory hasn't been set.
+ if (null == targetDirectory) {
+ targetDirectory = new File(System.getProperty("user.dir"));
+ }
+ if (null != targetContext) {
+ targetContext.setTargetDirectory(targetDirectory);
+ }
+
+ // It is illegal to specify targets AND -xmlonly.
+
+ if (xmlOnly && targets.size() > 0) {
+
+ printError("You can only specify one of -xmlonly and a target format.");
+ return false;
+ }
+
+ // If no target was specified and XML only was not
+ // requested, use HTML as default target.
+
+ if (!xmlOnly && targets.size() == 0) {
+ targets.add(targetContext = htmlTargetContext);
+ }
+
+ // Set the same target directory for all output.
+
+ // FIXME: Allow separate target directories for different
+ // output formats.
+
+ for (Iterator it = targets.iterator(); it.hasNext(); ) {
+ TargetContext t = (TargetContext)it.next();
+ t.setTargetDirectory(targetDirectory);
+ }
+
+ // Create temporary directory if necessary
+
+ if (xmlOnly) {
+
+ xmlTargetDirectory = targetDirectory;
+ }
+ else {
+
+ File workingTopDirectory = new File(workingPath);
+
+ workingDirectory = new File(workingTopDirectory, "gjdoc.tmp."+System.currentTimeMillis());
+
+ if (!workingDirectory.mkdir()) {
+ printError("Cannot create temporary directory at "+System.getProperty("java.io.tmpdir"));
+ return false;
+ }
+
+ File xmlTempDirectory = new File(workingDirectory, "xmloutput");
+
+ if (!xmlTempDirectory.mkdir()) {
+ printError("Cannot create temporary directory for XML output at "+System.getProperty("java.io.tmpdir"));
+ return false;
+ }
+
+ xmlTargetDirectory = xmlTempDirectory;
+ }
+
+ // Create target directory if necessary
+
+ if (!targetDirectory.exists()) {
+ printNotice("Creating destination directory: \""
+ + targetDirectory + "\"");
+ if (!targetDirectory.mkdirs()) {
+ printError("Failed to create destination directory \""
+ + targetDirectory + "\"");
+ return false;
+ }
+ }
+
+ // Check for deprecation
+
+ boolean hasDeprecatedClasses = false;
+ boolean hasDeprecatedInterfaces = false;
+ boolean hasDeprecatedExceptions = false;
+ boolean hasDeprecatedErrors = false;
+ boolean hasDeprecatedMethods = false;
+ boolean hasDeprecatedFields = false;
+
+ {
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
+ ClassDoc c = classes[i];
+ Tag[] deprecatedTags = c.tags("deprecated");
+ if (null != deprecatedTags && 0 != deprecatedTags.length) {
+ if (c.isInterface()) {
+ hasDeprecatedInterfaces = true;
+ }
+ else if (c.isException()) {
+ hasDeprecatedExceptions = true;
+ }
+ else if (c.isError()) {
+ hasDeprecatedErrors = true;
+ }
+ else /*if (c.isOrdinaryClass())*/ {
+ hasDeprecatedClasses = true;
+ }
+ }
+
+ MethodDoc[] methods = c.methods();
+ for (int j = 0, jlim = methods.length; j < jlim; ++ j) {
+ MethodDoc m = methods[j];
+ deprecatedTags = m.tags("deprecated");
+ if (null != deprecatedTags && 0 != deprecatedTags.length) {
+ hasDeprecatedMethods = true;
+ }
+ }
+
+ FieldDoc[] fields = c.fields();
+ for (int j = 0, jlim = fields.length; j < jlim; ++ j) {
+ FieldDoc f = fields[j];
+ deprecatedTags = f.tags("deprecated");
+ if (null != deprecatedTags && 0 != deprecatedTags.length) {
+ hasDeprecatedFields = true;
+ }
+ }
+ }
+ }
+
+ htmlRepairer = new HtmlRepairer(rootDoc, noHTMLWarn, noEmailWarn,
+ currentClass, currentMember,
+ false);
+
+ collectUsage();
+
+ // Begin XML generation
+
+ printNotice("Writing XML Index file...");
+
+ // Assign output stream
+
+ setTargetFile("index.xml");
+
+ // Output XML document header
+
+ println(0, "<?xml version=\"1.0\"?>");
+ println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc.dtd\">");
+ println();
+ printOpenTag(0, "rootdoc xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:gjdoc=\"http://www.gnu.org/software/cp-tools/gjdocxml\"");
+
+ println();
+ println(1, "<!-- Tags from overview page, if available -->");
+
+ if (rootDoc.firstSentenceTags().length > 0) {
+ printOpenTag(2, "firstSentenceTags", false);
+ outputTags(3, rootDoc.firstSentenceTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(0, "firstSentenceTags");
+ }
+
+ if (rootDoc.inlineTags().length > 0) {
+ printOpenTag(2, "inlineTags");
+ outputTags(3, rootDoc.inlineTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(2, "inlineTags");
+ }
+
+ if (null != bottomNote) {
+ printOpenTag(1, "bottomnote");
+ print(bottomNote);
+ printCloseTag(1, "bottomnote");
+ }
+
+ if (null != title) {
+ printOpenTag(1, "title");
+ println(2, title);
+ printCloseTag(1, "title");
+ }
+
+ printOpenTag(1, "created");
+ println(2, DateFormat.getDateInstance(DateFormat.LONG, Locale.US).format(new java.util.Date()));
+ printCloseTag(1, "created");
+
+ if (hasDeprecatedClasses) printAtomTag(1, "hasDeprecatedClasses");
+ if (hasDeprecatedInterfaces) printAtomTag(1, "hasDeprecatedInterfaces");
+ if (hasDeprecatedExceptions) printAtomTag(1, "hasDeprecatedExceptions");
+ if (hasDeprecatedErrors) printAtomTag(1, "hasDeprecatedErrors");
+ if (hasDeprecatedMethods) printAtomTag(1, "hasDeprecatedMethods");
+ if (hasDeprecatedFields) printAtomTag(1, "hasDeprecatedFields");
+
+ // Output summary of all classes specified on command line
+
+ println();
+ println(1, "<!-- Classes specified by user on command line -->");
+ ClassDoc[] specifiedClasses = rootDoc.specifiedClasses();
+ for (int i=0, ilim=specifiedClasses.length; i<ilim; ++i) {
+ ClassDoc sc = specifiedClasses[i];
+ printAtomTag(1, "specifiedclass fqname=\""+sc.qualifiedName()+"\" name=\""+sc.name()+"\"");
+ }
+ specifiedClasses = null;
+
+ // Output summary of all packages specified on command line
+
+ println();
+ println(1, "<!-- Packages specified by user on command line -->");
+ PackageDoc[] specifiedPackages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=specifiedPackages.length; i<ilim; ++i) {
+ PackageDoc sp = specifiedPackages[i];
+ printAtomTag(1, "specifiedpackage name=\""+sp.name()+"\"");
+ }
+ specifiedPackages = null;
+
+ // Output package group information specified on the
+ // command line
+
+ println();
+ println(1, "<!-- Package groups specified by user on command line -->");
+ {
+ Iterator packageGroupIt = packageGroups.iterator();
+ while (packageGroupIt.hasNext()) {
+ PackageGroup packageGroup = (PackageGroup)packageGroupIt.next();
+ SortedSet groupedPackages = packageGroup.getPackages();
+ if (groupedPackages.isEmpty()) {
+ printWarning("Package group named '"
+ + packageGroup.getName() + "' didn't match any packages.");
+ }
+ else {
+ printOpenTag(1, "packagegroup name=\"" + packageGroup.getName() + "\"");
+ Iterator groupedPackageIt = groupedPackages.iterator();
+ while (groupedPackageIt.hasNext()) {
+ PackageDoc groupedPackageDoc = (PackageDoc)groupedPackageIt.next();
+ printAtomTag(2, "package name=\"" + groupedPackageDoc.name() + "\"");
+ }
+ printCloseTag(1, "packagegroup");
+ }
+ }
+ packageGroups = null;
+ }
+
+ // Output information on all packages for which documentation
+ // has been made available via the Doclet API
+
+ println();
+ println(1, "<!-- Documentation for all packages -->");
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i<ilim; ++i) {
+ PackageDoc c = packages[i];
+ outputPackageDoc(c);
+ }
+ packages = null;
+
+ // Output brief summary on all classes for which documentation
+ // has been made available via the Doclet API.
+ //
+ // While this is redundant, it can speed up XSLT
+ // processing by orders of magnitude
+
+ println();
+ println(1, "<!-- Brief summary for all classes -->");
+ ClassDoc[] sumclasses = rootDoc.classes();
+ for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
+ ClassDoc c = sumclasses[i];
+ outputClassDocSummary(c);
+ }
+ sumclasses = null;
+
+ // Output closing tag, finish output stream
+
+ println();
+ printCloseTag(0, "rootdoc");
+
+ closeTargetFile();
+
+ createIndexByName();
+
+
+
+ // Output information on all classes for which documentation
+ // has been made available via the Doclet API
+
+ println();
+ println(1, "<!-- Documentation for all classes -->");
+ ClassDoc[] classes = rootDoc.classes();
+ String prevPackageName = null;
+ for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
+ ClassDoc c = classes[i];
+
+ if (isVerbose()) {
+ printNotice("Writing XML information for "+c.qualifiedName()+"...");
+ }
+ else {
+ String packageName = c.containingPackage().name();
+ if (null == prevPackageName || !packageName.equals(prevPackageName)) {
+ printNotice("Writing XML information for "+packageName+"...");
+ prevPackageName = packageName;
+ }
+ }
+
+ setTargetFile(c.qualifiedName().replace('/','.')+".xml");
+
+ println("<?xml version=\"1.0\"?>");
+ println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc.dtd\">");
+
+ outputClassDoc(c);
+
+ closeTargetFile();
+ }
+ classes = null;
+ }
+
+ // Copy DTD files to temporary directory
+
+ // FIXME: try to solve this via jar: URLs. but this will
+ // probably break libxmlj compatibility (?)
+
+ String[] resources = new String[] {
+ "gjdoc.dtd",
+ "gjdoc-alphaindex.dtd",
+ "dbcentx.mod",
+ "ent/iso-amsa.ent",
+ "ent/iso-amsb.ent",
+ "ent/iso-amsc.ent",
+ "ent/iso-amsn.ent",
+ "ent/iso-amso.ent",
+ "ent/iso-amsr.ent",
+ "ent/iso-box.ent",
+ "ent/iso-cyr1.ent",
+ "ent/iso-cyr2.ent",
+ "ent/iso-dia.ent",
+ "ent/iso-grk1.ent",
+ "ent/iso-grk2.ent",
+ "ent/iso-grk3.ent",
+ "ent/iso-grk4.ent",
+ "ent/iso-lat1.ent",
+ "ent/iso-lat2.ent",
+ "ent/iso-num.ent",
+ "ent/iso-pub.ent",
+ "ent/iso-tech.ent",
+ };
+
+ File tempDtdDirectory = new File(xmlTargetDirectory, "dtd");
+ File tempDtdEntDirectory = new File(tempDtdDirectory, "ent");
+
+ if ((tempDtdDirectory.exists() || tempDtdDirectory.mkdir())
+ && (tempDtdEntDirectory.exists() || tempDtdEntDirectory.mkdir())) {
+ for (int i = 0; i < resources.length; ++ i) {
+ copyResourceToFile("/dtd/" + resources[i],
+ new File(tempDtdDirectory, resources[i]));
+ }
+ }
+ else {
+ printError("Cannot create temporary directories for DTD data at " + tempDtdDirectory);
+ return false;
+ }
+
+ // Copy package data-dir directory
+
+ {
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i<ilim; ++i) {
+ PackageDoc c = packages[i];
+ if (c instanceof GjdocPackageDoc) {
+ copyPackageDataDir((GjdocPackageDoc)c);
+ }
+ }
+ }
+
+ // All information has been output. Apply stylesheet if given.
+
+ gnu.classpath.tools.gjdoc.Main.releaseRootDoc();
+
+ this.currentClass = null;
+ this.currentMember = null;
+ this.currentExecMember = null;
+
+ System.gc();
+
+ // From this point we are only operating on files, so we don't
+ // need this anymore and can free up some memory
+
+ for (Iterator it = targets.iterator(); it.hasNext(); ) {
+
+ TargetContext target = (TargetContext)it.next();
+
+ // We have XSLT postprocessing, run DocTranslet.
+
+ //DocTranslet docTranslet = DocTranslet.fromClasspath("/doctranslets/html/gjdoc.xsl");
+
+ //docTranslet.setOptions(docTransletOptions);
+
+ target.getDocTranslet().setOptions(docTransletOptions);
+
+ target.getDocTranslet().apply(xmlTargetDirectory,
+ target.getTargetDirectory(),
+ rootDoc);
+ }
+
+ // Done
+
+ targets = null;
+
+ System.gc();
+ Runtime.getRuntime().runFinalization();
+
+ return true;
+ }
+ catch (Exception e) {
+
+ // Something went wrong. Report to stderr and pass error to
+ // Javadoc Reporter
+
+ e.printStackTrace();
+ printError(e.toString());
+
+ Throwable rootCause = e.getCause();
+ if (null != rootCause) {
+ while (null != rootCause.getCause()) {
+ rootCause = rootCause.getCause();
+ }
+ System.err.println("Root cause:");
+ rootCause.printStackTrace();
+ }
+
+ return false;
+ }
+ finally {
+
+ // In any case, delete the working directory if we created one
+
+ if (null != workingDirectory) {
+
+ if (!deleteRecursive(workingDirectory)) {
+ printWarning("Could not delete temporary directory at "+workingDirectory);
+ }
+ }
+
+ printNotice("Done.");
+ }
+ }
+
+ /**
+ * Recursively delete the specified directory and its contents,
+ * like <code>rm -Rf directory</code>
+ *
+ * @return <code>true</code> on success
+ */
+ private static boolean deleteRecursive(File directory) {
+
+ boolean success = true;
+
+ File[] files = directory.listFiles();
+
+ for (int i=0, ilim=files.length; i<ilim; ++i) {
+
+ File file = files[i];
+
+ if (file.isDirectory()) {
+
+ success = deleteRecursive(file) && success;
+ }
+ else {
+
+ success = file.delete() && success;
+ }
+ }
+
+ return directory.delete() && success;
+ }
+
+ /**
+ * Prints a string to stdout and appends a newline. Convenience
+ * method.
+ */
+ protected void println(String str) {
+ out.println(str);
+ }
+
+ /**
+ * Prints a string to stdout without appending a newline.
+ * Convenience method.
+ */
+ protected void print(String str) {
+ out.print(str);
+ }
+
+ /**
+ * In standard mode, prints an empty line to stdout.
+ * In thight mode, nothing happens.
+ * Convenience method.
+ */
+ protected void println() {
+ if (!compress) {
+ out.println();
+ }
+ }
+
+ /**
+ * In standard mode, prints the given text indented to stdout and appends newline.
+ * In tight mode, doesn't print indentation or newlines.
+ */
+ protected void print(int indentLevel, String msg) {
+ if (compress) {
+ out.print(msg);
+ }
+ else {
+ StringBuffer indentation = new StringBuffer();
+ for (int i=0; i<indentLevel*indentStep; ++i) {
+ indentation.append(' ');
+ }
+ out.print(indentation+msg);
+ }
+ }
+
+ /**
+ * In tight mode, prints a message at a given indentation level.
+ * In standard mode, appends a newline in addition.
+ */
+ protected void println(int indentLevel, String msg) {
+ print(indentLevel, msg);
+ if (!compress) out.println();
+ }
+
+ /**
+ * Prints an atom tag at the given indentation level.
+ */
+ protected void printAtomTag(int level, String tag) {
+ println(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+"/>");
+ }
+
+ /**
+ * Prints an open tag at the given indentation level.
+ */
+ protected void printOpenTag(int level, String tag) {
+ printOpenTag(level, replaceCharsInTag(tag), true);
+ }
+
+ /**
+ * Prints an open tag at the given indentation level and
+ * conditionally appends a newline (if not in tight mode).
+ */
+ protected void printOpenTag(int level, String tag, boolean appendNewline) {
+ if (appendNewline && !compress) {
+ println(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ else {
+ print(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ }
+
+ /**
+ * Prints a close tag at the given indentation level.
+ */
+ protected void printCloseTag(int level, String tag) {
+ printCloseTag(level, tag, true);
+ }
+
+ /**
+ * Prints a close tag at the given indentation level and
+ * conditionally appends a newline (if not in tight mode).
+ */
+ protected void printCloseTag(int level, String tag, boolean appendNewline) {
+ if (appendNewline && !compress) {
+ println(level, "</"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ else {
+ print(level, "</"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ }
+
+ public static int optionLength(String option) {
+ if ("-d".equals(option)) return 2;
+ else if ("-fixhtml".equals(option)) return 1;
+ else if ("-compress".equals(option)) return 1;
+ else if ("-nohtmlwarn".equals(option)) return 1;
+ else if ("-noemailwarn".equals(option)) return 1;
+ else if ("-indentstep".equals(option)) return 2;
+ else if ("-xslsheet".equals(option)) return 2;
+ else if ("-xsltdriver".equals(option)) return 2;
+ else if ("-postprocess".equals(option)) return 2;
+ else if ("-genhtml".equals(option)) return 1;
+ else if ("-geninfo".equals(option)) return 1;
+ else if ("-gendocbook".equals(option)) return 1;
+ else if ("-xmlonly".equals(option)) return 1;
+ else if ("-bottomnote".equals(option)) return 2;
+ else if ("-workpath".equals(option)) return 2;
+ else if ("-title".equals(option)) return 2;
+ else if ("-tagletpath".equals(option)) return 2;
+ else if ("-taglet".equals(option)) return 2;
+ else if ("-authormail".equals(option)) return 2;
+ else if ("-mailmangledot".equals(option)) return 2;
+ else if ("-mailmangleat".equals(option)) return 2;
+ else if ("-noindex".equals(option)) return 1;
+ else if ("-nocomment".equals(option)) return 1;
+ else if ("-notree".equals(option)) return 1;
+ else if ("-nohelp".equals(option)) return 1;
+ else if ("-nonavbar".equals(option)) return 1;
+ else if ("-splitindex".equals(option)) return 1;
+ else if ("-author".equals(option)) return 1;
+ else if ("-version".equals(option)) return 1;
+ else if ("-nosince".equals(option)) return 1;
+ else if ("-nodeprecated".equals(option)) return 1;
+ else if ("-linksource".equals(option)) return 1;
+ else if ("-windowtitle".equals(option)) return 2;
+ else if ("-helpfile".equals(option)) return 2;
+ else if ("-stylesheetfile".equals(option)) return 2;
+ else if ("-tag".equals(option)) return 2;
+ else if ("-header".equals(option)) return 2;
+ else if ("-footer".equals(option)) return 2;
+ else if ("-bottom".equals(option)) return 2;
+ else if ("-doctitle".equals(option)) return 2;
+ else if ("-nodeprecatedlist".equals(option)) return 1;
+ else if ("-uses".equals(option)) return 1;
+ else if ("-group".equals(option)) return 3;
+
+ else return -1;
+ }
+
+ public static boolean validOptions(String[][] options) {
+ return true;
+ }
+
+
+ /**
+ * Workaround for non well-formed comments: fix tag contents
+ * by replacing <code>&lt;</code> with <code>&amp;lt;</code>,
+ * <code>&gt;</code> with <code>&amp;gt;</code> and
+ * <code>&amp;</code> with <code>&amp;amp;</code>.
+ *
+ * @param tagContent String to process
+ *
+ * @return given String with all special characters replaced by
+ * HTML entities.
+ */
+ private static String replaceCharsInTag(String tagContent) {
+ return
+ replaceString(
+ replaceString(
+ replaceString(
+ tagContent,
+ "<", "&lt;"
+ ),
+ ">", "&gt;"
+ ),
+ "&", "&amp;"
+ );
+ }
+
+ /**
+ * Replaces all occurences of string <code>needle</code> within string
+ * <code>haystack</code> by string <code>replacement</code>.
+ *
+ * @param haystack The string to search and replace in.
+ * @param needle The string which is searched for.
+ * @param replacement The string by which every occurence of <code>needle</code> is replaced.
+ */
+ private static String replaceString(String haystack, String needle, String replacement) {
+ int ndx = haystack.indexOf(needle);
+ if (ndx<0)
+ return haystack;
+ else
+ return haystack.substring(0, ndx) + replacement
+ + replaceString(haystack.substring(ndx+needle.length()), needle, replacement);
+ }
+
+ protected void setTargetFile(String filename) throws IOException {
+
+ OutputStream fileOut = new FileOutputStream(new File(xmlTargetDirectory, filename));
+ out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fileOut, "UTF8")));;
+ }
+
+ protected void closeTargetFile() {
+
+ out.flush();
+ out.close();
+ }
+
+ private String cdata(String str) {
+
+ if (null==str) {
+ return str;
+ } // end of if ((null==str)
+
+ StringBuffer rc = new StringBuffer();
+ for (int i=0; i<str.length(); ++i) {
+ char c = str.charAt(i);
+ if (c==0x09 || c==0x0a || c==0x0d || (c>=0x20 && c<=0xd7ff) || (c>=0xe000 && c<=0xfffd) || (c>=0x10000 && c<=0x10ffff)) {
+ rc.append(c);
+ }
+ else {
+ printWarning("Invalid Unicode character 0x"+Integer.toString(c, 16)+" in javadoc markup has been stripped.");
+ } // end of else
+
+ }
+ return rc.toString();
+ }
+
+ static void copyResourceToFile(String resourceName, File target) throws IOException {
+
+ InputStream in = Driver.class.getResourceAsStream(resourceName);
+
+ if (null != in) {
+
+ FileOutputStream out = new FileOutputStream(target);
+ int size;
+ byte[] buffer = new byte[512];
+ while ((size = in.read(buffer)) >= 0) {
+ out.write(buffer, 0, size);
+ }
+ out.close();
+ }
+ else {
+
+ throw new IOException("Can't find resource named "+resourceName);
+ }
+ }
+
+ private void printError(String error) {
+ if (null != rootDoc) {
+ rootDoc.printError(error);
+ }
+ else {
+ System.err.println("ERROR: "+error);
+ }
+ }
+
+ private void printWarning(String warning) {
+ if (null != rootDoc) {
+ rootDoc.printWarning(warning);
+ }
+ else {
+ System.err.println("WARNING: "+warning);
+ }
+ }
+
+ private void printNotice(String notice) {
+ if (null != rootDoc) {
+ rootDoc.printNotice(notice);
+ }
+ else {
+ System.err.println(notice);
+ }
+ }
+
+ /**
+ * Copy the contents of the input directory to the output
+ * directory. The output directory must exist.
+ */
+ private void copyPackageDataDir(GjdocPackageDoc packageDoc) throws IOException {
+ File docFilesSourceDirectory
+ = new File(packageDoc.packageDirectory(), "doc-files");
+ File docFilesTargetDirectory
+ = new File(this.targetDirectory,
+ packageDoc.name().replace('.', File.separatorChar));
+ if (docFilesSourceDirectory.exists()) {
+ printNotice("Copying files from " + docFilesSourceDirectory);
+ copyDirectory(docFilesSourceDirectory, docFilesTargetDirectory,
+ docFilesSubdirsEnabled,
+ excludeDocFilesSubDirs);
+ }
+ }
+
+ /**
+ * Recursively copy the contents of the input directory to the
+ * output directory. The output directory must exist.
+ */
+ private static void copyDirectory(File sourceDir, File targetDir,
+ boolean recursive,
+ Set excludeDirs) throws IOException {
+ if (!targetDir.exists() && !targetDir.mkdirs()) {
+ throw new IOException("Cannot create directory " + targetDir);
+ }
+
+ File[] sourceFiles = sourceDir.listFiles();
+ for (int i=0; i<sourceFiles.length; ++i) {
+ if (sourceFiles[i].isDirectory()) {
+ if (recursive && (null == excludeDirs
+ || !excludeDirs.contains(sourceFiles[i].getName()))) {
+ File targetSubDir = new File(targetDir,
+ sourceFiles[i].getName());
+ if (targetSubDir.exists() || targetSubDir.mkdir()) {
+ copyDirectory(sourceFiles[i], targetSubDir, recursive, null);
+ }
+ else {
+ throw new IOException("Cannot create directory " + targetSubDir);
+ }
+ }
+ }
+ else {
+ copyFile(sourceFiles[i], new File(targetDir, sourceFiles[i].getName()));
+ }
+ }
+ }
+
+ /**
+ * Copy the contents of the input file to the output file. The
+ * output file's parent directory must exist.
+ */
+ private static void copyFile(File sourceFile, File targetFile) throws IOException {
+
+ InputStream in = new FileInputStream(sourceFile);
+ OutputStream out = new FileOutputStream(targetFile);
+ int nread;
+ byte[] buf = new byte[512];
+ while ((nread = in.read(buf)) >= 0) {
+ out.write(buf, 0, nread);
+ }
+ in.close();
+ out.close();
+ }
+
+ private void createIndexByName() throws IOException {
+ // Create index
+
+ // Collect index
+
+ Map indexMap = new TreeMap(new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return o1.toString().toLowerCase().compareTo(o2.toString().toLowerCase());
+ }
+ });
+
+ // Add packages to index
+
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i<ilim; ++i) {
+ PackageDoc c = packages[i];
+ indexMap.put(c.name(), c);
+ }
+
+ // Add classes, fields and methods to index
+
+ ClassDoc[] sumclasses = rootDoc.classes();
+ for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
+ ClassDoc c = sumclasses[i];
+ if (null == c.containingClass()) {
+ indexMap.put(c.name(), c);
+ }
+ else {
+ indexMap.put(c.name().substring(c.containingClass().name().length() + 1), c);
+ }
+ FieldDoc[] fields = c.fields();
+ for (int j=0, jlim=fields.length; j<jlim; ++j) {
+ indexMap.put(fields[j].name(), fields[j]);
+ }
+ MethodDoc[] methods = c.methods();
+ for (int j=0, jlim=methods.length; j<jlim; ++j) {
+ MethodDoc method = methods[j];
+ StringBuffer signature = new StringBuffer();
+ signature.append(method.name());
+ signature.append('(');
+ Parameter[] parameters = method.parameters();
+ for (int k=0, klim=parameters.length; k<klim; ++k) {
+ if (k > 0) {
+ signature.append(", ");
+ }
+ signature.append(parameters[k].typeName());
+ }
+ signature.append(')');
+ indexMap.put(signature.toString(), method);
+ }
+ }
+
+ // Assign output stream
+
+ setTargetFile("alphaindex.xml");
+
+ // Output XML document header
+
+ println(0, "<?xml version=\"1.0\"?>");
+ println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc-alphaindex.dtd\">");
+ println();
+ printOpenTag(0, "alphaindex xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:gjdoc=\"http://www.gnu.org/software/cp-tools/gjdocxml\"");
+
+ Iterator it = indexMap.keySet().iterator();
+
+ char previousCategoryLetter = '\0';
+ boolean categoryOpen = false;
+
+ while (it.hasNext()) {
+ String key = (String)it.next();
+ Doc entry = (Doc)indexMap.get(key);
+
+ char firstChar = Character.toUpperCase(key.charAt(0));
+ if (firstChar != previousCategoryLetter) {
+ if (categoryOpen) {
+ printCloseTag(1, "category");
+ }
+ printOpenTag(1, "category letter=\"" + firstChar + "\"");
+ categoryOpen = true;
+ previousCategoryLetter = firstChar;
+ }
+
+ printOpenTag(2, "entry name=\"" + key + "\"");
+ if (entry instanceof PackageDoc) {
+ printAtomTag(3, "isPackage");
+ }
+ else if (entry instanceof ClassDoc) {
+ printAtomTag(3, "isClass");
+ ClassDoc centry = (ClassDoc)entry;
+ currentClass = centry;
+ printAtomTag(3, "containingPackage name=\"" + centry.containingPackage().name() + "\"");
+ if (null != centry.containingClass()) {
+ printAtomTag(3, "containingClass name=\"" + centry.containingClass().name() + "\"");
+ }
+ if (centry.isInterface()) {
+ printAtomTag(3, "isInterface");
+ }
+ if (centry.isException()) {
+ printAtomTag(3, "isException");
+ }
+ if (centry.isError()) {
+ printAtomTag(3, "isError");
+ }
+ if (centry.isOrdinaryClass()) {
+ printAtomTag(3, "isOrdinaryClass");
+ }
+ }
+ else if (entry instanceof ProgramElementDoc) {
+ ProgramElementDoc pentry = (ProgramElementDoc)entry;
+ currentClass = pentry.containingClass();
+ printAtomTag(3, "containingPackage name=\"" + pentry.containingPackage().name() + "\"");
+ printAtomTag(3, "containingClass name=\"" + pentry.containingClass().name() + "\"");
+ if (pentry.isMethod()) {
+ printAtomTag(3, "isMethod");
+ ExecutableMemberDoc mentry = (ExecutableMemberDoc)pentry;
+ printAtomTag(3, "signature full=\""+mentry.signature()+"\" flat=\""+mentry.flatSignature()+"\"");
+ printAtomTag(3, "method name=\"" + mentry.name() + "\"");
+ }
+ if (pentry.isField()) {
+ printAtomTag(3, "isField");
+ }
+ }
+
+ Tag[] tags = entry.firstSentenceTags();
+ for (int i=0, ilim=tags.length; i<ilim; ++i) {
+ Tag tag = tags[i];
+ if (tag.firstSentenceTags().length>0) {
+ printOpenTag(3, "firstSentenceTags", false);
+ outputTags(4, tag.firstSentenceTags(), false, CONTEXT_TYPE);
+ printCloseTag(3, "firstSentenceTags");
+ }
+ }
+
+
+ printCloseTag(2, "entry");
+ }
+
+ if (categoryOpen) {
+ printCloseTag(1, "category");
+ }
+
+ printCloseTag(0, "alphaindex");
+
+ closeTargetFile();
+ }
+
+ private static class UsageType
+ {
+ public static final UsageType CLASS_DERIVED_FROM = new UsageType("class-derived-from");
+ public static final UsageType FIELD_OF_TYPE = new UsageType("field-of-type");
+ public static final UsageType METHOD_WITH_RETURN_TYPE = new UsageType("method-with-return-type");
+ public static final UsageType METHOD_WITH_PARAMETER_TYPE = new UsageType("method-with-parameter-type");
+ public static final UsageType METHOD_WITH_THROWN_TYPE = new UsageType("method-with-thrown-type");
+ public static final UsageType CONSTRUCTOR_WITH_PARAMETER_TYPE = new UsageType("constructor-with-parameter-type");
+ public static final UsageType CONSTRUCTOR_WITH_THROWN_TYPE = new UsageType("constructor-with-thrown-type");
+ private String id;
+
+ private UsageType(String id)
+ {
+ this.id = id;
+ }
+
+ public String toString() {
+ return "UsageType{id=" + id + "}";
+ }
+
+ public String getId() {
+ return id;
+ }
+ }
+
+ /**
+ * ClassDoc -> (PackageDoc -> (UsageType -> (Set of Doc)))
+ */
+ private Map usedClassToPackagesMap = new HashMap();
+
+ private void addUsedBy(ClassDoc usedClass, UsageType usageType, Doc user, PackageDoc userPackage)
+ {
+ Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(usedClass);
+ if (null == packageToUsageTypeMap) {
+ packageToUsageTypeMap = new HashMap();
+ usedClassToPackagesMap.put(usedClass, packageToUsageTypeMap);
+ }
+
+ Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(userPackage);
+ if (null == usageTypeToUsersMap) {
+ usageTypeToUsersMap = new HashMap();
+ packageToUsageTypeMap.put(userPackage, usageTypeToUsersMap);
+ }
+
+ Set userSet = (Set)usageTypeToUsersMap.get(usageType);
+ if (null == userSet) {
+ userSet = new TreeSet(); // FIXME: we need the collator from Main here
+ usageTypeToUsersMap.put(usageType, userSet);
+ }
+ userSet.add(user);
+ }
+
+ /**
+ * Create the cross reference database.
+ */
+ private void collectUsage() {
+
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
+ ClassDoc clazz = classes[i];
+
+ // classes derived from
+ for (ClassDoc superclass = clazz.superclass(); superclass != null;
+ superclass = superclass.superclass()) {
+ addUsedBy(superclass, UsageType.CLASS_DERIVED_FROM, clazz, clazz.containingPackage());
+ }
+
+ FieldDoc[] fields = clazz.fields();
+ for (int j = 0, jlim = fields.length; j < jlim; ++ j) {
+ FieldDoc field = fields[j];
+
+ // fields of type
+ ClassDoc fieldType = field.type().asClassDoc();
+ if (null != fieldType) {
+ addUsedBy(fieldType, UsageType.FIELD_OF_TYPE,
+ field, clazz.containingPackage());
+ }
+ }
+
+ MethodDoc[] methods = clazz.methods();
+ for (int j = 0, jlim = methods.length; j < jlim; ++ j) {
+ MethodDoc method = methods[j];
+
+ // methods with return type
+
+ ClassDoc returnType = method.returnType().asClassDoc();
+ if (null != returnType) {
+ addUsedBy(returnType, UsageType.METHOD_WITH_RETURN_TYPE,
+ method, clazz.containingPackage());
+ }
+ Parameter[] parameters = method.parameters();
+ for (int k=0; k<parameters.length; ++k) {
+
+ // methods with parameter type
+
+ Parameter parameter = parameters[k];
+ ClassDoc parameterType = parameter.type().asClassDoc();
+ if (null != parameterType) {
+ addUsedBy(parameterType, UsageType.METHOD_WITH_PARAMETER_TYPE,
+ method, clazz.containingPackage());
+ }
+ }
+
+ // methods which throw
+
+ ClassDoc[] thrownExceptions = method.thrownExceptions();
+ for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
+ ClassDoc thrownException = thrownExceptions[k];
+ addUsedBy(thrownException, UsageType.METHOD_WITH_THROWN_TYPE,
+ method, clazz.containingPackage());
+ }
+ }
+
+ ConstructorDoc[] constructors = clazz.constructors();
+ for (int j = 0, jlim = constructors.length; j < jlim; ++ j) {
+
+ ConstructorDoc constructor = constructors[j];
+
+ Parameter[] parameters = constructor.parameters();
+ for (int k = 0, klim = parameters.length; k < klim; ++ k) {
+
+ // constructors with parameter type
+
+ Parameter parameter = parameters[k];
+ ClassDoc parameterType = parameter.type().asClassDoc();
+ if (null != parameterType) {
+ addUsedBy(parameterType, UsageType.CONSTRUCTOR_WITH_PARAMETER_TYPE,
+ constructor, clazz.containingPackage());
+ }
+ }
+
+ // constructors which throw
+
+ ClassDoc[] thrownExceptions = constructor.thrownExceptions();
+ for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
+ ClassDoc thrownException = thrownExceptions[k];
+ addUsedBy(thrownException, UsageType.CONSTRUCTOR_WITH_THROWN_TYPE,
+ constructor, clazz.containingPackage());
+ }
+ }
+ }
+ }
+
+ private void outputUsage(ClassDoc clazz, int level) {
+
+ Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(clazz);
+ if (null != packageToUsageTypeMap) {
+ printOpenTag(level, "references");
+
+ Iterator packagesIterator = packageToUsageTypeMap.keySet().iterator();
+
+ while (packagesIterator.hasNext()) {
+ PackageDoc packageDoc = (PackageDoc)packagesIterator.next();
+ printOpenTag(level + 1, "referencing-package name=\"" + packageDoc.name() + "\"");
+ Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(packageDoc);
+ Iterator usageTypeIterator = usageTypeToUsersMap.keySet().iterator();
+ while (usageTypeIterator.hasNext()) {
+ UsageType usageType = (UsageType)usageTypeIterator.next();
+ printOpenTag(level + 2, "usage-type id=\"" + usageType.getId() + "\"");
+ Set users = (Set)usageTypeToUsersMap.get(usageType);
+ Iterator userIterator = users.iterator();
+ while (userIterator.hasNext()) {
+ Doc user = (Doc)userIterator.next();
+ if (user instanceof ClassDoc) {
+ printAtomTag(level + 3, "user"
+ + " class=\"" + ((ClassDoc)user).name() + "\"");
+ }
+ else if (user instanceof FieldDoc) {
+ FieldDoc fieldDoc = (FieldDoc)user;
+ printAtomTag(level + 3, "user"
+ + " class=\"" + fieldDoc.containingClass().name() + "\""
+ + " field=\"" + fieldDoc.name() + "\"");
+ }
+ else if (user instanceof MethodDoc) {
+ MethodDoc methodDoc = (MethodDoc)user;
+ printAtomTag(level + 3, "user"
+ + " class=\"" + methodDoc.containingClass().name() + "\""
+ + " method=\"" + methodDoc.name() + "\""
+ + " signature=\"" + methodDoc.signature() + "\""
+ + " flatSignature=\"" + methodDoc.flatSignature() + "\"");
+ }
+ else if (user instanceof ConstructorDoc) {
+ ConstructorDoc constructorDoc = (ConstructorDoc)user;
+ printAtomTag(level + 3, "user"
+ + " class=\"" + constructorDoc.containingClass().name() + "\""
+ + " signature=\"" + constructorDoc.signature() + "\""
+ + " flatSignature=\"" + constructorDoc.flatSignature() + "\"");
+ }
+ }
+ printCloseTag(level +2, "usage-type");
+ }
+ printCloseTag(level + 1, "referencing-package");
+ }
+
+ printCloseTag(level, "references");
+ }
+ }
+
+ private boolean processGroupOption(String groupName, String colonSeparatedPackageList)
+ {
+ try {
+ PackageMatcher packageMatcher = new PackageMatcher();
+
+ StringTokenizer tokenizer = new StringTokenizer(colonSeparatedPackageList, ":");
+ while (tokenizer.hasMoreTokens()) {
+ String packageWildcard = tokenizer.nextToken();
+ packageMatcher.addWildcard(packageWildcard);
+ }
+
+ SortedSet groupPackages = packageMatcher.filter(rootDoc.specifiedPackages());
+
+ packageGroups.add(new PackageGroup(groupName, groupPackages));
+
+ return true;
+ }
+ catch (InvalidPackageWildcardException e) {
+ return false;
+ }
+ }
+
+ private void registerTaglet(Taglet taglet)
+ {
+ tagletMap.put(taglet.getName(), taglet);
+ }
+
+ private boolean isVerbose()
+ {
+ return false;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java
new file mode 100644
index 000000000..6744947af
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java
@@ -0,0 +1,84 @@
+/* gnu.classpath.tools.doclets.xmldoclet.Driver1_4
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import com.sun.javadoc.*;
+import java.io.IOException;
+
+/**
+ * A Doclet which retrieves all information presented by the Doclet
+ * API, dumping it to stdout in XML format.
+ *
+ * Supports Doclet API Version 1.4.
+ *
+ * @author Julian Scheid
+ */
+public class Driver1_4 extends Driver {
+
+ /**
+ * Official Doclet entry point.
+ */
+ public static boolean start(RootDoc root) {
+
+ // Create a new XmlDoclet instance and delegate control.
+ return new Driver1_4().instanceStart(root);
+ }
+
+ /* since 1.4
+ private void outputSourcePosition(int level, SourcePosition sourcePosition) {
+ println(level, "<sourceposition"
+ + " file=\""+sourcePosition.file().toString()+"\""
+ + " line=\""+sourcePosition.line()+"\""
+ + " column=\""+sourceposition.column()+"\""
+ + "/>");
+ }
+ */
+
+ protected void outputClassDoc(ClassDoc classDoc)
+ throws IOException
+ {
+ super.outputClassDoc(classDoc);
+ //outputSourcePosition(level, doc.position());
+ }
+
+ protected void outputFieldDocBody(int level, FieldDoc fieldDoc) {
+ super.outputFieldDocBody(level, fieldDoc);
+ //println(level, "<constantValueExpression>"+fieldDoc.constantValueExpression()+"</constantValueExpression>");
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java
new file mode 100644
index 000000000..582a45b32
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java
@@ -0,0 +1,690 @@
+/* gnu.classpath.tools.doclets.xmldoclet.HtmlRepairer.java
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import java.io.*;
+import java.util.*;
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.MemberDoc;
+
+/**
+ * Provides methods for tidying up HTML source.
+ *
+ * @author Julian Scheid
+ */
+public final class HtmlRepairer {
+
+ private static class TagInfo {
+
+ private Set parentTags = new HashSet();
+
+ public TagInfo(String parentTag) {
+ this.parentTags.add(parentTag);
+ }
+
+ public TagInfo(String[] parentTagArr) {
+ for (int i=0; i<parentTagArr.length; ++i) {
+ this.parentTags.add(parentTagArr[i]);
+ }
+ }
+
+ public boolean isLegalParentTag(String tag) {
+ return this.parentTags.contains(tag);
+ }
+ }
+
+ private DocErrorReporter warningReporter;
+ private boolean noWarn;
+ private boolean noEmailWarn;
+ private ClassDoc contextClass;
+ private MemberDoc contextMember;
+ private StringBuffer output = new StringBuffer();
+ private Stack tagStack = new Stack();
+ private boolean isLeadingTag = true;
+ private boolean throwAwayLeadingPara = false;
+
+ private static Map tagInfoMap;
+
+ private static Set noTextParentTags;
+
+ static {
+ tagInfoMap = new HashMap();
+ tagInfoMap.put("li", new TagInfo(new String[] { "ul", "ol", "nl", "menu", "dir" }));
+ tagInfoMap.put("td", new TagInfo(new String[] { "tr" }));
+ tagInfoMap.put("th", new TagInfo(new String[] { "tr" }));
+ tagInfoMap.put("tr", new TagInfo(new String[] { "table" }));
+ tagInfoMap.put("dt", new TagInfo(new String[] { "dl" }));
+ tagInfoMap.put("dd", new TagInfo(new String[] { "dl" }));
+ tagInfoMap.put("param", new TagInfo(new String[] { "applet" }));
+
+ String[] noTextParentTagArr = {
+ "area", "base", "body", "br", "dd", "dt", "head", "hr", "html",
+ "img", "input", "link", "map", "meta", "ol", "optgroup", "param",
+ "select", "table", "tbody", "tfoot", "thead", "tr", "ul",
+ };
+
+ noTextParentTags = new HashSet();
+ for (int i=0; i<noTextParentTagArr.length; ++i) {
+ noTextParentTags.add(noTextParentTagArr[i]);
+ }
+ }
+
+ public HtmlRepairer(DocErrorReporter warningReporter,
+ boolean noWarn, boolean noEmailWarn,
+ ClassDoc contextClass, MemberDoc contextMember,
+ boolean throwAwayLeadingPara) {
+ this.warningReporter = warningReporter;
+ this.noWarn = noWarn;
+ this.noEmailWarn = noEmailWarn;
+ this.contextClass = contextClass;
+ this.contextMember = contextMember;
+ this.throwAwayLeadingPara = throwAwayLeadingPara;
+ }
+
+ private static String replaceStr(String haystack, String needle, String replacement) {
+ int ndx=haystack.indexOf(needle);
+ if (ndx<0)
+ return haystack;
+ else
+ return haystack.substring(0, ndx)+replacement
+ + replaceStr(haystack.substring(ndx+needle.length()), needle, replacement);
+ }
+
+ private void haveText(String text) {
+
+ if (isLeadingTag && throwAwayLeadingPara) {
+ if (0 != text.trim().length()) {
+ isLeadingTag = false;
+ }
+ }
+
+ if (tagStack.isEmpty() || !noTextParentTags.contains(tagStack.peek())) {
+
+ text = replaceStr(text, "&lt1", "&lt;1");
+ text = replaceStr(text, "&&", "&amp;&amp;");
+ text = replaceStr(text, "& ", "&amp; ");
+ text = replaceStr(text, "&\t", "&amp;\t");
+ text = replaceStr(text, "&\r", "&amp;\r");
+ text = replaceStr(text, "&\n", "&amp;\n");
+ for (char c='0'; c<='9'; ++c)
+ text = replaceStr(text, "&"+c, "&amp;"+c);
+ text = replaceStr(text, "\u00a7", "&sect;");
+ output.append(text);
+ }
+ else {
+ printWarning("Discarded text in <" + tagStack.peek() + "> element");
+ }
+ }
+
+ private void haveStartOrEndTag(String tag) {
+
+ boolean _isLeadingTag = isLeadingTag;
+ isLeadingTag = false;
+
+ tag = tag.trim();
+
+ boolean isEndTag = tag.startsWith("/");
+ boolean isAtomTag = tag.endsWith("/");
+
+ if (isEndTag && isAtomTag) {
+ // got something like '</a/>' which is invalid.
+ // suppose a close tag was intended.
+ tag = tag.substring(0, tag.length()-1);
+ }
+
+ if (tag.length() < 1) {
+ printWarning("Deleting broken tag");
+ return;
+ }
+
+ String tagName = tag.substring(isEndTag?1:0, isAtomTag?tag.length()-1:tag.length());
+ String tagAttributes = "";
+
+ for (int i=0; i<tagName.length(); ++i) {
+ if (" \t\r\n".indexOf(tagName.charAt(i))>=0) {
+ tagAttributes = tagName.substring(i).trim();
+ tagName = tagName.substring(0, i);
+ break;
+ }
+ }
+
+ if (!isEndTag && tagName.indexOf('@')>0) {
+ if (!noEmailWarn) {
+ printWarning("Tag looks like email address: <"+tagName+">");
+ }
+ output.append("&lt;"+tag+"&gt;");
+ return;
+ }
+
+ tagName = tagName.toLowerCase();
+
+ if (_isLeadingTag && "p".equals(tagName) && !isEndTag && throwAwayLeadingPara) {
+ return;
+ }
+
+ if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) {
+ // throw away </p> and </br>
+ if (isEndTag) {
+ return;
+ }
+ // make sure every <p> is a <p/> and every <br> is a <br/>
+ else if (!isAtomTag) {
+ tag += "/";
+ isAtomTag = true;
+ }
+ }
+
+ if (isEndTag) {
+
+ // check whether this close tag is on the stack
+ // if yes, close all tags up to this tag
+ if (tagStack.contains(tagName)) {
+ String popped;
+ do {
+ popped = (String)tagStack.pop();
+ if (!popped.equals(tagName))
+ printWarning("Inserting '</"+popped+">");
+ output.append("</"+popped+">");
+ }
+ while (!popped.equals(tagName));
+ }
+ // if not, just throw it away
+ else {
+ printWarning("Deleting <"+tag+">");
+ }
+ }
+ else {
+
+ final int STATE_INITIAL = 1;
+ final int STATE_EXPECT_ATTRIBUTENAME = 2;
+ final int STATE_UNQUOTED_ATTRIBUTEVALUE = 3;
+ final int STATE_SINGLEQUOTE_ATTRIBUTEVALUE = 4;
+ final int STATE_DOUBLEQUOTE_ATTRIBUTEVALUE = 5;
+ final int STATE_EXPECT_ATTRIBUTEVALUE = 6;
+ final int STATE_EXPECT_EQUALSIGN = 7;
+
+ int state = STATE_INITIAL;
+
+ String newAttributes = "";
+ String attributeName = null;
+ StringBuffer buf = new StringBuffer();
+
+ char[] attrsAsChars = tagAttributes.toCharArray();
+ for (int i=0, ilim=attrsAsChars.length+1; i<ilim; ++i) {
+ int c;
+ if (i<attrsAsChars.length)
+ c = (int)attrsAsChars[i];
+ else
+ c = -1;
+
+ switch (state) {
+
+ case STATE_INITIAL:
+ if (" \t\r\n".indexOf(c)>=0){
+ continue;
+ }
+ else if (-1==c) {
+ continue;
+ }
+ else {
+ state = STATE_EXPECT_ATTRIBUTENAME;
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_EXPECT_ATTRIBUTENAME:
+ if ('='==c) {
+ attributeName = buf.toString();
+ buf.setLength(0);
+ state = STATE_EXPECT_ATTRIBUTEVALUE;
+ }
+ else if (-1==c) {
+ attributeName = buf.toString();
+ buf.setLength(0);
+ printWarning("In Tag '"+tag+"':\nAttribute name without a value, inserting value =\""+attributeName+"\"");
+ }
+ else if (" \t\r\n".indexOf(c)>=0) {
+ state = STATE_EXPECT_EQUALSIGN;
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_EXPECT_EQUALSIGN:
+ if (" \t\r\n".indexOf(c)>=0){
+ continue;
+ }
+ else if ('='==c) {
+ state = STATE_EXPECT_ATTRIBUTEVALUE;
+ attributeName = buf.toString();
+ buf.setLength(0);
+ }
+ else {
+ attributeName = buf.toString();
+ buf.setLength(0);
+ printWarning("In Tag '"+tag+"':\nAttribute name without a value, inserting value =\""+attributeName+"\"");
+ newAttributes += " "+attributeName+"=\""+attributeName+"\"";
+ buf.append((char)c);
+ state = STATE_EXPECT_ATTRIBUTENAME;
+ }
+ break;
+
+ case STATE_EXPECT_ATTRIBUTEVALUE:
+ if (" \t\r\n".indexOf(c)>=0){
+ continue;
+ }
+ else if ('\"'==c) {
+ state = STATE_DOUBLEQUOTE_ATTRIBUTEVALUE;
+ }
+ else if ('\''==c) {
+ state = STATE_SINGLEQUOTE_ATTRIBUTEVALUE;
+ }
+ else {
+ state = STATE_UNQUOTED_ATTRIBUTEVALUE;
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_UNQUOTED_ATTRIBUTEVALUE:
+ if (-1==c || " \t\r\n".indexOf(c)>=0){
+ state = STATE_INITIAL;
+ newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_SINGLEQUOTE_ATTRIBUTEVALUE:
+ if ('\''==c) {
+ state = STATE_INITIAL;
+ newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_DOUBLEQUOTE_ATTRIBUTEVALUE:
+ if ('\"'==c) {
+ state = STATE_INITIAL;
+ newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+ }
+ }
+
+
+ if (!isAtomTag) {
+
+ // check whether this open tag is equal to the topmost
+ // entry on the stack; if yes, emit a close tag first
+
+ // corrects stuff like '<tr><td>...<td>...');
+ if (!tagStack.isEmpty() && tagStack.peek().equals(tagName)) {
+ printWarning("Inserting </"+tagName+">");
+ output.append("</"+tagName+">");
+ tagStack.pop();
+ }
+ else {
+ processKnownChildTags(tagName, tagStack, output);
+ }
+
+ // otherwise, we assume there are no close tags required
+ // before this open tag.
+ tagStack.push(tagName);
+
+ output.append("<"+tagName+newAttributes+">");
+ }
+ else {
+ output.append("<"+tagName+newAttributes+"/>");
+ }
+ }
+ }
+
+ private boolean processKnownChildTags(String tagName, Stack tagStack, StringBuffer output) {
+
+ TagInfo tagInfo = (TagInfo)tagInfoMap.get(tagName);
+ if (null != tagInfo) {
+
+ String parentTag = null;
+ for (Enumeration en = tagStack.elements(); en.hasMoreElements(); ) {
+ String tag = (String)en.nextElement();
+ if (tagInfo.isLegalParentTag(tag)) {
+ parentTag = tag;
+ break;
+ }
+ }
+ if (parentTag != null) {
+ while (((String)tagStack.peek()) != parentTag) {
+ String poppedTagName = (String)tagStack.pop();
+ output.append("</"+poppedTagName+">");
+ printWarning("Inserting </"+poppedTagName+">");
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void flush() {
+
+ // close all pending tags
+ while (!tagStack.isEmpty()) {
+ String tagName = (String)tagStack.pop();
+ printWarning("Inserting </"+tagName+">");
+ output.append("</"+tagName+">");
+ }
+ }
+
+ /**
+ * Takes HTML fragment and returns a well-formed XHTML
+ * equivalent.
+ *
+ * In the returned String, all tags are properly closed and
+ * nested.
+ *
+ * Currently, the returned String is not guaranteed to be
+ * well-formed. In particular there are no checks on the tag
+ * names, attribute names and entity names.
+ */
+ public String getWellformedHTML(String text) {
+
+ final int STATE_INITIAL = 1;
+ final int STATE_TAG_START = 2;
+ final int STATE_TAG = 3;
+ final int STATE_TAG_DOUBLEQUOTE = 4;
+ final int STATE_TAG_SINGLEQUOTE = 5;
+ final int STATE_AMP = 6;
+
+ int state = STATE_INITIAL;
+ output.setLength(0);
+
+
+ StringBuffer buf = new StringBuffer();
+ char[] textAsChars = text.toCharArray();
+
+ outer_loop:
+ for (int i=0, ilim=textAsChars.length+1; i<ilim; ++i) {
+ int c;
+
+ if (i<textAsChars.length) {
+ c = textAsChars[i];
+ }
+ else {
+ c = -1;
+ }
+
+ switch (state) {
+
+ case STATE_INITIAL:
+ if ('<'==c) {
+ state = STATE_TAG_START;
+ if (buf.length()>0) {
+ haveText(buf.toString());
+ buf.setLength(0);
+ }
+ }
+ else if ('>'==c) {
+ // assume this is a greater-than sign
+ buf.append("&gt;");
+ }
+ else if ('&'==c) {
+ state = STATE_AMP;
+ }
+ else if (-1==c) {
+ if (buf.length()>0) {
+ haveText(buf.toString());
+ buf.setLength(0);
+ }
+ continue;
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_AMP:
+ if ('<'==c) {
+ buf.append("&amp;");
+ state = STATE_TAG_START;
+ if (buf.length()>0) {
+ haveText(buf.toString());
+ buf.setLength(0);
+ }
+ }
+ else if ('>'==c) {
+ // assume this is a greater-than sign
+ buf.append("&amp;");
+ buf.append("&gt;");
+ state = STATE_INITIAL;
+ }
+ else if ('&'==c) {
+ buf.append("&amp;");
+ buf.append("&amp;");
+ state = STATE_INITIAL;
+ }
+ else if (-1==c) {
+ buf.append("&amp;");
+ haveText(buf.toString());
+ buf.setLength(0);
+ state = STATE_INITIAL;
+ continue;
+ }
+ else {
+ // peek forward and see whether this is a valid entity.
+ if ('#'==c) {
+ buf.append("&");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ continue outer_loop;
+ }
+ else if (Character.isLetter((char)c)) {
+ for (int i2=i+1; i2<ilim-1; i2++) {
+ if (';' == textAsChars[i2]) {
+ buf.append("&");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ continue outer_loop;
+ }
+ else if (!Character.isLetter((char)c)
+ && !Character.isDigit((char)c)
+ && ".-_:".indexOf((char)c) < 0
+ //&& !isCombiningChar(c) // FIXME
+ //&& !isExtender(c) // FIXME
+ ) {
+ break;
+ }
+ }
+ // not a valid entity declaration; assume &amp;
+ }
+ buf.append("&amp;");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ }
+
+ /*
+ else if ('#'==c || Character.isLetter((char)c)) {
+ buf.append("&");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ }
+ else {
+ buf.append("&amp;");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ }
+ */
+ break;
+
+ case STATE_TAG_START:
+ if (" \t\r\n".indexOf(c)>=0) {
+ //continue;
+
+ // new: assume this is a less-sign
+ haveText("&lt;"+c);
+ state = STATE_INITIAL;
+ }
+ else if ('/'==c) {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ else if ('<'==c) {
+ // assume this is a less-sign
+ haveText("&lt;&lt;");
+ state = STATE_INITIAL;
+ }
+ else if ('>'==c) {
+ // assume this is a less-sign
+ haveText("&lt;&gt;");
+ state = STATE_INITIAL;
+ }
+ //else if ('-'==c || '+'==c || '='==c || '\''==c || "0123456789".indexOf(c)>=0) {
+ else if (!Character.isLetter((char)c)) {
+ // assume this is a less-sign
+ haveText("&lt;"+(char)c);
+ state = STATE_INITIAL;
+ }
+ else {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ break;
+
+ case STATE_TAG:
+ if ('\"'==c) {
+ buf.append((char)c);
+ state = STATE_TAG_DOUBLEQUOTE;
+ }
+ else if ('\''==c) {
+ buf.append((char)c);
+ state = STATE_TAG_SINGLEQUOTE;
+ }
+ else if ('>'==c) {
+ state = STATE_INITIAL;
+ haveStartOrEndTag(buf.toString());
+ buf.setLength(0);
+ }
+ else if ('<'==c) {
+ // notify user, missing greater-than sign
+ haveStartOrEndTag(buf.toString());
+ buf.setLength(0);
+ }
+ else if (-1==c) {
+ printWarning("Unclosed tag at end-of-comment: <"+buf);
+ haveStartOrEndTag(buf.toString());
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_TAG_DOUBLEQUOTE:
+ if ('\"'==c) {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ else if (-1==c) {
+ printWarning("Unclosed attribute value at end-of-comment.");
+ haveStartOrEndTag(buf.toString()+"\"");
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_TAG_SINGLEQUOTE:
+ if ('\''==c) {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ else if (-1==c) {
+ printWarning("Unclosed attribute value at end-of-comment.");
+ haveStartOrEndTag(buf.toString()+"'");
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+ }
+ }
+
+ return output.toString();
+ }
+
+ private String getContext() {
+ if (null != contextClass) {
+ StringBuffer rc = new StringBuffer();
+ rc.append(contextClass.qualifiedTypeName());
+ if (null != contextMember) {
+ rc.append("."+contextMember.toString());
+ }
+ return rc.toString();
+ }
+ else {
+ return null;
+ }
+ }
+
+ private void printWarning(String msg) {
+ if (null != warningReporter && !noWarn) {
+ String context = getContext();
+ if (null != context) {
+ warningReporter.printWarning("In "+getContext()+": "+msg);
+ }
+ else {
+ warningReporter.printWarning("In overview page: "+msg);
+ }
+ }
+ }
+
+ public String terminateText() {
+ output.setLength(0);
+ flush();
+ return output.toString();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java
new file mode 100644
index 000000000..6e05a5e96
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java
@@ -0,0 +1,103 @@
+/* gnu.classpath.tools.doclets.xmldoclet.TargetContext
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import java.net.URL;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+
+import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet;
+
+/**
+ * Stores any XSL transformation and postprocessing-specific
+ * information given by the user on the doclet command line.
+ *
+ * @author Julian Scheid
+ */
+public class TargetContext {
+
+ /**
+ * The DocTranslet to use for processing doclet output.
+ */
+ private DocTranslet docTranslet;
+
+ /**
+ * Directory to write final output to.
+ */
+ private File targetDirectory;
+
+ /**
+ * Directory where XSLT output will be written to. If an XSLT
+ * sheet was specified, but no postprocessing driver was given,
+ * this is the target directory specified by the user. Otherwise,
+ * this is a temporary directory.
+ */
+ private File xsltTargetDirectory;
+
+
+ public TargetContext(DocTranslet docTranslet, File targetDirectory) {
+ this.docTranslet = docTranslet;
+ this.targetDirectory = targetDirectory;
+ }
+
+ public File getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ public void setTargetDirectory(File targetDirectory) {
+ this.targetDirectory = targetDirectory;
+ }
+
+ public DocTranslet getDocTranslet() {
+ return docTranslet;
+ }
+
+ public void setDocTranslet(DocTranslet docTranslet) {
+ this.docTranslet = docTranslet;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.java
new file mode 100644
index 000000000..c5a9f82b9
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.java
@@ -0,0 +1,460 @@
+/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
+
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.URIResolver;
+
+import javax.xml.transform.dom.DOMResult;
+
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.xml.sax.SAXException;
+
+import gnu.classpath.tools.IOToolkit;
+import gnu.classpath.tools.doclets.xmldoclet.Driver;
+
+import com.sun.javadoc.DocErrorReporter;
+
+public class DocTranslet implements ErrorListener {
+
+ private static class DocErrorReporterOutputStream
+ extends OutputStream
+ {
+ private ByteArrayOutputStream out = new ByteArrayOutputStream();
+ private DocErrorReporter reporter;
+
+ public DocErrorReporterOutputStream(DocErrorReporter reporter) {
+ this.reporter = reporter;
+ }
+
+ public void write(int ch) {
+ out.write(ch);
+ if (ch == 10) {
+ reporter.printNotice(out.toString());
+ out.reset();
+ }
+ }
+ }
+
+ private String mainResourceFilename;
+ private ClassLoader classLoader;
+ private Map transformerMap = new java.util.HashMap(); //WeakHashMap();
+ private DocTransletOptions options;
+
+ protected DocTranslet(String mainResourceFilename,
+ ClassLoader classLoader)
+ throws DocTransletConfigurationException {
+
+ if (mainResourceFilename.length() > 0 && mainResourceFilename.charAt(0) == '/') {
+ mainResourceFilename = mainResourceFilename.substring(1);
+ }
+ this.mainResourceFilename = mainResourceFilename;
+ this.classLoader = classLoader;
+ }
+
+ private static boolean equalsFile(File file1, File file2) {
+ return file1.getAbsolutePath().equals(file2.getAbsolutePath());
+ }
+
+ private static File getParentFile(File file) {
+ String filename = file.getAbsolutePath();
+ if (filename.endsWith(File.separator)) {
+ filename = filename.substring(0, filename.length() - 1);
+ }
+ int lastSlash = filename.lastIndexOf(File.separatorChar);
+ if (lastSlash > 0) {
+ filename = filename.substring(0, lastSlash);
+ }
+ else {
+ filename = File.separator;
+ }
+
+ return new File(filename);
+ }
+
+ private static boolean cacheXSLTSheets = true;
+
+ public void apply(File xmlSourceDirectory, File targetDirectory,
+ DocErrorReporter reporter)
+ throws DocTransletException {
+
+ PrintStream err = System.err;
+
+ try{
+ URL mainResourceURL = classLoader == null ?
+ ClassLoader.getSystemResource(mainResourceFilename):
+ classLoader.getResource(mainResourceFilename);
+
+ if (null == mainResourceURL) {
+ throw new DocTransletException("Cannot find resource '" + mainResourceFilename + "'");
+ }
+
+
+ Map parameters = new HashMap();
+ parameters.put("gjdoc.xmldoclet.version", Driver.XMLDOCLET_VERSION);
+
+ parameters.put("gjdoc.option.nonavbar", xsltBoolean(options.nonavbar));
+ parameters.put("gjdoc.option.noindex", xsltBoolean(options.noindex));
+ parameters.put("gjdoc.option.notree", xsltBoolean(options.notree));
+ parameters.put("gjdoc.option.nocomment", xsltBoolean(options.nocomment));
+ parameters.put("gjdoc.option.nohelp", xsltBoolean(options.nohelp));
+ parameters.put("gjdoc.option.splitindex", xsltBoolean(options.splitindex));
+ parameters.put("gjdoc.option.linksource", xsltBoolean(options.linksource));
+ parameters.put("gjdoc.option.nodeprecatedlist", xsltBoolean(options.nodeprecatedlist));
+ parameters.put("gjdoc.option.uses", xsltBoolean(options.uses));
+ parameters.put("gjdoc.option.windowtitle", options.windowtitle);
+ parameters.put("gjdoc.option.helpfile", options.helpfile);
+ parameters.put("gjdoc.option.stylesheetfile", options.stylesheetfile);
+ parameters.put("gjdoc.option.header", options.header);
+ parameters.put("gjdoc.option.footer", options.footer);
+ parameters.put("gjdoc.option.bottom", options.bottom);
+ parameters.put("gjdoc.option.doctitle", options.doctitle);
+
+ List outputFileList = getOutputFileList(mainResourceURL,
+ xmlSourceDirectory,
+ parameters);
+
+ reporter.printNotice("Running DocTranslet...");
+
+ TransformerFactory transformerFactory
+ = TransformerFactory.newInstance();
+
+ transformerFactory.setErrorListener(this);
+
+ boolean isLibxmlJ
+ = transformerFactory.getClass().getName().equals("gnu.xml.libxmlj.transform.TransformerFactoryImpl");
+
+ for (Iterator it = outputFileList.iterator(); it.hasNext(); ) {
+
+ if (isLibxmlJ) {
+ System.gc();
+ Runtime.getRuntime().runFinalization();
+ }
+
+ OutputFileInfo fileInfo = (OutputFileInfo)it.next();
+
+ File targetFile = new File(targetDirectory, fileInfo.getName());
+ File packageTargetDir = getParentFile(targetFile);
+
+ if (!packageTargetDir.exists() && !packageTargetDir.mkdirs()) {
+ throw new DocTransletException("Target directory " + packageTargetDir + " does not exist and cannot be created.");
+ }
+
+ if (options.linksource) {
+ File sourceTargetDirectory = new File(targetDirectory, "src-html");
+ File sourceTargetFile = new File(sourceTargetDirectory, fileInfo.getName());
+ File sourcePackageTargetDir = getParentFile(sourceTargetFile);
+
+ if (!sourcePackageTargetDir.exists() && !sourcePackageTargetDir.mkdirs()) {
+ throw new DocTransletException("Target directory " + packageTargetDir + " does not exist and cannot be created.");
+ }
+ }
+
+ if (options.uses) {
+ File usesTargetDirectory = new File(targetDirectory, "class-use");
+ File usesTargetFile = new File(usesTargetDirectory, fileInfo.getName());
+ File usesPackageTargetDir = getParentFile(usesTargetFile);
+
+ if (!usesPackageTargetDir.exists() && !usesPackageTargetDir.mkdirs()) {
+ throw new DocTransletException("Target directory " + packageTargetDir + " does not exist and cannot be created.");
+ }
+ }
+
+ if (null != fileInfo.getSource()) {
+
+ reporter.printNotice("Copying " + fileInfo.getComment() + "...");
+ InputStream in = new URL(mainResourceURL, fileInfo.getSource()).openStream();
+ FileOutputStream out = new FileOutputStream(targetFile.getAbsolutePath());
+ IOToolkit.copyStream(in, out);
+ in.close();
+ out.close();
+ }
+ else {
+
+ reporter.printNotice("Generating " + fileInfo.getComment() + "...");
+
+ String pathToRoot = "";
+ for (File file = getParentFile(targetFile); !equalsFile(file, targetDirectory); file = getParentFile(file)) {
+ pathToRoot += "../";
+ }
+
+ StreamResult out = new StreamResult(targetFile.getAbsolutePath());
+
+ StreamSource in = new StreamSource(new File(xmlSourceDirectory, "index.xml").getAbsolutePath());
+ URL resource = new URL(mainResourceURL, fileInfo.getSheet());
+
+
+ StreamSource xsltSource = new StreamSource(resource.toExternalForm());
+
+ if (null != fileInfo.getInfo()) {
+ parameters.put("gjdoc.outputfile.info", fileInfo.getInfo());
+ }
+ parameters.put("gjdoc.pathtoroot", pathToRoot);
+
+ Transformer transformer;
+ transformer = (Transformer)transformerMap.get(xsltSource.getSystemId());
+ if (null == transformer) {
+ transformer = transformerFactory.newTransformer(xsltSource);
+ if (cacheXSLTSheets) {
+ transformerMap.put(xsltSource.getSystemId(), transformer);
+ }
+ }
+
+ transformer.clearParameters();
+ for (Iterator pit = parameters.keySet().iterator(); pit.hasNext(); ) {
+ String key = (String)pit.next();
+ String value = (String)parameters.get(key);
+ transformer.setParameter(key, value);
+ }
+
+ transformer.setErrorListener(this);
+ DocErrorReporterOutputStream errorReporterOut
+ = new DocErrorReporterOutputStream(reporter);
+ System.setErr(new PrintStream(errorReporterOut));
+
+ transformer.transform(in, out);
+ errorReporterOut.flush();
+ }
+ }
+ }
+ catch (MalformedURLException e) {
+ throw new DocTransletException(e);
+ }
+ catch (TransformerFactoryConfigurationError e) {
+ throw new DocTransletException(e);
+ }
+ catch (TransformerException e) {
+ throw new DocTransletException(e.getMessageAndLocation(), e);
+ }
+ catch (IOException e) {
+ throw new DocTransletException(e);
+ }
+ finally {
+ System.setErr(err);
+ }
+ }
+
+ private List getOutputFileList(URL resource, File xmlSourceDirectory, Map parameters)
+ throws DocTransletException {
+
+ try {
+ List result;
+
+ OutputStream out = new ByteArrayOutputStream();
+
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document document = documentBuilder.newDocument();
+ DOMResult domResult = new DOMResult(document);
+ {
+ StreamSource source = new StreamSource(resource.toExternalForm());
+
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = (Transformer)transformerFactory.newTransformer(source);
+
+ transformer.clearParameters();
+ for (Iterator pit = parameters.keySet().iterator(); pit.hasNext(); ) {
+ String key = (String)pit.next();
+ String value = (String)parameters.get(key);
+ transformer.setParameter(key, value);
+ }
+
+ transformer.transform(new StreamSource(new File(xmlSourceDirectory,
+ "index.xml").getAbsolutePath()),
+ domResult);
+ }
+
+ {
+ NodeList nodeList = document.getElementsByTagName("outputfile");
+ result = new ArrayList(nodeList.getLength());
+
+ for (int i=0; i<nodeList.getLength(); ++i) {
+ Element elem = (Element)nodeList.item(i);
+ String name = getTextContent(elem.getElementsByTagName("name").item(0));
+ String source
+ = (null != elem.getElementsByTagName("source").item(0))
+ ? getTextContent(elem.getElementsByTagName("source").item(0))
+ : null;
+ String sheet
+ = (null != elem.getElementsByTagName("sheet").item(0))
+ ? getTextContent(elem.getElementsByTagName("sheet").item(0))
+ : null;
+ String comment = getTextContent(elem.getElementsByTagName("comment").item(0));
+ String info = null;
+ if (elem.getElementsByTagName("info").getLength() > 0) {
+ if (null != elem.getElementsByTagName("info").item(0).getFirstChild()) {
+ info = getTextContent(elem.getElementsByTagName("info").item(0));
+ }
+ else {
+ info = "";
+ }
+ }
+ result.add(new OutputFileInfo(name, source, sheet, comment, info));
+ }
+ }
+ return result;
+ }
+ catch (TransformerFactoryConfigurationError e) {
+ throw new DocTransletException(e);
+ }
+ catch (TransformerException e) {
+ throw new DocTransletException(e.getMessageAndLocation(), e);
+ }
+ catch (ParserConfigurationException e) {
+ throw new DocTransletException(e);
+ }
+ }
+
+ private String getTextContent(Node elem)
+ {
+ StringBuffer result = new StringBuffer();
+ NodeList children = elem.getChildNodes();
+ for (int i=0; i<children.getLength(); ++i) {
+ Node item = children.item(i);
+ if (null != item) {
+ String value = item.getNodeValue();
+ if (null != value) {
+ result.append(value);
+ }
+ }
+ }
+ return result.toString();
+ }
+
+ public void setOptions(DocTransletOptions options) {
+ this.options = options;
+ }
+
+
+ public static DocTranslet fromClasspath(String resourceName)
+ throws DocTransletConfigurationException {
+
+ return new DocTranslet(resourceName,
+ DocTranslet.class.getClassLoader());
+ }
+
+ public static DocTranslet fromJarFile(File jarFile)
+ throws DocTransletConfigurationException {
+
+ try {
+ JarFile inputJarFile = new JarFile(jarFile, false, JarFile.OPEN_READ);
+
+ Manifest manifest = inputJarFile.getManifest();
+
+ if (null == manifest) {
+
+ throw new DocTransletConfigurationException("Jar file '" + jarFile + "' doesn't contain a manifest.");
+ }
+
+ Attributes mainAttributes = manifest.getMainAttributes();
+
+ String docTransletMainEntry = mainAttributes.getValue("doctranslet-main-entry");
+
+ if (null == docTransletMainEntry) {
+
+ throw new DocTransletConfigurationException("Manifest in Jar file '" + jarFile + "' doesn't contain a doctranslet-main-entry specification.");
+ }
+
+ return new DocTranslet(docTransletMainEntry,
+ new JarClassLoader(inputJarFile));
+ }
+ catch (IOException e) {
+ throw new DocTransletConfigurationException(e);
+ }
+ }
+
+ private static String xsltBoolean(boolean b) {
+ return b ? "1" : "";
+ }
+
+ public void error (TransformerException exception)
+ throws TransformerException {
+
+ throw exception;
+ }
+
+ public void fatalError (TransformerException exception)
+ throws TransformerException {
+
+ throw exception;
+ }
+
+ public void warning (TransformerException exception)
+ throws TransformerException {
+
+ System.err.println("WWW: " + exception.getMessage());
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.java
new file mode 100644
index 000000000..092d0cea7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.java
@@ -0,0 +1,53 @@
+/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTransletConfigurationException
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
+
+public class DocTransletConfigurationException extends Exception {
+
+ public DocTransletConfigurationException(String msg) {
+ super(msg);
+ }
+
+ public DocTransletConfigurationException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public DocTransletConfigurationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.java
new file mode 100644
index 000000000..96ffefa0f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.java
@@ -0,0 +1,63 @@
+/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTransletException
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
+
+public class DocTransletException extends Exception {
+
+ public DocTransletException(String msg) {
+ super(msg);
+ }
+
+ private void initCauseDynamic(Throwable cause)
+ {
+ try {
+ getClass().getMethod("initCause", new Class[]{Throwable.class}).invoke(this, new Object[] { cause });
+ }
+ catch (Exception ignore) {
+ }
+ }
+
+ public DocTransletException(String msg, Throwable cause) {
+ super(msg);
+ initCauseDynamic(cause);
+ }
+
+ public DocTransletException(Throwable cause) {
+ initCauseDynamic(cause);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.java
new file mode 100644
index 000000000..5c99ec3bd
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.java
@@ -0,0 +1,62 @@
+/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTransletOptions
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
+
+/**
+ * Value class for carrying command line options which need to be
+ * passed through to the stylesheets.
+ */
+public class DocTransletOptions
+{
+ public boolean nonavbar;
+ public boolean noindex;
+ public boolean notree;
+ public boolean nocomment;
+ public boolean nohelp;
+ public boolean splitindex;
+ public boolean linksource;
+ public boolean nodeprecatedlist;
+ public boolean uses;
+ public String windowtitle = "";
+ public String helpfile = "";
+ public String stylesheetfile = "";
+ public String header = "";
+ public String footer = "";
+ public String bottom = "";
+ public String doctitle = "";
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.java
new file mode 100644
index 000000000..b7b100be1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.java
@@ -0,0 +1,91 @@
+/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.JarClassLoader
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+
+public class JarClassLoader extends ClassLoader {
+
+ private JarFile jarFile;
+
+ public JarClassLoader(JarFile jarFile) {
+ this.jarFile = jarFile;
+ }
+
+ public Class findClass(String name)
+ throws ClassNotFoundException {
+
+ byte[] b = loadClassData(name);
+ return defineClass(name, b, 0, b.length);
+ }
+
+ private byte[] loadClassData(String className)
+ throws ClassNotFoundException
+ {
+ String classFileName = className.replace('.', File.separatorChar) + ".class";
+
+ try {
+ JarEntry jarEntry = jarFile.getJarEntry(classFileName);
+ if (null != jarEntry) {
+ return readFromStream(jarFile.getInputStream(jarEntry),
+ jarEntry.getSize());
+ }
+ }
+ catch (IOException ignore_) {
+ }
+ throw new ClassNotFoundException(className);
+ }
+
+ private byte[] readFromStream(InputStream in, long size)
+ throws IOException
+ {
+ byte[] result = new byte[(int)size];
+ int nread = 0;
+ int offset = 0;
+ while (offset < size && (nread = in.read(result, offset, (int)(size - offset))) >= 0) {
+ offset += nread;
+ }
+ in.close();
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java
new file mode 100644
index 000000000..b0ede615d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java
@@ -0,0 +1,66 @@
+/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.OutputFileInfo
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
+
+/**
+ * Holds information about a file to be generated by the DocTranslet.
+ */
+public class OutputFileInfo {
+
+ private String name;
+ private String source;
+ private String sheet;
+ private String comment;
+ private String info;
+
+ public OutputFileInfo(String name, String source, String sheet, String comment, String info) {
+ this.name = name;
+ this.source = source;
+ this.sheet = sheet;
+ this.comment = comment;
+ this.info = info;
+ }
+
+ public String getName() { return name; }
+ public String getSource() { return source; }
+ public String getSheet() { return sheet; }
+ public String getComment() { return comment; }
+ public String getInfo() { return info; }
+
+ public String toString() { return "OutputFileInfo{name="+name+",source="+source+",sheet="+sheet+",comment="+comment+",info="+info+"}"; }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
new file mode 100644
index 000000000..53a4f3d1d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
@@ -0,0 +1,62 @@
+/* FileArgumentCallback.java - handle non-option command line arguments
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.getopt;
+
+/**
+ * This is a callback class which is used when a "file name" is found by the
+ * command-line parser. A file name is any command-line argument which does not
+ * start with a dash and which is not the argument of some preceding option.
+ */
+public abstract class FileArgumentCallback
+{
+ /**
+ * Create a new instance.
+ */
+ protected FileArgumentCallback()
+ {
+ }
+
+ /**
+ * This is called when a file argument is seen.
+ *
+ * @param fileArgument the file name
+ */
+ public abstract void notifyFile(String fileArgument)
+ throws OptionException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java
new file mode 100644
index 000000000..19f101743
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- i18n support for getopt
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.getopt;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.getopt.Messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java
new file mode 100644
index 000000000..e7b5d82e7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java
@@ -0,0 +1,266 @@
+/* Option.java - represent a command-line option
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.getopt;
+
+/**
+ * This is the base class representing an option. An option can have a short
+ * form. This is a single character, like '-x'. An option can have a long form,
+ * like '--verbose'; if the parser is working in "long option only" mode, then a
+ * long flag has a single dash, like '-verbose'. Both a long and a short form
+ * may be specified; it is not valid to have neither. A description is mandatory
+ * for options; this is used to automatically generate '--help' output. An option
+ * which takes an argument and which has a short form can also be "joined", in
+ * this case the option's argument can either be separated, like "-I path" or
+ * joined with the short option name, like "-Ipath".
+ */
+public abstract class Option
+{
+ private char shortName;
+
+ private String longName;
+
+ private String description;
+
+ private String argumentName;
+
+ private boolean joined;
+
+ /**
+ * Create a new option with the given short name and description.
+ *
+ * @param shortName the short name
+ * @param description the description
+ */
+ protected Option(char shortName, String description)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.description = description;
+ }
+
+ /**
+ * Create a new option with the given short name and description.
+ *
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ */
+ protected Option(char shortName, String description, String argumentName)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.description = description;
+ this.argumentName = argumentName;
+ }
+
+ /**
+ * Create a new option with the given short name and description.
+ *
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ * @param joined true if the short option is joined to its argument
+ */
+ protected Option(char shortName, String description, String argumentName,
+ boolean joined)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.description = description;
+ this.argumentName = argumentName;
+ this.joined = joined;
+ }
+
+ /**
+ * Create a new option with the given long name and description. The long name
+ * should be specified without any leading dashes.
+ *
+ * @param longName the long name
+ * @param description the description
+ */
+ protected Option(String longName, String description)
+ {
+ this.longName = longName;
+ this.description = description;
+ }
+
+ /**
+ * Create a new option with the given long name and description. The long name
+ * should be specified without any leading dashes.
+ *
+ * @param longName the long name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ */
+ protected Option(String longName, String description, String argumentName)
+ {
+ this.longName = longName;
+ this.description = description;
+ this.argumentName = argumentName;
+ }
+
+ /**
+ * Create a new option with the given short and long names and description.
+ * The long name should be specified without any leading dashes.
+ *
+ * @param longName the long name
+ * @param shortName the short name
+ * @param description the description
+ */
+ protected Option(String longName, char shortName, String description)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.longName = longName;
+ this.description = description;
+ }
+
+ /**
+ * Create a new option with the given short and long names and description.
+ * The long name should be specified without any leading dashes.
+ *
+ * @param longName the long name
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ */
+ protected Option(String longName, char shortName, String description,
+ String argumentName)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.longName = longName;
+ this.argumentName = argumentName;
+ this.description = description;
+ }
+
+ /**
+ * Create a new option with the given short and long names and description.
+ * The long name should be specified without any leading dashes.
+ *
+ * @param longName the long name
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ * @param joined true if the short option is joined to its argument
+ */
+ protected Option(String longName, char shortName, String description,
+ String argumentName, boolean joined)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.longName = longName;
+ this.argumentName = argumentName;
+ this.description = description;
+ this.joined = joined;
+ }
+
+ /**
+ * Return the short name of the option, or \0 if none.
+ */
+ public char getShortName()
+ {
+ return shortName;
+ }
+
+ /**
+ * Return the long name of the option, or null if none.
+ */
+ public String getLongName()
+ {
+ return longName;
+ }
+
+ /**
+ * Return true if the argument takes an option.
+ */
+ public boolean getTakesArgument()
+ {
+ return argumentName != null;
+ }
+
+ /**
+ * Return the name of the argument. If the option does not take an argument,
+ * returns null.
+ */
+ public String getArgumentName()
+ {
+ return argumentName;
+ }
+
+ /**
+ * Return the description of the option.
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Return true if this is a "joined" option, false otherwise.
+ * Only the short form of an option can be joined; this will always
+ * return false for an option which does not have a short form.
+ */
+ public boolean isJoined()
+ {
+ return joined;
+ }
+
+ /**
+ * This is called by the parser when this option is recognized. It may be
+ * called multiple times during a single parse. If this option takes an
+ * argument, the argument will be passed in. Otherwise the argument will be
+ * null.
+ *
+ * @param argument the argument
+ * @throws OptionException if the option or its argument is somehow invalid
+ */
+ public abstract void parsed(String argument) throws OptionException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java
new file mode 100644
index 000000000..2d7f77a55
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java
@@ -0,0 +1,58 @@
+/* OptionException.java - when command-line processing fails
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.getopt;
+
+/**
+ * An OptionException is thrown internally when an error is seen when parsing a
+ * command line.
+ */
+public class OptionException
+ extends Exception
+{
+ public OptionException(String message)
+ {
+ super(message);
+ }
+
+ public OptionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java
new file mode 100644
index 000000000..83fcca0f8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java
@@ -0,0 +1,268 @@
+/* OptionGroup.java - a group of related command-line options
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.getopt;
+
+import java.io.PrintStream;
+import java.text.BreakIterator;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+
+/**
+ * An option group holds a collection of Options. It also has a name. Option
+ * groups are primarily useful for grouping help output.
+ */
+public class OptionGroup
+{
+ /** An 80-character string of whitespaces to use as a source for padding. */
+ private static final String FILLER = " "
+ + " ";
+ private String name;
+
+ ArrayList options = new ArrayList();
+
+ /**
+ * Create a new nameless option group. This can only be used by Parser.
+ */
+ OptionGroup()
+ {
+ }
+
+ /**
+ * Create a new option group with the indicated name.
+ *
+ * @param name the name
+ */
+ public OptionGroup(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Print a designated text to a {@link PrintStream}, eventually wrapping the
+ * lines of text so as to ensure that the width of each line does not overflow
+ * {@link Parser#MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+ * {@link BreakIterator} using the default {@link Locale}.
+ * <p>
+ * The text to print may contain <code>\n</code> characters. This method will
+ * force a line-break for each such character.
+ *
+ * @param out the {@link PrintStream} destination of the formatted text.
+ * @param text the text to print.
+ * @param leftMargin a positive value indicating the column position of the
+ * start of the first line. Continuation lines, if they exist, are
+ * printed starting at <code>leftMargin + 2</code> as per GNU
+ * convention.
+ * @see Parser#MAX_LINE_LENGTH
+ */
+ protected static void formatText(PrintStream out, String text, int leftMargin)
+ {
+ formatText(out, text, leftMargin, Locale.getDefault());
+ }
+
+ /**
+ * Similar to the method with the same name and three arguments, except that
+ * the caller MUST specify a non-null {@link Locale} instance.
+ * <p>
+ * Print a designated text to a {@link PrintStream}, eventually wrapping the
+ * lines of text so as to ensure that the width of each line does not overflow
+ * {@link Parser#MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+ * {@link BreakIterator} using the designated {@link Locale}.
+ * <p>
+ * The text to print may contain <code>\n</code> characters. This method will
+ * force a line-break for each such character.
+ *
+ * @param out the {@link PrintStream} destination of the formatted text.
+ * @param text the text to print.
+ * @param leftMargin a positive value indicating the column position of the
+ * start of the first line. Continuation lines, if they exist, are
+ * printed starting at <code>leftMargin + 2</code> as per GNU
+ * convention.
+ * @param aLocale the {@link Locale} instance to use when constructing the
+ * {@link BreakIterator}.
+ * @see Parser#MAX_LINE_LENGTH
+ */
+ protected static void formatText(PrintStream out, String text, int leftMargin,
+ Locale aLocale)
+ {
+ BreakIterator bit = BreakIterator.getLineInstance(aLocale);
+ String[] lines = text.split("\n");
+ int length = leftMargin;
+ String leftPadding = FILLER.substring(0, leftMargin + 2);
+ for (int i = 0; i < lines.length; i++)
+ {
+ text = lines[i];
+ bit.setText(text);
+ int start = bit.first();
+ int finish;
+ while ((finish = bit.next()) != BreakIterator.DONE)
+ {
+ String word = text.substring(start, finish);
+ length += word.length();
+ if (length >= Parser.MAX_LINE_LENGTH)
+ {
+ out.println();
+ out.print(leftPadding);
+ length = word.length() + leftMargin + 2;
+ }
+ out.print(word);
+ start = finish;
+ }
+ out.println();
+ if (i != lines.length - 1)
+ {
+ length = leftMargin + 2;
+ out.print(leftPadding);
+ }
+ }
+ }
+
+ /**
+ * Add an option to this option group.
+ *
+ * @param opt the option to add
+ */
+ public void add(Option opt)
+ {
+ options.add(opt);
+ }
+
+ /**
+ * Print the help output for this option group.
+ *
+ * @param out the stream to which to print
+ */
+ public void printHelp(PrintStream out, boolean longOnly)
+ {
+ // Compute maximum lengths.
+ int maxArgLen = 0;
+ boolean shortOptionSeen = false;
+ Iterator it;
+
+ // The first pass only looks to see if we have a short option.
+ it = options.iterator();
+ while (it.hasNext())
+ {
+ Option option = (Option) it.next();
+ if (option.getShortName() != '\0')
+ {
+ shortOptionSeen = true;
+ break;
+ }
+ }
+
+ it = options.iterator();
+ while (it.hasNext())
+ {
+ Option option = (Option) it.next();
+ String argName = option.getArgumentName();
+ // First compute the width required for the short
+ // option. "2" is the initial indentation. In the
+ // GNU style we don't print an argument name for
+ // a short option if there is also a long name for
+ // the option.
+ int thisArgLen = 2;
+ if (shortOptionSeen)
+ thisArgLen += 4;
+ if (option.getLongName() != null)
+ {
+ // Handle either '-' or '--'.
+ thisArgLen += 1 + option.getLongName().length();
+ if (! longOnly)
+ ++thisArgLen;
+ }
+ // Add in the width of the argument name.
+ if (argName != null)
+ thisArgLen += 1 + argName.length();
+ maxArgLen = Math.max(maxArgLen, thisArgLen);
+ }
+
+ // Print the help.
+ if (name != null)
+ out.println(name + ":");
+ it = options.iterator();
+ while (it.hasNext())
+ {
+ Option option = (Option) it.next();
+ String argName = option.getArgumentName();
+ int column = 0;
+ if (option.getShortName() != '\0')
+ {
+ out.print(" -");
+ out.print(option.getShortName());
+ column += 4;
+ if (option.getLongName() == null)
+ {
+ if (argName != null)
+ {
+ if (! option.isJoined())
+ {
+ out.print(' ');
+ ++column;
+ }
+ out.print(argName);
+ column += argName.length();
+ }
+ out.print(" ");
+ }
+ else
+ out.print(", ");
+ column += 2;
+ }
+ // Indent the long option past the short options, if one
+ // was seen.
+ for (; column < (shortOptionSeen ? 6 : 2); ++column)
+ out.print(' ');
+ if (option.getLongName() != null)
+ {
+ out.print(longOnly ? "-" : "--");
+ out.print(option.getLongName());
+ column += (longOnly ? 1 : 2) + option.getLongName().length();
+ if (argName != null)
+ {
+ out.print(" " + argName);
+ column += 1 + argName.length();
+ }
+ }
+ // FIXME: should have a better heuristic for padding.
+ out.print(FILLER.substring(0, maxArgLen + 4 - column));
+ formatText(out, option.getDescription(), maxArgLen + 4);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
new file mode 100644
index 000000000..f23250eca
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
@@ -0,0 +1,495 @@
+/* Parser.java - parse command line options
+ Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.getopt;
+
+import java.io.PrintStream;
+import java.text.BreakIterator;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+
+/**
+ * An instance of this class is used to parse command-line options. It does "GNU
+ * style" argument recognition and also automatically handles "--help" and
+ * "--version" processing. It can also be put in "long option only" mode. In
+ * this mode long options are recognized with a single dash (as well as a double
+ * dash) and strings of options like "-abc" are never parsed as a collection of
+ * short options.
+ */
+public class Parser
+{
+ /** The maximum right column position. */
+ public static final int MAX_LINE_LENGTH = 80;
+
+ private String programName;
+
+ private String headerText;
+
+ private String footerText;
+
+ private boolean longOnly;
+
+ // All of the options. This is null initially; users must call
+ // requireOptions before access.
+ private ArrayList options;
+
+ private ArrayList optionGroups = new ArrayList();
+
+ private OptionGroup defaultGroup = new OptionGroup();
+
+ private OptionGroup finalGroup;
+
+ // These are used while parsing.
+ private int currentIndex;
+
+ private String[] args;
+
+ /**
+ * Create a new parser. The program name is used when printing error messages.
+ * The version string is printed verbatim in response to "--version".
+ *
+ * @param programName the name of the program
+ * @param versionString the program's version information
+ */
+ public Parser(String programName, String versionString)
+ {
+ this(programName, versionString, false);
+ }
+
+ /**
+ * Print a designated text to a {@link PrintStream}, eventually wrapping the
+ * lines of text so as to ensure that the width of each line does not overflow
+ * {@link #MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+ * {@link BreakIterator} using the default {@link Locale}.
+ * <p>
+ * The text to print may contain <code>\n</code> characters. This method will
+ * force a line-break for each such character.
+ *
+ * @param out the {@link PrintStream} destination of the formatted text.
+ * @param text the text to print.
+ * @see Parser#MAX_LINE_LENGTH
+ */
+ protected static void formatText(PrintStream out, String text)
+ {
+ formatText(out, text, Locale.getDefault());
+ }
+
+ /**
+ * Similar to the method with the same name and two arguments, except that the
+ * caller MUST specify a non-null {@link Locale} instance.
+ * <p>
+ * Print a designated text to a {@link PrintStream}, eventually wrapping the
+ * lines of text so as to ensure that the width of each line does not overflow
+ * {@link #MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+ * {@link BreakIterator} using the designated {@link Locale}.
+ * <p>
+ * The text to print may contain <code>\n</code> characters. This method will
+ * force a line-break for each such character.
+ *
+ * @param out the {@link PrintStream} destination of the formatted text.
+ * @param text the text to print.
+ * @param aLocale the {@link Locale} instance to use when constructing the
+ * {@link BreakIterator}.
+ * @see Parser#MAX_LINE_LENGTH
+ */
+ protected static void formatText(PrintStream out, String text, Locale aLocale)
+ {
+ BreakIterator bit = BreakIterator.getLineInstance(aLocale);
+ String[] lines = text.split("\n"); //$NON-NLS-1$
+ for (int i = 0; i < lines.length; i++)
+ {
+ text = lines[i];
+ bit.setText(text);
+ int length = 0;
+ int finish;
+ int start = bit.first();
+ while ((finish = bit.next()) != BreakIterator.DONE)
+ {
+ String word = text.substring(start, finish);
+ length += word.length();
+ if (length >= MAX_LINE_LENGTH)
+ {
+ out.println();
+ length = word.length();
+ }
+ out.print(word);
+ start = finish;
+ }
+ out.println();
+ }
+ }
+
+ /**
+ * Create a new parser. The program name is used when printing error messages.
+ * The version string is printed verbatim in response to "--version".
+ *
+ * @param programName the name of the program
+ * @param versionString the program's version information
+ * @param longOnly true if the parser should work in long-option-only mode
+ */
+ public Parser(String programName, final String versionString, boolean longOnly)
+ {
+ this.programName = programName;
+ this.longOnly = longOnly;
+
+ // Put standard options in their own section near the end.
+ finalGroup = new OptionGroup(Messages.getString("Parser.StdOptions")); //$NON-NLS-1$
+ finalGroup.add(new Option("help", Messages.getString("Parser.PrintHelp")) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ printHelp(System.out);
+ System.exit(0);
+ }
+ });
+ finalGroup.add(new Option("version", Messages.getString("Parser.PrintVersion")) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ System.out.println(versionString);
+ System.exit(0);
+ }
+ });
+ add(finalGroup);
+
+ add(defaultGroup);
+ }
+
+ /**
+ * Set the header text that is printed by --help.
+ *
+ * @param headerText the header text
+ */
+ public synchronized void setHeader(String headerText)
+ {
+ this.headerText = headerText;
+ }
+
+ /**
+ * Set the footer text that is printed by --help.
+ *
+ * @param footerText the footer text
+ */
+ public synchronized void setFooter(String footerText)
+ {
+ this.footerText = footerText;
+ }
+
+ /**
+ * Add an option to this parser. The option is added to the default option
+ * group; this affects where it is placed in the help output.
+ *
+ * @param opt the option
+ */
+ public synchronized void add(Option opt)
+ {
+ defaultGroup.add(opt);
+ }
+
+ /**
+ * This is like {@link #add(Option)}, but adds the option to the "final"
+ * group. This should be used sparingly, if at all; it is intended for
+ * other very generic options like --help or --version.
+ * @param opt the option to add
+ */
+ protected synchronized void addFinal(Option opt)
+ {
+ finalGroup.add(opt);
+ }
+
+ /**
+ * Add an option group to this parser. All the options in this group will be
+ * recognized by the parser.
+ *
+ * @param group the option group
+ */
+ public synchronized void add(OptionGroup group)
+ {
+ // This ensures that the final group always appears at the end
+ // of the options.
+ if (optionGroups.isEmpty())
+ optionGroups.add(group);
+ else
+ optionGroups.add(optionGroups.size() - 1, group);
+ }
+
+ // Make sure the 'options' field is properly initialized.
+ private void requireOptions()
+ {
+ if (options != null)
+ return;
+ options = new ArrayList();
+ Iterator it = optionGroups.iterator();
+ while (it.hasNext())
+ {
+ OptionGroup group = (OptionGroup) it.next();
+ options.addAll(group.options);
+ }
+ }
+
+ public void printHelp()
+ {
+ this.printHelp(System.out);
+ }
+
+ synchronized void printHelp(PrintStream out)
+ {
+ requireOptions();
+
+ if (headerText != null)
+ {
+ formatText(out, headerText);
+ out.println();
+ }
+
+ Iterator it = optionGroups.iterator();
+ while (it.hasNext())
+ {
+ OptionGroup group = (OptionGroup) it.next();
+ // An option group might be empty, in which case we don't
+ // want to print it..
+ if (! group.options.isEmpty())
+ {
+ group.printHelp(out, longOnly);
+ out.println();
+ }
+ }
+
+ if (footerText != null)
+ formatText(out, footerText);
+ }
+
+ /**
+ * This method can be overridden by subclassses to provide some option
+ * validation. It is called by the parser after all options have been
+ * parsed. If an option validation problem is encountered, this should
+ * throw an {@link OptionException} whose message should be shown to
+ * the user.
+ * <p>
+ * It is better to do validation here than after {@link #parse(String[])}
+ * returns, because the parser will print a message referring the
+ * user to the <code>--help</code> option.
+ * <p>
+ * The base implementation does nothing.
+ *
+ * @throws OptionException the error encountered
+ */
+ protected void validate() throws OptionException
+ {
+ // Base implementation does nothing.
+ }
+
+ private String getArgument(String request) throws OptionException
+ {
+ ++currentIndex;
+ if (currentIndex >= args.length)
+ {
+ String message
+ = MessageFormat.format(Messages.getString("Parser.ArgReqd"), //$NON-NLS-1$
+ new Object[] { request });
+ throw new OptionException(request);
+ }
+ return args[currentIndex];
+ }
+
+ private void handleLongOption(String real, int index) throws OptionException
+ {
+ String option = real.substring(index);
+ String justName = option;
+ int eq = option.indexOf('=');
+ if (eq != -1)
+ justName = option.substring(0, eq);
+ boolean isPlainShort = justName.length() == 1;
+ char shortName = justName.charAt(0);
+ Option found = null;
+ for (int i = options.size() - 1; i >= 0; --i)
+ {
+ Option opt = (Option) options.get(i);
+ if (justName.equals(opt.getLongName()))
+ {
+ found = opt;
+ break;
+ }
+ if ((isPlainShort || opt.isJoined())
+ && opt.getShortName() == shortName)
+ {
+ if (! isPlainShort)
+ {
+ // The rest of the option string is the argument.
+ eq = 0;
+ }
+ found = opt;
+ break;
+ }
+ }
+ if (found == null)
+ {
+ String msg = MessageFormat.format(Messages.getString("Parser.Unrecognized"), //$NON-NLS-1$
+ new Object[] { real });
+ throw new OptionException(msg);
+ }
+ String argument = null;
+ if (found.getTakesArgument())
+ {
+ if (eq == -1)
+ argument = getArgument(real);
+ else
+ argument = option.substring(eq + 1);
+ }
+ else if (eq != - 1)
+ {
+ String msg
+ = MessageFormat.format(Messages.getString("Parser.NoArg"), //$NON-NLS-1$
+ new Object[] { real.substring(0, eq + index) });
+ throw new OptionException(msg);
+ }
+ found.parsed(argument);
+ }
+
+ private void handleShortOptions(String option) throws OptionException
+ {
+ for (int charIndex = 1; charIndex < option.length(); ++charIndex)
+ {
+ char optChar = option.charAt(charIndex);
+ Option found = null;
+ for (int i = options.size() - 1; i >= 0; --i)
+ {
+ Option opt = (Option) options.get(i);
+ if (optChar == opt.getShortName())
+ {
+ found = opt;
+ break;
+ }
+ }
+ if (found == null)
+ {
+ String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
+ new Object[] { "" + optChar }); //$NON-NLS-1$
+ throw new OptionException(msg);
+ }
+ String argument = null;
+ if (found.getTakesArgument())
+ {
+ // If this is a joined short option, and there are more
+ // characters left in this argument, use those as the
+ // argument.
+ if (found.isJoined() && charIndex + 1 < option.length())
+ {
+ argument = option.substring(charIndex + 1);
+ charIndex = option.length();
+ }
+ else
+ argument = getArgument("-" + optChar); //$NON-NLS-1$
+ }
+ found.parsed(argument);
+ }
+ }
+
+ /**
+ * Parse a command line. Any files which are found will be passed to the file
+ * argument callback. This method will exit on error or when --help or
+ * --version is specified.
+ *
+ * @param inArgs the command-line arguments
+ * @param files the file argument callback
+ */
+ public synchronized void parse(String[] inArgs, FileArgumentCallback files)
+ {
+ requireOptions();
+ try
+ {
+ args = inArgs;
+ for (currentIndex = 0; currentIndex < args.length; ++currentIndex)
+ {
+ if (args[currentIndex].length() == 0
+ || args[currentIndex].charAt(0) != '-'
+ || "-".equals(args[currentIndex])) //$NON-NLS-1$
+ {
+ files.notifyFile(args[currentIndex]);
+ continue;
+ }
+ if ("--".equals(args[currentIndex])) //$NON-NLS-1$
+ break;
+ if (args[currentIndex].charAt(1) == '-')
+ handleLongOption(args[currentIndex], 2);
+ else if (longOnly)
+ handleLongOption(args[currentIndex], 1);
+ else
+ handleShortOptions(args[currentIndex]);
+ }
+ // Add remaining arguments to leftovers.
+ for (++currentIndex; currentIndex < args.length; ++currentIndex)
+ files.notifyFile(args[currentIndex]);
+ // See if something went wrong.
+ validate();
+ }
+ catch (OptionException err)
+ {
+ System.err.println(programName + ": " + err.getMessage()); //$NON-NLS-1$
+ String fmt;
+ if (longOnly)
+ fmt = Messages.getString("Parser.TryHelpShort"); //$NON-NLS-1$
+ else
+ fmt = Messages.getString("Parser.TryHelpLong"); //$NON-NLS-1$
+ String msg = MessageFormat.format(fmt, new Object[] { programName });
+ System.err.println(programName + ": " + msg); //$NON-NLS-1$
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Parse a command line. Any files which are found will be returned. This
+ * method will exit on error or when --help or --version is specified.
+ *
+ * @param inArgs the command-line arguments
+ */
+ public String[] parse(String[] inArgs)
+ {
+ final ArrayList fileResult = new ArrayList();
+ parse(inArgs, new FileArgumentCallback()
+ {
+ public void notifyFile(String fileArgument)
+ {
+ fileResult.add(fileArgument);
+ }
+ });
+ return (String[]) fileResult.toArray(new String[0]);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/AbstractTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/AbstractTagImpl.java
new file mode 100644
index 000000000..adb5b65d5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/AbstractTagImpl.java
@@ -0,0 +1,107 @@
+/* gnu.classpath.tools.gjdoc.AbstractTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+
+public abstract class AbstractTagImpl
+ implements Tag, TagContainer {
+
+ private static final Tag[] emptyTags = new Tag[0];
+
+ protected String text;
+ protected Map tagMap;
+
+ protected AbstractTagImpl(String text) {
+ this.text=text;
+ }
+
+ public void resolve() {
+ Tag[] allTags=inlineTags();
+ if (null != allTags) {
+ for (int i=0; i<allTags.length; ++i) {
+ if (allTags[i]!=this) ((AbstractTagImpl)allTags[i]).resolve();
+ }
+ }
+ else {
+ System.err.println("Null tags for " + this);
+ }
+ }
+
+ protected void setBody(String body, ClassDocImpl contextClass, MemberDocImpl contextMember) {
+ this.tagMap=DocImpl.parseCommentTags(body.toCharArray(),
+ 0,
+ body.length(),
+ contextClass,
+ contextMember,
+ this,
+ null);
+ }
+
+ public Tag[] firstSentenceTags() {
+ return (tagMap!=null)? (Tag[])tagMap.get("first") : emptyTags;
+ }
+ public Tag[] inlineTags() {
+ return (tagMap!=null)? (Tag[])tagMap.get("inline") : emptyTags;
+ }
+
+ public String name() {
+ return kind();
+ }
+
+ public String text() {
+ return text;
+ }
+
+ public Map getTagMap() {
+ return tagMap;
+ }
+
+ /**
+ * Debug string containing class, name, text and tagMap.
+ */
+ public String toString()
+ {
+ return (this.getClass().getName()
+ + "[name=" + name()
+ + ", text=" + text()
+ + ", tagMap=" + getTagMap()
+ + "]");
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.java
new file mode 100644
index 000000000..cde5cbe90
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.java
@@ -0,0 +1,121 @@
+/* gnu.classpath.tools.gjdoc.ArrayCharacterIterator
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.text.CharacterIterator;
+
+public final class ArrayCharacterIterator implements CharacterIterator {
+
+ private char[] data;
+ private int beginIndex;
+ private int endIndex;
+ private int currentIndex;
+
+ public ArrayCharacterIterator(char[] data,
+ int beginIndex) {
+ this(data,beginIndex,data.length,beginIndex);
+ }
+
+ public ArrayCharacterIterator(char[] data,
+ int beginIndex,
+ int endIndex) {
+ this(data,beginIndex,endIndex,beginIndex);
+ }
+
+ public ArrayCharacterIterator(char[] data,
+ int beginIndex,
+ int endIndex,
+ int currentIndex) {
+ this.data=data;
+ this.beginIndex=beginIndex;
+ this.endIndex=endIndex;
+ this.currentIndex=currentIndex;
+ }
+
+ // Create a copy of this iterator
+ public Object clone() {
+ return new ArrayCharacterIterator(data,beginIndex,endIndex,currentIndex);
+ }
+
+ // Gets the character at the current position (as returned by getIndex()).
+ public char current() {
+ return (currentIndex>=beginIndex && currentIndex<endIndex) ? data[currentIndex] : DONE;
+ }
+
+ // Sets the position to getBeginIndex() and returns the character at that position.
+ public char first() {
+ return data[currentIndex=beginIndex];
+ }
+
+ // Returns the start index of the text.
+ public int getBeginIndex() {
+ return beginIndex;
+ }
+
+ // Returns the end index of the text.
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ // Returns the current index.
+ public int getIndex() {
+ return currentIndex;
+ }
+
+ // Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position.
+ public char last() {
+ return data[currentIndex=((endIndex>beginIndex)?endIndex-1:endIndex)];
+ }
+
+ // Increments the iterator's index by one and returns the character at the new index.
+ public char next() {
+ return (++currentIndex<endIndex)?data[currentIndex]:DONE;
+ }
+
+ // Decrements the iterator's index by one and returns the character at the new index.
+ public char previous() {
+ return (--currentIndex>=beginIndex)?data[currentIndex]:DONE;
+ }
+
+ // Sets the position to the specified position in the text and returns that character.
+ public char setIndex(int position) {
+ this.currentIndex=position;
+ return current();
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocImpl.java
new file mode 100644
index 000000000..b38c2b083
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocImpl.java
@@ -0,0 +1,1260 @@
+/* gnu.classpath.tools.gjdoc.ClassDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.io.*;
+import gnu.classpath.tools.gjdoc.expr.EvaluatorEnvironment;
+import gnu.classpath.tools.gjdoc.expr.CircularExpressionException;
+import gnu.classpath.tools.gjdoc.expr.IllegalExpressionException;
+import gnu.classpath.tools.gjdoc.expr.UnknownIdentifierException;
+
+public class ClassDocImpl
+ extends ProgramElementDocImpl
+ implements ClassDoc, WritableType, EvaluatorEnvironment {
+
+ private ClassDoc baseClassDoc;
+ private ClassDoc[] importedClasses;
+ private PackageDoc[] importedPackages;
+ private boolean definesSerializableFields;
+ private FieldDoc[] serialPersistentField;
+ private MethodDoc[] serializationMethods;
+ private String dimension = "";
+
+ public ClassDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ int accessLevel,
+ boolean isFinal,
+ boolean isStatic,
+ SourcePosition position) {
+ super(containingClass, containingPackage, accessLevel, isFinal, isStatic,
+ position);
+ this.baseClassDoc = this;
+ }
+
+ public ClassDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ ClassDoc[] importedClasses,
+ PackageDoc[] importedPackages,
+ SourcePosition position) {
+ super(containingClass, containingPackage,
+ position);
+ this.importedClasses=importedClasses;
+ this.importedPackages=importedPackages;
+ this.baseClassDoc = this;
+ }
+
+ // Return constructors in class.
+ public ConstructorDoc[] constructors() {
+ return constructors(true);
+ }
+
+ public ConstructorDoc[] constructors(boolean filter) {
+ return filter ? filteredConstructors : unfilteredConstructors;
+ }
+
+ // Return true if Serializable fields are explicitly defined with the special class member serialPersistentFields.
+ public boolean definesSerializableFields() {
+ return definesSerializableFields;
+ }
+
+ // Return fields in class.
+ public FieldDoc[] fields() {
+ return fields(true);
+ }
+
+ public FieldDoc[] fields(boolean filter) {
+ return filter ? filteredFields : unfilteredFields;
+ }
+
+ private static Set primitiveNames;
+ static {
+ primitiveNames = new HashSet();
+ primitiveNames.add("int");
+ primitiveNames.add("long");
+ primitiveNames.add("char");
+ primitiveNames.add("short");
+ primitiveNames.add("byte");
+ primitiveNames.add("float");
+ primitiveNames.add("double");
+ primitiveNames.add("boolean");
+ }
+
+ private Map findClassCache = new HashMap();
+
+ public ClassDoc findClass(String className, String dimension)
+ {
+ ClassDoc cached = (ClassDoc)findClassCache.get(className + dimension);
+ if (null != cached) {
+ return cached;
+ }
+ else {
+ ClassDoc classDoc = findClass(className);
+
+ if (null!=classDoc) {
+ try {
+ if (classDoc.dimension().equals(dimension)) {
+ return classDoc;
+ }
+ else {
+ ClassDoc rc = (ClassDoc) ((WritableType)classDoc).clone();
+ ((WritableType)rc).setDimension(dimension);
+ findClassCache.put(className + dimension, rc);
+ return rc;
+ }
+ }
+ catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ public ClassDoc findClass(String className)
+ {
+ String qualifiedName = Main.getRootDoc().resolveClassName(className, this);
+ ClassDoc rc=Main.getRootDoc().classNamed(qualifiedName);
+
+ if (null == rc) {
+ for (ClassDoc cdi=this; cdi!=null; cdi=cdi.containingClass()) {
+ for (ClassDoc sdi=cdi; sdi!=null; sdi=sdi.superclass()) {
+ if (sdi instanceof ClassDocProxy) {
+ ClassDoc realClass = Main.getRootDoc().classNamed(sdi.qualifiedName());
+ if (null != realClass) {
+ sdi = realClass;
+ }
+ }
+ rc=Main.getRootDoc().classNamed(sdi.qualifiedName()+"."+className);
+ if (rc!=null) return rc;
+ }
+ }
+ }
+
+ return rc;
+ }
+
+ // Get the list of classes declared as imported.
+ public ClassDoc[] importedClasses() {
+ return importedClasses;
+ }
+
+ // Get the list of packages declared as imported.
+ public PackageDoc[] importedPackages() {
+ return importedPackages;
+ }
+
+ // Return inner classes within this class.
+ public ClassDoc[] innerClasses() {
+ return innerClasses(true);
+ }
+
+ public ClassDoc[] innerClasses(boolean filtered) {
+ return filtered ? filteredInnerClasses : unfilteredInnerClasses;
+ }
+
+ void setFilteredInnerClasses(ClassDoc[] filteredInnerClasses) {
+ this.filteredInnerClasses=filteredInnerClasses;
+ }
+
+ void setInnerClasses(ClassDoc[] unfilteredInnerClasses) {
+ this.unfilteredInnerClasses=unfilteredInnerClasses;
+ }
+
+ // Return interfaces implemented by this class or interfaces extended by this interface.
+ public ClassDoc[] interfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(ClassDoc[] interfaces) {
+ this.interfaces=interfaces;
+ }
+
+ // Return true if this class is abstract
+ public boolean isAbstract() {
+ return isAbstract || isInterface();
+ }
+
+ public boolean isInterface() {
+ return isInterface;
+ }
+
+ public boolean isAnnotation() {
+ return isAnnotation;
+ }
+
+ public boolean isEnum()
+ {
+ return isEnum;
+ }
+
+ // Return true if this class is abstract
+ public void setIsAbstract(boolean b) {
+ this.isAbstract=b;
+ }
+
+ // Return true if this class implements java.io.Externalizable.
+ public boolean isExternalizable() {
+ return implementsInterface("java.io.Externalizable");
+ }
+
+ // Return true if this class implements java.io.Serializable.
+ public boolean isSerializable() {
+ return implementsInterface("java.io.Serializable");
+ }
+
+ public boolean implementsInterface(String name) {
+ for (ClassDoc cdi=this; cdi!=null; cdi=(ClassDoc)cdi.superclass()) {
+ if (cdi instanceof ClassDocImpl) {
+ ClassDoc[] cdiInterfaces=(ClassDoc[])cdi.interfaces();
+ if (null != cdiInterfaces) {
+ for (int i=0; i<cdiInterfaces.length; ++i) {
+ if (cdiInterfaces[i].qualifiedName().equals(name))
+ return true;
+ }
+ }
+ }
+ else {
+ //throw new RuntimeException("implementsInterface(\""+name+"\") failed: Not a ClassDocImpl:"+cdi);
+ }
+ }
+ return false;
+ }
+
+ // Return methods in class.
+ public MethodDoc[] methods() {
+ return methods(true);
+ }
+
+ // Return methods in class.
+ public MethodDoc[] methods(boolean filter) {
+ return filter ? filteredMethods : unfilteredMethods;
+ }
+
+ // Return the Serializable fields of class. Return either a list of default fields documented by serial tag or return a single FieldDoc for serialPersistentField member.
+ public FieldDoc[] serializableFields() {
+ if (serialPersistentField!=null) {
+ return serialPersistentField;
+ }
+ else{
+ return serializableFields;
+ }
+ }
+
+ // Return the serialization methods for this class.
+ public MethodDoc[] serializationMethods() {
+ return serializationMethods;
+ }
+
+ // Test whether this class is a subclass of the specified class.
+ public boolean subclassOf(ClassDoc cd) {
+ for (ClassDocImpl cdi=(ClassDocImpl)superclass(); cdi!=null; cdi=(ClassDocImpl)cdi.superclass()) {
+ if (cdi.equals(cd))
+ return true;
+ }
+ return false;
+ }
+
+ // Return the superclass of this class
+ public ClassDoc superclass() {
+ return superclass;
+ }
+
+ // Implementation of Interface Type
+
+ public ClassDoc asClassDoc() {
+
+ return (ClassDoc)this;
+ }
+
+ public String typeName() { return name(); }
+
+ public String qualifiedTypeName() {
+ return (containingPackage()!=null && !containingPackage().equals(PackageDocImpl.DEFAULT_PACKAGE))?(containingPackage().name()+"."+name()):(name());
+ }
+
+ public String qualifiedName() { return qualifiedTypeName(); }
+
+ public String dimension() { return dimension; }
+
+ public String toString() { return "ClassDoc{"+qualifiedTypeName()+"}"; }
+
+ public TypeVariable asTypeVariable() { return null; }
+
+ public static ClassDocImpl createInstance(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ ClassDoc[] importedClasses,
+ PackageDoc[] importedPackages,
+ char[] source, int startIndex, int endIndex,
+ List importStatementList) throws ParseException, IOException {
+
+ String superclassName = "java.lang.Object";
+
+ ClassDocImpl rc=new ClassDocImpl(containingClass,
+ containingPackage,
+ importedClasses,
+ importedPackages,
+ null);
+ rc.setImportStatementList(importStatementList);
+ List implementedInterfaces = new ArrayList();
+
+ String word="";
+ int item=0;
+
+ final int STATE_NORMAL = 1;
+ final int STATE_SLASHC = 2;
+ final int STATE_STARC = 3;
+ final int STATE_ANNO = 4;
+
+ int state=STATE_NORMAL;
+ int varLevel=0;
+ int parLevel=0;
+ char prev=0;
+ for (int ndx=startIndex; ndx<=endIndex; ++ndx) {
+ char c=(ndx==endIndex)?10:source[ndx];
+ boolean processWord=false;
+ if (state==STATE_SLASHC) {
+ if (c=='\n') {
+ state=STATE_NORMAL;
+ c=0;
+ }
+ }
+ else if (state==STATE_STARC) {
+ if (c=='/' && prev=='*') {
+ state=STATE_NORMAL;
+ c=0;
+ }
+ }
+ else {
+ if (c=='/' && prev=='/') {
+ state=STATE_SLASHC;
+ c=0;
+ word=word.substring(0,word.length()-1);
+ processWord=true;
+ }
+ else if (c=='*' && prev=='/') {
+ state=STATE_STARC;
+ c=0;
+ word=word.substring(0,word.length()-1);
+ processWord=true;
+ }
+ else if (c=='@') {
+ state=STATE_ANNO;
+ word += c;
+ }
+ else if (c=='(' && state==STATE_ANNO) {
+ ++parLevel;
+ word += c;
+ }
+ else if (c==')' && state==STATE_ANNO) {
+ --parLevel;
+ word += c;
+ if (parLevel == 0)
+ state=STATE_NORMAL;
+ }
+ else if (c=='<')
+ {
+ ++varLevel;
+ word += c;
+ }
+ else if (c=='>')
+ {
+ --varLevel;
+ word += c;
+ }
+ else if (c=='{' && parLevel == 0 ||
+ c==',' && varLevel == 0 && parLevel == 0 ||
+ Parser.WHITESPACE.indexOf(c)>=0 && parLevel == 0 && varLevel == 0) {
+ processWord=true;
+ state=STATE_NORMAL;
+ }
+ else {
+ word+=c;
+ }
+
+ if (processWord && word.length()>0) {
+ if (item==0) {
+ if (rc.processModifier(word)) {
+ }
+ else if (word.equals("abstract")) {
+ rc.setIsAbstract(true);
+ }
+ else if (word.equals("class")) {
+ rc.setIsInterface(false);
+ item=1;
+ }
+ else if (word.equals("enum"))
+ {
+ rc.setIsEnum(true);
+ item = 1;
+ }
+ else if (word.equals("interface")) {
+ rc.setIsInterface(true);
+ item=1;
+ }
+ else if (word.equals("@interface")) {
+ rc.setIsInterface(true);
+ rc.setIsAnnotation(true);
+ item=1;
+ }
+ else if (word.equals("strictfp")) {
+ }
+ else {
+ Main.getRootDoc().printWarning("unknown modifier '"+word+"'");
+ }
+ }
+ else if (word.equals("extends") && !rc.isAnnotation()) {
+ if (rc.isInterface()) {
+ item=3;
+ }
+ else {
+ item=2;
+ }
+ }
+ else if (word.equals("implements") && !rc.isAnnotation()) {
+ item=3;
+ }
+ else if (item==1) {
+ int parameterIndex = word.indexOf("<");
+ if (parameterIndex == -1)
+ rc.setClass(word);
+ else
+ {
+ rc.setClass(word.substring(0, parameterIndex));
+ parseTypeVariables(rc,word.substring(parameterIndex,
+ word.length()));
+ }
+ }
+ else if (item==2) {
+ //Debug.log(9,"setting baseclass of "+rc+" to "+word);
+ int parameterIndex = word.indexOf("<");
+ if (parameterIndex == -1)
+ superclassName=word;
+ else
+ {
+ /* FIXME: Parse type parameters */
+ superclassName=word.substring(0,parameterIndex);
+ }
+ }
+ else if (item==3) {
+ int parameterIndex = word.indexOf("<");
+ if (parameterIndex == -1)
+ implementedInterfaces.add(word);
+ else
+ {
+ /* FIXME: Parse type parameters */
+ implementedInterfaces.add(word.substring(0,parameterIndex));
+ }
+ }
+ word="";
+ }
+
+ if (c=='{' && state==STATE_NORMAL) break;
+ }
+ prev=c;
+ }
+
+ if (null != containingClass
+ && containingClass.isInterface()) {
+ rc.accessLevel = ACCESS_PUBLIC;
+ }
+
+ if (rc.name()==null) {
+ throw new ParseException("No classdef found in expression \""+new String(source,startIndex,endIndex-startIndex)+"\"");
+ }
+
+ rc.setPosition(ClassDocImpl.getPosition(rc, source, startIndex));
+
+ ClassDoc superclassProxy=new ClassDocProxy(superclassName, rc);
+
+ if (!rc.qualifiedName().equals("java.lang.Object")) {
+ rc.setSuperclass(superclassProxy);
+ }
+
+ ClassDoc[] interfaces=new ClassDoc[implementedInterfaces.size()];
+ for (int i=0; i<interfaces.length; ++i) {
+ interfaces[i]=new ClassDocProxy((String)implementedInterfaces.get(i), rc);
+ }
+ rc.setInterfaces(interfaces);
+
+ if (rc.isInterface() && rc.containingClass()!=null) {
+ rc.setIsStatic(true);
+ }
+ return rc;
+ }
+
+ public void setFields(FieldDoc[] fields) {
+ this.unfilteredFields=fields;
+ }
+
+ public void setFilteredFields(FieldDoc[] fields) {
+ this.filteredFields=fields;
+ }
+
+ public void setSerializableFields(FieldDoc[] sfields) {
+ this.serializableFields=sfields;
+ }
+
+ public void setMethods(MethodDoc[] methods) {
+ this.unfilteredMethods=methods;
+ }
+
+ public void setFilteredMethods(MethodDoc[] methods) {
+ this.filteredMethods=methods;
+ }
+
+ public void setConstructors(ConstructorDoc[] constructors) {
+ this.unfilteredConstructors=constructors;
+ }
+
+ public void setFilteredConstructors(ConstructorDoc[] constructors) {
+ this.filteredConstructors=constructors;
+ }
+
+ // Returns the name of this Doc item.
+ public String name() {
+ if (containingClass==null) {
+ return className;
+ }
+ else {
+ return containingClass.name()+"."+className;
+ }
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClass(String className) {
+ this.className=className;
+ }
+
+ void setSuperclass(ClassDoc superclass) {
+ this.superclass=superclass;
+ }
+
+ public void resolve() throws ParseException {
+ if (!resolved) {
+ resolved=true;
+
+ if (containingClass!=null)
+ ((ClassDocImpl)containingClass).resolve();
+
+ //Debug.log(9,"resolving class '"+qualifiedName()+"'");
+ /*
+ for (int i=0; i<importedPackages.length; ++i) {
+ Debug.log(9,"class "+qualifiedName()+" imports "+importedPackages[i].name());
+ }
+ */
+
+ if (superclass instanceof ClassDocProxy) {
+
+ ClassDoc realClassDoc=findClass(superclass.qualifiedName());
+
+ if (realClassDoc==null) {
+ /*
+ if (true) { // Main.recursiveClasses) {
+ throw new ParseException("In class '"+qualifiedName()+"': class '"+className+"' not found.");
+ }
+ */
+ }
+ else {
+ superclass=realClassDoc;
+ }
+ }
+
+ if (null != interfaces) {
+ for (int i=0; i<interfaces.length; ++i) {
+ if (interfaces[i] instanceof ClassDocProxy) {
+ //Debug.log(9,"class "+qualifiedName()+" implements "+interfaces[i].qualifiedName());
+ ClassDoc realClassDoc=findClass(interfaces[i].qualifiedName());
+ if (realClassDoc==null) {
+ /*
+ if (Main.recursiveClasses) {
+ throw new ParseException("In class '"+qualifiedName()+"': class '"+className+"' not found.");
+ }
+ */
+ }
+ else {
+ //Debug.log(9,"found class '"+className+"': "+interfaces[i]);
+ interfaces[i]=realClassDoc;
+ }
+ }
+ }
+ }
+
+ if (unfilteredFields!=null) {
+ for (int i=0; i<unfilteredFields.length; ++i) {
+ ((FieldDocImpl)unfilteredFields[i]).resolve();
+ if (unfilteredFields[i].name().equals("serialPersistentField")) {
+ serialPersistentField=new FieldDoc[]{unfilteredFields[i]};
+ definesSerializableFields=true;
+ }
+ }
+ }
+
+ if (unfilteredMethods!=null) {
+ for (int i=0; i<unfilteredMethods.length; ++i) {
+ ((MethodDocImpl)unfilteredMethods[i]).resolve();
+ }
+ }
+
+ if (unfilteredConstructors!=null) {
+ for (int i=0; i<unfilteredConstructors.length; ++i) {
+ ((ConstructorDocImpl)unfilteredConstructors[i]).resolve();
+ }
+ }
+
+ List isSerMethodList=new ArrayList();
+
+ if (null != maybeSerMethodList) {
+ for (Iterator it=maybeSerMethodList.iterator(); it.hasNext(); ) {
+ MethodDocImpl method=(MethodDocImpl)it.next();
+ method.resolve();
+
+ if (((method.name().equals("readObject")
+ && method.signature().equals("(java.io.ObjectInputStream)"))
+ || (method.name().equals("writeObject")
+ && method.signature().equals("(java.io.ObjectOutputStream)"))
+ || (method.name().equals("readExternal")
+ && method.signature().equals("(java.io.ObjectInput)"))
+ || (method.name().equals("writeExternal")
+ && method.signature().equals("(java.io.ObjectOutput)"))
+ || (method.name().equals("readResolve")
+ && method.signature().equals("()")))) {
+
+ isSerMethodList.add(method);
+ }
+ }
+ this.serializationMethods=(MethodDoc[])isSerMethodList.toArray(new MethodDoc[0]);
+ maybeSerMethodList=null;
+ }
+ }
+ }
+
+ public FieldDoc findFieldRec(String name) {
+ return findFieldRec(this, name);
+ }
+
+ private static FieldDoc findFieldRec(ClassDoc classDoc, String name)
+ {
+ FieldDoc field = findField(classDoc, name);
+ if (null!=field) {
+ return field;
+ }
+ else {
+ ClassDoc[] interfaces = classDoc.interfaces();
+ for (int i=0; i<interfaces.length; ++i) {
+ field = findFieldRec(interfaces[i], name);
+ if (null != field) {
+ return field;
+ }
+ }
+ if (null != classDoc.superclass()) {
+ return findFieldRec(classDoc.superclass(), name);
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ private static FieldDoc findField(ClassDoc classDoc, String name)
+ {
+ FieldDoc[] fields = classDoc.fields(false);
+ for (int i=0; i<fields.length; ++i) {
+ if (fields[i].name().equals(name)) {
+ return fields[i];
+ }
+ }
+ return null;
+ }
+
+ public FieldDoc findField(String fieldName) {
+ for (int i=0; i<filteredFields.length; ++i) {
+ if (filteredFields[i].name().equals(fieldName)) {
+ return filteredFields[i];
+ }
+ }
+ return null;
+ }
+
+ public void resolveComments() {
+
+ super.resolveComments();
+
+ if (null != unfilteredFields) {
+ for (int i=0; i<unfilteredFields.length; ++i) {
+ ((FieldDocImpl)unfilteredFields[i]).resolveComments();
+ }
+ }
+
+ if (null != serializableFields) {
+ for (int i=0; i<serializableFields.length; ++i) {
+ ((FieldDocImpl)serializableFields[i]).resolveComments();
+ }
+ }
+ if (null != unfilteredMethods) {
+ for (int i=0; i<unfilteredMethods.length; ++i) {
+ ((MethodDocImpl)unfilteredMethods[i]).resolveComments();
+ }
+ }
+ if (null != unfilteredConstructors) {
+ for (int i=0; i<unfilteredConstructors.length; ++i) {
+ ((ConstructorDocImpl)unfilteredConstructors[i]).resolveComments();
+ }
+ }
+
+ resolveTags();
+ }
+
+
+ private String className=null;
+
+ private boolean isAbstract;
+ private boolean isInterface;
+ private boolean isAnnotation;
+ private boolean isEnum;
+ private ClassDoc[] interfaces;
+ private ClassDoc[] filteredInnerClasses;
+ private ClassDoc[] unfilteredInnerClasses;
+ private FieldDoc[] filteredFields;
+ private FieldDoc[] unfilteredFields;
+ private FieldDoc[] serializableFields;
+ private MethodDoc[] filteredMethods;
+ private MethodDoc[] unfilteredMethods;
+ private ConstructorDoc[] filteredConstructors;
+ private ConstructorDoc[] unfilteredConstructors;
+ private TypeVariable[] typeParameters;
+
+ private boolean resolved=false;
+
+ private ClassDoc superclass;
+
+ // Is this Doc item a class.
+ public boolean isClass() {
+ return !isInterface;
+ }
+
+ // return true if this Doc is include in the active set.
+ public boolean isIncluded() {
+ if (this == baseClassDoc) {
+ return isIncluded
+ || (null != containingClass && Main.getInstance().includeAccessLevel(accessLevel));
+ }
+ else {
+ return baseClassDoc.isIncluded();
+ }
+ }
+
+ void setIsIncluded(boolean b) {
+ this.isIncluded=b;
+ }
+
+ private boolean isIncluded=false;
+
+ void setImportedClasses(ClassDoc[] importedClasses) {
+ this.importedClasses=importedClasses;
+ }
+
+ private static Map typeMap = new HashMap();
+
+ Type typeForString(String typeName) throws ParseException {
+ String orgTypename=typeName;
+ int ndx=typeName.indexOf('[');
+ String dim="";
+ if (ndx>=0) {
+ for (int i=ndx; i<typeName.length(); ++i) {
+ if ("[]".indexOf(typeName.charAt(i))>=0) {
+ dim+=typeName.charAt(i);
+ }
+ }
+ typeName=typeName.substring(0,ndx).trim();
+ }
+
+ ClassDoc classDoc = findClass(typeName, dim);
+ if (null != classDoc) {
+ return classDoc;
+ }
+
+ Type type = (Type)typeMap.get(typeName+dim);
+ if (null!=type) {
+ try {
+ if (type.dimension().equals(dim)) {
+ return type;
+ }
+ else {
+ Type rc = (Type) ((WritableType)type).clone();
+ ((WritableType)rc).setDimension(dim);
+ return rc;
+ }
+ }
+ catch (CloneNotSupportedException e) {
+ throw new ParseException(e.toString());
+ }
+ }
+
+ if ("boolean".equals(typeName)
+ || "char".equals(typeName)
+ || "byte".equals(typeName)
+ || "short".equals(typeName)
+ || "int".equals(typeName)
+ || "long".equals(typeName)
+ || "void".equals(typeName)
+ || "float".equals(typeName)
+ || "double".equals(typeName)) {
+ Type rc=new TypeImpl(null, typeName, dim);
+ typeMap.put(typeName+dim, rc);
+ return rc;
+ }
+
+ if (Main.getInstance().isDocletRunning()) {
+ //System.err.println(findClass("java.lang.String"));
+ //throw new ParseException("Doclet running, class not found: "+typeName+" ("+orgTypename+")");
+ }
+ Type rc=new ClassDocProxy(typeName, this);
+ ((WritableType)rc).setDimension(dim);
+ return rc;
+ }
+
+ public boolean isException() {
+ for (ClassDoc cdi=this;
+ cdi!=null;
+ cdi=cdi.superclass()) {
+
+ if ("java.lang.Exception".equals(cdi.qualifiedName()))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isError() {
+ for (ClassDoc cdi=this; cdi!=null; cdi=cdi.superclass()) {
+ if ("java.lang.Error".equals(cdi.qualifiedName()))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isOrdinaryClass() {
+ return !isException() && !isError() && !isInterface();
+ }
+
+ public void setIsInterface(boolean b) {
+ this.isInterface=b;
+ }
+
+ public void setIsAnnotation(boolean b) {
+ this.isAnnotation=b;
+ }
+
+ public void setIsEnum(boolean b)
+ {
+ isEnum = b;
+ }
+
+ public ExecutableMemberDoc findExecutableRec(String nameAndSignature) {
+
+ ExecutableMemberDoc rc;
+ for (ClassDoc cdi=this; cdi!=null; ) {
+ rc=findMethod(cdi, nameAndSignature);
+ if (rc!=null) return rc;
+ rc=findConstructor(cdi, nameAndSignature);
+ if (rc!=null) return rc;
+
+ ClassDoc _superclass = cdi.superclass();
+ if (null == _superclass) {
+ break;
+ }
+ else {
+ cdi = _superclass;
+ }
+ }
+ return null;
+ }
+
+ public static ConstructorDoc findConstructor(ClassDoc classDoc, String nameAndSignature) {
+ int ndx=nameAndSignature.indexOf('(');
+ if (ndx<=0)
+ return null;
+ else {
+ String fullSignature = resolveSignature(classDoc, nameAndSignature.substring(ndx));
+ return findConstructor(classDoc,
+ nameAndSignature.substring(0,ndx),
+ fullSignature);
+ }
+ }
+
+ public static ConstructorDoc findConstructor(ClassDoc classDoc, String name, String signature) {
+ ConstructorDoc[] filteredConstructors = classDoc.constructors(true);
+ if (null != filteredConstructors) {
+ for (int i=0; i<filteredConstructors.length; ++i) {
+ ConstructorDoc constructor = filteredConstructors[i];
+ if (constructor.name().equals(name) && constructor.signature().equals(signature))
+ return constructor;
+ }
+ }
+ return null;
+ }
+
+ public static MethodDoc findMethod(ClassDoc classDoc, String nameAndSignature) {
+ int ndx=nameAndSignature.indexOf('(');
+ if (ndx<=0) {
+ return null;
+ }
+ else {
+ String name = nameAndSignature.substring(0,ndx);
+ String fullSignature = resolveSignature(classDoc, nameAndSignature.substring(ndx));
+ return findMethod(classDoc, name, fullSignature);
+ }
+ }
+
+ private static String resolveSignature(ClassDoc classDoc, String signature)
+ {
+ signature = signature.substring(1, signature.length() - 1).trim();
+ if (0 == signature.length()) {
+ return "()";
+ }
+ StringTokenizer st = new StringTokenizer(signature, ",");
+ StringBuffer fullSignature = new StringBuffer("(");
+ while (st.hasMoreTokens()) {
+ String type = st.nextToken().trim();
+ int ndx = type.length();
+ while (ndx > 0 && type.charAt(ndx - 1) == '[' || type.charAt(ndx - 1) == ']') {
+ -- ndx;
+ }
+ String dim = type.substring(ndx);
+ type = type.substring(0, ndx);
+ ClassDoc typeClass = classDoc.findClass(type);
+ if (fullSignature.length() > 1) {
+ fullSignature.append(",");
+ }
+ if (null != typeClass) {
+ fullSignature.append(typeClass.qualifiedName());
+ }
+ else {
+ fullSignature.append(type);
+ }
+ fullSignature.append(dim);
+ }
+ fullSignature.append(')');
+ return fullSignature.toString();
+ }
+
+ public static MethodDoc findMethod(ClassDoc classDoc, String name, String signature) {
+ MethodDoc[] filteredMethods = classDoc.methods(true);
+ if (null != filteredMethods) {
+ for (int i=0; i<filteredMethods.length; ++i) {
+ MethodDoc method = filteredMethods[i];
+ if (method.name().equals(name) && method.signature().equals(signature))
+ return method;
+ }
+ }
+ return null;
+ }
+
+ public boolean equals(Object o) {
+ return (o!=null) && (o instanceof ClassDoc) && ((ClassDoc)o).qualifiedName().equals(qualifiedName());
+ }
+
+ private List maybeSerMethodList;
+
+ void setMaybeSerMethodList(List maybeSerMethodList) {
+ this.maybeSerMethodList=maybeSerMethodList;
+ }
+
+ public void setDimension(String dimension) {
+ this.dimension = dimension;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ ClassDocImpl result = (ClassDocImpl)super.clone();
+ result.baseClassDoc = baseClassDoc;
+ return result;
+ }
+
+ public int superHashCode()
+ {
+ return super.hashCode();
+ }
+
+ public int hashCode()
+ {
+ return qualifiedTypeName().hashCode();
+ }
+
+ public ClassDoc getBaseClassDoc()
+ {
+ return baseClassDoc;
+ }
+
+ public FieldDoc getFieldDoc(String name)
+ {
+ for (int i=0; i<unfilteredFields.length; ++i) {
+ if (name.equals(unfilteredFields[i].name())) {
+ return unfilteredFields[i];
+ }
+ }
+ return null;
+ }
+
+ public MethodDoc getMethodDoc(String name, String signature)
+ {
+ for (int i=0; i<unfilteredMethods.length; ++i) {
+ if (name.equals(unfilteredMethods[i].name())
+ && signature.equals(unfilteredMethods[i].signature())) {
+ return unfilteredMethods[i];
+ }
+ }
+ return null;
+ }
+
+
+ public ConstructorDoc getConstructorDoc(String signature)
+ {
+ for (int i=0; i<unfilteredConstructors.length; ++i) {
+ if (signature.equals(unfilteredConstructors[i].signature())) {
+ return unfilteredConstructors[i];
+ }
+ }
+ return null;
+ }
+
+ private Object findFieldValue(String identifier,
+ ClassDoc classDoc,
+ String fieldName,
+ Set visitedFields)
+ throws UnknownIdentifierException, IllegalExpressionException
+ {
+ while (classDoc != null) {
+ if (classDoc instanceof ClassDocImpl) {
+ FieldDocImpl fieldDoc
+ = (FieldDocImpl)((ClassDocImpl)classDoc).getFieldDoc(fieldName);
+ if (visitedFields.contains(fieldDoc)) {
+ throw new CircularExpressionException("Circular reference detected");
+ }
+ else if (null != fieldDoc) {
+ return fieldDoc.constantValue(visitedFields);
+ }
+ }
+ else {
+ ClassDoc[] _interfaces = classDoc.interfaces();
+ if (null != _interfaces) {
+ for (int i=0; i<_interfaces.length; ++i) {
+ if (_interfaces[i] instanceof ClassDocImpl) {
+ FieldDocImpl fieldDoc
+ = (FieldDocImpl)((ClassDocImpl)_interfaces[i]).getFieldDoc(fieldName);
+ if (visitedFields.contains(fieldDoc)) {
+ throw new CircularExpressionException("Circular reference detected");
+ }
+ else if (null != fieldDoc) {
+ return fieldDoc.constantValue(visitedFields);
+ }
+ }
+ }
+ }
+ }
+ classDoc = classDoc.superclass();
+ }
+ throw new UnknownIdentifierException(identifier);
+ }
+
+ public Object getValue(String identifier, Set visitedFields)
+ throws UnknownIdentifierException, IllegalExpressionException
+ {
+ int ndx = identifier.lastIndexOf('.');
+ if (ndx >= 0) {
+ String _className = identifier.substring(0, ndx);
+ String _fieldName = identifier.substring(ndx + 1);
+
+ ClassDoc _classDoc = findClass(_className);
+ if (null != _classDoc) {
+ return findFieldValue(identifier, _classDoc, _fieldName, visitedFields);
+ }
+ else {
+ throw new UnknownIdentifierException(identifier);
+ }
+ }
+ else {
+ return findFieldValue(identifier, this, identifier, visitedFields);
+ }
+ }
+
+ public boolean isPrimitive()
+ {
+ return false;
+ }
+
+ // Compares this Object with the specified Object for order.
+ public int compareTo(java.lang.Object o) {
+ int rc;
+
+ if (o instanceof ClassDocImpl) {
+
+ ClassDocImpl c1 = this;
+ ClassDocImpl c2 = (ClassDocImpl)o;
+
+ if (null != c1.containingClass() && null == c2.containingClass()) {
+ rc = c1.containingClass().compareTo(c2);
+ if (0 == rc) {
+ rc = 1;
+ }
+ return rc;
+ }
+ else if (null == c1.containingClass() && null != c2.containingClass()) {
+ rc = c1.compareTo(c2.containingClass());
+ if (0 == rc) {
+ rc = -1;
+ }
+ return rc;
+ }
+ else if (null != c1.containingClass() && null != c2.containingClass()) {
+ rc = c1.containingClass().compareTo(c2.containingClass());
+ if (0 != rc) {
+ return rc;
+ }
+ }
+
+ rc = super.compareTo(o);
+ if (0 == rc) {
+ return Main.getInstance().getCollator().compare(containingPackage().name(),
+ ((ClassDocImpl)o).containingPackage().name());
+ }
+ else {
+ return rc;
+ }
+ }
+ else {
+ return 1;
+ }
+ }
+
+ private List importStatementList;
+
+ public void setImportStatementList(List importStatementList)
+ {
+ this.importStatementList = new LinkedList();
+ this.importStatementList.addAll(importStatementList);
+ }
+
+ public List getImportSpecifierList()
+ {
+ return importStatementList;
+ }
+
+ public TypeVariable[] typeParameters()
+ {
+ return typeParameters;
+ }
+
+ /**
+ * <p>
+ * Parses the type variables declared in the class definition.
+ * The syntax is:
+ * </p>
+ * <p>
+ * <dl>
+ * <dt>TypeParameters:</dt>
+ * <dd><code>&lt; <em>TypeParameter</em> { <em>, TypeParameter }</code></dd>
+ * <dt>TypeParameter:</dt>
+ * <dd><code><em>Identifier</em> { <strong>extends</strong> <em>Bound</em>
+ * }</dd>
+ * <dt>Bound:</dt>
+ * <dd><code><em>Type</em>{<strong>&</strong> <em>Type</em> } </dd>
+ * </dl>
+ *
+ * @param rc the owning class.
+ * @param typeVariables the string to be parsed.
+ * @throws ParseException if parsing fails.
+ */
+ public static void parseTypeVariables(ClassDocImpl rc,
+ String typeVariables)
+ throws ParseException
+ {
+ List parsedBounds = null;
+ StringTokenizer parameters = new StringTokenizer(typeVariables,
+ Parser.WHITESPACE +
+ "<>,");
+ List variables = new ArrayList();
+ while (parameters.hasMoreTokens())
+ {
+ String parameter = parameters.nextToken();
+ StringTokenizer parts = new StringTokenizer(parameter,
+ Parser.WHITESPACE);
+ TypeVariableImpl variable = new TypeVariableImpl(rc.qualifiedName(),
+ parts.nextToken(),"",
+ rc);
+ if (parts.hasMoreTokens())
+ {
+ if (!parts.nextToken().equals("extends"))
+ throw new ParseException("Invalid type parameter: " + parameter);
+ StringTokenizer bounds = new StringTokenizer(parts.nextToken(),
+ Parser.WHITESPACE
+ + "&");
+ parsedBounds = new ArrayList();
+ while (bounds.hasMoreTokens())
+ {
+ String bound = bounds.nextToken();
+ int nameSep = bound.lastIndexOf(".");
+ String packageName = bound.substring(0, nameSep);
+ String boundName = bound.substring(nameSep, bound.length());
+ parsedBounds.add(new TypeImpl(packageName,boundName,""));
+ }
+ }
+ if (parsedBounds != null)
+ variable.setBounds(parsedBounds);
+ variables.add(variable);
+ }
+ rc.setTypeParameters(variables);
+ }
+
+ /**
+ * Set the type parameters to the contents of the supplied list.
+ *
+ * @param variables a list of type parameters.
+ */
+ void setTypeParameters(List variables)
+ {
+ typeParameters =
+ (TypeVariable[]) variables.toArray(new TypeVariable[variables.size()]);
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocProxy.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocProxy.java
new file mode 100644
index 000000000..253cf5ec4
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocProxy.java
@@ -0,0 +1,169 @@
+/* gnu.classpath.tools.gjdoc.ClassDocProxy
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+
+import java.io.*;
+
+public class ClassDocProxy implements ClassDoc, WritableType {
+
+ private String name;
+ private String qualifiedName;
+ private ClassDoc classContext;
+ private String dimension = "";
+
+ public ClassDocProxy(String qualifiedName, ClassDoc classContext)
+ {
+ this.qualifiedName
+ = Main.getRootDoc().resolveClassName(qualifiedName,
+ (ClassDocImpl)classContext);
+ this.classContext=classContext;
+ int pndx=qualifiedName.lastIndexOf('.');
+ if (pndx>=0) {
+ this.name=qualifiedName.substring(pndx+1);
+ }
+ else {
+ this.name=qualifiedName;
+ }
+ }
+
+ private final String errorText()
+ {
+ return "CLASS "+qualifiedName+" NOT LOADED.";
+ }
+
+ public ConstructorDoc[] constructors() { return new ConstructorDoc[0]; }
+ public ConstructorDoc[] constructors(boolean filtered) { return new ConstructorDoc[0]; }
+ public boolean definesSerializableFields() { return false; }
+ public FieldDoc[] fields() { return new FieldDoc[0]; }
+ public FieldDoc[] fields(boolean filtered) { return new FieldDoc[0]; }
+ public ClassDoc findClass(java.lang.String className) { return null; }
+ public ClassDoc[] importedClasses() { return new ClassDoc[0]; }
+ public PackageDoc[] importedPackages() { return new PackageDoc[0]; }
+ public ClassDoc[] innerClasses() { return new ClassDoc[0]; }
+ public ClassDoc[] innerClasses(boolean filtered) { return new ClassDoc[0]; }
+ public ClassDoc[] interfaces() { return new ClassDoc[0]; }
+ public boolean isAbstract() { return false; }
+ public boolean isExternalizable() { return false; }
+ public boolean isSerializable() { return false; }
+ public MethodDoc[] methods() { return new MethodDoc[0]; }
+ public MethodDoc[] methods(boolean filtered) { return new MethodDoc[0]; }
+ public FieldDoc[] serializableFields() { return new FieldDoc[0]; }
+ public MethodDoc[] serializationMethods() { return new MethodDoc[0]; }
+ public boolean subclassOf(ClassDoc cd) { return false; }
+ public ClassDoc superclass() { return null; }
+ public ClassDoc containingClass() { return null; }
+ public PackageDoc containingPackage() {
+ /*
+ try {
+ File file=Main.getRootDoc().findScheduledClass(qualifiedName, classContext);
+ if (file!=null) {
+ //String clsName=file.getCanonicalFile().getAbsolutePath().substring(new File(Main.getRootDoc().getSourcePath()).getCanonicalFile().getAbsolutePath().length()+1);
+ String clsName=file.getAbsolutePath().substring(new File(Main.getRootDoc().getSourcePath()).getAbsolutePath().length()+1);
+ clsName=clsName.substring(0,clsName.length()-5).replace(File.separatorChar,'.');
+ Debug.log(9,"ClassDocProxy '"+qualifiedName+"': found class "+clsName);
+ qualifiedName=clsName;
+ }
+ return new PackageDocImpl("test.");
+ }
+ catch (Exception e) {
+ return PackageDocImpl.DEFAULT_PACKAGE;
+ }
+ */
+ return PackageDocImpl.DEFAULT_PACKAGE;
+ }
+
+ public boolean isFinal() { return false; }
+ public boolean isPackagePrivate() { return false; }
+ public boolean isPrivate() { return false; }
+ public boolean isProtected() { return false; }
+ public boolean isPublic() { return false; }
+ public boolean isStatic() { return false; }
+ public String modifiers() { return ""; }
+ public int modifierSpecifier() { return 0; }
+ public String qualifiedName() { return qualifiedName; }
+ public String commentText() { return null; }
+ public Tag[] firstSentenceTags() { return new Tag[0]; }
+ public String getRawCommentText() { return null; }
+ public Tag[] inlineTags() { return new Tag[0]; }
+ public boolean isClass() { return false; }
+ public boolean isConstructor() { return false; }
+ public boolean isError() { return false; }
+ public boolean isException() { return false; }
+ public boolean isField() { return false; }
+ public boolean isIncluded() { return false; }
+ public boolean isInterface() { return false; }
+ public boolean isMethod() { return false; }
+ public boolean isOrdinaryClass() { return false; }
+ public String name() { return name; }
+ public SourcePosition position() { return null; }
+ public SeeTag[] seeTags() { return new SeeTag[0]; }
+ public void setRawCommentText(java.lang.String rawDocumentation) {}
+ public Tag[] tags() { return new Tag[0]; }
+ public Tag[] tags(java.lang.String tagname) { return new Tag[0]; }
+ public String typeName() { return name; }
+ public String qualifiedTypeName() { return qualifiedName; }
+ public String dimension() { return dimension; }
+ public ClassDoc asClassDoc() { return this; }
+ public TypeVariable asTypeVariable() { return null; }
+ public boolean isPrimitive() { return false; }
+
+ public String toString() { return "ClassDocProxy{"+qualifiedName+", context="+classContext+"}"; }
+
+ public void setDimension(String dimension) {
+ this.dimension = dimension;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ // Compares this Object with the specified Object for order.
+ public int compareTo(java.lang.Object o) {
+ if (o instanceof Doc) {
+ return Main.getInstance().getCollator().compare(name(), ((Doc)o).name());
+ }
+ else {
+ return 0;
+ }
+ }
+
+ public TypeVariable[] typeParameters() { return new TypeVariable[0]; }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.java
new file mode 100644
index 000000000..9a81cb793
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.java
@@ -0,0 +1,219 @@
+/* gnu.classpath.tools.gjdoc.ClassDocReflectedImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.Map;
+import java.util.HashMap;
+
+public class ClassDocReflectedImpl
+ implements ClassDoc, WritableType
+{
+ private Class clazz;
+ private String name;
+ private ClassDoc superclassDoc;
+ private ClassDoc[] unfilteredInnerClasses;
+ private String dimension = "";
+
+ private static Map reflectionCache = new HashMap();
+
+ public static ClassDocReflectedImpl newInstance(Class clazz)
+ {
+ ClassDocReflectedImpl result
+ = (ClassDocReflectedImpl)reflectionCache.get(clazz);
+ if (null != result) {
+ return result;
+ }
+ else {
+ return new ClassDocReflectedImpl(clazz);
+ }
+ }
+
+ public ClassDocReflectedImpl(Class clazz)
+ {
+ reflectionCache.put(clazz, this);
+
+ //System.err.println("ClassDocReflectedImpl: " + clazz);
+
+ this.clazz = clazz;
+ String className = clazz.getName();
+ int ndx = className.lastIndexOf('.');
+ if (ndx >= 0) {
+ this.name = className.substring(ndx + 1);
+ }
+ else {
+ this.name = className;
+ }
+
+ Class superclass = clazz.getSuperclass();
+ if (null != superclass && !clazz.getName().equals("java.lang.Object")) {
+ this.superclassDoc = (ClassDocReflectedImpl)reflectionCache.get(superclass);
+ if (null == this.superclassDoc) {
+ this.superclassDoc = new ClassDocReflectedImpl(superclass);
+ }
+ }
+
+ Class[] innerclasses = clazz.getDeclaredClasses();
+ this.unfilteredInnerClasses = new ClassDoc[innerclasses.length];
+ for (int i=0; i<innerclasses.length; ++i) {
+ this.unfilteredInnerClasses[i] = (ClassDocReflectedImpl)reflectionCache.get(innerclasses[i]);
+ if (null == this.unfilteredInnerClasses[i]) {
+ this.unfilteredInnerClasses[i] = new ClassDocReflectedImpl(innerclasses[i]);
+ //System.err.println("adding " + this.unfilteredInnerClasses[i] + " [" + innerclasses[i] + "] as inner class of " + this + " [" + clazz + "]");
+ }
+ }
+ }
+
+ public ConstructorDoc[] constructors() { return new ConstructorDoc[0]; }
+ public ConstructorDoc[] constructors(boolean filtered) { return new ConstructorDoc[0]; }
+ public boolean definesSerializableFields() { return false; }
+ public FieldDoc[] fields() { return new FieldDoc[0]; }
+ public FieldDoc[] fields(boolean filtered) { return new FieldDoc[0]; }
+ public ClassDoc findClass(java.lang.String className) { return null; }
+ public ClassDoc[] importedClasses() { return new ClassDoc[0]; }
+ public PackageDoc[] importedPackages() { return new PackageDoc[0]; }
+ public ClassDoc[] innerClasses() { return new ClassDoc[0]; }
+ public ClassDoc[] innerClasses(boolean filtered)
+ {
+ if (filtered) {
+ return new ClassDoc[0];
+ }
+ else {
+ return unfilteredInnerClasses;
+ }
+ }
+
+ public ClassDoc[] interfaces() { return new ClassDoc[0]; }
+ public boolean isAbstract() { return false; }
+ public boolean isExternalizable() { return false; }
+ public boolean isSerializable() { return false; }
+ public MethodDoc[] methods() { return new MethodDoc[0]; }
+ public MethodDoc[] methods(boolean filtered) { return new MethodDoc[0]; }
+ public FieldDoc[] serializableFields() { return new FieldDoc[0]; }
+ public MethodDoc[] serializationMethods() { return new MethodDoc[0]; }
+ public boolean subclassOf(ClassDoc cd) { return false; }
+ public ClassDoc superclass() {
+ return superclassDoc;
+ }
+ public ClassDoc containingClass()
+ {
+ Class declaringClass = clazz.getDeclaringClass();
+ if (null != declaringClass) {
+ return new ClassDocReflectedImpl(declaringClass);
+ }
+ else {
+ return null;
+ }
+ }
+ public PackageDoc containingPackage()
+ {
+ Class outerClass = clazz;
+ while (null != outerClass.getDeclaringClass()) {
+ outerClass = outerClass.getDeclaringClass();
+ }
+
+ String packageName = outerClass.getName();
+ int ndx = packageName.lastIndexOf('.');
+ if (ndx > 0) {
+ packageName = packageName.substring(0, ndx);
+ }
+ else {
+ packageName = "";
+ }
+ PackageDoc result = Main.getRootDoc().findOrCreatePackageDoc(packageName);
+ return result;
+ }
+
+ public boolean isFinal() { return false; }
+ public boolean isPackagePrivate() { return false; }
+ public boolean isPrivate() { return false; }
+ public boolean isProtected() { return false; }
+ public boolean isPublic() { return false; }
+ public boolean isStatic() { return false; }
+ public String modifiers() { return ""; }
+ public int modifierSpecifier() { return 0; }
+ public String qualifiedName() { return clazz.getName().replace('$', '.'); }
+ public String commentText() { return null; }
+ public Tag[] firstSentenceTags() { return new Tag[0]; }
+ public String getRawCommentText() { return null; }
+ public Tag[] inlineTags() { return new Tag[0]; }
+ public boolean isClass() { return false; }
+ public boolean isConstructor() { return false; }
+ public boolean isError() { return false; }
+ public boolean isException() { return false; }
+ public boolean isField() { return false; }
+ public boolean isIncluded() { return false; }
+ public boolean isInterface() { return false; }
+ public boolean isMethod() { return false; }
+ public boolean isOrdinaryClass() { return false; }
+ public String name() { return name; }
+ public SourcePosition position() { return null; }
+ public SeeTag[] seeTags() { return new SeeTag[0]; }
+ public void setRawCommentText(java.lang.String rawDocumentation) {}
+ public Tag[] tags() { return new Tag[0]; }
+ public Tag[] tags(java.lang.String tagname) { return new Tag[0]; }
+ public String typeName() { return name; }
+ public String qualifiedTypeName() { return qualifiedName(); }
+ public ClassDoc asClassDoc() { return this; }
+ public TypeVariable asTypeVariable() { return null; }
+ public boolean isPrimitive() { return false; }
+
+ public String toString() { return "ClassDocReflectedImpl{"+qualifiedName()+"}"; }
+
+ public int compareTo(java.lang.Object o) {
+ if (o instanceof Doc) {
+ return Main.getInstance().getCollator().compare(name(), ((Doc)o).name());
+ }
+ else {
+ return 0;
+ }
+ }
+
+ public String dimension() { return dimension; }
+
+ public void setDimension(String dimension) {
+ this.dimension = dimension;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public TypeVariable[] typeParameters() { return new TypeVariable[0]; }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ConstructorDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ConstructorDocImpl.java
new file mode 100644
index 000000000..ad31ba69e
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ConstructorDocImpl.java
@@ -0,0 +1,59 @@
+/* gnu.classpath.tools.gjdoc.ConstructorDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.util.*;
+import com.sun.javadoc.*;
+
+public class ConstructorDocImpl extends ExecutableMemberDocImpl implements ConstructorDoc {
+
+ public ConstructorDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ SourcePosition position) {
+
+ super(containingClass,
+ containingPackage,
+ position);
+ }
+
+ // Is this Doc item a constructor.
+ public boolean isConstructor() {
+ return true;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Debug.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Debug.java
new file mode 100644
index 000000000..d5020236c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Debug.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.Debug
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+public final class Debug {
+
+ //private static int logLevel = 7;
+ private static int logLevel = 0;
+
+ static {
+ String llProp = System.getProperty("gnu.classpath.tools.gjdoc.LogLevel");
+ if (null!=llProp) logLevel = Integer.parseInt(llProp);
+ }
+
+ public static final void log(String msg) {
+ System.err.println(msg);
+ }
+
+ public static final void log(int level, String msg) {
+ if (level<=logLevel) {
+ System.err.println(msg);
+ }
+ }
+
+ public static final void dumpArray(int level, Object[] array) {
+ if (level<=logLevel) {
+ for (int i=0; i<array.length; ++i) {
+ System.err.println(" #"+i+": "+array[i]);
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/DirectoryTree.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/DirectoryTree.java
new file mode 100644
index 000000000..706e9b6cc
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/DirectoryTree.java
@@ -0,0 +1,74 @@
+/* gnu.classpath.tools.gjdoc.DirectoryTree
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.io.*;
+
+public class DirectoryTree {
+
+ class FileNode {
+ File file;
+ FileNode[] subNodes;
+
+ FileNode(File file) {
+ this.file=file;
+ if (file.isDirectory()) {
+ File[] subFiles=file.listFiles();
+ subNodes=new FileNode[subFiles.length];
+ for (int i=0; i<subFiles.length; ++i) {
+ subNodes[i]=new FileNode(subFiles[i]);
+ }
+ }
+ }
+ }
+
+ FileNode root;
+
+ DirectoryTree(File path) {
+
+ System.err.print("Scanning "+path.getAbsolutePath()+"... ");
+
+ long now1=System.currentTimeMillis();
+
+ root=new FileNode(path);
+
+ long now2=System.currentTimeMillis();
+
+ System.err.println("took "+(now2-now1)+" ms");
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/DocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/DocImpl.java
new file mode 100644
index 000000000..ecd810040
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/DocImpl.java
@@ -0,0 +1,1090 @@
+/* gnu.classpath.tools.gjdoc.DocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+import java.io.File;
+import javax.swing.text.Segment;
+
+/**
+ * Represents the least common denominator of all Javadoc
+ * comment classes.
+ */
+public abstract class DocImpl implements Doc, TagContainer {
+
+ protected static Tag[] seeTagEmptyArr = new SeeTagImpl[0];
+ protected static Tag[] linkTagEmptyArr = new LinkTagImpl[0];
+ protected static Tag[] paramTagEmptyArr = new ParamTagImpl[0];
+ protected static Tag[] throwsTagEmptyArr = new ThrowsTagImpl[0];
+ protected SourcePosition position;
+ private String boilerplateComment;
+
+ // Return the text of the comment for this doc item.
+ public String commentText() {
+
+ StringBuffer rc=new StringBuffer();
+
+ Tag[] textTags=(Tag[])tagMap.get("text");
+ if (textTags!=null) {
+ for (int i=0; i<textTags.length; ++i) {
+ rc.append(textTags[i].text());
+ }
+ }
+ return rc.toString();
+ }
+
+ // Compares this Object with the specified Object for order.
+ public int compareTo(java.lang.Object o) {
+ return Main.getInstance().getCollator().compare(name(), ((Doc)o).name());
+ }
+
+ // Return the first sentence of the comment as tags.
+ public Tag[] firstSentenceTags() {
+
+ Tag[] rc=(Tag[])tagMap.get("first");
+ if (rc==null) rc=new Tag[0];
+ return rc;
+ }
+
+ // Return the full unprocessed text of the comment.
+ public String getRawCommentText() {
+ if (rawDocumentation!=null)
+ return rawDocumentation;
+ else if (rawDocOffset>=0)
+ return Main.getRootDoc().readRawComment(rawDocOffset);
+ else
+ return null;
+ }
+
+ // Return comment as tags.
+ public Tag[] inlineTags() {
+
+ Tag[] rc=(Tag[])tagMap.get("inline");
+ if (rc==null) rc=new Tag[0];
+ return rc;
+ }
+
+ // Is this Doc item a class.
+ public boolean isClass() {
+ return false;
+ }
+
+ // Is this Doc item a constructor? False until overridden.
+ public boolean isConstructor() {
+ return false;
+ }
+
+ // Is this Doc item a error class? False until overridden.
+ public boolean isError() {
+ return false;
+ }
+
+ // Is this Doc item a exception class? False until overridden.
+ public boolean isException() {
+ return false;
+ }
+
+ // Is this Doc item a field? False until overridden.
+ public boolean isField() {
+ return false;
+ }
+
+ // return true if this Doc is include in the active set.
+ public boolean isIncluded() {
+ return false;
+ }
+
+ // Is this Doc item a interface? False until overridden.
+ public boolean isInterface() {
+ return false;
+ }
+
+ // Is this Doc item a simple method (i.e.
+ public boolean isMethod() {
+ return false;
+ }
+
+ public boolean isPackage() {
+ return false;
+ }
+
+ // Is this Doc item a ordinary class (i.e.
+ public boolean isOrdinaryClass() {
+ return false;
+ }
+
+ // Return the see also tags in this Doc item.
+ public SeeTag[] seeTags() {
+ return (SeeTag[])getTagArr("see", seeTagEmptyArr);
+ }
+
+ protected Tag[] getTagArr(String kindOfTag, Tag[] defaultRc) {
+ Tag[] rc=(Tag[])tagMap.get(kindOfTag);
+ if (rc==null) rc=defaultRc;
+ return rc;
+ }
+
+ // Set the full unprocessed text of the comment.
+ public void setRawCommentText(String rawDocumentation) {
+ this.rawDocumentation=rawDocumentation;
+ }
+
+ public void resolveComments() {
+
+ if (rawDocumentation!=null && tagMap.isEmpty()) {
+ char[] charArray = rawDocumentation.toCharArray();
+ int length = rawDocumentation.length();
+ int startOffset = 0;
+ int endOffset = 0;
+ if (charArray[0] == '/'
+ && charArray[1] == '*'
+ && charArray[2] == '*'
+ && charArray[length - 2] == '*'
+ && charArray[length - 1] == '/') {
+
+ startOffset = 3;
+ endOffset = 2;
+ }
+
+ this.tagMap=parseCommentTags(charArray,
+ startOffset,
+ length - endOffset,
+ getContextClass(),
+ getContextMember(),
+ null,
+ boilerplateComment);
+
+ if (Main.getInstance().isCacheRawComments()) {
+ rawDocOffset=Main.getRootDoc().writeRawComment(rawDocumentation);
+ rawDocumentation=null;
+ }
+
+ resolveTags();
+ }
+ else if (tagMap.isEmpty() && null != boilerplateComment) {
+ tagMap.put("all", new Tag[] { new TagImpl("@boilerplate", boilerplateComment,getContextClass(),null) });
+ tagMap.put("@boilerplate", new Tag[] { new TagImpl("@boilerplate", boilerplateComment,getContextClass(),null) });
+ }
+ }
+
+ public static int skipHtmlWhitespace(char[] buffer, int startIndex) {
+ while (startIndex < buffer.length) {
+ char c=buffer[startIndex];
+ if (!Parser.isWhitespace(c)) {
+ break;
+ }
+ else {
+ ++ startIndex;
+ }
+ }
+ return startIndex;
+ }
+
+ /**
+ * Looks for an end-of-sentence marker in <code>text</code>,
+ * starting at <code>startIndex</code> and stopping at
+ * <code>endIndex</code>.
+ *
+ * @param text the text to be searched
+ * @param startIndex index in <code>text</code> at which to start
+ * @param endIndex index in <code>text</code> at which to stop
+ *
+ * @return the index of the character following the end-of-sentence
+ * marker, <code>endIndex</code> if no end-of-sentence
+ * marker could be found, or -1 if not implemented.
+ */
+ private static int findEndOfSentence(char[] text, int startIndex,
+ int endIndex)
+ {
+ if (Main.getInstance().isUseBreakIterator()) {
+ Segment segment = new Segment(text, startIndex, endIndex - startIndex);
+ BreakIterator breakIterator = BreakIterator.getSentenceInstance(Main.getInstance().getLocale());
+ breakIterator.setText(segment);
+ int result = breakIterator.next();
+ if (BreakIterator.DONE == result) {
+ return endIndex;
+ }
+ else {
+ return result;
+ }
+ }
+ else {
+ while (startIndex < endIndex) {
+ if (text[startIndex] == '.'
+ && (startIndex+1 == endIndex
+ || Character.isWhitespace(text[startIndex+1])
+ || isHTMLBreakTag(text, startIndex+1, endIndex)
+ )) {
+ return startIndex;
+ }
+
+ startIndex++;
+ }
+ return endIndex;
+ }
+ }
+
+ /**
+ * Returns true is the text from start to end begins with a 'p' or 'br' tag.
+ */
+ private static boolean isHTMLBreakTag(char[] text, int start, int end)
+ {
+ String[] breakTags = {
+ "p>", "/p>", "h1>", "h2>", "h3>", "h4>", "h5>", "h6>", "hr>",
+ "pre>", "/pre>"
+ };
+
+ if (text[start] == '<') {
+
+ outer:
+ for (int i=0; i<breakTags.length; ++i) {
+ String tag = breakTags[i];
+ int len = tag.length();
+ if (start + len < end) {
+ for (int j=0; j<len; ++j) {
+ char c = tag.charAt(j);
+ if (Character.toLowerCase(text[start + 1 + j]) != c) {
+ continue outer;
+ }
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ //private static final StringBuffer buf=new StringBuffer(32768);
+ private static final StringBuffer whitespaceBuf=new StringBuffer();
+ private static char[] charBuf = new char[60000];
+ private static int bufPos = 0;
+
+ private static void appendToBuf(char c)
+ {
+ if (bufPos < charBuf.length) {
+ charBuf[bufPos++] = c;
+ }
+ else {
+ //
+ }
+ }
+
+ private static void appendToBuf(StringBuffer s)
+ {
+ if (bufPos + s.length() <= charBuf.length) {
+ s.getChars(0, s.length(), charBuf, bufPos);
+ bufPos += s.length();
+ }
+ else {
+ //
+ }
+ }
+
+ private static void setBufLength(int length)
+ {
+ bufPos = 0;
+ }
+
+ private static String bufToString()
+ {
+ return new String(charBuf, 0, bufPos);
+ }
+
+ private static int bufLength()
+ {
+ return bufPos;
+ }
+
+ public static Map parseCommentTags(char[] comment, int startIndex, int endIndex,
+ ClassDocImpl contextClass, MemberDocImpl contextMember,
+ AbstractTagImpl contextTag, String boilerplateComment) {
+
+ int rawDocStart=skipHtmlWhitespace(comment, startIndex);
+
+ int firstSentenceEnd = 0;
+
+ if (comment.length>rawDocStart) {
+
+ firstSentenceEnd = findEndOfSentence(comment, rawDocStart, comment.length);
+
+ if (firstSentenceEnd < 0) {
+ BreakIterator boundary = BreakIterator.getSentenceInstance(Locale.ENGLISH);
+ boundary.setText(new ArrayCharacterIterator(comment, rawDocStart));
+ boundary.first();
+ boundary.next();
+ firstSentenceEnd = boundary.current();
+ }
+
+ // Always include period at end of sentence if there is one.
+ if (firstSentenceEnd < comment.length
+ && '.' == comment[firstSentenceEnd]) {
+ ++ firstSentenceEnd;
+ }
+ }
+
+ final int STATE_BEGOFLINE = 1;
+ final int STATE_TEXT = 2;
+ final int STATE_PARAM = 3;
+ final int STATE_PARAMVALUE = 4;
+ final int STATE_PARAMWRAP = 5;
+ final int STATE_INLINEPARAM = 6;
+ final int STATE_INLINEPARAMVALUE = 7;
+ final int STATE_WHITESPACE = 8;
+ final int STATE_INLINEPARAMVALUE_BOL = 9;
+ final int STATE_IPV_WHITESPACE = 10;
+
+ int state=STATE_BEGOFLINE;
+ int prevState=STATE_TEXT;
+
+ setBufLength(0);
+ whitespaceBuf.setLength(0);
+
+ String paramName="", paramValue="";
+
+ Map tags=new HashMap();
+ tags.put("inline", new LinkedList());
+ tags.put("first", new LinkedList());
+ tags.put("all", new LinkedList());
+
+ final char EOL=(char)-1;
+
+ for (int i=rawDocStart; i<=endIndex; ++i) {
+ char c=(i<endIndex)?comment[i]:EOL;
+ char peek=(i<endIndex-1)?comment[i+1]:EOL;
+
+ switch (state){
+
+ case STATE_BEGOFLINE:
+ if (i==firstSentenceEnd) {
+ AbstractTagImpl newTag = addTag(tags, "text", bufToString(), true, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ setBufLength(0);
+ }
+
+ if (Parser.isWhitespace(c)) {
+ // ignore
+ }
+ else if (c=='*') {
+ // ignore, but go to STATE_TEXT
+ if (peek!='*' && peek!='@' && peek!=EOL) {
+ state=STATE_WHITESPACE;
+ }
+ }
+ else if (c=='@' || (c=='{' && peek=='@') || c==EOL) {
+ if (bufLength()>0) {
+ addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ setBufLength(0);
+ }
+ if (c=='{') {
+ ++i;
+ state=STATE_INLINEPARAM;
+ }
+ else {
+ state=STATE_PARAM;
+ }
+ }
+ else {
+ state=STATE_TEXT;
+ appendToBuf(whitespaceBuf);
+ whitespaceBuf.setLength(0);
+ appendToBuf(c);
+ }
+ break;
+
+ case STATE_WHITESPACE:
+ if (i==firstSentenceEnd) {
+ AbstractTagImpl newTag = addTag(tags, "text", bufToString(), true, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ setBufLength(0);
+ }
+
+ if (c=='\n') {
+ whitespaceBuf.append(c);
+ state=STATE_BEGOFLINE;
+ }
+ else if (Parser.isWhitespace(c)) {
+ whitespaceBuf.append(c);
+ }
+ else if (c=='@' || (c=='{' && peek=='@') || c==EOL) {
+ if (bufLength()>0) {
+ AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ setBufLength(0);
+ }
+ if (c=='{') {
+ ++i;
+ state=STATE_INLINEPARAM;
+ }
+ else {
+ state=STATE_PARAM;
+ }
+ }
+ else {
+ appendToBuf(whitespaceBuf);
+ whitespaceBuf.setLength(0);
+ appendToBuf(c);
+ state=STATE_TEXT;
+ }
+ break;
+
+ case STATE_PARAMWRAP:
+ if (c=='\n') {
+ appendToBuf(c);
+ }
+ else if (Parser.isWhitespace(c)) {
+ // ignore
+ }
+ else if (c=='*') {
+ // ignore, but go to STATE_TEXT
+ /*
+ if (i<endIndex && comment[i+1]!='*' && comment[i+1]!='@') {
+ state=STATE_PARAMVALUE;
+ }
+ */
+ }
+ else if (c=='@' || c==EOL) {
+ paramValue=bufToString();
+ AbstractTagImpl newTag = addTag(tags, paramName, paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ setBufLength(0);
+ if (c=='{') {
+ ++i;
+ state=STATE_INLINEPARAM;
+ }
+ else {
+ state=STATE_PARAM;
+ }
+ }
+ else {
+ state=STATE_PARAMVALUE;
+ appendToBuf(c);
+ }
+ break;
+
+ case STATE_PARAM:
+ if (!(c==EOL || Parser.isWhitespace(c))) {
+ appendToBuf(c);
+ }
+ else if (c=='\n') {
+ paramName=bufToString();
+ setBufLength(0);
+ state=STATE_PARAMWRAP;
+ }
+ else {
+ paramName=bufToString();
+ setBufLength(0);
+ state=STATE_PARAMVALUE;
+ }
+ break;
+
+ case STATE_INLINEPARAM:
+ if (c=='}') {
+ // tag without value
+ paramName=bufToString();
+ AbstractTagImpl newTag = addTag(tags, paramName, "", i<firstSentenceEnd, contextClass, contextMember, contextTag, true);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ state=prevState;
+ setBufLength(0);
+ }
+ else if (!(c==EOL || Parser.isWhitespace(c))) {
+ appendToBuf(c);
+ }
+ else if (c=='\n') {
+ paramName=bufToString();
+ setBufLength(0);
+ state=STATE_INLINEPARAMVALUE_BOL;
+ }
+ else {
+ paramName=bufToString();
+ setBufLength(0);
+ state=STATE_INLINEPARAMVALUE;
+ }
+ break;
+
+ case STATE_PARAMVALUE:
+ if (c==EOL) {
+ paramValue=bufToString();
+ AbstractTagImpl newTag = addTag(tags, paramName, paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ }
+ else if (c=='\n') {
+ appendToBuf(c);
+ state=STATE_PARAMWRAP;
+ }
+ else {
+ appendToBuf(c);
+ }
+ break;
+
+ case STATE_INLINEPARAMVALUE:
+ if (c=='\n') {
+ appendToBuf(c);
+ state=STATE_INLINEPARAMVALUE_BOL;
+ }
+ else if (c==EOL || c=='}') {
+ paramValue=bufToString();
+ AbstractTagImpl newTag = addTag(tags, paramName, paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, true);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ state=prevState;
+ setBufLength(0);
+ }
+ else {
+ appendToBuf(c);
+ }
+ break;
+
+ case STATE_INLINEPARAMVALUE_BOL:
+ if (Parser.isWhitespace(c)) {
+ // ignore
+ }
+ else if (c=='*') {
+ // ignore, but go to STATE_TEXT
+ if (i<endIndex && peek!='*') {
+ state=STATE_IPV_WHITESPACE;
+ }
+ }
+ else if (c==EOL) {
+ if (bufLength()>0) {
+ AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ }
+ }
+ else {
+ state=STATE_INLINEPARAMVALUE;
+ appendToBuf(whitespaceBuf);
+ whitespaceBuf.setLength(0);
+ appendToBuf(c);
+ }
+ break;
+
+ case STATE_IPV_WHITESPACE:
+ if (c=='\n') {
+ whitespaceBuf.append(c);
+ state=STATE_INLINEPARAMVALUE_BOL;
+ }
+ else if (Parser.isWhitespace(c)) {
+ whitespaceBuf.append(c);
+ }
+ else if (c==EOL) {
+ if (bufLength()>0) {
+ AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ setBufLength(0);
+ }
+ }
+ else {
+ appendToBuf(whitespaceBuf);
+ whitespaceBuf.setLength(0);
+ appendToBuf(c);
+ state=STATE_INLINEPARAMVALUE;
+ }
+ break;
+
+ case STATE_TEXT:
+ if (i==firstSentenceEnd) {
+ AbstractTagImpl newTag = addTag(tags, "text", bufToString(), true, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ setBufLength(0);
+ }
+
+ if (c==EOL) {
+ paramValue=bufToString();
+ AbstractTagImpl newTag = addTag(tags, "text", paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ }
+ else if (c=='\n') {
+ appendToBuf(c);
+ state=STATE_BEGOFLINE;
+ }
+ else if (c=='{' && peek=='@') {
+ paramValue=bufToString();
+ AbstractTagImpl newTag = addTag(tags, "text", paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false);
+ if (null != newTag) {
+ contextTag = newTag;
+ }
+ ++i;
+ setBufLength(0);
+ state=STATE_INLINEPARAM;
+ }
+ else {
+ appendToBuf(c);
+ }
+ break;
+
+ default:
+ throw new Error("illegal state "+state);
+ }
+ }
+
+
+ if (null == contextMember && null != boilerplateComment && Main.getInstance().isCopyLicenseText()) {
+ addTag(tags, "@boilerplate", boilerplateComment, false, contextClass, null, null, false);
+ }
+
+ Map rc=new HashMap();
+
+ for (Iterator it=tags.keySet().iterator(); it.hasNext(); ) {
+ String key=(String)it.next();
+ Tag[] templateArr;
+ List list=(List)tags.get(key);
+
+ if ("see".equals(key))
+ templateArr=new SeeTag[list.size()];
+ else if ("param".equals(key))
+ templateArr=new ParamTag[list.size()];
+ else if ("serialField".equals(key))
+ templateArr=new SerialFieldTag[list.size()];
+ else if ("throws".equals(key) || "exception".equals(key))
+ templateArr=new ThrowsTag[list.size()];
+ else {
+ templateArr=new Tag[list.size()];
+ }
+
+ rc.put(key, list.toArray(templateArr));
+ }
+
+ return rc;
+ }
+
+ private ClassDocImpl getContextClass() {
+ if (isClass() || isInterface()) {
+ return (ClassDocImpl)this;
+ }
+ else if (isField() || isMethod() || isConstructor()) {
+ return (ClassDocImpl)((MemberDocImpl)this).containingClass();
+ }
+ else {
+ return null;
+ }
+ }
+
+ private MemberDocImpl getContextMember() {
+ if (isField() || isMethod() || isConstructor()) {
+ return (MemberDocImpl)this;
+ }
+ else {
+ return null;
+ }
+ }
+
+ protected static AbstractTagImpl addTag(Map tags, String name,
+ String value, boolean isFirstSentence,
+ ClassDocImpl contextClass,
+ MemberDocImpl contextMember,
+ AbstractTagImpl contextTag,
+ boolean isInline) {
+
+ AbstractTagImpl tag = null;
+
+ boolean haveValue = (0 != value.trim().length());
+
+ String emptyWarning = "Empty @" + name + " tag.";
+
+ if (name.equals("param")) {
+ if (haveValue) {
+ tag=new ParamTagImpl(value, contextClass, contextMember);
+ }
+ else {
+ //printWarning(emptyWarning);
+ }
+ }
+ else if (name.equals("see")) {
+ if (haveValue) {
+ tag=new SeeTagImpl(value, contextClass);
+ }
+ else {
+ //printWarning(emptyWarning);
+ }
+ }
+ else if (name.equals("link") || name.equals("linkplain")) {
+ if (haveValue) {
+ tag=new LinkTagImpl("@" + name, value, contextClass);
+ isInline = true;
+ }
+ else {
+ //printWarning(emptyWarning);
+ }
+ }
+ else if (name.equals("value")) {
+ if (haveValue) {
+ tag=new ValueTagImpl(value, contextClass);
+ isInline = true;
+ }
+ else {
+ //printWarning(emptyWarning);
+ }
+ }
+ else if (name.equals("inheritDoc")) {
+ if (haveValue) {
+ //printWarning("@inheritDoc tags are not supposed to have any content.");
+ }
+ tag=new InheritDocTagImpl(contextClass, contextMember, contextTag);
+ isInline = true;
+ }
+ else if (name.equals("serialField")) {
+ if (haveValue) {
+ tag=new SerialFieldTagImpl(value, contextClass, contextMember);
+ }
+ else {
+ //printWarning(emptyWarning);
+ }
+ }
+ else if (name.equals("throws") || name.equals("exception")) {
+ if (haveValue) {
+ tag=new ThrowsTagImpl(value, contextClass, contextMember);
+ }
+ else {
+ //printWarning(emptyWarning);
+ }
+ name="throws";
+ }
+ else if (name.equals("text")) {
+ tag=new TextTagImpl(value);
+ isInline = true;
+ }
+ else {
+ tag=new TagImpl("@"+name, value.trim(), contextClass, contextMember);
+ // FIXME: consider taglets
+ }
+
+ if (tag != null) {
+ if (isInline) {
+ ((List)tags.get("inline")).add(tag);
+ if (isFirstSentence) {
+ if (name.equals("text")) {
+ String txt = ((TextTagImpl)tag).getText();
+ Tag newTag;
+ if (txt.startsWith("<p>")) {
+ newTag = new TextTagImpl(txt.substring(3));
+ }
+ else if (txt.endsWith("</p>")) {
+ newTag = new TextTagImpl(txt.substring(0, txt.length() - 4));
+ }
+ else {
+ newTag = tag;
+ }
+ ((List)tags.get("first")).add(newTag);
+
+ }
+ else {
+ ((List)tags.get("first")).add(tag);
+ }
+ }
+ }
+ else {
+ ((List)tags.get("all")).add(tag);
+ }
+
+ List l=((List)tags.get(name));
+ if (l==null) {
+ l=new LinkedList();
+ tags.put(name,l);
+ }
+ l.add(tag);
+
+ return isInline ? tag : contextTag;
+ }
+ else {
+ return null;
+ }
+ }
+
+ // Return all tags in this Doc item.
+ public Tag[] tags() {
+ Tag[] rc=(Tag[])tagMap.get("all");
+ if (rc==null) rc=new Tag[0];
+ return rc;
+ }
+
+ // Return tags of the specified kind in this Doc item.
+ public Tag[] tags(java.lang.String tagname) {
+ Tag[] rc=(Tag[])tagMap.get(tagname);
+ if (rc==null) rc=new Tag[0];
+ return rc;
+ }
+
+ protected String rawDocumentation;
+ protected long rawDocOffset=-1;
+
+ protected Map tagMap = new HashMap();
+
+ public Map getTagMap() { return tagMap; }
+
+ protected void resolveTags() {
+
+ Tag[] tags=tags();
+ for (int i=0; i<tags.length; ++i) {
+ ((AbstractTagImpl)tags[i]).resolve();
+ }
+
+ Tag[] inlineTags=inlineTags();
+ for (int i=0; i<inlineTags.length; ++i) {
+ ((AbstractTagImpl)inlineTags[i]).resolve();
+ }
+ }
+
+ private static Map classDocToFileMap = new HashMap();
+
+ private static File getFile(ClassDoc classDoc) {
+ File result = (File)classDocToFileMap.get(classDoc);
+ if (null == result) {
+ result = new File(((GjdocPackageDoc)classDoc.containingPackage()).packageDirectory(),
+ classDoc.name() + ".java");
+ classDocToFileMap.put(classDoc, result);
+ }
+ return result;
+ }
+
+ public static SourcePosition getPosition(ClassDoc classDoc)
+ {
+ return new SourcePositionImpl(getFile(classDoc), 0, 0);
+ }
+
+ public static SourcePosition getPosition(ClassDoc classDoc, char[] source, int startIndex)
+ {
+ int column = 0;
+ int line = 0;
+ for (int i=0; i<startIndex; ++i) {
+ if (10 == source[i]) {
+ ++ line;
+ column = 0;
+ }
+ else if (13 != source[i]) {
+ ++ column;
+ }
+ }
+ while (true) {
+ ClassDoc containingClassDoc = classDoc.containingClass();
+ if (null != containingClassDoc) {
+ classDoc = containingClassDoc;
+ }
+ else {
+ break;
+ }
+ }
+
+ File file = getFile(classDoc);
+
+ return new SourcePositionImpl(file, line + 1, column + 1);
+ }
+
+ public SourcePosition position()
+ {
+ return this.position;
+ }
+
+ public DocImpl(SourcePosition position)
+ {
+ this.position = position;
+ }
+
+ public void setPosition(SourcePosition position)
+ {
+ this.position = position;
+ }
+
+ private static TagContainer checkForInheritedDoc(ClassDoc classDoc,
+ MemberDocImpl memberDoc,
+ AbstractTagImpl tag)
+ {
+ DocImpl result;
+
+ if (!(classDoc instanceof ClassDocImpl)) {
+ result = null;
+ }
+ else if (null == memberDoc) {
+ result = (DocImpl)classDoc;
+ }
+ else if (memberDoc.isField()) {
+ result = (DocImpl)((ClassDocImpl)classDoc).getFieldDoc(memberDoc.name());
+ }
+ else if (memberDoc.isMethod()) {
+ result = (DocImpl)((ClassDocImpl)classDoc).getMethodDoc(memberDoc.name(),
+ ((MethodDoc)memberDoc).signature());
+ }
+ else if (memberDoc.isConstructor()) {
+ result = (DocImpl)((ClassDocImpl)classDoc).getConstructorDoc(((ConstructorDoc)memberDoc).signature());
+ }
+ else {
+ //assert(false);
+ throw new RuntimeException("memberDoc is supposed to be field, method or constructor");
+ }
+
+ if (null != result
+ && null != memberDoc
+ && null != tag) {
+
+ TagContainer tagDoc = null;
+
+ Tag[] tags = result.tags();
+ for (int i=0; i<tags.length; ++i) {
+ if (tags[i].kind().equals(tag.kind())) {
+ if ("@param".equals(tag.kind())) {
+ if (((ParamTagImpl)tags[i]).parameterName().equals(((ParamTagImpl)tag).parameterName())) {
+ tagDoc = (TagContainer)tags[i];
+ break;
+ }
+ }
+ else if ("@throws".equals(tag.kind())) {
+ if (((ThrowsTagImpl)tags[i]).exceptionName().equals(((ThrowsTagImpl)tag).exceptionName())) {
+ tagDoc = (TagContainer)tags[i];
+ break;
+ }
+ }
+ else if ("@return".equals(tag.kind())) {
+ tagDoc = (TagContainer)tags[i];
+ }
+ }
+ }
+
+ return tagDoc;
+ }
+
+ if (null == result || result.isEmptyDoc()) {
+ return null;
+ }
+ else {
+ return result;
+ }
+ }
+
+ public static TagContainer findInheritedDoc(ClassDoc classDoc,
+ MemberDocImpl memberDoc,
+ AbstractTagImpl tag)
+ {
+ TagContainer result;
+
+ // (Taken from Javadoc Solaris Tool documentation 1.5,
+ // section "Automatic Copying of Method Comments")
+
+ // Algorithm for Inheriting Method Comments - If a method does
+ // not have a doc comment, or has an {@inheritDoc} tag, the
+ // Javadoc tool searches for an applicable comment using the
+ // following algorithm, which is designed to find the most
+ // specific applicable doc comment, giving preference to
+ // interfaces over superclasses:
+
+ // 1. Look in each directly implemented (or extended) interface
+ // in the order they appear following the word implements (or
+ // extends) in the method declaration. Use the first doc comment
+ // found for this method.
+
+ ClassDoc[] interfaces = classDoc.interfaces();
+ if (null != interfaces) {
+ for (int i=0; i<interfaces.length; ++i) {
+ result = checkForInheritedDoc(interfaces[i], memberDoc, tag);
+ if (null != result) {
+ return result;
+ }
+ }
+ }
+
+ // 2. If step 1 failed to find a doc comment, recursively apply
+ // this entire algorithm to each directly implemented (or
+ // extended) interface, in the same order they were examined
+ // in step 1.
+
+ if (null != interfaces) {
+ for (int i=0; i<interfaces.length; ++i) {
+ result = findInheritedDoc(interfaces[i], memberDoc, tag);
+ if (null != result) {
+ return result;
+ }
+ }
+ }
+
+ ClassDoc superclassDoc = classDoc.superclass();
+
+ // 3. If step 2 failed to find a doc comment and this is a class
+ // other than Object (not an interface):
+ if (!classDoc.isInterface()
+ && null != superclassDoc
+ && !"java.lang.Object".equals(classDoc.qualifiedTypeName())) {
+
+ // 3a. If the superclass has a doc comment for this method, use it.
+
+ result = checkForInheritedDoc(superclassDoc, memberDoc, tag);
+ if (null != result) {
+ return result;
+ }
+
+ // 3b. If step 3a failed to find a doc comment, recursively
+ // apply this entire algorithm to the superclass.
+
+ return findInheritedDoc(superclassDoc,
+ memberDoc, tag);
+ }
+ else {
+ return null;
+ }
+ }
+
+ public boolean isEmptyDoc()
+ {
+ return tagMap.isEmpty();
+ }
+
+ void setBoilerplateComment(String boilerplateComment)
+ {
+ this.boilerplateComment = boilerplateComment;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java
new file mode 100644
index 000000000..3c139ab25
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java
@@ -0,0 +1,121 @@
+/* gnu.classpath.tools.gjdoc.ErrorReporter
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.io.*;
+import java.util.*;
+import java.lang.reflect.*;
+
+/**
+ * Simple implementation of a <code>DocErrorReporter</code>: writes
+ * to <code>System.err</code>.
+ */
+public class ErrorReporter implements DocErrorReporter {
+
+ private PrintStream out;
+
+ /**
+ * Keeps track of the number of errors occured
+ * during generation.
+ */
+ private int errorCount=0;
+
+ /**
+ * Keeps track of the number of warnings occured
+ * during generation.
+ */
+ private int warningCount=0;
+
+ /*
+ * When <code>true</code>, no notices will be emitted.
+ */
+ private boolean quiet = false;
+
+ /*
+ * When <code>true</code>, no warnings will be emitted.
+ */
+ private boolean noWarn = false;
+
+ public ErrorReporter()
+ {
+ this.out = System.err;
+ }
+
+ // Print error message, increment error count.
+ public void printError(java.lang.String msg) {
+ out.println("ERROR: "+msg);
+ ++errorCount;
+ }
+
+ // Print error message, increment error count.
+ public void printFatal(java.lang.String msg) {
+ out.println("FATAL: "+msg);
+ System.exit(10);
+ }
+
+ // Print a message.
+ public void printNotice(java.lang.String msg) {
+ if (!quiet) {
+ out.println(msg);
+ }
+ }
+
+ // Print warning message, increment warning count.
+ public void printWarning(java.lang.String msg) {
+ if (!noWarn) {
+ out.println("WARNING: "+msg);
+ ++warningCount;;
+ }
+ }
+
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ public int getWarningCount() {
+ return warningCount;
+ }
+
+ /**
+ * Specify whether notices should be printed.
+ */
+ public void setQuiet(boolean quiet) {
+ this.quiet = quiet;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.java
new file mode 100644
index 000000000..d5b1b1eb0
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.java
@@ -0,0 +1,427 @@
+/* gnu.classpath.tools.gjdoc.ExecutableMemberDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.util.*;
+import java.io.*;
+import com.sun.javadoc.*;
+
+public class ExecutableMemberDocImpl extends MemberDocImpl implements ExecutableMemberDoc {
+
+ protected ExecutableMemberDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ SourcePosition position) {
+
+ super(containingClass,
+ containingPackage,
+ position);
+ }
+
+ protected boolean processModifier(String word) {
+ if (super.processModifier(word)) {
+ return true;
+ }
+ else if (word.equals("synchronized")) {
+ isSynchronized=true;
+ return true;
+ }
+ else if (word.equals("native")) {
+ isNative=true;
+ return true;
+ }
+ else if (word.equals("abstract")) {
+ isAbstract=true;
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ private boolean isAbstract=false;
+ private boolean isNative=false;
+ private boolean isSynchronized=false;
+
+ public boolean isAbstract() { return isAbstract; }
+
+ public boolean isNative() { return isNative; }
+
+ public boolean isSynchronized() { return isSynchronized; }
+
+ public ClassDoc[] thrownExceptions() { return thrownExceptions; }
+
+ public Parameter[] parameters() { return parameters; }
+
+ public ThrowsTag[] throwsTags() {
+ return (ThrowsTag[])getTagArr("throws", throwsTagEmptyArr);
+ }
+
+ public ParamTag[] paramTags() {
+ return (ParamTag[])getTagArr("param", paramTagEmptyArr);
+ }
+
+ public String signature() { return signature; }
+ public String flatSignature() { return flatSignature; }
+
+ public ClassDoc overriddenClass() {
+ for (ClassDoc cdi=(ClassDoc)containingClass().superclass(); cdi!=null; cdi=(ClassDoc)cdi.superclass()) {
+ if (null!=ClassDocImpl.findMethod(cdi, name(), signature()))
+ return cdi;
+ }
+ return null;
+ }
+
+ public static ExecutableMemberDocImpl createFromSource(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ char[] source, int startIndex, int endIndex) throws IOException, ParseException {
+
+ int lastchar=32;
+ StringBuffer methodName=new StringBuffer();
+ for (int i=startIndex; i<endIndex && source[i]!='('; ++i) {
+ if ((Parser.WHITESPACE.indexOf(lastchar)>=0 && Parser.WHITESPACE.indexOf(source[i])<0)
+ || (lastchar == ']' && Parser.WHITESPACE.indexOf(source[i])<0 && '[' != source[i])) {
+ methodName.setLength(0);
+ methodName.append(source[i]);
+ }
+ else if (Parser.WHITESPACE.indexOf(source[i])<0) {
+ methodName.append(source[i]);
+ }
+ lastchar=source[i];
+ }
+
+ ExecutableMemberDocImpl rc;
+
+ SourcePosition position = DocImpl.getPosition(containingClass, source, startIndex);
+
+ if (methodName.toString().equals(((ClassDocImpl)containingClass).getClassName())) {
+
+ // Constructor
+
+ rc=new ConstructorDocImpl(containingClass,
+ containingPackage,
+ position);
+ }
+ else {
+
+ // Normal method
+
+ rc=new MethodDocImpl(containingClass,
+ containingPackage,
+ position);
+ }
+
+ if (containingClass.isInterface())
+ rc.accessLevel=ACCESS_PUBLIC;
+
+ int ndx=rc.parseModifiers(source, startIndex, endIndex);
+ StringBuffer name = new StringBuffer();
+
+ final int STATE_NORMAL=1;
+ final int STATE_STARC=2;
+ final int STATE_SLASHC=3;
+
+ int state=STATE_NORMAL;
+
+ while (source[ndx]!='(' && ndx<endIndex) {
+ if (state==STATE_NORMAL) {
+ if (ndx<endIndex-1 && source[ndx]=='/' && source[ndx+1]=='/') {
+ ++ndx;
+ state=STATE_SLASHC;
+ }
+ else if (ndx<endIndex-1 && source[ndx]=='/' && source[ndx+1]=='*') {
+ ++ndx;
+ state=STATE_STARC;
+ }
+ else {
+ name.append(source[ndx]);
+ }
+ }
+ else if (state==STATE_SLASHC) {
+ if (source[ndx]=='\n')
+ state=STATE_NORMAL;
+ }
+ else if (state==STATE_STARC) {
+ if (ndx<endIndex-1 && source[ndx]=='*' && source[ndx+1]=='/') {
+ ++ndx;
+ state=STATE_NORMAL;
+ }
+ }
+ ++ndx;
+ }
+ rc.setName(name.toString().trim());
+
+ state=STATE_NORMAL;
+
+ ++ndx;
+ int endx;
+ String param="";
+ List parameterList=new ArrayList();
+ for (endx=ndx; endx<endIndex; ++endx) {
+ if (state==STATE_SLASHC) {
+ if (source[endx]=='\n') {
+ state=STATE_NORMAL;
+ }
+ }
+ else if (state==STATE_STARC) {
+ if (source[endx]=='*' && source[endx+1]=='/') {
+ state=STATE_NORMAL;
+ ++endx;
+ }
+ }
+ else if (source[endx]=='/' && source[endx+1]=='*') {
+ state=STATE_STARC;
+ ++endx;
+ }
+ else if (source[endx]=='/' && source[endx+1]=='/') {
+ state=STATE_SLASHC;
+ ++endx;
+ }
+ else if (source[endx]==',' || source[endx]==')') {
+ param=param.trim();
+ if (param.length()>0) {
+ int n = param.length()-1;
+ int paramNameStart = 0;
+ while (n >= 0) {
+ char c = param.charAt(n);
+ if ('[' == c || ']' == c || Parser.WHITESPACE.indexOf(c)>=0) {
+ paramNameStart = n + 1;
+ break;
+ }
+ else {
+ -- n;
+ }
+ }
+ while (n >= 0 && ('[' == param.charAt(n)
+ || ']' == param.charAt(n)
+ || Parser.WHITESPACE.indexOf(param.charAt(n))>=0)) {
+ -- n;
+ }
+ int paramTypeEnd = n + 1;
+ int paramTypeStart = 0;
+ while (n >= 0) {
+ char c = param.charAt(n);
+ if ('[' == c || ']' == c || Parser.WHITESPACE.indexOf(c)>=0) {
+ paramTypeStart = n + 1;
+ break;
+ }
+ else {
+ -- n;
+ }
+ }
+
+ String paramType;
+ String paramName;
+ if (0 != paramNameStart) {
+ paramType=param.substring(paramTypeStart, paramTypeEnd);
+ paramName=param.substring(paramNameStart);
+ }
+ else {
+ paramName = "";
+ StringBuffer paramTypeBuffer = new StringBuffer();
+ for (int i=0; i<param.length(); ++i) {
+ char c = param.charAt(i);
+ if ('[' != c && ']' != c && Parser.WHITESPACE.indexOf(c)<0) {
+ paramTypeBuffer.append(c);
+ }
+ }
+ paramType = paramTypeBuffer.toString();
+ }
+ String dimSuffix="";
+
+ for (int i=0; i<param.length(); ++i) {
+ if ('[' == param.charAt(i)) {
+ dimSuffix += "[]";
+ }
+ }
+ paramType+=dimSuffix;
+
+ if (paramType.startsWith("[")) {
+ System.err.println("broken param type in " + rc + " in " +containingClass);
+ }
+
+ parameterList.add(new ParameterImpl(paramName, paramType,
+ ((ClassDocImpl)containingClass).typeForString(paramType)));
+
+ param="";
+ }
+ }
+ else
+ param+=source[endx];
+
+ if (source[endx]==')' && state==STATE_NORMAL)
+ break;
+ }
+
+ rc.setParameters((Parameter[])parameterList.toArray(new Parameter[0]));
+
+ ++endx;
+ String word="";
+ String dimSuffix="";
+ boolean haveThrowsKeyword=false;
+ List thrownExceptionsList=new ArrayList();
+
+ state=STATE_NORMAL;
+ for (; endx<endIndex; ++endx) {
+ if (state==STATE_SLASHC) {
+ if (source[endx]=='\n') state=STATE_NORMAL;
+ }
+ else if (state==STATE_STARC) {
+ if (source[endx]=='*' && source[endx+1]=='/') {
+ state=STATE_NORMAL;
+ ++endx;
+ }
+ }
+ else if (source[endx]=='/' && source[endx+1]=='*') {
+ state=STATE_STARC;
+ ++endx;
+ }
+ else if (source[endx]=='/' && source[endx+1]=='/') {
+ state=STATE_SLASHC;
+ ++endx;
+ }
+ else if (Parser.WHITESPACE.indexOf(source[endx])>=0) {
+ word=word.trim();
+ if (!haveThrowsKeyword && word.length()>0) {
+ if (word.equals("throws")) haveThrowsKeyword=true;
+ else System.err.println("ARGH! "+word);
+ word="";
+ }
+ }
+ else if (source[endx]=='[' || source[endx]==']') {
+ dimSuffix += source[endx];
+ }
+ else if (source[endx]==',' || source[endx]=='{' || source[endx]==';') {
+ word=word.trim();
+ if (word.length()>0) {
+ ClassDoc exceptionType=rc.containingClass().findClass(word);
+ if (exceptionType==null) {
+ exceptionType=new ClassDocProxy(word,
+ rc.containingClass());
+ }
+ thrownExceptionsList.add(exceptionType);
+ }
+ if (source[endx]=='{') {
+ break;
+ }
+ else {
+ word="";
+ }
+ }
+ else {
+ word+=source[endx];
+ }
+ }
+
+ if (dimSuffix.length()>0) {
+ rc.setTypeName(rc.getTypeName()+dimSuffix);
+ }
+
+ rc.setThrownExceptions((ClassDoc[])thrownExceptionsList.toArray(new ClassDoc[0]));
+
+ return rc;
+ }
+
+ private ClassDoc[] thrownExceptions;
+ private Parameter[] parameters;
+ private String signature;
+ private String flatSignature;
+
+ void setParameters(Parameter[] parameters) {
+ this.parameters=parameters;
+ }
+
+ void setThrownExceptions(ClassDoc[] thrownExceptions) {
+ this.thrownExceptions=thrownExceptions;
+ }
+
+ void resolve() {
+
+ for (int i=0; i<thrownExceptions.length; ++i) {
+ if (thrownExceptions[i] instanceof ClassDocProxy) {
+ String className=thrownExceptions[i].qualifiedName();
+ ClassDoc realClassDoc=containingClass().findClass(className);
+ if (realClassDoc!=null)
+ thrownExceptions[i]=realClassDoc;
+ }
+ }
+
+ StringBuffer signatureBuf=new StringBuffer();
+ StringBuffer flatSignatureBuf=new StringBuffer();
+
+ for (int i=0; i<parameters.length; ++i) {
+ ((ParameterImpl)parameters[i]).resolve(containingClass());
+
+ if (signatureBuf.length()>0) {
+ signatureBuf.append(",");
+ flatSignatureBuf.append(",");
+ }
+ signatureBuf.append(parameters[i].type().qualifiedTypeName());
+ flatSignatureBuf.append(parameters[i].type().typeName());
+ signatureBuf.append(parameters[i].type().dimension());
+ flatSignatureBuf.append(parameters[i].type().dimension());
+ }
+ this.signature="("+signatureBuf.toString()+")";
+ this.flatSignature="("+flatSignatureBuf.toString()+")";
+
+ super.resolve();
+
+ }
+
+ public int compareTo(Object other) {
+ int rc;
+ if (other instanceof MemberDocImpl) {
+ MemberDocImpl otherMember = (MemberDocImpl)other;
+ rc = name().compareTo(otherMember.name());
+ if (0 == rc) {
+ if (other instanceof ExecutableMemberDocImpl) {
+ rc = signature().compareTo(((ExecutableMemberDocImpl)other).signature());
+ if (0 == rc) {
+ return containingClass().compareTo(otherMember.containingClass());
+ }
+ }
+ else {
+ rc = 1;
+ }
+ }
+ }
+ else {
+ rc = 1;
+ }
+ return rc;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/FieldDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/FieldDocImpl.java
new file mode 100644
index 000000000..f99024daa
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/FieldDocImpl.java
@@ -0,0 +1,409 @@
+/* gnu.classpath.tools.gjdoc.FieldDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.util.*;
+import com.sun.javadoc.*;
+import java.lang.reflect.Modifier;
+
+import gnu.classpath.tools.gjdoc.expr.Evaluator;
+import gnu.classpath.tools.gjdoc.expr.CircularExpressionException;
+import gnu.classpath.tools.gjdoc.expr.IllegalExpressionException;
+
+public class FieldDocImpl
+ extends MemberDocImpl
+ implements FieldDoc, Cloneable
+{
+
+ private boolean isTransient;
+ private boolean isVolatile;
+ private String valueLiteral;
+ private Object constantValue;
+ private boolean constantValueEvaluated;
+
+ private FieldDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ SourcePosition position) {
+
+ super(containingClass,
+ containingPackage,
+ position);
+ }
+
+ private static FieldDocImpl createFieldDoc(FieldDocImpl prototype,
+ String fieldDef,
+ String fieldValueLiteral)
+ {
+ if (null != fieldValueLiteral && fieldValueLiteral.length() == 0) {
+ fieldValueLiteral = null;
+ }
+
+ try {
+ FieldDocImpl fieldDoc=(FieldDocImpl)prototype.clone();
+ String dimSuffix="";
+ while (fieldDef.trim().endsWith("[")
+ || fieldDef.trim().endsWith("]")) {
+ fieldDef=fieldDef.trim();
+ dimSuffix=fieldDef.charAt(fieldDef.length()-1)+dimSuffix;
+ fieldDef=fieldDef.substring(0,fieldDef.length()-1);
+ }
+
+ fieldDoc.setTypeName(fieldDoc.getTypeName()+dimSuffix);
+ fieldDoc.setName(fieldDef.trim());
+ fieldDoc.setValueLiteral(fieldValueLiteral);
+ return fieldDoc;
+ }
+ catch (CloneNotSupportedException e) {
+ // should not happen
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static Collection createFromSource(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ char[] source, int startIndex, int endIndex) {
+
+ List rcList=new ArrayList();
+
+ FieldDocImpl fd=new FieldDocImpl(containingClass,
+ containingPackage,
+ DocImpl.getPosition(containingClass, source, startIndex));
+
+ int ndx=fd.parseModifiers(source, startIndex, endIndex);
+
+ if (containingClass.isInterface()) {
+ fd.accessLevel = ACCESS_PUBLIC;
+ }
+
+ final int STATE_FIELDNAME = 1;
+ final int STATE_FIELDVALUE = 2;
+ final int STATE_QUOTE = 3;
+ final int STATE_QUOTEBS = 4;
+ final int STATE_SQUOTE = 5;
+ final int STATE_SQUOTEBS = 6;
+ final int STATE_COMMENT = 7;
+ final int STATE_LINECOMMENT = 8;
+
+ int lastFieldDefStart = ndx;
+ int state = STATE_FIELDNAME;
+ int prevState = state;
+
+ int bracketCount = 0;
+
+ StringBuffer fieldNameBuf = new StringBuffer();
+ StringBuffer fieldValueLiteralBuf = new StringBuffer();
+
+ for (int i=ndx; i<endIndex; ++i) {
+
+ char c = source[i];
+ char nextChar = '\0';
+ if (i + 1 < endIndex) {
+ nextChar = source[i + 1];
+ }
+ switch (state) {
+ case STATE_FIELDNAME:
+ if ('/' == c && '/' == nextChar) {
+ prevState = state;
+ state = STATE_LINECOMMENT;
+ }
+ else if ('/' == c && '*' == nextChar) {
+ prevState = state;
+ state = STATE_COMMENT;
+ }
+ else if (',' == c || ';' == c) {
+ rcList.add(createFieldDoc(fd, fieldNameBuf.toString(), null));
+ fieldNameBuf.setLength(0);
+ }
+ else if ('=' == c) {
+ state = STATE_FIELDVALUE;
+ }
+ else if (!(' ' == c || '\n' == c || '\r' == c || '\t' == c)) {
+ fieldNameBuf.append(c);
+ }
+ break;
+
+ case STATE_FIELDVALUE:
+ if ('/' == c && '/' == nextChar) {
+ prevState = state;
+ state = STATE_LINECOMMENT;
+ }
+ else if ('/' == c && '*' == nextChar) {
+ prevState = state;
+ state = STATE_COMMENT;
+ }
+ else if ('\"' == c) {
+ prevState = state;
+ state = STATE_QUOTE;
+ fieldValueLiteralBuf.append(c);
+ }
+ else if ('\'' == c) {
+ prevState = state;
+ state = STATE_SQUOTE;
+ fieldValueLiteralBuf.append(c);
+ }
+ else if ('{' == c || '(' == c) {
+ ++ bracketCount;
+ fieldValueLiteralBuf.append(c);
+ }
+ else if ('}' == c || ')' == c) {
+ -- bracketCount;
+ fieldValueLiteralBuf.append(c);
+ }
+ else if (0 == bracketCount && (',' == c || ';' == c)) {
+ rcList.add(createFieldDoc(fd, fieldNameBuf.toString(),
+ fieldValueLiteralBuf.toString()));
+ fieldNameBuf.setLength(0);
+ fieldValueLiteralBuf.setLength(0);
+ state = STATE_FIELDNAME;
+ }
+ else {
+ fieldValueLiteralBuf.append(c);
+ }
+ break;
+
+ case STATE_QUOTE:
+ fieldValueLiteralBuf.append(c);
+ if ('\\' == c) {
+ state = STATE_QUOTEBS;
+ }
+ else if ('\"' == c) {
+ state = prevState;
+ }
+ break;
+
+ case STATE_SQUOTE:
+ fieldValueLiteralBuf.append(c);
+ if ('\\' == c) {
+ state = STATE_SQUOTEBS;
+ }
+ else if ('\'' == c) {
+ state = prevState;
+ }
+ break;
+
+ case STATE_QUOTEBS:
+ fieldValueLiteralBuf.append(c);
+ state = STATE_QUOTE;
+ break;
+
+ case STATE_SQUOTEBS:
+ fieldValueLiteralBuf.append(c);
+ state = STATE_SQUOTE;
+ break;
+
+ case STATE_LINECOMMENT:
+ if ('\n' == c) {
+ state = prevState;
+ }
+ break;
+
+ case STATE_COMMENT:
+ if ('*' == c && '/' == nextChar) {
+ ++ i;
+ state = prevState;
+ }
+ break;
+ }
+ }
+
+ if (fieldNameBuf.length() > 0) {
+ rcList.add(createFieldDoc(fd, fieldNameBuf.toString(),
+ fieldValueLiteralBuf.toString()));
+ }
+
+ return rcList;
+ }
+
+ public boolean isField() {
+ return true;
+ }
+
+ public boolean isTransient() { return isTransient; }
+
+ public boolean isVolatile() { return isVolatile; }
+
+ public SerialFieldTag[] serialFieldTags() { return new SerialFieldTag[0]; }
+
+ public int modifierSpecifier() {
+ return super.modifierSpecifier()
+ | (isVolatile()?Modifier.VOLATILE:0)
+ | (isTransient()?Modifier.TRANSIENT:0)
+ ;
+ }
+
+ protected boolean processModifier(String word) {
+ if (super.processModifier(word)) {
+ return true;
+ }
+ else if (word.equals("transient")) {
+ isTransient=true;
+ return true;
+ }
+ else if (word.equals("volatile")) {
+ isVolatile=true;
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ void resolve() {
+ resolveTags();
+ }
+
+ public boolean hasSerialTag() {
+ return true; //tagMap.get("serial")!=null;
+ }
+
+ public String toString() { return name(); }
+
+ public Object constantValue() {
+ return constantValue(new HashSet());
+ }
+
+ public Object constantValue(Set visitedFields) {
+ if (!isStatic()
+ || !isFinal()
+ || (!type().isPrimitive() && !"java.lang.String".equals(type().qualifiedTypeName()))
+ || type.dimension().length()>0
+ || null == valueLiteral) {
+
+ return null;
+
+ }
+ else {
+ if (!constantValueEvaluated) {
+
+ visitedFields.add(this);
+
+ String expression = "(" + type().typeName() + ")(" + valueLiteral + ")";
+ try {
+ this.constantValue = Evaluator.evaluate(expression,
+ visitedFields,
+ (ClassDocImpl)containingClass());
+ }
+ catch (CircularExpressionException e) {
+ // FIXME: This should use the error reporter
+ System.err.println("WARNING: Cannot resolve expression for field " + containingClass.qualifiedTypeName() + "." + name() + ": " + e.getMessage());
+ }
+ catch (IllegalExpressionException ignore) {
+ }
+ constantValueEvaluated = true;
+ }
+ return this.constantValue;
+ }
+ }
+
+ private static void appendCharString(StringBuffer result, char c, boolean inSingleCuotes)
+ {
+ switch (c) {
+ case '\b': result.append("\\b"); break;
+ case '\t': result.append("\\t"); break;
+ case '\n': result.append("\\n"); break;
+ case '\f': result.append("\\f"); break;
+ case '\r': result.append("\\r"); break;
+ case '\"': result.append("\\\""); break;
+ case '\'': result.append(inSingleCuotes ? "\\'" : "'"); break;
+ default:
+ if (c >= 32 && c <= 127) {
+ result.append(c);
+ }
+ else {
+ result.append("\\u");
+ String hexValue = Integer.toString((int)c, 16);
+ int zeroCount = 4 - hexValue.length();
+ for (int i=0; i<zeroCount; ++i) {
+ result.append('0');
+ }
+ result.append(hexValue);
+ }
+ }
+ }
+
+ public String constantValueExpression() {
+ Object value = constantValue();
+
+ if (null == value) {
+ return "null";
+ }
+ else if (value instanceof String) {
+ StringBuffer result = new StringBuffer("\"");
+ char[] chars = ((String)value).toCharArray();
+ for (int i=0; i<chars.length; ++i) {
+ appendCharString(result, chars[i], false);
+ }
+ result.append("\"");
+ return result.toString();
+ }
+ else if (value instanceof Float) {
+ return value.toString() + "f";
+ }
+ else if (value instanceof Long) {
+ return value.toString() + "L";
+ }
+ else if (value instanceof Character) {
+ StringBuffer result = new StringBuffer("'");
+ appendCharString(result, ((Character)value).charValue(), false);
+ result.append("'");
+ return result.toString();
+ }
+ else /* if (value instanceof Double
+ || value instanceof Integer
+ || value instanceof Short
+ || value instanceof Byte) */ {
+ return value.toString();
+ }
+ }
+
+ void setValueLiteral(String valueLiteral)
+ {
+ this.valueLiteral = valueLiteral;
+ }
+
+ public boolean isStatic()
+ {
+ return super.isStatic() || containingClass().isInterface();
+ }
+
+ public boolean isFinal()
+ {
+ return super.isFinal() || containingClass().isInterface();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocPackageDoc.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocPackageDoc.java
new file mode 100644
index 000000000..4cfbbe451
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocPackageDoc.java
@@ -0,0 +1,56 @@
+/* gnu.classpath.tools.gjdoc.GjdocPackageDoc
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.io.File;
+import com.sun.javadoc.PackageDoc;
+
+/**
+ * Extension of the PackageDoc interface which additionally provides
+ * the directory the package's source files are located in.
+ *
+ * @author Julian Scheid
+ */
+public interface GjdocPackageDoc extends PackageDoc
+{
+ /**
+ * Returns the directory this package's source files are located
+ * in.
+ */
+ public File packageDirectory();
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocRootDoc.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocRootDoc.java
new file mode 100644
index 000000000..d45786fb9
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocRootDoc.java
@@ -0,0 +1,56 @@
+/* gnu.classpath.tools.gjdoc.GjdocRootDoc
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.io.File;
+import com.sun.javadoc.RootDoc;
+
+/**
+ * Extension of the RootDoc interface which additionally provides
+ * a method for flushing all state.
+ *
+ * @author Julian Scheid
+ */
+public interface GjdocRootDoc extends RootDoc
+{
+ /**
+ * Invalidate this RootDoc by flushing all associated data, but
+ * keep its error reporting functionality intact.
+ */
+ public void flush();
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/InheritDocTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/InheritDocTagImpl.java
new file mode 100644
index 000000000..3be63dd79
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/InheritDocTagImpl.java
@@ -0,0 +1,103 @@
+/* gnu.classpath.tools.gjdoc.InheritDocTagImpl
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+
+/**
+ * Represents the <code>inheritDoc</code> tag.
+ */
+public class InheritDocTagImpl
+ extends AbstractTagImpl
+{
+ private ClassDocImpl contextClass;
+ private MemberDocImpl contextMember;
+ private AbstractTagImpl contextTag;
+
+ public InheritDocTagImpl(ClassDocImpl contextClass,
+ MemberDocImpl contextMember,
+ AbstractTagImpl contextTag)
+ {
+ super("");
+ this.contextClass = contextClass;
+ this.contextMember = contextMember;
+ this.contextTag = contextTag;
+ }
+
+ public String kind() {
+ return "@inheritDoc";
+ }
+
+ public String name() {
+ return "@inheritDoc";
+ }
+
+ private TagContainer inheritedDoc;
+ private boolean inheritedDocInitialized = false;
+
+ private TagContainer getInheritedDoc()
+ {
+ if (!inheritedDocInitialized) {
+ inheritedDoc = DocImpl.findInheritedDoc(contextClass, contextMember, contextTag);
+ inheritedDocInitialized = true;
+ }
+ return inheritedDoc;
+ }
+
+ public Tag[] firstSentenceTags() {
+ TagContainer _inheritedDoc = getInheritedDoc();
+ if (_inheritedDoc != null) {
+ return _inheritedDoc.firstSentenceTags();
+ }
+ else {
+ return null;
+ }
+ }
+
+ public Tag[] inlineTags() {
+ TagContainer _inheritedDoc = getInheritedDoc();
+ if (_inheritedDoc != null) {
+ return _inheritedDoc.inlineTags();
+ }
+ else {
+ return null;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/JavadocWrapper.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/JavadocWrapper.java
new file mode 100644
index 000000000..93c08b94d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/JavadocWrapper.java
@@ -0,0 +1,53 @@
+/* gnu.classpath.tools.gjdoc.JavadocWrapper
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.util.*;
+import java.io.*;
+import com.sun.javadoc.*;
+
+public class JavadocWrapper {
+
+ public static void main(String[] args) throws Exception {
+
+ Timer.setStartTime();
+ Class sunJavadocMain=Class.forName("com.sun.tools.javadoc.Main");
+ sunJavadocMain.getMethod("main", new Class[]{String[].class}).invoke(null, new Object[]{args});
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/LinkTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/LinkTagImpl.java
new file mode 100644
index 000000000..3b2b8a848
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/LinkTagImpl.java
@@ -0,0 +1,63 @@
+/* gnu.classpath.tools.gjdoc.LinkTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+
+public class LinkTagImpl extends SeeTagImpl {
+
+ private String name;
+
+ public LinkTagImpl(String name, String _text, ClassDocImpl contextClass) {
+ super(_text, contextClass);
+ this.name = name;
+ }
+
+ public String name() { return name; }
+
+ public Tag[] firstSentenceTags() {
+ return new Tag[0]; //inlineTags();
+ }
+
+ public Tag[] inlineTags() {
+ return new Tag[0]; //new Tag[]{new TextTagImpl(referencedClassName)};
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Main.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Main.java
new file mode 100644
index 000000000..ce9e96d82
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Main.java
@@ -0,0 +1,1854 @@
+/* gnu.classpath.tools.gjdoc.Main
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.io.*;
+import java.util.*;
+import java.lang.reflect.*;
+import java.text.Collator;
+
+import gnu.classpath.tools.FileSystemClassLoader;
+
+/**
+ * Class that will launch the gjdoc tool.
+ */
+public final class Main
+{
+
+ /**
+ * Do we load classes that are referenced as base class?
+ */
+ static final boolean DESCEND_SUPERCLASS = true;
+
+ /**
+ * Do we load classes that are referenced as interface?
+ */
+ static final boolean DESCEND_INTERFACES = false;
+
+ /**
+ * Do we load classes that are imported in a source file?
+ */
+ static final boolean DESCEND_IMPORTED = true;
+
+ /**
+ * Document only public members.
+ */
+ static final int COVERAGE_PUBLIC = 0;
+
+ /**
+ * Document only public and protected members.
+ */
+ static final int COVERAGE_PROTECTED = 1;
+
+ /**
+ * Document public, protected and package private members.
+ */
+ static final int COVERAGE_PACKAGE = 2;
+
+ /**
+ * Document all members.
+ */
+ static final int COVERAGE_PRIVATE = 3;
+
+ /*
+ * FIXME: This should come from a ResourceBundle
+ */
+ private static final String STRING_TRY_GJDOC_HELP =
+ "Try `gjdoc --help' for more information.";
+
+ /**
+ * Grid for looking up whether a particular access level is included in the
+ * documentation.
+ */
+ static final boolean[][] coverageTemplates = new boolean[][]
+ { new boolean[]
+ { true, false, false, false }, // public
+ new boolean[]
+ { true, true, false, false }, // protected
+ new boolean[]
+ { true, true, true, false }, // package
+ new boolean[]
+ { true, true, true, true }, // private
+ };
+
+ /**
+ * Holds the Singleton instance of this class.
+ */
+ private static Main instance = new Main();
+
+ /**
+ * Avoid re-instantiation of this class.
+ */
+ private Main()
+ {
+ }
+
+ private static RootDocImpl rootDoc;
+
+ private ErrorReporter reporter;
+
+ /**
+ * Cache for version string from resource /version.properties
+ */
+ private String gjdocVersion;
+
+ /**
+ * <code>false</code> during Phase I: preparation of the documentation data.
+ * <code>true</code> during Phase II: documentation output by doclet.
+ */
+ boolean docletRunning = false;
+
+ //---- Command line options
+
+ /**
+ * Option "-doclet": name of the Doclet class to use.
+ */
+ private String option_doclet = "gnu.classpath.tools.doclets.htmldoclet.HtmlDoclet";
+
+ /**
+ * Option "-overview": path to the special overview file.
+ */
+ private String option_overview;
+
+ /**
+ * Option "-coverage": which members to include in generated documentation.
+ */
+ private int option_coverage = COVERAGE_PROTECTED;
+
+ /**
+ * Option "-help": display command line usage.
+ */
+ private boolean option_help;
+
+ /**
+ * Option "-docletpath": path to doclet classes.
+ */
+ private String option_docletpath;
+
+ /**
+ * Option "-classpath": path to additional classes.
+ */
+ private String option_classpath;
+
+ /**
+ * Option "-sourcepath": path to the Java source files to be documented.
+ * FIXME: this should be a list of paths
+ */
+ private List option_sourcepath = new ArrayList();
+
+ /**
+ * Option "-extdirs": path to Java extension files.
+ */
+ private String option_extdirs;
+
+ /**
+ * Option "-verbose": Be verbose when generating documentation.
+ */
+ private boolean option_verbose;
+
+ /**
+ * Option "-nowarn": Do not print warnings.
+ */
+ private boolean option_nowarn;
+
+ /**
+ * Option "-locale:" Specify the locale charset of Java source files.
+ */
+ private Locale option_locale = new Locale("en", "us");
+
+ /**
+ * Option "-encoding": Specify character encoding of Java source files.
+ */
+ private String option_encoding;
+
+ /**
+ * Option "-J": Specify flags to be passed to Java runtime.
+ */
+ private List option_java_flags = new LinkedList(); //ArrayList();
+
+ /**
+ * Option "-source:" should be 1.4 to handle assertions, 1.1 is no
+ * longer supported.
+ */
+ private String option_source = "1.2";
+
+ /**
+ * Option "-subpackages": list of subpackages to be recursively
+ * added.
+ */
+ private List option_subpackages = new ArrayList();
+
+ /**
+ * Option "-exclude": list of subpackages to exclude.
+ */
+ private List option_exclude = new ArrayList();
+
+ /**
+ * Option "-breakiterator" - whether to use BreakIterator for
+ * detecting the end of the first sentence.
+ */
+ private boolean option_breakiterator;
+
+ /**
+ * Option "-licensetext" - whether to copy license text.
+ */
+ private boolean option_licensetext;
+
+ /**
+ * The locale-dependent collator used for sorting.
+ */
+ private Collator collator;
+
+ /**
+ * true when --version has been specified on the command line.
+ */
+ private boolean option_showVersion;
+
+ /**
+ * true when -bootclasspath has been specified on the command line.
+ */
+ private boolean option_bootclasspath_specified;
+
+ /**
+ * true when -all has been specified on the command line.
+ */
+ private boolean option_all;
+
+ /**
+ * true when -reflection has been specified on the command line.
+ */
+ private boolean option_reflection;
+
+ // TODO: add the rest of the options as instance variables
+
+ /**
+ * Parse all source files/packages and subsequentially start the Doclet given
+ * on the command line.
+ *
+ * @param allOptions List of all command line tokens
+ */
+ private boolean startDoclet(List allOptions)
+ {
+
+ try
+ {
+
+ //--- Fetch the Class object for the Doclet.
+
+ Debug.log(1, "loading doclet class...");
+
+ Class docletClass;
+
+ if (null != option_docletpath) {
+ try {
+ FileSystemClassLoader docletPathClassLoader
+ = new FileSystemClassLoader(option_docletpath);
+ System.err.println("trying to load class " + option_doclet + " from path " + option_docletpath);
+ docletClass = docletPathClassLoader.findClass(option_doclet);
+ }
+ catch (Exception e) {
+ docletClass = Class.forName(option_doclet);
+ }
+ }
+ else {
+ docletClass = Class.forName(option_doclet);
+ }
+ //Object docletInstance = docletClass.newInstance();
+
+ Debug.log(1, "doclet class loaded...");
+
+ Method startTempMethod = null;
+ Method startMethod = null;
+ Method optionLenMethod = null;
+ Method validOptionsMethod = null;
+
+ //--- Try to find the optionLength method in the Doclet class.
+
+ try
+ {
+ optionLenMethod = docletClass.getMethod("optionLength", new Class[]
+ { String.class });
+ }
+ catch (NoSuchMethodException e)
+ {
+ // Ignore if not found; it's OK it the Doclet class doesn't define
+ // this method.
+ }
+
+ //--- Try to find the validOptions method in the Doclet class.
+
+ try
+ {
+ validOptionsMethod = docletClass.getMethod("validOptions", new Class[]
+ { String[][].class, DocErrorReporter.class });
+ }
+ catch (NoSuchMethodException e)
+ {
+ // Ignore if not found; it's OK it the Doclet class doesn't define
+ // this method.
+ }
+
+ //--- Find the start method in the Doclet class; complain if not found
+
+ try
+ {
+ startTempMethod = docletClass.getMethod("start", new Class[]
+ { TemporaryStore.class });
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ startMethod = docletClass.getMethod("start", new Class[]
+ { RootDoc.class });
+
+ //--- Feed the custom command line tokens to the Doclet
+
+ // stores all recognized options
+ List options = new LinkedList();
+
+ // stores packages and classes defined on the command line
+ List packageAndClasses = new LinkedList();
+
+ for (Iterator it = allOptions.iterator(); it.hasNext();)
+ {
+ String option = (String) it.next();
+
+ Debug.log(9, "parsing option '" + option + "'");
+
+ if (option.startsWith("-"))
+ {
+
+ //--- Parse option
+
+ int optlen = optionLength(option);
+
+ //--- Try to get option length from Doclet class
+
+ if (optlen <= 0 && optionLenMethod != null)
+ {
+
+ optionLenMethod.invoke(null, new Object[]
+ { option });
+
+ Debug.log(3, "invoking optionLen method");
+
+ optlen = ((Integer) optionLenMethod.invoke(null, new Object[]
+ { option })).intValue();
+
+ Debug.log(3, "done");
+ }
+
+ if (optlen <= 0) {
+
+ if (option.startsWith("-JD")) {
+ // Simulate VM option -D
+ String propertyValue = option.substring(3);
+ int ndx = propertyValue.indexOf('=');
+ if (ndx <= 0) {
+ reporter.printError("Illegal format in option " + option + ": use -JDproperty=value");
+ return false;
+ }
+ else {
+ String property = propertyValue.substring(0, ndx);
+ String value = propertyValue.substring(ndx + 1);
+ System.setProperty(property, value);
+ }
+ }
+ else if (option.startsWith("-J")) {
+ //--- Warn if VM option is encountered
+ reporter.printWarning("Ignored option " + option + ". Pass this option to the VM if required.");
+ }
+ else {
+ //--- Complain if not found
+
+ reporter.printError("Unknown option " + option);
+ reporter.printNotice(STRING_TRY_GJDOC_HELP);
+ return false;
+ }
+ }
+ else
+ {
+
+ //--- Read option values
+
+ String[] optionAndValues = new String[optlen];
+ optionAndValues[0] = option;
+ for (int i = 1; i < optlen; ++i)
+ {
+ if (!it.hasNext())
+ {
+ reporter.printError("Missing value for option " + option);
+ return false;
+ }
+ else
+ {
+ optionAndValues[i] = (String) it.next();
+ }
+ }
+
+ //--- Store option for processing later
+
+ options.add(optionAndValues);
+ }
+ }
+ else if (option.length() > 0)
+ {
+
+ //--- Add to list of packages/classes if not option or option
+ // value
+
+ packageAndClasses.add(option);
+ }
+ }
+
+ Debug.log(9, "options parsed...");
+
+ //--- For each package specified with the -subpackages option on
+ // the command line, recursively find all valid java files
+ // beneath it.
+
+ //--- For each class or package specified on the command line,
+ // check that it exists and find out whether it is a class
+ // or a package
+
+ for (Iterator it = option_subpackages.iterator(); it.hasNext();)
+ {
+ String subpackage = (String) it.next();
+ Set foundPackages = new LinkedHashSet();
+
+ for (Iterator pit = option_sourcepath.iterator(); pit.hasNext(); ) {
+ File sourceDir = (File)pit.next();
+ File packageDir = new File(sourceDir, subpackage.replace('.', File.separatorChar));
+ findPackages(subpackage, packageDir, foundPackages);
+ }
+
+ addFoundPackages(subpackage, foundPackages);
+ }
+
+ if (option_all) {
+ Set foundPackages = new LinkedHashSet();
+ for (Iterator pit = option_sourcepath.iterator(); pit.hasNext(); ) {
+ File sourceDir = (File)pit.next();
+ findPackages("", sourceDir, foundPackages);
+ }
+ addFoundPackages(null, foundPackages);
+ for (Iterator packageIt = foundPackages.iterator(); packageIt.hasNext(); ) {
+ String packageName = (String)packageIt.next();
+ if (null == packageName) {
+ packageName = "";
+ }
+ rootDoc.addSpecifiedPackageName(packageName);
+ }
+ }
+
+ for (Iterator it = packageAndClasses.iterator(); it.hasNext();)
+ {
+
+ String classOrPackage = (String) it.next();
+
+ boolean foundSourceFile = false;
+
+ if (classOrPackage.endsWith(".java")) {
+ for (Iterator pit = option_sourcepath.iterator(); pit.hasNext() && !foundSourceFile; ) {
+ File sourceDir = (File)pit.next();
+ File sourceFile = new File(sourceDir, classOrPackage);
+ if (sourceFile.exists() && !sourceFile.isDirectory()) {
+ rootDoc.addSpecifiedSourceFile(sourceFile);
+ foundSourceFile = true;
+ break;
+ }
+ }
+ if (!foundSourceFile) {
+ File sourceFile = new File(classOrPackage);
+ if (sourceFile.exists() && !sourceFile.isDirectory()) {
+ rootDoc.addSpecifiedSourceFile(sourceFile);
+ foundSourceFile = true;
+ }
+ }
+ }
+
+ if (!foundSourceFile) {
+ //--- Check for illegal name
+
+ if (classOrPackage.startsWith(".")
+ || classOrPackage.endsWith(".")
+ || classOrPackage.indexOf("..") > 0
+ || !checkCharSet(classOrPackage,
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_."))
+ {
+ throw new ParseException("Illegal class or package name '"
+ + classOrPackage + "'");
+ }
+
+ //--- Assemble absolute path to package
+
+ String classOrPackageRelPath = classOrPackage.replace('.',
+ File.separatorChar);
+
+ //--- Create one file object each for a possible package directory
+ // and a possible class file, and find out if they exist.
+
+ List packageDirs = rootDoc.findSourceFiles(classOrPackageRelPath);
+ List sourceFiles = rootDoc.findSourceFiles(classOrPackageRelPath + ".java");
+
+ boolean packageDirExists = !packageDirs.isEmpty();
+ boolean sourceFileExists = !sourceFiles.isEmpty();
+
+ //--- Complain if neither exists: not found
+
+ if (!packageDirExists && !sourceFileExists)
+ {
+ reporter.printError("Class or package " + classOrPackage
+ + " not found.");
+ return false;
+ }
+
+ //--- Complain if both exist: ambigious
+
+ else
+ if (packageDirExists && sourceFileExists)
+ {
+ reporter.printError("Ambigious class/package name "
+ + classOrPackage + ".");
+ return false;
+ }
+
+ //--- Otherwise, if the package directory exists, it is a package
+
+ else
+ if (packageDirExists) {
+ Iterator packageDirIt = packageDirs.iterator();
+ boolean packageDirFound = false;
+ while (packageDirIt.hasNext()) {
+ File packageDir = (File)packageDirIt.next();
+ if (packageDir.isDirectory()) {
+ rootDoc.addSpecifiedPackageName(classOrPackage);
+ packageDirFound = true;
+ break;
+ }
+ }
+ if (!packageDirFound) {
+ reporter.printError("No suitable file or directory found for" + classOrPackage);
+ return false;
+ }
+ }
+
+ //--- Otherwise, emit error message
+
+ else {
+ reporter.printError("No sources files found for package " + classOrPackage);
+ }
+ }
+ }
+
+ //--- Complain if no packages or classes specified
+
+ if (option_help) {
+ usage();
+ return true;
+ }
+
+ //--- Validate custom options passed on command line
+ // by asking the Doclet if they are OK.
+
+ String[][] customOptionArr = (String[][]) options
+ .toArray(new String[0][0]);
+ if (validOptionsMethod != null
+ && !((Boolean) validOptionsMethod.invoke(null, new Object[]
+ { customOptionArr, reporter })).booleanValue())
+ {
+ // Not ok: shutdown system.
+ reporter.printNotice(STRING_TRY_GJDOC_HELP);
+ return false;
+ }
+
+ if (!rootDoc.hasSpecifiedPackagesOrClasses()) {
+ reporter.printError("No packages or classes specified.");
+ reporter.printNotice(STRING_TRY_GJDOC_HELP);
+ return false;
+ }
+
+ rootDoc.setOptions(customOptionArr);
+
+ rootDoc.build();
+
+ //--- Bail out if no classes found
+
+ if (0 == rootDoc.classes().length
+ && 0 == rootDoc.specifiedPackages().length
+ && 0 == rootDoc.specifiedClasses().length)
+ {
+ reporter.printError("No packages or classes found(!).");
+ return false;
+ }
+
+ //--- Our work is done, tidy up memory
+
+ System.gc();
+ System.gc();
+
+ //--- Set flag indicating Phase II of documentation generation
+
+ docletRunning = true;
+
+ //--- Invoke the start method on the Doclet: produce output
+
+ reporter.printNotice("Running doclet...");
+
+ TemporaryStore tstore = new TemporaryStore(Main.rootDoc);
+
+ Thread.currentThread().setContextClassLoader(docletClass.getClassLoader());
+
+ if (null != startTempMethod)
+ {
+ startTempMethod.invoke(null, new Object[]
+ { tstore });
+ }
+ else
+ {
+ startMethod.invoke(null, new Object[]
+ { tstore.getAndClear() });
+ }
+
+ //--- Let the user know how many warnings/errors occured
+
+ if (reporter.getWarningCount() > 0)
+ {
+ reporter.printNotice(reporter.getWarningCount() + " warnings");
+ }
+
+ if (reporter.getErrorCount() > 0)
+ {
+ reporter.printNotice(reporter.getErrorCount() + " errors");
+ }
+
+ System.gc();
+
+ //--- Done.
+ return true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ private void addFoundPackages(String subpackage, Set foundPackages)
+ {
+ if (foundPackages.isEmpty()) {
+ reporter.printWarning("No classes found under subpackage " + subpackage);
+ }
+ else {
+ boolean onePackageAdded = false;
+ for (Iterator rit = foundPackages.iterator(); rit.hasNext();) {
+ String foundPackage = (String)rit.next();
+ boolean excludeThisPackage = false;
+
+ for (Iterator eit = option_exclude.iterator(); eit.hasNext();) {
+ String excludePackage = (String)eit.next();
+ if (foundPackage.equals(excludePackage) ||
+ foundPackage.startsWith(excludePackage + ":")) {
+ excludeThisPackage = true;
+ break;
+ }
+ }
+
+ if (!excludeThisPackage) {
+ rootDoc.addSpecifiedPackageName(foundPackage);
+ onePackageAdded = true;
+ }
+ }
+ if (!onePackageAdded) {
+ if (null != subpackage) {
+ reporter.printWarning("No non-excluded classes found under subpackage " + subpackage);
+ }
+ else {
+ reporter.printWarning("No non-excluded classes found.");
+ }
+ }
+ }
+ }
+
+ /**
+ * Verify that the given file is a valid Java source file and that
+ * it specifies the given package.
+ */
+ private boolean isValidJavaFile(File file,
+ String expectedPackage)
+ {
+ try {
+ InputStream in = new BufferedInputStream(new FileInputStream(file));
+
+ int ch, prevChar = 0;
+
+ final int STATE_DEFAULT = 0;
+ final int STATE_COMMENT = 1;
+ final int STATE_LINE_COMMENT = 2;
+
+ int state = STATE_DEFAULT;
+
+ StringBuffer word = new StringBuffer();
+ int wordIndex = 0;
+
+ while ((ch = in.read()) >= 0) {
+ String completeWord = null;
+
+ switch (state) {
+ case STATE_COMMENT:
+ if (prevChar == '*' && ch == '/') {
+ state = STATE_DEFAULT;
+ }
+ break;
+
+ case STATE_LINE_COMMENT:
+ if (ch == '\n') {
+ state = STATE_DEFAULT;
+ }
+ break;
+
+ case STATE_DEFAULT:
+ if (prevChar == '/' && ch == '*') {
+ word.deleteCharAt(word.length() - 1);
+ if (word.length() > 0) {
+ completeWord = word.toString();
+ word.setLength(0);
+ }
+ state = STATE_COMMENT;
+ }
+ else if (prevChar == '/' && ch == '/') {
+ word.deleteCharAt(word.length() - 1);
+ if (word.length() > 0) {
+ completeWord = word.toString();
+ word.setLength(0);
+ }
+ state = STATE_LINE_COMMENT;
+ }
+ else if (" \t\r\n".indexOf(ch) >= 0) {
+ if (word.length() > 0) {
+ completeWord = word.toString();
+ word.setLength(0);
+ }
+ }
+ else if (1 == wordIndex && ';' == ch) {
+ if (word.length() > 0) {
+ completeWord = word.toString();
+ word.setLength(0);
+ }
+ else {
+ // empty package name in source file: "package ;" -> invalid source file
+ in.close();
+ return false;
+ }
+ }
+ else {
+ word.append((char)ch);
+ }
+ break;
+ }
+
+ if (null != completeWord) {
+ if (0 == wordIndex && !"package".equals(completeWord)) {
+ in.close();
+ return "".equals(expectedPackage);
+ }
+ else if (1 == wordIndex) {
+ in.close();
+ return expectedPackage.equals(completeWord);
+ }
+ ++ wordIndex;
+ }
+
+ prevChar = ch;
+ }
+
+ // no package or class found before end-of-file -> invalid source file
+
+ in.close();
+ return false;
+ }
+ catch (IOException e) {
+ reporter.printWarning("Could not examine file " + file + ": " + e);
+ return false;
+ }
+ }
+
+ /**
+ * Recursively try to locate valid Java packages under the given
+ * package specified by its name and its directory. Add the names
+ * of all valid packages to the result list.
+ */
+ private void findPackages(String subpackage,
+ File packageDir,
+ Set result)
+ {
+ File[] files = packageDir.listFiles();
+ if (null != files) {
+ for (int i=0; i<files.length; ++i) {
+ File file = files[i];
+ if (!file.isDirectory() && file.getName().endsWith(".java")) {
+ if (isValidJavaFile(file, subpackage)) {
+ if ("".equals(subpackage)) {
+ result.add(null);
+ }
+ else {
+ result.add(subpackage);
+ }
+ break;
+ }
+ }
+ }
+ for (int i=0; i<files.length; ++i) {
+ File file = files[i];
+ if (file.isDirectory()) {
+ String newSubpackage;
+ if (null != subpackage && subpackage.length() > 0) {
+ newSubpackage = subpackage + "." + file.getName();
+ }
+ else {
+ newSubpackage = file.getName();
+ }
+ findPackages(newSubpackage, file, result);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static boolean validOptions(String options[][],
+ DocErrorReporter reporter)
+ {
+
+ boolean foundDocletOption = false;
+ for (int i = 0; i < options.length; i++)
+ {
+ String[] opt = options[i];
+ if (opt[0].equalsIgnoreCase("-doclet"))
+ {
+ if (foundDocletOption)
+ {
+ reporter.printError("Only one -doclet option allowed.");
+ return false;
+ }
+ else
+ {
+ foundDocletOption = true;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Main entry point. This is the method called when gjdoc is invoked from the
+ * command line.
+ *
+ * @param args
+ * command line arguments
+ */
+ public static void main(String[] args)
+ {
+
+ try
+ {
+ //--- Remember current time for profiling purposes
+
+ Timer.setStartTime();
+
+ //--- Handle control to the Singleton instance of this class
+
+ int result = instance.start(args);
+
+ if (result < 0) {
+ // fatal error
+ System.exit(5);
+ }
+ else if (result > 0) {
+ // errors encountered
+ System.exit(1);
+ }
+ else {
+ // success
+ System.exit(0);
+ }
+ }
+ catch (Exception e)
+ {
+ //--- unexpected error
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Parses command line arguments and subsequentially handles control to the
+ * startDoclet() method
+ *
+ * @param args The command line parameters.
+ */
+ public static int execute(String[] args)
+ {
+ try
+ {
+ int result = instance.start(args);
+ if (result < 0) {
+ // fatal error
+ return 5;
+ }
+ else if (result > 0) {
+ // errors encountered
+ return 1;
+ }
+ else {
+ // success
+ return 0;
+ }
+ }
+ catch (Exception e)
+ {
+ // unexpected error
+ return 1;
+ }
+ }
+
+ /**
+ * @param programName Name of the program (for error messages). *disregarded*
+ * @param args The command line parameters.
+ * @returns The return code.
+ */
+ public static int execute(String programName,
+ String[] args)
+ {
+ return execute(args);
+ }
+
+ /**
+ * @param programName Name of the program (for error messages).
+ * @param defaultDocletClassName Fully qualified class name.
+ * @param args The command line parameters.
+ * @returns The return code.
+ *//*
+ public static int execute(String programName,
+ String defaultDocletClassName,
+ String[] args)
+ {
+ // not yet implemented
+ }*/
+
+ /**
+ * @param programName Name of the program (for error messages).
+ * @param defaultDocletClassName Fully qualified class name.
+ * @param args The command line parameters.
+ * @returns The return code.
+ *//*
+ public static int execute(String programName,
+ String defaultDocletClassName,
+ String[] args)
+ {
+ // not yet implemented
+ }*/
+
+ /**
+ * @param programName Name of the program (for error messages).
+ * @param errWriter PrintWriter to receive error messages.
+ * @param warnWriter PrintWriter to receive error messages.
+ * @param noticeWriter PrintWriter to receive error messages.
+ * @param defaultDocletClassName Fully qualified class name.
+ * @param args The command line parameters.
+ * @returns The return code.
+ *//*
+ public static int execute(String programName,
+ PrintWriter errWriter,
+ PrintWriter warnWriter,
+ PrintWriter noticeWriter,
+ String defaultDocletClassName,
+ String[] args)
+ {
+ // not yet implemented
+ }*/
+
+ /**
+ * Parses command line arguments and subsequentially handles control to the
+ * startDoclet() method
+ *
+ * @param args
+ * Command line arguments, as passed to the main() method
+ * @return {@code -1} in case of a fatal error (invalid arguments),
+ * or the number of errors encountered.
+ * @exception ParseException
+ * FIXME
+ * @exception IOException
+ * if an IO problem occur
+ */
+ public int start(String[] args) throws ParseException, IOException
+ {
+
+ //--- Collect unparsed arguments in array and resolve references
+ // to external argument files.
+
+ List arguments = new ArrayList(args.length);
+
+ for (int i = 0; i < args.length; ++i)
+ {
+ if (!args[i].startsWith("@"))
+ {
+ arguments.add(args[i]);
+ }
+ else
+ {
+ FileReader reader = new FileReader(args[i].substring(1));
+ StreamTokenizer st = new StreamTokenizer(reader);
+ st.resetSyntax();
+ st.wordChars('\u0000', '\uffff');
+ st.quoteChar('\"');
+ st.quoteChar('\'');
+ st.whitespaceChars(' ', ' ');
+ st.whitespaceChars('\t', '\t');
+ st.whitespaceChars('\r', '\r');
+ st.whitespaceChars('\n', '\n');
+ while (st.nextToken() != StreamTokenizer.TT_EOF)
+ {
+ arguments.add(st.sval);
+ }
+ }
+ }
+
+ //--- Initialize Map for option parsing
+
+ initOptions();
+
+ //--- This will hold all options recognized by gjdoc itself
+ // and their associated arguments.
+ // Contains objects of type String[], where each entry
+ // specifies an option along with its aguments.
+
+ List options = new LinkedList();
+
+ //--- This will hold all command line tokens not recognized
+ // to be part of a standard option.
+ // These options are intended to be processed by the doclet
+ // Contains objects of type String, where each entry is
+ // one unrecognized token.
+
+ List customOptions = new LinkedList();
+
+ rootDoc = new RootDocImpl();
+ reporter = rootDoc.getReporter();
+
+ //--- Iterate over all options given on the command line
+
+ for (Iterator it = arguments.iterator(); it.hasNext();)
+ {
+
+ String arg = (String) it.next();
+
+ //--- Check if gjdoc recognizes this option as a standard option
+ // and remember the options' argument count
+
+ int optlen = optionLength(arg);
+
+ //--- Argument count == 0 indicates that the option is not recognized.
+ // Add it to the list of custom option tokens
+
+ //--- Otherwise the option is recognized as a standard option.
+ // if all required arguments are supplied. Create a new String
+ // array for the option and its arguments, and store it
+ // in the options array.
+
+ if (optlen > 0)
+ {
+ String[] option = new String[optlen];
+ option[0] = arg;
+ boolean optargs_ok = true;
+ for (int j = 1; j < optlen && optargs_ok; ++j)
+ {
+ if (it.hasNext())
+ {
+ option[j] = (String) it.next();
+ if (option[j].startsWith("-"))
+ {
+ optargs_ok = false;
+ }
+ }
+ else
+ {
+ optargs_ok = false;
+ }
+ }
+ if (optargs_ok)
+ options.add(option);
+ else
+ {
+ // If the option requires more arguments than given on the
+ // command line, issue a fatal error
+
+ reporter.printFatal("Missing value for option " + arg + ".");
+ }
+ }
+ }
+
+ //--- Create an array of String arrays from the dynamic array built above
+
+ String[][] optionArr = (String[][]) options.toArray(new String[options
+ .size()][0]);
+
+ //--- Validate all options and issue warnings/errors
+
+ if (validOptions(optionArr, rootDoc))
+ {
+
+ //--- We got valid options; parse them and store the parsed values
+ // in 'option_*' fields.
+
+ readOptions(optionArr);
+
+ //--- Show version and exit if requested by user
+
+ if (option_showVersion) {
+ System.out.println("gjdoc " + getGjdocVersion());
+ System.exit(0);
+ }
+
+ if (option_bootclasspath_specified) {
+ reporter.printWarning("-bootclasspath ignored: not supported by"
+ + " gjdoc wrapper script, or no wrapper script in use.");
+ }
+
+ // If we have an empty source path list, add the current directory ('.')
+
+ if (option_sourcepath.size() == 0)
+ option_sourcepath.add(new File("."));
+
+ //--- We have all information we need to start the doclet at this time
+
+ if (null != option_encoding) {
+ rootDoc.setSourceEncoding(option_encoding);
+ }
+ else {
+ // be quiet about this for now:
+ // reporter.printNotice("No encoding specified, using platform default: " + System.getProperty("file.encoding"));
+ rootDoc.setSourceEncoding(System.getProperty("file.encoding"));
+ }
+ rootDoc.setSourcePath(option_sourcepath);
+
+ //addJavaLangClasses();
+
+ if (!startDoclet(arguments)) {
+ return -1;
+ }
+ }
+
+ return reporter.getErrorCount();
+ }
+
+ private void addJavaLangClasses()
+ throws IOException
+ {
+ String resourceName = "/java.lang-classes-" + option_source + ".txt";
+ InputStream in = getClass().getResourceAsStream(resourceName);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line;
+ while ((line = reader.readLine()) != null) {
+
+ String className = line.trim();
+ if (className.length() > 0) {
+ ClassDocImpl classDoc =
+ new ClassDocImpl(null, new PackageDocImpl("java.lang"),
+ ProgramElementDocImpl.ACCESS_PUBLIC,
+ false, false, null);
+ classDoc.setClass(className);
+ rootDoc.addClassDoc(classDoc);
+ }
+ }
+ }
+
+ /**
+ * Helper class for parsing command line arguments. An instance of this class
+ * represents a particular option accepted by gjdoc (e.g. '-sourcepath') along
+ * with the number of expected arguments and behavior to parse the arguments.
+ */
+ private abstract class OptionProcessor
+ {
+
+ /**
+ * Number of arguments expected by this option.
+ */
+ private int argCount;
+
+ /**
+ * Initializes this instance.
+ *
+ * @param argCount
+ * number of arguments
+ */
+ public OptionProcessor(int argCount)
+ {
+ this.argCount = argCount;
+ }
+
+ /**
+ * Overridden by derived classes with behavior to parse the arguments
+ * specified with this option.
+ *
+ * @param args
+ * command line arguments
+ */
+ abstract void process(String[] args);
+ }
+
+ /**
+ * Maps option tags (e.g. '-sourcepath') to OptionProcessor objects.
+ * Initialized only once by method initOptions(). FIXME: Rename to
+ * 'optionProcessors'.
+ */
+ private static Map options = null;
+
+ /**
+ * Initialize all OptionProcessor objects needed to scan/parse command line
+ * options. This cannot be done in a static initializer block because
+ * OptionProcessors need access to the Singleton instance of the Main class.
+ */
+ private void initOptions()
+ {
+
+ options = new HashMap();
+
+ //--- Put one OptionProcessor object into the map
+ // for each option recognized.
+
+ options.put("-overview", new OptionProcessor(2)
+ {
+
+ void process(String[] args)
+ {
+ option_overview = args[0];
+ }
+ });
+ options.put("-public", new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ option_coverage = COVERAGE_PUBLIC;
+ }
+ });
+ options.put("-protected", new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ option_coverage = COVERAGE_PROTECTED;
+ }
+ });
+ options.put("-package", new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ option_coverage = COVERAGE_PACKAGE;
+ }
+ });
+ options.put("-private", new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ option_coverage = COVERAGE_PRIVATE;
+ }
+ });
+ OptionProcessor helpProcessor = new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ option_help = true;
+ }
+ };
+
+ options.put("-help", helpProcessor);
+ options.put("--help", helpProcessor);
+ options.put("-doclet", new OptionProcessor(2)
+ {
+
+ void process(String[] args)
+ {
+ option_doclet = args[0];
+ }
+ });
+ options.put("-docletpath", new OptionProcessor(2)
+ {
+
+ void process(String[] args)
+ {
+ option_docletpath = args[0];
+ }
+ });
+ options.put("-nowarn", new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ option_nowarn = true;
+ }
+ });
+ options.put("-source", new OptionProcessor(2)
+ {
+
+ void process(String[] args)
+ {
+ option_source = args[0];
+ if (!"1.2".equals(option_source)
+ && !"1.3".equals(option_source)
+ && !"1.4".equals(option_source)) {
+
+ throw new RuntimeException("Only he following values are currently"
+ + " supported for option -source: 1.2, 1.3, 1.4.");
+ }
+ }
+ });
+ OptionProcessor sourcePathProcessor = new OptionProcessor(2) {
+ void process(String[] args)
+ {
+ Debug.log(1, "-sourcepath is '" + args[0] + "'");
+ for (StringTokenizer st = new StringTokenizer(args[0],
+ File.pathSeparator); st.hasMoreTokens();)
+ {
+ String path = st.nextToken();
+ File file = new File(path);
+ if (!(file.exists()))
+ {
+ throw new RuntimeException("The source path " + path
+ + " does not exist.");
+ }
+ option_sourcepath.add(file);
+ }
+ }
+ };
+ options.put("-s", sourcePathProcessor);
+ options.put("-sourcepath", sourcePathProcessor);
+ options.put("-subpackages", new OptionProcessor(2)
+ {
+ void process(String[] args)
+ {
+ StringTokenizer st = new StringTokenizer(args[0], ":");
+ while (st.hasMoreTokens()) {
+ String packageName = st.nextToken();
+
+ if (packageName.startsWith(".")
+ || packageName.endsWith(".")
+ || packageName.indexOf("..") > 0
+ || !checkCharSet(packageName,
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.")) {
+ throw new RuntimeException("Illegal package name '"
+ + packageName + "'");
+ }
+ option_subpackages.add(packageName);
+ }
+ }
+ });
+ options.put("-exclude", new OptionProcessor(2)
+ {
+ void process(String[] args)
+ {
+ StringTokenizer st = new StringTokenizer(args[0], ":");
+ while (st.hasMoreTokens()) {
+ String packageName = st.nextToken();
+
+ if (packageName.startsWith(".")
+ || packageName.endsWith(".")
+ || packageName.indexOf("..") > 0
+ || !checkCharSet(packageName,
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.")) {
+ throw new RuntimeException("Illegal package name '"
+ + packageName + "'");
+ }
+ option_exclude.add(packageName);
+ }
+ }
+ });
+ // TODO include other options here
+ options.put("-verbose", new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ option_verbose = true;
+ System.err.println("WARNING: Unsupported option -verbose ignored");
+ }
+ });
+ options.put("-quiet", new OptionProcessor(1)
+ {
+
+ void process(String[] args)
+ {
+ reporter.setQuiet(true);
+ }
+ });
+ options.put("-locale", new OptionProcessor(2)
+ {
+
+ void process(String[] args)
+ {
+ String localeName = args[0];
+ String language = null;
+ String country = null;
+ String variant = null;
+ StringTokenizer st = new StringTokenizer(localeName, "_");
+ if (st.hasMoreTokens()) {
+ language = st.nextToken();
+ }
+ if (st.hasMoreTokens()) {
+ country = st.nextToken();
+ }
+ if (st.hasMoreTokens()) {
+ variant = st.nextToken();
+ }
+ if (variant != null) {
+ option_locale = new Locale(language, country, variant);
+ }
+ else if (country != null) {
+ option_locale = new Locale(language, country);
+ }
+ else if (language != null) {
+ option_locale = new Locale(language);
+ }
+ else {
+ throw new RuntimeException("Illegal locale specification '"
+ + localeName + "'");
+ }
+ }
+ });
+ options.put("-encoding", new OptionProcessor(2)
+ {
+
+ void process(String[] args)
+ {
+ option_encoding = args[0];
+ }
+ });
+ options.put("-breakiterator", new OptionProcessor(1)
+ {
+ void process(String[] args)
+ {
+ option_breakiterator = true;
+ }
+ });
+ options.put("-licensetext", new OptionProcessor(1)
+ {
+ void process(String[] args)
+ {
+ option_licensetext = true;
+ }
+ });
+ options.put("-overview", new OptionProcessor(2)
+ {
+ void process(String[] args)
+ {
+ try {
+ getRootDoc().setRawCommentText(RootDocImpl.readHtmlBody(new File(args[0])));
+ }
+ catch (IOException e) {
+ throw new RuntimeException("Cannot read file specified in option -overview: " + e.getMessage());
+ }
+ }
+ });
+ options.put("-classpath", new OptionProcessor(2)
+ {
+ void process(String[] args)
+ {
+ reporter.printWarning("-classpath option could not be passed to the VM. Faking it with ");
+ reporter.printWarning(" System.setProperty(\"java.class.path\", \"" + args[0] + "\");");
+ System.setProperty("java.class.path", args[0]);
+ }
+ });
+ options.put("--version", new OptionProcessor(1)
+ {
+ void process(String[] args)
+ {
+ option_showVersion = true;
+ }
+ });
+ options.put("-bootclasspath", new OptionProcessor(1)
+ {
+ void process(String[] args)
+ {
+ option_bootclasspath_specified = true;
+ }
+ });
+ options.put("-all", new OptionProcessor(1)
+ {
+ void process(String[] args)
+ {
+ option_all = true;
+ }
+ });
+ options.put("-reflection", new OptionProcessor(1)
+ {
+ void process(String[] args)
+ {
+ option_reflection = true;
+ }
+ });
+ }
+
+ /**
+ * Determine how many arguments the given option requires.
+ *
+ * @param option
+ * The name of the option without leading dash.
+ */
+ private static int optionLength(String option)
+ {
+
+ OptionProcessor op = (OptionProcessor) options.get(option.toLowerCase());
+ if (op != null)
+ return op.argCount;
+ else
+ return 0;
+ }
+
+ /**
+ * Process all given options. Assumes that the options have been validated
+ * before.
+ *
+ * @param optionArr
+ * Each element is a series of Strings where [0] is the name of the
+ * option and [1..n] are the arguments to the option.
+ */
+ private void readOptions(String[][] optionArr)
+ {
+
+ //--- For each option, find the appropriate OptionProcessor
+ // and call its process() method
+
+ for (int i = 0; i < optionArr.length; ++i)
+ {
+ String[] opt = optionArr[i];
+ String[] args = new String[opt.length - 1];
+ System.arraycopy(opt, 1, args, 0, opt.length - 1);
+ OptionProcessor op = (OptionProcessor) options.get(opt[0].toLowerCase());
+ op.process(args);
+ }
+ }
+
+ /**
+ * Print command line usage.
+ */
+ private static void usage()
+ {
+ System.out
+ .print("\n"
+ + "USAGE: gjdoc [options] [packagenames] "
+ + "[sourcefiles] [@files]\n\n"
+ + " --version Show version information and exit\n"
+ + " -all Process all source files found in the source path\n"
+ + " -overview <file> Read overview documentation from HTML file\n"
+ + " -public Include only public classes and members\n"
+ + " -protected Include protected and public classes and members\n"
+ + " This is the default\n"
+ + " -package Include package/protected/public classes and members\n"
+ + " -private Include all classes and members\n"
+ + " -help, --help Show this information\n"
+ + " -doclet <class> Doclet class to use for generating output\n"
+ + " -docletpath <classpath> Specifies the search path for the doclet and\n"
+ + " dependencies\n"
+ + " -source <release> Provide source compatibility with specified\n"
+ + " release (1.4 to handle assertion)\n"
+ + " -sourcepath <pathlist> Where to look for source files\n"
+ + " -s <pathlist> Alias for -sourcepath\n"
+ + " -subpackages <spkglist> List of subpackages to recursively load\n"
+ + " -exclude <pkglist> List of packages to exclude\n"
+ + " -verbose Output messages about what Gjdoc is doing [ignored]\n"
+ + " -quiet Do not print non-error and non-warning messages\n"
+ + " -locale <name> Locale to be used, e.g. en_US or en_US_WIN\n"
+ + " -encoding <name> Source file encoding name\n"
+ + " -breakiterator Compute first sentence with BreakIterator\n"
+ + " -classpath <pathlist> Set the path used for loading auxilliary classes\n"
+ + "\n"
+ + "Standard doclet options:\n"
+ + " -d Set target directory\n"
+ + " -use Includes the 'Use' page for each documented class\n"
+ + " and package\n"
+ + " -version Includes the '@version' tag\n"
+ + " -author Includes the '@author' tag\n"
+ + " -splitindex Splits the index file into multiple files\n"
+ + " -windowtitle <text> Browser window title\n"
+ + " -doctitle <text> Title near the top of the overview summary file\n"
+ + " (HTML allowed)\n"
+ + " -title <text> Title for this set of API documentation\n"
+ + " (deprecated, -doctitle should be used instead)\n"
+ + " -header <text> Text to include in the top navigation bar\n"
+ + " (HTML allowed)\n"
+ + " -footer <text> Text to include in the bottom navigation bar\n"
+ + " (HTML allowed)\n"
+ + " -bottom <text> Text to include at the bottom of each output file\n"
+ + " (HTML allowed)\n"
+ + " -link <extdoc URL> Link to external generated documentation at URL\n"
+ + " -linkoffline <extdoc URL> <packagelistLoc>\n"
+ + " Link to external generated documentation for\n"
+ + " the specified package-list\n"
+ + " -linksource Creates an HTML version of each source file\n"
+ + " -group <groupheading> <packagepattern:packagepattern:...>\n"
+ + " Separates packages on the overview page into groups\n"
+ + " -nodeprecated Prevents the generation of any deprecated API\n"
+ + " -nodeprecatedlist Prevents the generation of the file containing\n"
+ + " the list of deprecated APIs and the link to the\n"
+ + " navigation bar to that page\n"
+ + " -nosince Omit the '@since' tag\n"
+ + " -notree Do not generate the class/interface hierarchy page\n"
+ + " -noindex Do not generate the index file\n"
+ + " -nohelp Do not generate the help link\n"
+ + " -nonavbar Do not generate the navbar, header and footer\n"
+ + " -helpfile <filen> Path to an alternate help file\n"
+ + " -stylesheetfile <file> Path to an alternate CSS stylesheet\n"
+ + " -addstylesheet <file> Path to an additional CSS stylesheet\n"
+ + " -serialwarn Complain about missing '@serial' tags [ignored]\n"
+ + " -charset <IANACharset> Specifies the HTML charset\n"
+ + " -docencoding <IANACharset>\n"
+ + " Specifies the encoding of the generated HTML files\n"
+ + " -tag <tagname>:Xaoptcmf:\"<taghead>\"\n"
+ + " Enables gjdoc to interpret a custom tag\n"
+ + " -taglet Adds a Taglet class to the map of taglets\n"
+ + " -tagletpath Sets the CLASSPATH to load subsequent Taglets from\n"
+ + " -docfilessubdirs Enables deep copy of 'doc-files' directories\n"
+ + " -excludedocfilessubdir <name1:name2:...>\n"
+ + " Excludes 'doc-files' subdirectories with a give name\n"
+ + " -noqualifier all|<packagename1:packagename2:...>\n"
+ + " Do never fully qualify given package names\n"
+ + " -nocomment Suppress the entire comment body including the main\n"
+ + " description and all tags, only generate declarations\n"
+ + "\n"
+ + "Gjdoc extension options:\n"
+ + " -reflection Use reflection for resolving unqualified class names\n"
+ + " -licensetext Include license text from source files\n"
+ + " -validhtml Use valid HTML/XML names (breaks compatibility)\n"
+ + " -baseurl <url> Hardwire the given base URL into generated pages\n"
+ /**
+ + " -genhtml Generate HTML code instead of XML code. This is the\n"
+ + " default.\n"
+ + " -geninfo Generate Info code instead of XML code.\n"
+ + " -xslsheet <file> If specified, XML files will be written to a\n"
+ + " temporary directory and transformed using the\n"
+ + " given XSL sheet. The result of the transformation\n"
+ + " is written to the output directory. Not required if\n"
+ + " -genhtml or -geninfo has been specified.\n"
+ + " -xmlonly Generate XML code only, do not generate HTML code.\n"
+ + " -bottomnote HTML code to include at the bottom of each page.\n"
+ + " -nofixhtml If not specified, heurestics will be applied to\n"
+ + " fix broken HTML code in comments.\n"
+ + " -nohtmlwarn Do not emit warnings when encountering broken HTML\n"
+ + " code.\n"
+ + " -noemailwarn Do not emit warnings when encountering strings like\n"
+ + " <abc@foo.com>.\n"
+ + " -indentstep <n> How many spaces to indent each tag level in\n"
+ + " generated XML code.\n"
+ + " -xsltdriver <class> Specifies the XSLT driver to use for transformation.\n"
+ + " By default, xsltproc is used.\n"
+ + " -postprocess <class> XmlDoclet postprocessor class to apply after XSL\n"
+ + " transformation.\n"
+ + " -compress Generated info pages will be Zip-compressed.\n"
+ + " -workpath Specify a temporary directory to use.\n"
+ + " -authormail <type> Specify handling of mail addresses in @author tags.\n"
+ + " no-replace do not replace mail addresses (default).\n"
+ + " mailto-name replace by <a>Real Name</a>.\n"
+ + " name-mailto-address replace by Real Name (<a>abc@foo.com</a>).\n"
+ + " name-mangled-address replace by Real Name (<a>abc AT foo DOT com</a>).\n"
+ **/
+ );
+ }
+
+ /**
+ * The root of the gjdoc tool.
+ *
+ * @return all the options of the gjdoc application.
+ */
+ public static RootDocImpl getRootDoc()
+ {
+ return rootDoc;
+ }
+
+ /**
+ * Get the gjdoc singleton.
+ *
+ * @return the gjdoc instance.
+ */
+ public static Main getInstance()
+ {
+ return instance;
+ }
+
+ /**
+ * Is this access level covered?
+ *
+ * @param accessLevel
+ * the access level we want to know if it is covered.
+ * @return true if the access level is covered.
+ */
+ public boolean includeAccessLevel(int accessLevel)
+ {
+ return coverageTemplates[option_coverage][accessLevel];
+ }
+
+ /**
+ * Is the doclet running?
+ *
+ * @return true if it's running
+ */
+ public boolean isDocletRunning()
+ {
+ return docletRunning;
+ }
+
+ /**
+ * Check the charset. Check that all the characters of the string 'toCheck'
+ * and query if they exist in the 'charSet'. The order does not matter. The
+ * number of times a character is in the variable does not matter.
+ *
+ * @param toCheck
+ * the charset to check.
+ * @param charSet
+ * the reference charset
+ * @return true if they match.
+ */
+ public static boolean checkCharSet(String toCheck, String charSet)
+ {
+ for (int i = 0; i < toCheck.length(); ++i)
+ {
+ if (charSet.indexOf(toCheck.charAt(i)) < 0)
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Makes the RootDoc eligible for the GC.
+ */
+ public static void releaseRootDoc()
+ {
+ rootDoc.flush();
+ }
+
+ /**
+ * Return whether the -breakiterator option has been specified.
+ */
+ public boolean isUseBreakIterator()
+ {
+ return this.option_breakiterator
+ || !getLocale().getLanguage().equals(Locale.ENGLISH.getLanguage());
+ }
+
+ /**
+ * Return whether boilerplate license text should be copied.
+ */
+ public boolean isCopyLicenseText()
+ {
+ return this.option_licensetext;
+ }
+
+ /**
+ * Return the locale specified using the -locale option or the
+ * default locale;
+ */
+ public Locale getLocale()
+ {
+ return this.option_locale;
+ }
+
+ /**
+ * Return the collator to use based on the specified -locale
+ * option. If no collator can be found for the given locale, a
+ * warning is emitted and the default collator is used instead.
+ */
+ public Collator getCollator()
+ {
+ if (null == this.collator) {
+ Locale locale = getLocale();
+ this.collator = Collator.getInstance(locale);
+ Locale defaultLocale = Locale.getDefault();
+ if (null == this.collator
+ && !defaultLocale.equals(locale)) {
+ this.collator = Collator.getInstance(defaultLocale);
+ if (null != this.collator) {
+ reporter.printWarning("No collator found for locale "
+ + locale.getDisplayName()
+ + "; using collator for default locale "
+ + defaultLocale.getDisplayName()
+ + ".");
+ }
+ else {
+ this.collator = Collator.getInstance();
+ reporter.printWarning("No collator found for specified locale "
+ + locale.getDisplayName()
+ + " or default locale "
+ + defaultLocale.getDisplayName()
+ + ": using default collator.");
+ }
+ }
+ if (null == this.collator) {
+ this.collator = Collator.getInstance();
+ reporter.printWarning("No collator found for locale "
+ + locale.getDisplayName()
+ + ": using default collator.");
+ }
+ }
+ return this.collator;
+ }
+
+ public boolean isCacheRawComments()
+ {
+ return true;
+ }
+
+ public String getGjdocVersion()
+ {
+ if (null == gjdocVersion) {
+ gjdocVersion = gnu.classpath.Configuration.CLASSPATH_VERSION;
+ }
+ return gjdocVersion;
+ }
+
+ public boolean isReflectionEnabled()
+ {
+ return this.option_reflection;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/MemberDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/MemberDocImpl.java
new file mode 100644
index 000000000..acc812863
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/MemberDocImpl.java
@@ -0,0 +1,235 @@
+/* gnu.classpath.tools.gjdoc.MemberDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.util.*;
+import com.sun.javadoc.*;
+
+public abstract class MemberDocImpl extends ProgramElementDocImpl implements MemberDoc {
+
+ protected String typeName;
+ protected Type type;
+
+ public MemberDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ SourcePosition position) {
+
+ super(containingClass,
+ containingPackage,
+ position);
+ }
+
+ public String qualifiedName() {
+ return containingClass().qualifiedName()+"."+name();
+ }
+
+ public boolean isSynthetic() {
+ return false;
+ }
+
+ int parseModifiers(char[] source, int startIndex, int endIndex) {
+
+ Debug.log(9,"parseModifiers '"+new String(source,startIndex,endIndex-startIndex)+"'");
+
+ final int STATE_NORMAL = 1;
+ final int STATE_STARC = 2;
+ final int STATE_SLASHC = 3;
+
+ int state = STATE_NORMAL;
+
+ StringBuffer word = new StringBuffer();
+ StringBuffer typeNameBuf = new StringBuffer();
+ int lastWordStart = startIndex;
+ int firstChar = 0;
+ int lastChar = 0;
+ for (; startIndex<endIndex; ++startIndex) {
+ if (state==STATE_STARC) {
+ if (startIndex<endIndex-1 && source[startIndex]=='*' && source[startIndex+1]=='/') {
+ ++startIndex;
+ state=STATE_NORMAL;
+ }
+ }
+ else if (state==STATE_SLASHC) {
+ if (source[startIndex]=='\n') {
+ state=STATE_NORMAL;
+ }
+ }
+ else if (startIndex<endIndex-1 && source[startIndex]=='/' && source[startIndex+1]=='*') {
+ ++startIndex;
+ state=STATE_STARC;
+ }
+ else if (source[startIndex]=='=' || source[startIndex]=='(' || source[startIndex]==';') {
+ typeName = typeNameBuf.toString();
+ return lastWordStart;
+ }
+ else if (Parser.WHITESPACE.indexOf(source[startIndex])>=0
+ || (startIndex > 0 && source[startIndex-1] == ']' && source[startIndex] != '[')) {
+ if (word.length()>0 && lastChar != '.') {
+ if (processModifier(word.toString())) {
+ }
+ else if (typeNameBuf.length()==0 && !isConstructor()) {
+ typeNameBuf.setLength(0);
+ typeNameBuf.append(word);
+ }
+ else if ((firstChar=='[' || firstChar==']') && !isConstructor()) {
+ typeNameBuf.append(word);
+ }
+ else {
+ typeName = typeNameBuf.toString();
+ return lastWordStart;
+ }
+ word.setLength(0);
+ lastWordStart=startIndex;
+ }
+ }
+ else {
+ if (lastWordStart<0) lastWordStart=startIndex;
+ lastChar = source[startIndex];
+ if (0 == word.length()) {
+ firstChar = lastChar;
+ }
+ word.append((char)lastChar);
+ }
+ }
+
+ typeName = typeNameBuf.toString();
+ return startIndex;
+ }
+
+ public Type type() {
+ //public Type type() throws ParseException {
+ Debug.log(9,"type() called on "+containingClass()+"."+this);
+ if (type==null) {
+ try {
+ type=((ClassDocImpl)containingClass()).typeForString(typeName);
+ } catch (ParseException e) {
+ System.err.println("FIXME: add try-catch to force compilation");
+ e.printStackTrace();
+ }
+ }
+ return type;
+ }
+
+
+ protected void setName(String name) {
+ this.name=name;
+ }
+ private String name;
+
+
+ public String name() {
+ return name;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName=typeName;
+ this.type=null;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ // return true if this Doc is include in the active set.
+ public boolean isIncluded() {
+ return Main.getInstance().includeAccessLevel(accessLevel);
+ }
+
+ public int compareTo(Object o) {
+ if (o instanceof MemberDocImpl) {
+ int rc=name().compareTo(((MemberDocImpl)o).name());
+ if (rc==0)
+ rc=containingClass().qualifiedName().compareTo(((MemberDocImpl)o).containingClass().qualifiedName());
+ return rc;
+ }
+ else {
+ return super.compareTo(o);
+ }
+ }
+
+ void resolve() {
+
+ if (type==null && typeName!=null) {
+ Debug.log(1, "MemberDocImpl.resolve(), looking up type named "+typeName);
+ try {
+ type=((ClassDocImpl)containingClass()).typeForString(typeName);
+ } catch (ParseException e) {
+ //System.err.println("FIXME: add try-catch to force compilation");
+ //e.printStackTrace();
+ Debug.log(1, "INTERNAL WARNING: Couldn't find type for name '"+typeName+"'");
+ }
+ }
+
+ if (type instanceof ClassDocProxy) {
+ String className=type.qualifiedTypeName();
+ ClassDoc realClassDoc=((ClassDocImpl)containingClass()).findClass(className, type.dimension());
+ if (realClassDoc!=null) {
+ type=realClassDoc;
+ }
+ else {
+ //throw new Error("Class not found: "+className);
+ /*** This is not an error, the class was not included
+ * on the command line. Perhaps emit a notice here.
+ *
+
+ Main.getRootDoc().printError("Class not found '"
+ + className
+ + "' in class '"
+ + containingClass().qualifiedName()
+ + "' member '"
+ + name()
+ + "'");
+ */
+ }
+ }
+ }
+
+ public void resolveComments()
+ {
+ super.resolveComments();
+
+ if (tagMap.isEmpty()) {
+ TagContainer inheritedTagMap = ClassDocImpl.findInheritedDoc(containingClass(),
+ this,
+ null);
+ if (null != inheritedTagMap) {
+ this.tagMap = inheritedTagMap.getTagMap();
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/MethodDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/MethodDocImpl.java
new file mode 100644
index 000000000..78748c848
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/MethodDocImpl.java
@@ -0,0 +1,64 @@
+/* gnu.classpath.tools.gjdoc.MethodDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.util.*;
+import com.sun.javadoc.*;
+
+public class MethodDocImpl extends ExecutableMemberDocImpl implements MethodDoc {
+
+ public MethodDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ SourcePosition position) {
+
+ super(containingClass,
+ containingPackage,
+ position);
+ }
+
+ // Is this Doc item a class.
+ public boolean isMethod() {
+ return true;
+ }
+
+ public Type returnType() {
+ return super.type();
+ }
+
+ public String toString() { return name()+((signature()==null)?"()":signature()); }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/PackageDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/PackageDocImpl.java
new file mode 100644
index 000000000..84960bcf3
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/PackageDocImpl.java
@@ -0,0 +1,223 @@
+/* gnu.classpath.tools.gjdoc.PackageDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.io.File;
+
+class PackageDocImpl extends DocImpl implements GjdocPackageDoc {
+
+ private String packageName;
+ private File packageDirectory;
+
+ private Set allClassesSet = new TreeSet();
+ private List ordinaryClassesList = new ArrayList();
+ private List exceptionsList = new ArrayList();
+ private List interfacesList = new ArrayList();
+ private List errorsList = new ArrayList();
+
+ private ClassDoc[] allClasses;
+ private ClassDoc[] ordinaryClasses;
+ private ClassDoc[] exceptions;
+ private ClassDoc[] interfaces;
+ private ClassDoc[] errors;
+
+ PackageDocImpl(String packageName) {
+ super(null);
+ this.packageName=packageName;
+ }
+
+ public void addClass(ClassDoc classDoc) {
+ if (Main.getInstance().includeAccessLevel(((ClassDocImpl)classDoc).accessLevel)) {
+ allClassesSet.add(classDoc);
+ }
+ }
+
+ public void resolve() {
+ for (Iterator it=allClassesSet.iterator(); it.hasNext(); ) {
+ ClassDocImpl classDoc=(ClassDocImpl)it.next();
+ try {
+ classDoc.resolve();
+ } catch (ParseException e) {
+ System.err.println("FIXME: add try-catch to force compilation"
+ + e);
+ }
+
+ if (classDoc.isInterface()) {
+ interfacesList.add(classDoc);
+ }
+ else if (classDoc.isException()) {
+ exceptionsList.add(classDoc);
+ }
+ else if (classDoc.isError()) {
+ errorsList.add(classDoc);
+ }
+ else {
+ ordinaryClassesList.add(classDoc);
+ }
+ }
+ }
+
+ public void resolveComments() {
+ if (rawDocumentation!=null) {
+ this.tagMap=parseCommentTags(rawDocumentation.toCharArray(),
+ 0,
+ rawDocumentation.length(),
+ null,
+ null,
+ null,
+ null);
+ }
+
+ resolveTags();
+ }
+
+ public String name() {
+ return packageName;
+ }
+
+ public ClassDoc[] allClasses()
+ {
+ if (null == this.allClasses) {
+ this.allClasses = toClassDocArray(allClassesSet);
+ }
+ return this.allClasses;
+ }
+
+ public ClassDoc[] ordinaryClasses()
+ {
+ if (null == this.ordinaryClasses) {
+ this.ordinaryClasses = toClassDocArray(ordinaryClassesList);
+ }
+ return this.ordinaryClasses;
+ }
+
+
+ public ClassDoc[] exceptions()
+ {
+ if (null == this.exceptions) {
+ this.exceptions = toClassDocArray(exceptionsList);
+ }
+ return this.exceptions;
+ }
+
+ public ClassDoc[] interfaces()
+ {
+ if (null == this.interfaces) {
+ this.interfaces = toClassDocArray(interfacesList);
+ }
+ return this.interfaces;
+ }
+
+ public ClassDoc[] errors()
+ {
+ if (null == this.errors) {
+ this.errors = toClassDocArray(errorsList);
+ }
+ return this.errors;
+ }
+
+ private ClassDoc[] toClassDocArray(Collection classDocList)
+ {
+ ClassDoc[] result = (ClassDoc[])classDocList.toArray(new ClassDoc[classDocList.size()]);
+ Arrays.sort(result);
+ return result;
+ }
+
+ public ClassDoc findClass(String name) {
+ return Main.getRootDoc().classNamed(packageName+"."+name);
+ }
+
+ public void dump(int level) {
+ Debug.log(level, "All classes:");
+ Debug.dumpArray(level, allClasses());
+
+ Debug.log(level, "Ordinary classes:");
+ Debug.dumpArray(level, ordinaryClasses());
+
+ }
+
+ public static final PackageDocImpl DEFAULT_PACKAGE = new PackageDocImpl("");
+
+ public boolean isPackage() {
+ return true;
+ }
+
+ public boolean isIncluded() {
+ return isIncluded;
+ }
+
+ void setIsIncluded(boolean b) {
+ this.isIncluded=b;
+ }
+
+ private boolean isIncluded = false;
+
+ public String toString() {
+ return packageName;
+ }
+
+ public int compareTo(Object o) {
+ if (o!=null && o instanceof PackageDocImpl)
+ return name().compareTo(((PackageDocImpl)o).name());
+ else
+ return 0;
+ }
+
+ public boolean equals(Object o) {
+ if (o!=null && o instanceof PackageDocImpl)
+ return name().equals(((PackageDocImpl)o).name());
+ else
+ return false;
+ }
+
+ /**
+ * Sets the directory containing this package's source files.
+ */
+ public void setPackageDirectory(File packageDirectory) {
+ this.packageDirectory = packageDirectory;
+ }
+
+ /**
+ * Gets the directory containing this package's source files.
+ */
+ public File packageDirectory() {
+ return this.packageDirectory;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParamTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParamTagImpl.java
new file mode 100644
index 000000000..a7491dc8e
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParamTagImpl.java
@@ -0,0 +1,81 @@
+/* gnu.classpath.tools.gjdoc.ParamTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+
+public class ParamTagImpl extends AbstractTagImpl implements ParamTag {
+
+ private String parameterName;
+ private String parameterComment;
+
+ public ParamTagImpl(String text,
+ ClassDocImpl contextClass,
+ MemberDocImpl contextMember) {
+ super(text);
+ char[] textarr=text.toCharArray();
+ int i=0;
+ for (; i<textarr.length; ++i) {
+ if (!Parser.isWhitespace(textarr[i])) break;
+ }
+ for (; i<textarr.length; ++i) {
+ if (Parser.isWhitespace(textarr[i])) {
+ parameterName=new String(textarr,0,i).trim();
+ parameterComment=new String(textarr,i,textarr.length-i).trim();
+ break;
+ }
+ }
+ if (parameterComment!=null) {
+ setBody(parameterComment, contextClass, contextMember);
+ }
+ }
+
+ public String parameterComment() {
+ return parameterComment;
+ }
+
+ public String parameterName() {
+ return parameterName;
+ }
+
+ public String kind() {
+ return "@param";
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParameterImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParameterImpl.java
new file mode 100644
index 000000000..29b8e9b70
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParameterImpl.java
@@ -0,0 +1,69 @@
+/* gnu.classpath.tools.gjdoc.ParameterImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+
+public class ParameterImpl implements Parameter {
+
+ String name;
+ String typeName;
+ Type type;
+
+ ParameterImpl(String name, String typeName, Type type) {
+
+ this.name=name;
+ this.typeName=typeName;
+ this.type=type;
+ }
+
+ public void resolve(ClassDoc classContext) {
+ if (type instanceof ClassDocProxy) {
+ String className=type.qualifiedTypeName();
+ ClassDoc realClassDoc=((ClassDocImpl)classContext).findClass(className, type.dimension());
+ if (realClassDoc!=null) {
+ type=realClassDoc;
+ }
+ }
+ }
+
+ public String name() { return name; }
+ public String typeName() { return typeName; }
+ public Type type() { return type; }
+ public String toString() { return typeName+" "+name; }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParseException.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParseException.java
new file mode 100644
index 000000000..3ecd84592
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParseException.java
@@ -0,0 +1,51 @@
+/* gnu.classpath.tools.gjdoc.ParseException
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+class ParseException extends Exception {
+
+ public ParseException()
+ {
+ }
+
+ public ParseException(String msg)
+ {
+ super(msg);
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Parser.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Parser.java
new file mode 100644
index 000000000..d355b5384
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Parser.java
@@ -0,0 +1,1064 @@
+/* gnu.classpath.tools.gjdoc.Parser
+ Copyright (C) 2001, 2005, 2008 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
+import java.util.*;
+
+import com.sun.javadoc.*;
+
+import gnu.classpath.tools.IOToolkit;
+import gnu.classpath.tools.NotifyingInputStreamReader;
+import gnu.classpath.tools.MalformedInputListener;
+import gnu.classpath.tools.MalformedInputEvent;
+
+ class IgnoredFileParseException extends ParseException
+ {
+ // marker exception
+ }
+
+ abstract class SourceComponent {
+
+ abstract int match(char[] source, int index) throws ParseException;
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) throws ParseException, IOException {
+ return endIndex;
+ }
+
+ int getEndIndex(char[] source, int endIndex) throws ParseException {
+ return endIndex;
+ }
+ }
+
+ abstract class BlockSourceComponent extends SourceComponent {
+
+ int getEndIndex(char[] source, int endIndex) throws ParseException {
+ return Parser.skipExpression(source, endIndex, 1, '\0');
+ }
+
+ }
+
+ class Whitespace extends SourceComponent {
+
+ int match(char[] source, int index) {
+
+ int rc=index;
+ int slen=source.length;
+ while (rc<slen && Parser.WHITESPACE.indexOf(source[rc])>=0) ++rc;
+
+ return (rc!=index) ? rc : -1;
+ }
+ }
+
+ class BracketClose extends SourceComponent {
+
+ int match(char[] source, int index) {
+ if (source[index]=='}') {
+ return index+1;
+ }
+ else {
+ return -1;
+ }
+ }
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex)
+ throws ParseException, IOException
+ {
+ parser.classClosed();
+ return endIndex;
+ }
+ }
+
+ class CommentComponent extends SourceComponent {
+
+ int match(char[] source, int index) throws ParseException {
+ if (index+1<source.length && source[index]=='/' && source[index+1]=='*') {
+ for (index+=2; index+1<source.length; ++index) {
+ if (source[index]=='*' && source[index+1]=='/')
+ return index+2;
+ }
+ throw new ParseException("unexpected end of input");
+ }
+ return -1;
+ }
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) {
+
+ if (source[startIndex+0]=='/'
+ && source[startIndex+1]=='*'
+ && source[startIndex+2]=='*') {
+
+ parser.setLastComment(new String(source, startIndex, endIndex-startIndex));
+ }
+ else if (null == parser.getBoilerplateComment() && Main.getInstance().isCopyLicenseText()) {
+ String boilerplateComment = new String(source, startIndex + 2, endIndex-startIndex - 4);
+ if (boilerplateComment.toLowerCase().indexOf("copyright") >= 0) {
+ parser.setBoilerplateComment(boilerplateComment);
+ }
+ }
+
+ return endIndex;
+ }
+ }
+
+ class SlashSlashCommentComponent extends SourceComponent {
+
+ int match(char[] source, int index) {
+ if (index+1<source.length && source[index]=='/' && source[index+1]=='/') {
+ index+=2;
+ while (index<source.length && source[index]!='\n')
+ ++index;
+ return index;
+ }
+ else {
+ return -1;
+ }
+ }
+ }
+
+ class EmptyStatementComponent extends SourceComponent {
+
+ int match(char[] source, int index) {
+ while (index < source.length
+ && Parser.isWhitespace(source[index])) {
+ ++ index;
+ }
+ if (index < source.length && source[index] == ';') {
+ return index+1;
+ }
+ else {
+ return -1;
+ }
+ }
+ }
+
+ class ImportComponent extends SourceComponent {
+
+ int match(char[] source, int index) {
+ if (index+7<source.length) {
+ if (source[index+0]=='i'
+ && source[index+1]=='m'
+ && source[index+2]=='p'
+ && source[index+3]=='o'
+ && source[index+4]=='r'
+ && source[index+5]=='t'
+ && Parser.WHITESPACE.indexOf(source[index+6])>=0) {
+
+ for (index+=7; index<source.length && source[index]!=';'; ++index)
+ ;
+
+ return index+1;
+ }
+ }
+ return -1;
+ }
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) throws ParseException, IOException {
+ String importString=new String(source,startIndex+7,endIndex-startIndex-7-1).trim();
+ parser.importEncountered(importString);
+ return endIndex;
+ }
+ }
+
+ class PackageComponent extends SourceComponent {
+
+ int match(char[] source, int index) {
+ if (index+10<source.length) {
+ if (source[index+0]=='p'
+ && source[index+1]=='a'
+ && source[index+2]=='c'
+ && source[index+3]=='k'
+ && source[index+4]=='a'
+ && source[index+5]=='g'
+ && source[index+6]=='e'
+ && Parser.WHITESPACE.indexOf(source[index+7])>=0) {
+
+ for (index+=7; index<source.length && source[index]!=';'; ++index)
+ ;
+
+ return index+1;
+ }
+ }
+ return -1;
+ }
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) {
+ String packageName=new String(source,startIndex+8,endIndex-startIndex-8-1).trim();
+ parser.packageOpened(packageName);
+ return endIndex;
+ }
+ }
+
+ class FieldComponent extends SourceComponent {
+
+ int match(char[] source, int index) throws ParseException {
+ boolean isField=false;
+ final int STATE_NORMAL=1;
+ final int STATE_SLASHC=2;
+ final int STATE_STARC=3;
+ final int STATE_FIELDVAL=4;
+ final int STATE_STRING=5;
+ final int STATE_SINGLEQUOTED=6;
+ final int STATE_STRING_BS=7;
+ final int STATE_SINGLEQUOTED_BS=8;
+
+ int state=STATE_NORMAL;
+ int prevState=STATE_NORMAL;
+
+ int fieldValueLevel = 0;
+
+ for (; index<source.length && !isField; ++index) {
+ if (state==STATE_STARC) {
+ if (index<source.length-1 && source[index]=='*' && source[index+1]=='/') {
+ ++index;
+ state=prevState;
+ }
+ }
+ else if (state==STATE_SLASHC) {
+ if (source[index]=='\n') {
+ state=prevState;
+ }
+ }
+ else if (state==STATE_STRING) {
+ if (source[index]=='\\') {
+ state=STATE_STRING_BS;
+ }
+ else if (source[index]=='\"') {
+ state=prevState;
+ }
+ }
+ else if (state==STATE_STRING_BS) {
+ state=STATE_STRING;
+ }
+ else if (state==STATE_SINGLEQUOTED) {
+ if (source[index]=='\\') {
+ state=STATE_SINGLEQUOTED_BS;
+ }
+ else if (source[index]=='\'') {
+ state=prevState;
+ }
+ }
+ else if (state==STATE_SINGLEQUOTED_BS) {
+ state=STATE_SINGLEQUOTED;
+ }
+ else if (state==STATE_FIELDVAL) {
+ if (source[index]=='/') {
+ if (index<source.length-1 && source[index+1]=='*') {
+ state=STATE_STARC;
+ ++index;
+ }
+ else if (index<source.length-1 && source[index+1]=='/') {
+ state=STATE_SLASHC;
+ ++index;
+ }
+ }
+ else if (source[index]=='{') {
+ ++ fieldValueLevel;
+ }
+ else if (source[index]=='}') {
+ -- fieldValueLevel;
+ }
+ else if (source[index]=='\"') {
+ state=STATE_STRING;
+ }
+ else if (source[index]=='\'') {
+ state=STATE_SINGLEQUOTED;
+ }
+ else if (source[index]==';' && 0 == fieldValueLevel) {
+ isField=true;
+ break;
+ }
+ }
+ else switch (source[index]) {
+ case '/':
+ if (index<source.length-1 && source[index+1]=='*') {
+ state=STATE_STARC;
+ ++index;
+ }
+ else if (index<source.length-1 && source[index+1]=='/') {
+ state=STATE_SLASHC;
+ ++index;
+ }
+ break;
+ case '{': // class
+ case '(': // method
+ return -1;
+ case '=': // field
+ state=STATE_FIELDVAL;
+ prevState=state;
+ continue;
+ case ';': // field
+ isField=true;
+ break;
+ }
+ if (isField) break;
+ }
+ if (!isField || index==source.length) {
+ return -1;
+ }
+
+ //System.err.println("char is "+source[index]);
+
+ if (source[index]!=';') {
+ index=Parser.skipExpression(source, index, 0, ';');
+ }
+ return index+1;
+ }
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) {
+
+ //Debug.log(9,"found package statement: \""+str+"\"");
+ //Debug.log(9,"found function component: '"+str+"'");
+ //xxx(new FieldDocImpl(ctx.classDoc, ctx.classDoc.containingPackage(), 0, false, false));
+
+ // Ignore superfluous semicoli after class definition
+ if (endIndex-startIndex<=1) return endIndex;
+
+ //assert (parser.ctx!=null);
+ Collection fields=FieldDocImpl.createFromSource(parser.ctx.classDoc,
+ parser.ctx.classDoc.containingPackage(),
+ source, startIndex, endIndex);
+
+ for (Iterator it=fields.iterator(); it.hasNext(); ) {
+ FieldDocImpl field=(FieldDocImpl)it.next();
+ boolean fieldHasSerialTag=!field.isTransient() && !field.isStatic(); //field.hasSerialTag();
+ if ((field.isIncluded() || fieldHasSerialTag) && parser.getAddComments()) {
+ field.setRawCommentText(parser.getLastComment());
+ }
+ parser.ctx.fieldList.add(field);
+ if (field.isIncluded()) {
+ parser.ctx.filteredFieldList.add(field);
+ }
+ if (fieldHasSerialTag) {
+ parser.ctx.sfieldList.add(field);
+ }
+ }
+
+ parser.setLastComment(null);
+ return endIndex;
+ }
+
+
+ }
+
+ class FunctionComponent extends BlockSourceComponent {
+
+ int getEndIndex(char[] source, int endIndex) throws ParseException {
+ if (source[endIndex-1]==';') {
+ return endIndex;
+ }
+ else {
+ return super.getEndIndex(source, endIndex);
+ }
+ }
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) throws IOException, ParseException {
+
+ //ctx.fieldList.add(FieldDocImpl.createFromSource(source, startIndex, endIndex));
+
+ //System.out.println("function match '"+new String(source,startIndex,endIndex-startIndex)+"'");
+ ExecutableMemberDocImpl execDoc=MethodDocImpl.createFromSource(parser.ctx.classDoc,
+ parser.ctx.classDoc.containingPackage(),
+ source, startIndex, endIndex);
+
+ if (parser.getAddComments())
+ execDoc.setRawCommentText(parser.getLastComment());
+
+ parser.setLastComment(null);
+
+ if (execDoc.isMethod()) {
+ parser.ctx.methodList.add(execDoc);
+ if (execDoc.isIncluded()) {
+ parser.ctx.filteredMethodList.add(execDoc);
+ }
+ }
+ else {
+ parser.ctx.constructorList.add(execDoc);
+ if (execDoc.isIncluded()) {
+ parser.ctx.filteredConstructorList.add(execDoc);
+ }
+ }
+
+ if (execDoc.isMethod()
+ && (execDoc.name().equals("readObject")
+ || execDoc.name().equals("writeObject")
+ || execDoc.name().equals("readExternal")
+ || execDoc.name().equals("writeExternal")
+ || execDoc.name().equals("readResolve"))) {
+ // FIXME: add readExternal here?
+
+ parser.ctx.maybeSerMethodList.add(execDoc);
+ }
+
+ return endIndex;
+ }
+
+ int match(char[] source, int index) {
+ boolean isFunc=false;
+ final int STATE_NORMAL=1;
+ final int STATE_SLASHC=2;
+ final int STATE_STARC=3;
+ int state=STATE_NORMAL;
+ for (; index<source.length && !isFunc; ++index) {
+ if (state==STATE_STARC) {
+ if (source[index]=='*' && source[index+1]=='/') {
+ ++index;
+ state=STATE_NORMAL;
+ }
+ }
+ else if (state==STATE_SLASHC) {
+ if (source[index]=='\n') {
+ state=STATE_NORMAL;
+ }
+ }
+ else switch (source[index]) {
+ case '/':
+ if (source[index+1]=='*') {
+ state=STATE_STARC;
+ ++index;
+ }
+ else if (source[index+1]=='/') {
+ state=STATE_SLASHC;
+ ++index;
+ }
+ break;
+ case '=': // field
+ case ';': // field
+ case '{': // class
+ return -1;
+ case '(':
+ isFunc=true;
+ break;
+ }
+ if (isFunc) break;
+ }
+ if (!isFunc || index==source.length)
+ return -1;
+
+ for (; index<source.length && (state!=STATE_NORMAL || (source[index]!='{' && source[index]!=';')); ++index)
+ if (state==STATE_SLASHC && source[index]=='\n') {
+ state=STATE_NORMAL;
+ }
+ else if (index<source.length-1) {
+ if (state==STATE_STARC) {
+ if (source[index]=='*' && source[index+1]=='/') {
+ state=STATE_NORMAL;
+ }
+ }
+ else {
+ if (source[index]=='/' && source[index+1]=='*') {
+ state=STATE_STARC;
+ }
+ else if (source[index]=='/' && source[index+1]=='/') {
+ state=STATE_SLASHC;
+ }
+ }
+ }
+ return index+1;
+ }
+
+
+ }
+
+ class StaticBlockComponent extends BlockSourceComponent {
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) {
+ //Debug.log(9,"found package statement: \""+str+"\"");
+ //Debug.log(9,"found function component: '"+str+"'");
+ parser.setLastComment(null);
+ return endIndex;
+ }
+
+ int match(char[] source, int index) {
+ if (source[index]=='{') return index+1;
+
+ if (index+7<source.length) {
+ if (source[index+0]=='s'
+ && source[index+1]=='t'
+ && source[index+2]=='a'
+ && source[index+3]=='t'
+ && source[index+4]=='i'
+ && source[index+5]=='c') {
+
+ for (index+=6; index<source.length && Parser.WHITESPACE.indexOf(source[index])>=0; ++index)
+ ;
+
+ if (index<source.length && source[index]=='{')
+ return index+1;
+ else
+ return -1;
+ }
+ }
+ return -1;
+ }
+
+ }
+
+ class ClassComponent extends SourceComponent {
+
+ int match(char[] source, int index) {
+ boolean isClass=false;
+ for (; index<source.length && !isClass; ++index) {
+ switch (source[index]) {
+ case '/': // possible comment
+ if (index<source.length-1) {
+ char c = source[index+1];
+ if ('/' == c) {
+ index += 2;
+ while (index<source.length && source[index]!=10) {
+ ++ index;
+ }
+ }
+ else if ('*' == c) {
+ index += 3;
+ while (index<source.length && (source[index-1] != '*' || source[index]!='/')) {
+ ++ index;
+ }
+ }
+ }
+ break;
+ case '@': // annotation
+ index += 1;
+ while(index<source.length && Character.isJavaIdentifierPart(source[index])) {
+ ++ index;
+ }
+ if (index<source.length && source[index]=='(') {
+ int parLevel = 1;
+ index += 1;
+ while (index<source.length && parLevel>0) {
+ if (source[index] == '(')
+ ++ parLevel;
+ if (source[index] == ')')
+ -- parLevel;
+ ++ index;
+ if (parLevel==0)
+ break;
+ }
+ }
+ break;
+ case '=': // field
+ case ';': // field
+ case '(': // function
+ return -1;
+ case '{':
+ isClass=true;
+ break;
+ }
+ if (isClass) break;
+ }
+ if (!isClass || index>=source.length)
+ return -1;
+
+ return index+1;
+ }
+
+ int process(Parser parser, char[] source, int startIndex, int endIndex) throws ParseException, IOException {
+
+ parser.classOpened(source, startIndex, endIndex);
+ if (parser.getAddComments())
+ parser.ctx.classDoc.setRawCommentText(parser.getLastComment());
+ parser.setLastComment(null);
+ if (parser.ctx.classDoc.isEnum())
+ {
+ int depth = 0;
+ for (int a = endIndex; a < source.length; ++a)
+ {
+ Debug.log(9, "Enum skipping " + a);
+ if (source[a] == '{')
+ {
+ Debug.log(1, "Found inner { in enum");
+ ++depth;
+ }
+ if (source[a] == '}')
+ {
+ if (depth > 0)
+ {
+ Debug.log(1, "Found inner } in enum");
+ --depth;
+ }
+ else
+ {
+ Debug.log(1, "Found enum }");
+ parser.classClosed();
+ return a + 1;
+ }
+ }
+ }
+ }
+ int rc=parser.parse(source, endIndex, parser.getClassLevelComponents());
+ return rc;
+ }
+
+ }
+
+
+public class Parser {
+
+
+ static int skipExpression(char[] source, int endIndex, int level, char delimiter) throws ParseException {
+
+ int orgEndIndex=endIndex;
+
+ final int STATE_NORMAL=1;
+ final int STATE_STARC=2;
+ final int STATE_SLASHC=3;
+ final int STATE_CHAR=4;
+ final int STATE_STRING=5;
+
+ int state=STATE_NORMAL;
+ int prev=0;
+ for (; !((level==0 && state==STATE_NORMAL && (delimiter=='\0' || source[endIndex]==delimiter))) && endIndex<source.length; ++endIndex) {
+ int c=source[endIndex];
+ if (state==STATE_NORMAL) {
+ if (c=='}') --level;
+ else if (c=='{') ++level;
+ else if (c=='/' && prev=='/') { state=STATE_SLASHC; c=0; }
+ else if (c=='*' && prev=='/') { state=STATE_STARC; c=0; }
+ else if (c=='\'' && prev!='\\') { state=STATE_CHAR; c=0; }
+ else if (c=='\"' && prev!='\\') { state=STATE_STRING; c=0; }
+ }
+ else if (state==STATE_SLASHC) {
+ if (c=='\n') state=STATE_NORMAL;
+ }
+ else if (state==STATE_CHAR) {
+ if (c=='\'' && prev!='\\') state=STATE_NORMAL;
+ else if (c=='\\' && prev=='\\') c=0;
+ }
+ else if (state==STATE_STRING) {
+ if (c=='\"' && prev!='\\') state=STATE_NORMAL;
+ else if (c=='\\' && prev=='\\') c=0;
+ }
+ else {
+ if (c=='/' && prev=='*') { state=STATE_NORMAL; c=0; }
+ }
+ prev=c;
+ }
+ if (level>0)
+ throw new ParseException("Unexpected end of source.");
+ else {
+ String rc=new String(source, orgEndIndex, endIndex-orgEndIndex);
+ return endIndex;
+ }
+ }
+
+ private boolean addComments = false;
+
+ public boolean getAddComments()
+ {
+ return this.addComments;
+ }
+
+ public static final String WHITESPACE=" \t\r\n ";
+
+ public static final boolean isWhitespace(char c) {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == ' ');
+ //return WHITESPACE.indexOf(c)>=0;
+ }
+
+ private int currentLine;
+
+ static char[] loadFile(final File file, String encoding)
+ throws IOException
+ {
+ InputStream in = new FileInputStream(file);
+ NotifyingInputStreamReader notifyingInput
+ = new NotifyingInputStreamReader(in, encoding);
+ notifyingInput.addMalformedInputListener(new MalformedInputListener() {
+ public void malformedInputEncountered(MalformedInputEvent event) {
+ Main.getRootDoc().printWarning("Illegal character in file " + file + ", line " + event.getLineNumber() + ", column " + event.getColumnNumber());
+ try {
+ Main.getRootDoc().printWarning(IOToolkit.getLineFromFile(file, event.getLineNumber()));
+ Main.getRootDoc().printWarning(IOToolkit.getColumnDisplayLine(event.getColumnNumber()));
+ }
+ catch (IOException ignore) {
+ }
+ }
+ });
+ Reader reader
+ = new BufferedReader(notifyingInput);
+ char[] result = IOToolkit.readFully(reader);
+ reader.close();
+ return result;
+ }
+
+ private SourceComponent[] sourceLevelComponents;
+ private SourceComponent[] classLevelComponents;
+
+ public SourceComponent[] getClassLevelComponents()
+ {
+ return this.classLevelComponents;
+ }
+
+ public Parser() {
+ try {
+
+ sourceLevelComponents=new SourceComponent[] {
+ new Whitespace(),
+ new CommentComponent(),
+ new SlashSlashCommentComponent(),
+ new PackageComponent(),
+ new EmptyStatementComponent(),
+ new ImportComponent(),
+ new ClassComponent(),
+ };
+
+ classLevelComponents=new SourceComponent[] {
+ new Whitespace(),
+ new BracketClose(),
+ new CommentComponent(),
+ new SlashSlashCommentComponent(),
+ new FunctionComponent(),
+ new StaticBlockComponent(),
+ new ImportComponent(),
+ new ClassComponent(),
+ new FieldComponent(),
+ };
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public int getNumberOfProcessedFiles() {
+ return processedFiles.size();
+ }
+
+ static Set processedFiles = new HashSet();
+
+ ClassDocImpl processSourceFile(File file, boolean addComments,
+ String encoding, String expectedPackageName)
+ throws IOException, ParseException
+ {
+ //System.err.println("Processing " + file + "...");
+ this.currentFile = file;
+ this.currentPackage = null;
+ this.currentPackageName = null;
+ this.expectedPackageName = expectedPackageName;
+ this.outerClass = null;
+ this.boilerplateComment = null;
+
+ this.addComments=addComments;
+
+ if (processedFiles.contains(file)) {
+ return null;
+ }
+
+ processedFiles.add(file);
+
+ Debug.log(1,"Processing file "+file);
+
+ contextStack.clear();
+ ctx=null;
+
+ importedClassesList.clear();
+ importedStringList.clear();
+ importedPackagesList.clear();
+ importedStatementList.clear();
+
+ currentLine = 1;
+
+ char[] source = loadFile(file, encoding);
+
+ try {
+ parse(source, 0, sourceLevelComponents);
+
+ ClassDoc[] importedClasses=(ClassDoc[])importedClassesList.toArray(new ClassDoc[0]);
+ PackageDoc[] importedPackages=(PackageDoc[])importedPackagesList.toArray(new PackageDoc[0]);
+
+ if (Main.DESCEND_IMPORTED) {
+ for (int i=0; i<importedClasses.length; ++i) {
+ Main.getRootDoc().scheduleClass(currentClass, importedClasses[i].qualifiedName());
+ }
+ }
+
+
+ if (contextStack.size()>0) {
+ Debug.log(1,"-->contextStack not empty! size is "+contextStack.size());
+ }
+
+ return outerClass;
+ }
+ catch (IgnoredFileParseException ignore) {
+ Debug.log(1, "File ignored: " + ignore);
+ return null;
+ }
+ }
+
+ int parse(char[] source, int index, SourceComponent[] componentTypes) throws ParseException, IOException {
+
+ while (index<source.length) {
+
+ int match=-1;
+ int i=0;
+ for (; i<componentTypes.length; ++i) {
+ if ((match=componentTypes[i].match(source, index))>=0) {
+ //Debug.log(1,componentTypes[i].getClass().getName()+" ("+match+"/"+source.length+")");
+ break;
+ }
+ }
+
+ if (i<componentTypes.length) {
+ int endIndex=componentTypes[i].getEndIndex(source, match);
+ Debug.log(9, "Processing " + new String(source,index,endIndex-index) + " with " + componentTypes[i]);
+ index=componentTypes[i].process(this, source, index, endIndex);
+ if (index<0) {
+ //Debug.log(9,"exiting parse because of "+componentTypes[i].getClass().getName()+" (\""+new String(source, index, endIndex-index)+"\")");
+ return endIndex;
+ }
+ }
+ else {
+ //Debug.log(9,"index="+index+", source.length()="+source.length);
+ throw new ParseException("unmatched input in line "+currentLine+": "+new String(source, index, Math.min(50,source.length-index)));
+ }
+
+ }
+ //Debug.log(9,"exiting parse normally, index="+index+" source.length="+source.length);
+ return index;
+ }
+
+ private static int countNewLines(String source) {
+ int i=0;
+ int rc=0;
+ while ((i=source.indexOf('\n',i)+1)>0)
+ ++rc;
+ return rc;
+ }
+
+ public void processSourceDir(File dir, String encoding, String expectedPackageName)
+ throws IOException, ParseException
+ {
+ Debug.log(9,"Processing "+dir.getParentFile().getName()+"."+dir.getName());
+ File[] files=dir.listFiles();
+ if (null!=files) {
+ for (int i=0; i<files.length; ++i) {
+ if (files[i].getName().toLowerCase().endsWith(".java")) {
+ processSourceFile(files[i], true, encoding, expectedPackageName);
+ }
+ }
+ }
+ }
+
+ void classOpened(char[] source, int startIndex, int endIndex) throws ParseException, IOException {
+
+ referencedClassesList.clear();
+
+ if (null == currentPackage) {
+
+ if (expectedPackageName != null) {
+ if (null == currentPackageName ||
+ !currentPackageName.equals(expectedPackageName)) {
+
+ Main.getRootDoc().printWarning("Ignoring file " + currentFile + ": (wrong package, " + currentPackageName + "!=" + expectedPackageName + ")");
+ throw new IgnoredFileParseException();
+ }
+ }
+
+ if (null != currentPackageName) {
+ currentPackage = Main.getRootDoc().findOrCreatePackageDoc(currentPackageName);
+ }
+ else {
+ currentPackage = Main.getRootDoc().findOrCreatePackageDoc("");
+ }
+ }
+
+ if (currentPackageName != null)
+ importedStatementList.add(currentPackageName + ".*");
+ importedStatementList.add("java.lang.*");
+
+ ClassDocImpl classDoc
+ = ClassDocImpl.createInstance((ctx!=null)?(ctx.classDoc):null, currentPackage,
+ null,
+ (PackageDoc[])importedPackagesList.toArray(new PackageDoc[0]),
+ source, startIndex, endIndex,
+ importedStatementList);
+
+ if (ctx != null) {
+ ctx.innerClassesList.add(classDoc);
+ if (classDoc.isIncluded()) {
+ ctx.filteredInnerClassesList.add(classDoc);
+ }
+ }
+
+ if (importedClassesList.isEmpty()) {
+ for (Iterator it=importedStringList.iterator(); it.hasNext(); ) {
+ importedClassesList.add(new ClassDocProxy((String)it.next(), classDoc));
+ }
+ }
+ classDoc.setImportedClasses((ClassDoc[])importedClassesList.toArray(new ClassDoc[0]));
+
+ currentPackage.addClass(classDoc);
+
+ currentClass = classDoc;
+
+ if (null == outerClass) {
+ outerClass = classDoc;
+ }
+
+ if (classDoc.superclass()!=null)
+ referencedClassesList.add(classDoc.superclass());
+
+ Debug.log(1,"classOpened "+classDoc+", adding superclass "+classDoc.superclass());
+ Debug.log(1,"Pushing " + ctx);
+ contextStack.push(ctx);
+ ctx=new Context(classDoc);
+ //Debug.log(9,"ctx="+ctx);
+ }
+
+ private Doc[] toArray(List list, Doc[] template)
+ {
+ Doc[] result = (Doc[])list.toArray(template);
+ return result;
+ }
+
+ void classClosed() throws ParseException, IOException {
+ ctx.classDoc.setFields((FieldDoc[])toArray(ctx.fieldList,
+ new FieldDoc[0]));
+ ctx.classDoc.setFilteredFields((FieldDoc[])toArray(ctx.filteredFieldList,
+ new FieldDoc[0]));
+ ctx.classDoc.setSerializableFields((FieldDoc[])toArray(ctx.sfieldList, new FieldDoc[0]));
+ ctx.classDoc.setMethods((MethodDoc[])toArray(ctx.methodList, new MethodDoc[0]));
+ ctx.classDoc.setFilteredMethods((MethodDoc[])toArray(ctx.filteredMethodList, new MethodDoc[0]));
+ ctx.classDoc.setMaybeSerMethodList(ctx.maybeSerMethodList);
+ ctx.classDoc.setConstructors((ConstructorDoc[])toArray(ctx.constructorList, new ConstructorDoc[0]));
+ ctx.classDoc.setFilteredConstructors((ConstructorDoc[])toArray(ctx.filteredConstructorList, new ConstructorDoc[0]));
+
+ ctx.classDoc.setInnerClasses((ClassDocImpl[])toArray(ctx.innerClassesList, new ClassDocImpl[0]));
+ ctx.classDoc.setFilteredInnerClasses((ClassDocImpl[])toArray(ctx.filteredInnerClassesList, new ClassDocImpl[0]));
+ ctx.classDoc.setBoilerplateComment(boilerplateComment);
+
+ Main.getRootDoc().addClassDoc(ctx.classDoc);
+
+ if (Main.DESCEND_INTERFACES) {
+ for (int i=0; i<ctx.classDoc.interfaces().length; ++i) {
+ Main.getRootDoc().scheduleClass(ctx.classDoc, ctx.classDoc.interfaces()[i].qualifiedName());
+ }
+ }
+
+ Debug.log(1,"classClosed: "+ctx.classDoc);
+
+ ctx=(Context)contextStack.pop();
+ Debug.log(1, "Popping " + ctx);
+ ClassDoc[] referencedClasses=(ClassDoc[])referencedClassesList.toArray(new ClassDoc[0]);
+
+ if (Main.DESCEND_SUPERCLASS) {
+ for (int i=0; i<referencedClasses.length; ++i) {
+ Main.getRootDoc().scheduleClass(currentClass, referencedClasses[i].qualifiedName());
+ }
+ }
+ }
+
+ Context ctx = null;
+ Stack contextStack = new Stack();
+ class Context {
+ Context(ClassDocImpl classDoc) { this.classDoc=classDoc; }
+ ClassDocImpl classDoc = null;
+ List fieldList = new LinkedList();
+ List filteredFieldList = new LinkedList();
+ List sfieldList = new LinkedList();
+ List methodList = new LinkedList();
+ List filteredMethodList = new LinkedList();
+ List maybeSerMethodList = new LinkedList();
+ List constructorList = new LinkedList();
+ List filteredConstructorList = new LinkedList();
+ List innerClassesList = new LinkedList();
+ List filteredInnerClassesList = new LinkedList();
+ }
+
+ File currentFile = null;
+ String lastComment = null;
+ String expectedPackageName = null;
+ String currentPackageName = null;
+ PackageDocImpl currentPackage = null;
+ ClassDocImpl currentClass = null;
+ ClassDocImpl outerClass = null;
+ List ordinaryClassesList = new LinkedList();
+ List allClassesList = new LinkedList();
+ List interfacesList = new LinkedList();
+
+ List importedClassesList = new LinkedList();
+ List importedStringList = new LinkedList();
+ List importedPackagesList = new LinkedList();
+ List importedStatementList = new LinkedList();
+
+ List referencedClassesList = new LinkedList();
+
+ String boilerplateComment = null;
+
+ void packageOpened(String packageName) {
+ currentPackageName = packageName;
+ }
+
+ void importEncountered(String importString) throws ParseException, IOException {
+ //Debug.log(9,"importing '"+importString+"'");
+
+ importedStatementList.add(importString);
+
+ if (importString.endsWith(".*")) {
+ importedPackagesList.add(Main.getRootDoc().findOrCreatePackageDoc(importString.substring(0,importString.length()-2)));
+ }
+ else {
+ importedStringList.add(importString);
+ }
+ }
+
+
+ void setLastComment(String lastComment) {
+ this.lastComment=lastComment;
+ }
+
+ String getLastComment() {
+ return this.lastComment;
+ }
+
+ void setBoilerplateComment(String boilerplateComment)
+ {
+ this.boilerplateComment = boilerplateComment;
+ }
+
+ String getBoilerplateComment()
+ {
+ return boilerplateComment;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.java
new file mode 100644
index 000000000..bdcf61bf6
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.java
@@ -0,0 +1,177 @@
+/* gnu.classpath.tools.gjdoc.ProgramElementDocImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.lang.reflect.Modifier;
+
+public abstract class ProgramElementDocImpl extends DocImpl implements ProgramElementDoc {
+
+ protected ClassDoc containingClass;
+ protected PackageDoc containingPackage;
+
+ protected boolean isFinal;
+ protected boolean isStatic;
+ protected int accessLevel=ProgramElementDocImpl.ACCESS_PACKAGEPRIVATE;
+
+ public static final int ACCESS_PUBLIC = 0;
+ public static final int ACCESS_PROTECTED = 1;
+ public static final int ACCESS_PACKAGEPRIVATE = 2;
+ public static final int ACCESS_PRIVATE = 3;
+
+ private static final String[] accessModifiers = { "public ", "protected ", "", "private "};
+
+ public ProgramElementDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ SourcePosition position) {
+ super(position);
+ this.containingClass=containingClass;
+ this.containingPackage=containingPackage;
+ }
+ public ProgramElementDocImpl(ClassDoc containingClass, SourcePosition position) {
+ super(position);
+ this.containingClass=containingClass;
+ this.containingPackage=containingClass.containingPackage();
+ }
+ public ProgramElementDocImpl(ClassDoc containingClass,
+ PackageDoc containingPackage,
+ int accessLevel,
+ boolean isFinal,
+ boolean isStatic,
+ SourcePosition position) {
+ super(position);
+ this.containingClass=containingClass;
+ this.containingPackage=containingPackage;
+ this.accessLevel=accessLevel;
+ this.isFinal=isFinal;
+ this.isStatic=isStatic;
+ }
+
+ //Get the containing class of this program element.
+ public ClassDoc containingClass() {
+ return containingClass;
+ }
+
+ // Get the package that this program element is contained in.
+ public PackageDoc containingPackage() {
+ return containingPackage;
+ }
+
+ // Return true if this program element is final
+ public boolean isFinal() {
+ return isFinal;
+ }
+
+ // Return true if this program element is package private
+ public boolean isPackagePrivate() {
+ return accessLevel==ACCESS_PACKAGEPRIVATE;
+ }
+
+ // Return true if this program element is private
+ public boolean isPrivate() {
+ return accessLevel==ACCESS_PRIVATE;
+ }
+
+ // Return true if this program element is protected
+ public boolean isProtected() {
+ return accessLevel==ACCESS_PROTECTED;
+ }
+
+ // Return true if this program element is public
+ public boolean isPublic() {
+ return accessLevel==ACCESS_PUBLIC;
+ }
+
+ // Return true if this program element is static
+ public boolean isStatic() {
+ return isStatic;
+ }
+
+ // Get modifiers string.
+ public String modifiers() {
+ return
+ (accessModifiers[accessLevel]+
+ (isStatic()?"static ":"")+
+ (isFinal()?"final ":"")).trim();
+ }
+
+ // Get the modifier specifier integer.
+ public int modifierSpecifier() {
+ return (isStatic()?Modifier.STATIC:0)
+ | (isFinal()?Modifier.FINAL:0)
+ | (isPublic()?Modifier.PUBLIC:0)
+ | (isProtected()?Modifier.PROTECTED:0)
+ | (isPrivate()?Modifier.PRIVATE:0)
+// | (isAbstract()?Modifier.ABSTRACT:0)
+ ;
+ }
+
+ // Get the fully qualified name.
+ public abstract String qualifiedName();
+
+ protected boolean processModifier(String word) {
+ if (word.equals("public")) {
+ accessLevel=ACCESS_PUBLIC;
+ return true;
+ }
+ else if (word.equals("protected")) {
+ accessLevel=ACCESS_PROTECTED;
+ return true;
+ }
+ else if (word.equals("private")) {
+ accessLevel=ACCESS_PRIVATE;
+ return true;
+ }
+ else if (word.equals("static")) {
+ isStatic=true;
+ return true;
+ }
+ else if (word.equals("final")) {
+ isFinal=true;
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ void setIsStatic(boolean b) {
+ this.isStatic=b;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/RootDocImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/RootDocImpl.java
new file mode 100644
index 000000000..09d1be73b
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/RootDocImpl.java
@@ -0,0 +1,1334 @@
+/* gnu.classpath.tools.gjdoc.RootDocImpl
+ Copyright (C) 2001, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.io.*;
+import java.lang.reflect.*;
+
+public class RootDocImpl
+ extends DocImpl
+ implements GjdocRootDoc {
+
+ private ErrorReporter reporter = new ErrorReporter();
+
+ private RandomAccessFile rawCommentCache;
+
+ /**
+ * All options and their corresponding values which are not recognized
+ * by Gjdoc. These are passed to the Doclet as "custom options".
+ * Each element in this array is again a String array, with the
+ * option name as first element (including prefix dash) and possible
+ * option values as following elements.
+ */
+ private String[][] customOptionArr;
+
+ /**
+ * All source files explicitly specified on the command line.
+ *
+ * @contains File
+ */
+ private List specifiedSourceFiles = new LinkedList();
+
+ /**
+ * The names of all packages explicitly specified on the
+ * command line.
+ *
+ * @contains String
+ */
+ private Set specifiedPackageNames = new LinkedHashSet();
+
+ /**
+ * Stores all classes specified by the user: those given by
+ * individual class names on the command line, and those
+ * contained in the packages given on the command line.
+ *
+ * @contains ClassDocImpl
+ */
+ private List classesList = new LinkedList(); //new LinkedList();
+
+ /**
+ * Stores all classes loaded in the course of preparing
+ * the documentation data. Maps the fully qualified name
+ * of a class to its ClassDocImpl representation.
+ *
+ * @contains String->ClassDocImpl
+ */
+ private Map classDocMap = new HashMap();
+
+ /**
+ * Stores all packages loaded in the course of preparing
+ * the documentation data. Maps the package name
+ * to its PackageDocImpl representation.
+ *
+ * @contains String->PackageDocImpl
+ */
+ private Map packageDocMap = new HashMap();
+
+ /**
+ * All classes specified by the user, both those explicitly
+ * individually specified on the command line and those contained
+ * in packages specified on the command line (as Array for quick
+ * retrieval by Doclet). This is created from classesList after
+ * all classes have been loaded.
+ */
+ private ClassDocImpl[] classes;
+
+ /**
+ * All classes which were individually specified on the command
+ * line (as Array for quick retrieval by Doclet). This is created
+ * from specifiedClassNames after all classes have been loaded.
+ */
+ private List specifiedClasses;
+
+ /**
+ * All packages which were specified on the command line (as Array
+ * for quick retrieval by Doclet). This is created from
+ * specifiedPackageNames after all classes have been loaded.
+ */
+ private Set specifiedPackages;
+
+
+ /**
+ * Temporarily stores a list of classes which are referenced
+ * by classes already loaded and which still have to be
+ * resolved.
+ */
+ private List scheduledClasses=new LinkedList();
+
+ private List sourcePath;
+
+ private String sourceEncoding;
+
+ private Parser parser = new Parser();
+
+ private Set unlocatableReportedSet = new HashSet();
+
+ private Set inaccessibleReportedSet = new HashSet();
+
+ //--------------------------------------------------------------------------
+ //
+ // Implementation of RootDoc interface
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Return classes and interfaces to be documented.
+ */
+ public ClassDoc[] classes() { return classes; }
+
+ /**
+ * Return a ClassDoc object for the specified class/interface
+ * name.
+ *
+ * @return a ClassDoc object describing the given class, or
+ * <code>null</code> if no corresponding ClassDoc object
+ * has been constructed.
+ */
+ public ClassDoc classNamed(String qualifiedName) {
+ return (ClassDoc)classDocMap.get(qualifiedName);
+ }
+
+ /**
+ * Return an xxx
+ */
+ public String[][] options() { return customOptionArr; }
+
+ // Return a PackageDoc for the specified package name
+ public PackageDoc packageNamed(String name) {
+ return (PackageDoc)packageDocMap.get(name);
+ }
+
+
+ // classes and interfaces specified on the command line.
+ public ClassDoc[] specifiedClasses()
+ {
+ return (ClassDocImpl[]) specifiedClasses.toArray(new ClassDocImpl[0]);
+ }
+
+ // packages specified on the command line.
+ public PackageDoc[] specifiedPackages()
+ {
+ return (PackageDocImpl[])specifiedPackages.toArray(new PackageDocImpl[0]);
+ }
+
+ // Print error message, increment error count.
+ public void printError(java.lang.String msg) {
+ reporter.printError(msg);
+ }
+
+ // Print error message, increment error count.
+ public void printFatal(java.lang.String msg) {
+ reporter.printFatal(msg);
+ }
+
+ // Print a message.
+ public void printNotice(java.lang.String msg) {
+ reporter.printNotice(msg);
+ }
+
+ // Print warning message, increment warning count.
+ public void printWarning(java.lang.String msg) {
+ reporter.printWarning(msg);
+ }
+
+ public String name() {
+ return "RootDoc";
+ }
+
+ public ErrorReporter getReporter() {
+ return reporter;
+ }
+
+ public void build() throws ParseException, IOException {
+
+ //--- Create a temporary random access file for caching comment text.
+
+ //File rawCommentCacheFile=File.createTempFile("gjdoc_rawcomment",".cache");
+ File rawCommentCacheFile = new File("gjdoc_rawcomment.cache");
+ rawCommentCacheFile.deleteOnExit();
+ rawCommentCache = new RandomAccessFile(rawCommentCacheFile, "rw");
+
+ //--- Parse all files in "java.lang".
+
+ List javaLangSourceDirs = findSourceFiles("java/lang");
+ if (!javaLangSourceDirs.isEmpty()) {
+ Iterator it = javaLangSourceDirs.iterator();
+ while (it.hasNext()) {
+ File javaLangSourceDir = (File)it.next();
+ parser.processSourceDir(javaLangSourceDir,
+ sourceEncoding, "java.lang");
+ }
+ }
+ else {
+
+ Debug.log(1, "Sourcepath is "+sourcePath);
+
+ // Core docs not included in source-path:
+ // we need to gather the information about java.lang
+ // classes via reflection...
+
+ }
+
+ //--- Parse all files in explicitly specified package directories.
+
+ for (Iterator it=specifiedPackageNames.iterator(); it.hasNext(); ) {
+
+ String specifiedPackageName = (String)it.next();
+ String displayPackageName = specifiedPackageName;
+ if (null == displayPackageName || 0 == displayPackageName.length()) {
+ displayPackageName = "<unnamed>";
+ }
+ printNotice("Loading classes for package "+displayPackageName+"...");
+ String relPath;
+ if (null != specifiedPackageName) {
+ relPath = specifiedPackageName.replace('.',File.separatorChar);
+ }
+ else {
+ relPath = "";
+ }
+ List sourceDirs = findSourceFiles(relPath);
+ if (!sourceDirs.isEmpty()) {
+ Iterator sourceDirIt = sourceDirs.iterator();
+ while (sourceDirIt.hasNext()) {
+ File sourceDir = (File)sourceDirIt.next();
+ parser.processSourceDir(sourceDir, sourceEncoding, specifiedPackageName);
+ }
+ }
+ else {
+ printError("Package '"+specifiedPackageName+"' not found.");
+ }
+ }
+
+ specifiedClasses = new LinkedList();
+
+ //--- Parse all explicitly specified source files.
+
+ for (Iterator it=specifiedSourceFiles.iterator(); it.hasNext(); ) {
+
+ File specifiedSourceFile = (File)it.next();
+ printNotice("Loading source file "+specifiedSourceFile+" ...");
+ ClassDocImpl classDoc = parser.processSourceFile(specifiedSourceFile, true, sourceEncoding, null);
+ if (null != classDoc) {
+ specifiedClasses.add(classDoc);
+ classesList.add(classDoc);
+ classDoc.setIsIncluded(true);
+ addPackageDoc(classDoc.containingPackage());
+ }
+ }
+
+
+ //--- Let the user know that all specified classes are loaded.
+
+ printNotice("Constructing Javadoc information...");
+
+ //--- Load all classes implicitly referenced by explicitly specified classes.
+
+ loadScheduledClasses(parser);
+
+ printNotice("Resolving references in comments...");
+
+ resolveComments();
+
+ //--- Resolve pending references in all ClassDocImpls
+
+ printNotice("Resolving references in classes...");
+
+ for (Iterator it = classDocMap.values().iterator(); it.hasNext(); ) {
+ ClassDoc cd=(ClassDoc)it.next();
+ if (cd instanceof ClassDocImpl) {
+ ((ClassDocImpl)cd).resolve();
+ }
+ }
+
+ //--- Resolve pending references in all PackageDocImpls
+
+ printNotice("Resolving references in packages...");
+
+ for (Iterator it = packageDocMap.values().iterator(); it.hasNext(); ) {
+ PackageDocImpl pd=(PackageDocImpl)it.next();
+ pd.resolve();
+ }
+
+ //--- Assemble the array with all specified packages
+
+ specifiedPackages = new LinkedHashSet();
+ for (Iterator it = specifiedPackageNames.iterator(); it.hasNext(); ) {
+ String specifiedPackageName = (String)it.next();
+ PackageDoc specifiedPackageDoc = (PackageDoc)packageDocMap.get(specifiedPackageName);
+ if (null!=specifiedPackageDoc) {
+ ((PackageDocImpl)specifiedPackageDoc).setIsIncluded(true);
+ specifiedPackages.add(specifiedPackageDoc);
+
+ ClassDoc[] packageClassDocs=specifiedPackageDoc.allClasses();
+ for (int i=0; i<packageClassDocs.length; ++i) {
+ ClassDocImpl specifiedPackageClassDoc=(ClassDocImpl)packageClassDocs[i];
+
+ specifiedPackageClassDoc.setIsIncluded(true);
+ classesList.add(specifiedPackageClassDoc);
+ }
+ }
+ }
+
+ //--- Resolve pending references in comment data of all classes
+
+ printNotice("Resolving references in class comments...");
+
+ for (Iterator it=classDocMap.values().iterator(); it.hasNext(); ) {
+ ClassDoc cd=(ClassDoc)it.next();
+ if (cd instanceof ClassDocImpl) {
+ ((ClassDocImpl)cd).resolveComments();
+ }
+ }
+
+ //--- Resolve pending references in comment data of all packages
+
+ printNotice("Resolving references in package comments...");
+
+ for (Iterator it=packageDocMap.values().iterator(); it.hasNext(); ) {
+ PackageDocImpl pd=(PackageDocImpl)it.next();
+ pd.resolveComments();
+ }
+
+ //--- Create array with all loaded classes
+
+ this.classes=(ClassDocImpl[])classesList.toArray(new ClassDocImpl[0]);
+ Arrays.sort(this.classes);
+
+ //--- Close comment cache
+
+ parser = null;
+ System.gc();
+ System.gc();
+ }
+
+ public long writeRawComment(String rawComment) {
+ try {
+ long pos=rawCommentCache.getFilePointer();
+ //rawCommentCache.writeUTF(rawComment);
+ byte[] bytes = rawComment.getBytes("utf-8");
+ rawCommentCache.writeInt(bytes.length);
+ rawCommentCache.write(bytes);
+ return pos;
+ }
+ catch (IOException e) {
+ printFatal("Cannot write to comment cache: "+e.getMessage());
+ return -1;
+ }
+ }
+
+ public String readRawComment(long pos) {
+ try {
+ rawCommentCache.seek(pos);
+ int sz = rawCommentCache.readInt();
+ byte[] bytes = new byte[sz];
+ rawCommentCache.read(bytes);
+ return new String(bytes, "utf-8");
+ //return rawCommentCache.readUTF();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ printFatal("Cannot read from comment cache: "+e.getMessage());
+ return null;
+ }
+ }
+
+ List findSourceFiles(String relPath) {
+
+ List result = new LinkedList();
+ for (Iterator it = sourcePath.iterator(); it.hasNext(); ) {
+ File path = (File)it.next();
+ File file = new File(path, relPath);
+ if (file.exists()) {
+ result.add(file);
+ }
+ }
+
+ return result;
+ }
+
+ PackageDocImpl findOrCreatePackageDoc(String packageName) {
+ PackageDocImpl rc=(PackageDocImpl)getPackageDoc(packageName);
+ if (null==rc) {
+ rc=new PackageDocImpl(packageName);
+ if (specifiedPackageNames.contains(packageName)) {
+ String packageDirectoryName = packageName.replace('.', File.separatorChar);
+ List packageDirectories = findSourceFiles(packageDirectoryName);
+ Iterator it = packageDirectories.iterator();
+ boolean packageDocFound = false;
+ while (it.hasNext()) {
+ File packageDirectory = (File)it.next();
+ File packageDocFile = new File(packageDirectory, "package.html");
+ rc.setPackageDirectory(packageDirectory);
+ packageDocFound = true;
+ if (null!=packageDocFile && packageDocFile.exists()) {
+ try {
+ rc.setRawCommentText(readHtmlBody(packageDocFile));
+ }
+ catch (IOException e) {
+ printWarning("Error while reading documentation for package "+packageName+": "+e.getMessage());
+ }
+ break;
+ }
+ }
+ if (!packageDocFound) {
+ printNotice("No description found for package "+packageName);
+ }
+ }
+ addPackageDoc(rc);
+ }
+ return rc;
+ }
+
+ public void addClassDoc(ClassDoc cd) {
+ classDocMap.put(cd.qualifiedName(), cd);
+ }
+
+ public void addClassDocRecursive(ClassDoc cd) {
+ classDocMap.put(cd.qualifiedName(), cd);
+ ClassDoc[] innerClasses = cd.innerClasses(false);
+ for (int i=0; i<innerClasses.length; ++i) {
+ addClassDocRecursive(innerClasses[i]);
+ }
+ }
+
+ public void addPackageDoc(PackageDoc pd) {
+ packageDocMap.put(pd.name(), pd);
+ }
+
+ public PackageDocImpl getPackageDoc(String name) {
+ return (PackageDocImpl)packageDocMap.get(name);
+ }
+
+ public ClassDocImpl getClassDoc(String qualifiedName) {
+ return (ClassDocImpl)classDocMap.get(qualifiedName);
+ }
+
+ class ScheduledClass {
+
+ ClassDoc contextClass;
+ String qualifiedName;
+ ScheduledClass(ClassDoc contextClass, String qualifiedName) {
+ this.contextClass=contextClass;
+ this.qualifiedName=qualifiedName;
+ }
+
+ public String toString() { return "ScheduledClass{"+qualifiedName+"}"; }
+ }
+
+ public void scheduleClass(ClassDoc context, String qualifiedName) throws ParseException, IOException {
+
+ if (classDocMap.get(qualifiedName)==null) {
+
+ //Debug.log(9,"Scheduling "+qualifiedName+", context "+context+".");
+ //System.err.println("Scheduling " + qualifiedName + ", context " + context);
+
+ scheduledClasses.add(new ScheduledClass(context, qualifiedName));
+ }
+ }
+
+ /**
+ * Load all classes that were implictly referenced by the classes
+ * (already loaded) that the user explicitly specified on the
+ * command line.
+ *
+ * For example, if the user generates Documentation for his simple
+ * 'class Test {}', which of course 'extends java.lang.Object',
+ * then 'java.lang.Object' is implicitly referenced because it is
+ * the base class of Test.
+ *
+ * Gjdoc needs a ClassDocImpl representation of all classes
+ * implicitly referenced through derivation (base class),
+ * or implementation (interface), or field type, method argument
+ * type, or method return type.
+ *
+ * The task of this method is to ensure that Gjdoc has all this
+ * information at hand when it exits.
+ *
+ *
+ */
+ public void loadScheduledClasses(Parser parser) throws ParseException, IOException {
+
+ // Because the referenced classes could in turn reference other
+ // classes, this method runs as long as there are still unloaded
+ // classes.
+
+ while (!scheduledClasses.isEmpty()) {
+
+ // Make a copy of scheduledClasses and empty it. This
+ // prevents any Concurrent Modification issues.
+ // As the copy won't need to grow (as it won't change)
+ // we make it an Array for performance reasons.
+
+ ScheduledClass[] scheduledClassesArr = (ScheduledClass[])scheduledClasses.toArray(new ScheduledClass[0]);
+ scheduledClasses.clear();
+
+ // Load each class specified in our array copy
+
+ for (int i=0; i<scheduledClassesArr.length; ++i) {
+
+ // The name of the class we are looking for. This name
+ // needs not be fully qualified.
+
+ String scheduledClassName=scheduledClassesArr[i].qualifiedName;
+
+ // The ClassDoc in whose context the scheduled class was looked for.
+ // This is necessary in order to resolve non-fully qualified
+ // class names.
+ ClassDoc scheduledClassContext=scheduledClassesArr[i].contextClass;
+
+ // If there already is a class doc with this name, skip. There's
+ // nothing to do for us.
+ if (classDocMap.get(scheduledClassName)!=null) {
+ continue;
+ }
+
+ try {
+ // Try to load the class
+ //printNotice("Trying to load " + scheduledClassName);
+ loadScheduledClass(parser, scheduledClassName, scheduledClassContext);
+ }
+ catch (ParseException e) {
+
+ /**********************************************************
+
+ // Check whether the following is necessary at all.
+
+
+ if (scheduledClassName.indexOf('.')>0) {
+
+ // Maybe the dotted notation doesn't mean a package
+ // name but instead an inner class, as in 'Outer.Inner'.
+ // so let's assume this and try to load the outer class.
+
+ String outerClass="";
+ for (StringTokenizer st=new StringTokenizer(scheduledClassName,"."); st.hasMoreTokens(); ) {
+ if (outerClass.length()>0) outerClass+=".";
+ outerClass+=st.nextToken();
+ if (!st.hasMoreTokens()) break;
+ try {
+ loadClass(outerClass);
+ //FIXME: shouldn't this be loadScheduledClass(outerClass, scheduledClassContext); ???
+ continue;
+ }
+ catch (Exception ee) {
+ // Ignore: try next level
+ }
+ }
+ }
+
+ **********************************************************/
+
+ // If we arrive here, the class could not be found
+
+ printWarning("Couldn't load class "+scheduledClassName+" referenced by "+scheduledClassContext);
+
+ //FIXME: shouldn't this be throw new Error("cannot load: "+scheduledClassName);
+ }
+ }
+ }
+ }
+
+ private void loadScheduledClass(Parser parser, String scheduledClassName, ClassDoc scheduledClassContext) throws ParseException, IOException {
+
+ ClassDoc loadedClass=(ClassDoc)scheduledClassContext.findClass(scheduledClassName);
+
+ if (loadedClass==null || loadedClass instanceof ClassDocProxy) {
+
+ ClassDoc classDoc = findScheduledClassFile(scheduledClassName, scheduledClassContext);
+ if (null != classDoc) {
+
+ if (classDoc instanceof ClassDocReflectedImpl) {
+ Main.getRootDoc().addClassDocRecursive(classDoc);
+ }
+
+ if (Main.DESCEND_SUPERCLASS
+ && null != classDoc.superclass()
+ && (classDoc.superclass() instanceof ClassDocProxy)) {
+ scheduleClass(classDoc, classDoc.superclass().qualifiedName());
+ }
+ }
+ else {
+ // It might be an inner class of one of the outer/super classes.
+ // But we can only check that when they are all fully loaded.
+ boolean retryLater = false;
+
+ int numberOfProcessedFilesBefore = parser.getNumberOfProcessedFiles();
+
+ ClassDoc cc = scheduledClassContext.containingClass();
+ while (cc != null && !retryLater) {
+ ClassDoc sc = cc.superclass();
+ while (sc != null && !retryLater) {
+ if (sc instanceof ClassDocProxy) {
+ ((ClassDocImpl)cc).resolve();
+ retryLater = true;
+ }
+ sc = sc.superclass();
+ }
+ cc = cc.containingClass();
+ }
+
+ // Now that outer/super references have been resolved, try again
+ // to find the class.
+
+ loadedClass = (ClassDoc)scheduledClassContext.findClass(scheduledClassName);
+
+ int numberOfProcessedFilesAfter = parser.getNumberOfProcessedFiles();
+
+ boolean filesWereProcessed = numberOfProcessedFilesAfter > numberOfProcessedFilesBefore;
+
+ // Only re-schedule class if additional files have been processed
+ // If there haven't, there's no point in re-scheduling.
+ // Will avoid infinite loops of re-scheduling
+ if (null == loadedClass && retryLater && filesWereProcessed)
+ scheduleClass(scheduledClassContext, scheduledClassName);
+
+ /* A warning needn't be emitted - this is normal, can happen
+ if the scheduled class is in a package which is not
+ included on the command line.
+
+ else if (null == loadedClass)
+ printWarning("Can't find scheduled class '"
+ + scheduledClassName
+ + "' in context '"
+ + scheduledClassContext.qualifiedName()
+ + "'");
+ */
+ }
+ }
+ }
+
+ private static interface ResolvedImport
+ {
+ public String match(String name);
+ public boolean mismatch(String name);
+ public ClassDoc tryFetch(String name);
+ }
+
+ private class ResolvedImportNotFound
+ implements ResolvedImport
+ {
+ private String importSpecifier;
+ private String name;
+
+ ResolvedImportNotFound(String importSpecifier)
+ {
+ this.importSpecifier = importSpecifier;
+ int ndx = importSpecifier.lastIndexOf('.');
+ if (ndx >= 0) {
+ this.name = importSpecifier.substring(ndx + 1);
+ }
+ else {
+ this.name = importSpecifier;
+ }
+ }
+
+ public String toString()
+ {
+ return "ResolvedImportNotFound{" + importSpecifier + "}";
+ }
+
+ public String match(String name)
+ {
+ if ((name.equals(this.name)) || (importSpecifier.equals(name)))
+ return this.name;
+ // FIXME: note that we don't handle on-demand imports here.
+ return null;
+ }
+
+ public boolean mismatch(String name)
+ {
+ return true; // FIXME!
+ }
+
+ public ClassDoc tryFetch(String name)
+ {
+ return null;
+ }
+ }
+
+ private class ResolvedImportPackageFile
+ implements ResolvedImport
+ {
+ private Set topLevelClassNames;
+ private File packageFile;
+ private String packageName;
+ private Map cache = new HashMap();
+
+ ResolvedImportPackageFile(File packageFile, String packageName)
+ {
+ this.packageFile = packageFile;
+ this.packageName = packageName;
+ topLevelClassNames = new HashSet();
+ File[] files = packageFile.listFiles();
+ for (int i=0; i<files.length; ++i) {
+ if (!files[i].isDirectory() && files[i].getName().endsWith(".java")) {
+ String topLevelClassName = files[i].getName();
+ topLevelClassName
+ = topLevelClassName.substring(0, topLevelClassName.length() - 5);
+ topLevelClassNames.add(topLevelClassName);
+ }
+ }
+ }
+
+ public String match(String name)
+ {
+ ClassDoc loadedClass = classNamed(packageName + "." + name);
+ if (null != loadedClass) {
+ return loadedClass.qualifiedName();
+ }
+ else {
+ String topLevelName = name;
+ int ndx = topLevelName.indexOf('.');
+ String innerClassName = null;
+ if (ndx > 0) {
+ innerClassName = topLevelName.substring(ndx + 1);
+ topLevelName = topLevelName.substring(0, ndx);
+ }
+
+ if (topLevelClassNames.contains(topLevelName)) {
+ //System.err.println(this + ".match returns " + packageName + "." + name);
+ return packageName + "." + name;
+ }
+ // FIXME: inner classes
+ else {
+ return null;
+ }
+ }
+ }
+
+ public boolean mismatch(String name)
+ {
+ return null == match(name);
+ }
+
+ public ClassDoc tryFetch(String name)
+ {
+ ClassDoc loadedClass = classNamed(packageName + "." + name);
+ if (null != loadedClass) {
+ return loadedClass;
+ }
+ else if (null != match(name)) {
+
+ String topLevelName = name;
+ int ndx = topLevelName.indexOf('.');
+ String innerClassName = null;
+ if (ndx > 0) {
+ innerClassName = topLevelName.substring(ndx + 1);
+ topLevelName = topLevelName.substring(0, ndx);
+ }
+
+ ClassDoc topLevelClass = (ClassDoc)cache.get(topLevelName);
+ if (null == topLevelClass) {
+ File classFile = new File(packageFile, topLevelName + ".java");
+ try {
+ // FIXME: inner classes
+ topLevelClass = parser.processSourceFile(classFile, false, sourceEncoding, null);
+ }
+ catch (Exception ignore) {
+ printWarning("Could not parse source file " + classFile);
+ }
+ cache.put(topLevelName, topLevelClass);
+ }
+ if (null == innerClassName) {
+ return topLevelClass;
+ }
+ else {
+ return getInnerClass(topLevelClass, innerClassName);
+ }
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString()
+ {
+ return "ResolvedImportPackageFile{" + packageFile + "," + packageName + "}";
+ }
+ }
+
+ private ClassDoc getInnerClass(ClassDoc topLevelClass, String innerClassName)
+ {
+ StringTokenizer st = new StringTokenizer(innerClassName, ".");
+ outer:
+
+ while (st.hasMoreTokens()) {
+ String innerClassNameComponent = st.nextToken();
+ ClassDoc[] innerClasses = topLevelClass.innerClasses();
+ for (int i=0; i<innerClasses.length; ++i) {
+ if (innerClasses[i].name().equals(innerClassNameComponent)) {
+ topLevelClass = innerClasses[i];
+ continue outer;
+ }
+ }
+ printWarning("Could not find inner class " + innerClassName + " in class " + topLevelClass.qualifiedName());
+ return null;
+ }
+ return topLevelClass;
+ }
+
+ private class ResolvedImportClassFile
+ implements ResolvedImport
+ {
+ private File classFile;
+ private String innerClassName;
+ private String name;
+ private ClassDoc classDoc;
+ private boolean alreadyFetched;
+ private String qualifiedName;
+
+ ResolvedImportClassFile(File classFile, String innerClassName, String name, String qualifiedName)
+ {
+ this.classFile = classFile;
+ this.innerClassName = innerClassName;
+ this.name = name;
+ this.qualifiedName = qualifiedName;
+ }
+
+ public String toString()
+ {
+ return "ResolvedImportClassFile{" + classFile + "," + innerClassName + "}";
+ }
+
+ public String match(String name)
+ {
+ String topLevelName = name;
+ int ndx = topLevelName.indexOf('.');
+
+ String _innerClassName = null;
+ if (ndx > 0) {
+ _innerClassName = topLevelName.substring(ndx + 1);
+ topLevelName = topLevelName.substring(0, ndx);
+ }
+
+ if (this.name.equals(topLevelName)) {
+ if (null == _innerClassName) {
+ return qualifiedName;
+ }
+ else {
+ return qualifiedName + "." + _innerClassName;
+ }
+ }
+ else {
+ return null;
+ }
+ }
+
+ public boolean mismatch(String name)
+ {
+ return null == match(name);
+ }
+
+ public ClassDoc tryFetch(String name)
+ {
+ if (null != match(name)) {
+ ClassDoc topLevelClass = null;
+ if (alreadyFetched) {
+ topLevelClass = classDoc;
+ }
+ else {
+ alreadyFetched = true;
+ try {
+ topLevelClass = parser.processSourceFile(classFile, false, sourceEncoding, null);
+ }
+ catch (Exception ignore) {
+ printWarning("Could not parse source file " + classFile);
+ }
+ }
+ if (null == topLevelClass) {
+ return null;
+ }
+ else {
+ return getInnerClass(topLevelClass, innerClassName);
+ }
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String getName()
+ {
+ if (innerClassName != null) {
+ return name + innerClassName;
+ }
+ else {
+ return name;
+ }
+ }
+ }
+
+ private class ResolvedImportReflectionClass
+ implements ResolvedImport
+ {
+ private Class clazz;
+ private String name;
+
+ ResolvedImportReflectionClass(Class clazz)
+ {
+ this.clazz = clazz;
+ String className = clazz.getName();
+ int ndx = className.lastIndexOf('.');
+ if (ndx >= 0) {
+ this.name = className.substring(ndx + 1);
+ }
+ else {
+ this.name = className;
+ }
+ }
+
+ public String toString()
+ {
+ return "ResolvedImportReflectionClass{" + clazz.getName() + "}";
+ }
+
+ public String match(String name)
+ {
+ if ((this.name.equals(name)) || (clazz.getName().equals(name))) {
+ return clazz.getName();
+ }
+ else {
+ return null;
+ }
+ }
+
+ public boolean mismatch(String name)
+ {
+ return null == match(name);
+ }
+
+ public ClassDoc tryFetch(String name)
+ {
+ if (null != match(name)) {
+ return new ClassDocReflectedImpl(clazz);
+ }
+ // FIXME: inner classes?
+ else {
+ return null;
+ }
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+ private class ResolvedImportReflectionPackage
+ implements ResolvedImport
+ {
+ private String packagePrefix;
+
+ ResolvedImportReflectionPackage(String packagePrefix)
+ {
+ this.packagePrefix = packagePrefix;
+ }
+
+ public String toString()
+ {
+ return "ResolvedImportReflectionPackage{" + packagePrefix + ".*}";
+ }
+
+ public String match(String name)
+ {
+ try {
+ Class clazz = Class.forName(packagePrefix + "." + name);
+ return clazz.getName();
+ }
+ catch (Exception e) {
+ return null;
+ }
+ }
+
+ public boolean mismatch(String name)
+ {
+ return null == match(name);
+ }
+
+ public ClassDoc tryFetch(String name)
+ {
+ try {
+ Class clazz = Class.forName(packagePrefix + name);
+ return ClassDocReflectedImpl.newInstance(clazz);
+ }
+ catch (Exception e) {
+ return null;
+ }
+ }
+
+ public String getName()
+ {
+ return packagePrefix;
+ }
+ }
+
+ private List unlocatablePrefixes = new LinkedList();
+
+ private ResolvedImport resolveImport(String importSpecifier)
+ {
+ ResolvedImport result = resolveImportFileSystem(importSpecifier);
+ if (null == result && Main.getInstance().isReflectionEnabled()) {
+ result = resolveImportReflection(importSpecifier);
+ }
+ if (null == result) {
+ result = new ResolvedImportNotFound(importSpecifier);
+ }
+ return result;
+ }
+
+ private ResolvedImport resolveImportReflection(String importSpecifier)
+ {
+ String importedPackageOrClass = importSpecifier;
+ if (importedPackageOrClass.endsWith(".*")) {
+ importedPackageOrClass = importedPackageOrClass.substring(0, importedPackageOrClass.length() - 2);
+
+ return new ResolvedImportReflectionPackage(importedPackageOrClass);
+
+ //return null;
+ }
+ else {
+ try {
+ Class importedClass = Class.forName(importSpecifier);
+ return new ResolvedImportReflectionClass(importedClass);
+ }
+ catch (Throwable ignore) {
+ return null;
+ }
+ }
+ }
+
+ private ResolvedImport resolveImportFileSystem(String importSpecifier)
+ {
+ for (Iterator it = unlocatablePrefixes.iterator(); it.hasNext(); ) {
+ String unlocatablePrefix = (String)it.next();
+ if (importSpecifier.startsWith(unlocatablePrefix)) {
+ return null;
+ }
+ }
+
+ String longestUnlocatablePrefix = "";
+
+ for (Iterator it=sourcePath.iterator(); it.hasNext(); ) {
+
+ File _sourcePath = (File)it.next();
+
+ StringBuffer packageOrClassPrefix = new StringBuffer();
+ StringTokenizer st = new StringTokenizer(importSpecifier, ".");
+ while (st.hasMoreTokens() && _sourcePath.isDirectory()) {
+ String token = st.nextToken();
+ if ("*".equals(token)) {
+ return new ResolvedImportPackageFile(_sourcePath,
+ packageOrClassPrefix.substring(0, packageOrClassPrefix.length() - 1));
+ }
+ else {
+ packageOrClassPrefix.append(token);
+ packageOrClassPrefix.append('.');
+ File classFile = new File(_sourcePath, token + ".java");
+ //System.err.println(" looking for file " + classFile);
+ if (classFile.exists()) {
+ StringBuffer innerClassName = new StringBuffer();
+ while (st.hasMoreTokens()) {
+ token = st.nextToken();
+ if (innerClassName.length() > 0) {
+ innerClassName.append('.');
+ }
+ innerClassName.append(token);
+ }
+ return new ResolvedImportClassFile(classFile, innerClassName.toString(), token, importSpecifier);
+ }
+ else {
+ _sourcePath = new File(_sourcePath, token);
+ }
+ }
+ }
+ if (st.hasMoreTokens()) {
+ if (packageOrClassPrefix.length() > longestUnlocatablePrefix.length()) {
+ longestUnlocatablePrefix = packageOrClassPrefix.toString();
+ }
+ }
+ }
+
+ if (longestUnlocatablePrefix.length() > 0) {
+ unlocatablePrefixes.add(longestUnlocatablePrefix);
+ }
+
+ return null;
+ }
+
+ private Map resolvedImportCache = new HashMap();
+
+ private ResolvedImport getResolvedImport(String importSpecifier)
+ {
+ ResolvedImport result
+ = (ResolvedImport)resolvedImportCache.get(importSpecifier);
+ if (null == result) {
+ result = resolveImport(importSpecifier);
+ resolvedImportCache.put(importSpecifier, result);
+ }
+ return result;
+ }
+
+ public String resolveClassName(String className, ClassDocImpl context)
+ {
+ Iterator it = context.getImportSpecifierList().iterator();
+ while (it.hasNext()) {
+ String importSpecifier = (String)it.next();
+ ResolvedImport resolvedImport = getResolvedImport(importSpecifier);
+ String resolvedScheduledClassName = resolvedImport.match(className);
+
+ if (null != resolvedScheduledClassName) {
+ return resolvedScheduledClassName;
+ }
+ }
+ return className;
+ }
+
+ public ClassDoc findScheduledClassFile(String scheduledClassName,
+ ClassDoc scheduledClassContext)
+ throws ParseException, IOException
+ {
+ String resolvedScheduledClassName = null;
+
+ if (scheduledClassContext instanceof ClassDocImpl) {
+
+ //((ClassDocImpl)scheduledClassContext).resolveReferencedName(scheduledClassName);
+ Iterator it = ((ClassDocImpl)scheduledClassContext).getImportSpecifierList().iterator();
+ while (it.hasNext()) {
+ String importSpecifier = (String)it.next();
+ ResolvedImport resolvedImport = getResolvedImport(importSpecifier);
+ //System.err.println(" looking in import '" + resolvedImport + "'");
+ resolvedScheduledClassName = resolvedImport.match(scheduledClassName);
+ if (null != resolvedScheduledClassName) {
+ ClassDoc result = resolvedImport.tryFetch(scheduledClassName);
+ if (null != result) {
+ return result;
+ }
+ else {
+ if (!inaccessibleReportedSet.contains(scheduledClassName)) {
+ inaccessibleReportedSet.add(scheduledClassName);
+ printWarning("Error while loading class " + scheduledClassName);
+ }
+ // FIXME: output resolved class name here
+ return null;
+ }
+ }
+ }
+ }
+ else {
+ System.err.println("findScheduledClassFile for '" + scheduledClassName + "' in proxy for " + scheduledClassContext);
+ }
+
+ // interpret as fully qualified name on file system
+
+ ResolvedImport fqImport = resolveImportFileSystem(scheduledClassName);
+ if (null != fqImport && fqImport instanceof ResolvedImportClassFile) {
+ return fqImport.tryFetch(((ResolvedImportClassFile)fqImport).getName());
+ }
+
+ // use reflection, assume fully qualified class name
+
+ if (!unlocatableReflectedClassNames.contains(scheduledClassName)) {
+ if (Main.getInstance().isReflectionEnabled()) {
+ try {
+ Class clazz = Class.forName(scheduledClassName);
+ printWarning("Cannot locate class " + scheduledClassName + " on file system, falling back to reflection.");
+ ClassDoc result = new ClassDocReflectedImpl(clazz);
+ return result;
+ }
+ catch (Throwable ignore) {
+ unlocatableReflectedClassNames.add(scheduledClassName);
+ }
+ }
+ else {
+ unlocatableReflectedClassNames.add(scheduledClassName);
+ }
+ }
+
+ if (null == resolvedScheduledClassName) {
+ resolvedScheduledClassName = scheduledClassName;
+ }
+ if (!unlocatableReportedSet.contains(resolvedScheduledClassName)) {
+ unlocatableReportedSet.add(resolvedScheduledClassName);
+ printWarning("Cannot locate class " + resolvedScheduledClassName + " referenced in class " + scheduledClassContext.qualifiedName());
+ }
+ return null;
+ }
+
+ private Set unlocatableReflectedClassNames = new HashSet();
+
+ public static boolean recursiveClasses = false;
+
+ public void addSpecifiedPackageName(String packageName) {
+ specifiedPackageNames.add(packageName);
+ }
+
+ public void addSpecifiedSourceFile(File sourceFile) {
+ specifiedSourceFiles.add(sourceFile);
+ }
+
+ public boolean hasSpecifiedPackagesOrClasses() {
+ return !specifiedPackageNames.isEmpty()
+ || !specifiedSourceFiles.isEmpty();
+ }
+
+ public void setOptions(String[][] customOptionArr) {
+ this.customOptionArr = customOptionArr;
+ }
+
+ public void setSourcePath(List sourcePath) {
+ this.sourcePath = sourcePath;
+ }
+
+ public void finalize() throws Throwable {
+ super.finalize();
+ }
+
+ public void flush()
+ {
+ try {
+ rawCommentCache.close();
+ }
+ catch (IOException e) {
+ printError("Cannot close raw comment cache");
+ }
+
+ rawCommentCache = null;
+ customOptionArr = null;
+ specifiedPackageNames = null;
+ classesList = null;
+ classDocMap = null;
+ packageDocMap = null;
+ classes = null;
+ specifiedClasses = null;
+ specifiedPackages = null;
+ scheduledClasses = null;
+ sourcePath = null;
+ parser = null;
+ unlocatableReportedSet = null;
+ inaccessibleReportedSet = null;
+ }
+
+ public void setSourceEncoding(String sourceEncoding)
+ {
+ this.sourceEncoding = sourceEncoding;
+ }
+
+ public RootDocImpl()
+ {
+ super(null);
+ }
+
+ public static String readHtmlBody(File file)
+ throws IOException
+ {
+ FileReader fr=new FileReader(file);
+ long size = file.length();
+ char[] packageDocBuf=new char[(int)(size)];
+ int index = 0;
+ int i = fr.read(packageDocBuf, index, (int)size);
+ while (i > 0) {
+ index += i;
+ size -= i;
+ i = fr.read(packageDocBuf, index, (int)size);
+ }
+ fr.close();
+
+ // We only need the part between the begin and end body tag.
+ String html = new String(packageDocBuf);
+ int start = html.indexOf("<body");
+ if (start == -1)
+ start = html.indexOf("<BODY");
+ int end = html.indexOf("</body>");
+ if (end == -1)
+ end = html.indexOf("</BODY>");
+ if (start != -1 && end != -1) {
+ // Start is end of body tag.
+ start = html.indexOf('>', start) + 1;
+ if (start != -1 && start < end)
+ html = html.substring(start, end);
+ }
+ return html.trim();
+ }
+
+ public Parser getParser()
+ {
+ return parser;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SeeTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SeeTagImpl.java
new file mode 100644
index 000000000..12e2256dc
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SeeTagImpl.java
@@ -0,0 +1,215 @@
+/* gnu.classpath.tools.gjdoc.SeeTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+
+public class SeeTagImpl extends AbstractTagImpl implements SeeTag {
+
+ protected String reference;
+ private String referencedClassName;
+ private String referencedMemberName;
+ private ClassDoc referencedClass;
+ private MemberDoc referencedMember;
+ private PackageDoc referencedPackage;
+ private String label;
+ private ClassDocImpl contextClass;
+
+ public SeeTagImpl(String text, ClassDocImpl contextClass) {
+ super(text);
+ this.contextClass=contextClass;
+ }
+
+ public void resolve() {
+
+ super.resolve();
+
+ text = text.trim();
+
+ if (text.startsWith("<") || text.startsWith("\"")) {
+ label = text;
+ return;
+ }
+
+ int labelNdx=text.indexOf(';');
+ if (labelNdx>=0) {
+ label="";
+ return;
+ }
+
+ for (int i=0; i<text.length(); ++i) {
+ if (" \t\r\n".indexOf(text.charAt(i)) >= 0) {
+ labelNdx = i;
+ break;
+ }
+ }
+
+ int openParenNdx = text.indexOf('(');
+ if (openParenNdx >= 0 && openParenNdx < labelNdx) {
+ labelNdx=text.indexOf(')', openParenNdx);
+ if (labelNdx >= 0) {
+ ++ labelNdx;
+ }
+ }
+
+ if (labelNdx<0 || labelNdx>=text.length()) {
+ reference=text.trim();
+ label="";
+ }
+ else {
+ reference=text.substring(0,labelNdx).trim();
+ label=text.substring(labelNdx).trim();
+ }
+
+ int mspecNdx=reference.indexOf('#');
+ String referencedFqName;
+ if (mspecNdx<0) {
+ referencedFqName=reference;
+ }
+ else {
+ referencedFqName=reference.substring(0,mspecNdx);
+ referencedMemberName=reference.substring(mspecNdx+1);
+ }
+
+ // the following is in contradiction to the api docs, but
+ // conform to sun javadoc: return fully qualified classname
+ // with referencedClassName().
+ if (referencedFqName.trim().length()>0) {
+ referencedClassName=referencedFqName;
+ if (contextClass==null)
+ referencedClass=Main.getRootDoc().classNamed(referencedFqName);
+ else
+ referencedClass=contextClass.findClass(referencedFqName);
+ }
+ else {
+ referencedClassName="";
+ referencedClass=contextClass;
+ }
+
+ if (referencedClass==null) {
+ referencedClass = Main.getRootDoc().classNamed("java.lang." + referencedFqName);
+ }
+
+ if (referencedClass!=null && !referencedClass.isIncluded()) referencedClass=null;
+
+ if (referencedClass!=null) {
+ referencedPackage=referencedClass.containingPackage();
+ referencedClassName=referencedClass.qualifiedName();
+
+ if (referencedMemberName!=null) {
+
+ if (referencedMemberName.indexOf('(')<0) {
+ referencedMember=((ClassDocImpl)referencedClass).findFieldRec(referencedMemberName);
+ if (null == referencedMember) {
+ MethodDoc[] methods = ((ClassDocImpl)referencedClass).methods();
+ for (int i=0; i<methods.length; ++i) {
+ if (methods[i].name().equals(referencedMemberName)) {
+ if (null == referencedMember) {
+ referencedMember = methods[i];
+ }
+ else {
+ referencedClass = null;
+ referencedMember = null;
+ //print warning here
+ break;
+ }
+ }
+ }
+ }
+ else {
+ referencedClass = referencedMember.containingClass();
+ }
+ }
+ else {
+ referencedMember=((ClassDocImpl)referencedClass).findExecutableRec(referencedMemberName);
+ if (referencedMember==null) {
+ //System.err.println("cannot find member for '"+referencedMemberName+"'");
+ referencedClass = null;
+ }
+ }
+ }
+ }
+ /*
+ else {
+ System.err.println("class not found: '"+referencedFqName + "' in context class " + contextClass + " in " + this);
+ }
+ */
+ }
+
+ public ClassDoc referencedClass() {
+ return referencedClass;
+ }
+
+ public String referencedClassName() {
+ return referencedClassName;
+ }
+
+ public MemberDoc referencedMember() {
+ return referencedMember;
+ }
+
+ public String referencedMemberName() {
+ return referencedMemberName;
+ }
+
+ public PackageDoc referencedPackage() {
+ return referencedPackage;
+ }
+
+ public String label() {
+ return label;
+ }
+
+ public String kind() {
+ return "@see";
+ }
+
+ public String name() {
+ return "@see";
+ }
+
+ public Tag[] firstSentenceTags() {
+ return inlineTags();
+ }
+
+ public Tag[] inlineTags() {
+ return new Tag[]{new TextTagImpl(referencedClassName)};
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.java
new file mode 100644
index 000000000..0ecfe637c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.java
@@ -0,0 +1,128 @@
+/* gnu.classpath.tools.gjdoc.SerialFieldTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+
+public class SerialFieldTagImpl extends AbstractTagImpl implements SerialFieldTag {
+
+ private String fieldName;
+ private String fieldType;
+ private String description;
+ private ClassDoc fieldTypeDoc;
+ private ClassDocImpl contextClass;
+
+ public SerialFieldTagImpl(String text,
+ ClassDocImpl contextClass,
+ MemberDocImpl contextMember) {
+ super(text);
+ this.contextClass=contextClass;
+
+ if (fieldName==null)
+ fieldName="";
+ if (fieldType==null)
+ fieldType="";
+ if (description==null)
+ description="";
+
+ int state=1;
+ char[] textArr=text.toCharArray();
+ for (int i=0; i<textArr.length; ++i) {
+ char c=textArr[i];
+ switch (state) {
+ case 1:
+ if (Parser.isWhitespace(c)) state=2;
+ else fieldName+=c;
+ break;
+ case 2:
+ if (Parser.isWhitespace(c)) state=3;
+ else fieldType+=c;
+ break;
+ case 3:
+ description+=c;
+ break;
+ }
+ }
+
+ setBody(description, contextClass, contextMember);
+
+ }
+
+ public void resolve() {
+
+ super.resolve();
+ try {
+ Type type=contextClass.typeForString(fieldType);
+ this.fieldTypeDoc=type.asClassDoc();
+ } catch (ParseException e) {
+ System.err.println("FIXME: add try-catch to force compilation"
+ + e);
+ }
+ }
+
+ public ClassDoc fieldTypeDoc() {
+ return fieldTypeDoc;
+ }
+
+ public String fieldName() {
+ return fieldName;
+ }
+
+ public String fieldType() {
+ return fieldType;
+ }
+
+ public String description() {
+ return description;
+ }
+
+ public String kind() {
+ return "@serialField";
+ }
+
+ public int compareTo(Object o) {
+ if (o!=null && o instanceof SerialFieldTagImpl) {
+ return fieldName().compareTo(((SerialFieldTagImpl)o).fieldName());
+ }
+ else {
+ return 0;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SourcePositionImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SourcePositionImpl.java
new file mode 100644
index 000000000..e2d73bbd5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/SourcePositionImpl.java
@@ -0,0 +1,77 @@
+/* gnu.classpath.tools.gjdoc.SourcePositionImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.SourcePosition;
+
+import java.io.File;
+
+public class SourcePositionImpl
+ implements SourcePosition
+{
+ private File file;
+ private int line;
+ private int column;
+
+ public SourcePositionImpl(File file, int line, int column)
+ {
+ this.file = file;
+ this.line = line;
+ this.column = column;
+ }
+
+ public File file()
+ {
+ return this.file;
+ }
+
+ public int line()
+ {
+ return this.line;
+ }
+
+ public int column()
+ {
+ return this.column;
+ }
+
+ public String toString()
+ {
+ return this.file + ":" + this.line;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagContainer.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagContainer.java
new file mode 100644
index 000000000..1b9bc40d9
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagContainer.java
@@ -0,0 +1,52 @@
+/* gnu.classpath.tools.gjdoc.TagContainer
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.Tag;
+
+import java.util.Map;
+
+/**
+ * Implemented by Doclet API classes that are associated with tags.
+ */
+interface TagContainer
+{
+ public Tag[] firstSentenceTags();
+ public Tag[] inlineTags();
+ public Map getTagMap();
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagImpl.java
new file mode 100644
index 000000000..a4b1f4b2a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagImpl.java
@@ -0,0 +1,60 @@
+/* gnu.classpath.tools.gjdoc.TagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+
+public class TagImpl extends AbstractTagImpl implements Tag {
+
+ private String kind;
+ private String name;
+
+ TagImpl(String name, String text, ClassDocImpl contextClass, MemberDocImpl contextMember) {
+ super(text);
+ this.kind=name;
+ this.name=name;
+
+ setBody(text, contextClass, contextMember);
+ }
+
+ public String kind() { return kind; }
+ public String name() { return name; }
+ public String toString() { return kind()+":"+text(); }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java
new file mode 100644
index 000000000..0333ee2b7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java
@@ -0,0 +1,132 @@
+/* gnu.classpath.tools.gjdoc.TemporaryStore
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+/**
+ * Useful for passing big objects that are no longer needed by the
+ * calling method, reducing memory usage. <p/>
+ *
+ * Consider the following problem:
+ * <pre>
+ * public class A {
+ * public static void foo() {
+ * long[] hugeArray = new long[1000000]; // takes around 8 MB
+ * // ... fill hugeArray with some information ...
+ * bar(hugeArray);
+ * // ... hugeArray is no more required at this point
+ * }
+ * public static void bar(long[] arr) {
+ * // ... process contents of arr ...
+ * arr = null;
+ * System.gc(); // NOTE: will not collect arr!
+ * // ... do something memory-intensive where arr is not needed
+ * }
+ * }
+ * </pre>
+ *
+ * In method <code>bar()</code>, the array cannot be garbage
+ * collected because the local variable <code>hugeArray</code> in
+ * method <code>foo()</code> still holds a reference to the array.
+ * <p/>
+ *
+ * When calling <code>bar(new long[1000000]);</code> in
+ * <code>arr</code> the array <i>can</i> be collected in
+ * <code>bar()</code>, but that way it can't be initialized in
+ * <code>foo()</code>. A local variable is needed for
+ * initialization, but the variable can't be cleared before it is
+ * passed to <code>bar()</code>! <p/>
+ *
+ * <code>TemporaryStore</code> is the solution for this
+ * dilemma. The modified method <code>foo()</code> which uses a
+ * <code>TemporaryStore</code> object would look like this:
+ *
+ * <pre>
+ * public static void foo() {
+ * long[] hugeArray = new long[1000000]; // takes around 7 MB
+ * // ... fill hugeArray with some very important information ...
+ * TemporaryStore tstore = new TemporaryStore(hugeArray);
+ * hugeArray = null;
+ * bar((long[])tstore.getAndClear());
+ * }
+ * </pre>
+ *
+ * When control flow is transferred to <code>bar()</code>,
+ * <code>foo()</code> will hold no more references to the array
+ * and so it can be garbage collected in <code>bar()</code>.
+ *
+ */
+public class TemporaryStore {
+
+ private Object storedObject;
+
+ /**
+ * Temporarily store the given object for passing it to a
+ * different method. <p/>
+ *
+ * The method constructing a new TemporaryStore object should
+ * clear all other references to the stored object, so that
+ * this TemporaryStore is the only object referencing it.
+ *
+ * @param storedObject the object to store temporarily
+ *
+ */
+ public TemporaryStore(Object storedObject) {
+ this.storedObject = storedObject;
+ }
+
+ /**
+ * Return the stored object after clearing the reference to it.
+ * <p/>
+ *
+ * When the user of this class followed the recommendations in
+ * the documentation of @link{TemporaryStore(Object)}, the
+ * returned reference will be the only reference to the stored
+ * object after this method returns. If the returned reference
+ * is passed in a method call, the called method will hold the
+ * only reference to the stored object and can release it by
+ * nulling the corresponding parameter.
+ *
+ * @return the object which was passed to the constructor.
+ *
+ */
+ public Object getAndClear() {
+ Object rc = this.storedObject;
+ this.storedObject = null;
+ return rc;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TextTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TextTagImpl.java
new file mode 100644
index 000000000..812fd2fde
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TextTagImpl.java
@@ -0,0 +1,56 @@
+/* gnu.classpath.tools.gjdoc.TextTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+
+public class TextTagImpl extends AbstractTagImpl implements Tag {
+
+ TextTagImpl(String text) {
+ super(text);
+ }
+
+ public Tag[] firstSentenceTags() { return new Tag[]{this}; }
+ public Tag[] inlineTags() { return new Tag[]{this}; }
+ public String kind() { return "Text"; }
+
+ public String toString() { return "TextTagImpl{text=" + text + "}"; }
+
+ public String getText() { return text; }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ThrowsTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ThrowsTagImpl.java
new file mode 100644
index 000000000..e4e7bbfcb
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ThrowsTagImpl.java
@@ -0,0 +1,105 @@
+/* gnu.classpath.tools.gjdoc.ThrowsTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+
+public class ThrowsTagImpl extends AbstractTagImpl implements ThrowsTag {
+
+ private ClassDoc exception;
+ private String exceptionName;
+ private String exceptionComment;
+
+ public ThrowsTagImpl(String text,
+ ClassDocImpl contextClass,
+ MemberDocImpl contextMember) {
+ super(text);
+
+ char[] textarr=text.toCharArray();
+ int i=0;
+ for (; i<textarr.length; ++i) {
+ if (!Parser.isWhitespace(textarr[i])) break;
+ }
+ for (; i<textarr.length; ++i) {
+ if (Parser.isWhitespace(textarr[i])) {
+ this.exceptionName=new String(textarr,0,i).trim();
+ this.exceptionComment=new String(textarr,i,textarr.length-i).trim();
+ break;
+ }
+ }
+ if (null != exceptionName) {
+ if (contextClass==null) {
+ this.exception=Main.getRootDoc().classNamed(exceptionName);
+ }
+ else {
+ this.exception=contextClass.findClass(exceptionName);
+ }
+ if (exception!=null)
+ this.exceptionName=exception.qualifiedName();
+ else {
+ if (text.trim().startsWith("<")) {
+ Main.getRootDoc().printWarning("Expected exception name but got '"+text+"' in class "+contextClass.getClassName());
+ }
+ }
+ }
+ else {
+ Main.getRootDoc().printWarning("@throws tag in comment for " + contextClass.qualifiedName() + "." + contextMember.name() + " doesn't specify an exception.");
+ }
+ if (this.exceptionComment!=null) {
+ setBody(this.exceptionComment, contextClass, contextMember);
+ }
+ }
+
+ public ClassDoc exception() {
+ return exception;
+ }
+
+ public String exceptionName() {
+ return exceptionName;
+ }
+
+ public String exceptionComment() {
+ return exceptionComment;
+ }
+
+ public String kind() {
+ return "@throws";
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Timer.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Timer.java
new file mode 100644
index 000000000..93404d08e
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/Timer.java
@@ -0,0 +1,88 @@
+/* gnu.classpath.tools.gjdoc.Timer
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import java.io.*;
+import java.text.*;
+
+public class Timer {
+
+ private static long startTime, beforeDocletTime, stopTime, memoryUsed, maxDriverHeap=-1, maxDocletHeap=-1;
+
+ static void shutdown() {
+ try{
+ if (stopTime==0) return;
+ PrintWriter pw=new PrintWriter(new FileWriter("timer.out"));
+ pw.println("Preparation (driver) took "+(((double)(beforeDocletTime-startTime))/1000.)+" s");
+ pw.println("Generation (doclet) took "+(((double)(stopTime-beforeDocletTime))/1000.)+" s");
+ pw.println("");
+ pw.println("Memory used for documentation tree: "+(memoryUsed/(1024*1024))+" MB");
+ pw.println("Max. heap used for driver: "+((maxDriverHeap<0)?"N/A":((maxDriverHeap/(1024*1024))+" MB")));
+ pw.println("Max. heap used for doclet: "+((maxDocletHeap<0)?"N/A":((maxDocletHeap/(1024*1024))+" MB")));
+ pw.println("");
+ pw.println("TOTAL TIME: "+(((double)(stopTime-startTime))/1000.)+" s");
+ pw.println("TOTAL HEAP: "+((maxDocletHeap<0)?"N/A":(Math.max(maxDocletHeap,maxDriverHeap)/(1024*1024))+" MB"));
+ pw.close();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void setStartTime() {
+ Timer.startTime=System.currentTimeMillis();
+ }
+
+ public static void setStopTime() {
+ Timer.stopTime=System.currentTimeMillis();
+ }
+
+ public static void setBeforeDocletTime() {
+ Timer.beforeDocletTime=System.currentTimeMillis();
+ Timer.memoryUsed=Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory();
+ }
+
+ public static void setMaxDocletHeap(long maximumHeap) {
+ Timer.maxDocletHeap=maximumHeap;
+ }
+
+ public static void setMaxDriverHeap(long maximumHeap) {
+ Timer.maxDriverHeap=maximumHeap;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TimerDoclet.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TimerDoclet.java
new file mode 100644
index 000000000..c2c3c3edf
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TimerDoclet.java
@@ -0,0 +1,104 @@
+/* gnu.classpath.tools.gjdoc.TimerDoclet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+
+public class TimerDoclet {
+
+ private static Object doclet = null;
+
+ private static long maximumHeap = -1;
+
+ private static Thread memThread;
+
+ private static boolean runMemThread = true;
+
+ private static void init() throws Exception {
+ if (doclet==null) {
+ doclet=Class.forName("com.sun.tools.doclets.standard.Standard").newInstance();
+ memThread=new Thread() {
+
+ public void run() {
+ while (runMemThread) {
+ synchronized (TimerDoclet.class) {
+ TimerDoclet.maximumHeap=Math.max(TimerDoclet.maximumHeap,
+ Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory());
+ }
+ try { Thread.sleep(50); } catch (Exception e) {}
+ }
+ }
+ };
+ //memThread.start();
+ }
+ }
+
+ public static boolean validOptions(String[][] options, DocErrorReporter reporter)
+ throws Exception {
+
+ init();
+ return ((Boolean)doclet.getClass().getMethod("validOptions", new Class[]{String[][].class, DocErrorReporter.class}).invoke(null, new Object[]{options, reporter})).booleanValue();
+ //return false; //doclet.validOptions(options, reporter);
+ }
+
+ public static int optionLength(String option) throws Exception {
+ init();
+ return ((Integer)doclet.getClass().getMethod("optionLength", new Class[]{String.class}).invoke(null, new Object[]{option})).intValue();
+ }
+
+ public static boolean start(RootDoc root) throws Exception {
+ Timer.setBeforeDocletTime();
+ synchronized (TimerDoclet.class) {
+ Timer.setMaxDriverHeap(maximumHeap);
+ maximumHeap=-1;
+ }
+ //new com.sun.tools.doclets.standard.Standard().validOptions(root.options(), root);
+ //new com.sun.tools.doclets.standard.Standard().start(root);
+
+ if (validOptions(root.options(), root)) {
+ doclet.getClass().getMethod("start", new Class[]{RootDoc.class}).invoke(null, new Object[]{root});
+ }
+ runMemThread=false;
+ Timer.setStopTime();
+ synchronized (TimerDoclet.class) {
+ Timer.setMaxDocletHeap(maximumHeap);
+ }
+ Timer.shutdown();
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeImpl.java
new file mode 100644
index 000000000..8c1bd5a0d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeImpl.java
@@ -0,0 +1,109 @@
+/* gnu.classpath.tools.gjdoc.TypeImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+
+public class TypeImpl implements Type, WritableType {
+
+ private String packageName;
+ private String typeName;
+ private String dimension;
+
+ TypeImpl(String packageName, String typeName, String dimension) {
+ this.packageName=packageName;
+ this.typeName=typeName;
+ this.dimension=dimension;
+
+ if (typeName.indexOf('[') >= 0 || typeName.indexOf(']') >= 0) {
+ throw new RuntimeException("Typename must not contain dimension information.");
+ }
+ }
+
+ public ClassDoc asClassDoc() {
+
+ if (this instanceof ClassDoc)
+ return ((ClassDocImpl)(ClassDoc)this).getBaseClassDoc();
+ else
+ return null;
+ }
+
+ public String typeName() { return typeName; }
+
+ public String qualifiedTypeName() { return (packageName!=null)?(packageName+"."+typeName):(typeName); }
+
+ public String dimension() { return dimension; }
+ public void setDimension(String dimension) { this.dimension = dimension; }
+
+ public String toString() { return "Type{"+qualifiedTypeName()+dimension()+"}"; }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public boolean isPrimitive()
+ {
+ return null == packageName && primitiveNames.contains(typeName);
+ }
+
+ private static final Set primitiveNames;
+ static {
+ Set _primitiveNames = new HashSet();
+ _primitiveNames.add("boolean");
+ _primitiveNames.add("char");
+ _primitiveNames.add("byte");
+ _primitiveNames.add("short");
+ _primitiveNames.add("int");
+ _primitiveNames.add("long");
+ _primitiveNames.add("float");
+ _primitiveNames.add("double");
+ primitiveNames = Collections.unmodifiableSet(_primitiveNames);
+ }
+
+ public TypeVariable asTypeVariable()
+ {
+ if (this instanceof TypeVariable)
+ return (TypeVariable) this;
+ else
+ return null;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeVariableImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeVariableImpl.java
new file mode 100644
index 000000000..08a236683
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeVariableImpl.java
@@ -0,0 +1,108 @@
+/* gnu.classpath.tools.gjdoc.TypeVariableImpl
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.ProgramElementDoc;
+import com.sun.javadoc.Type;
+import com.sun.javadoc.TypeVariable;
+
+import java.util.List;
+
+public class TypeVariableImpl
+ extends TypeImpl
+ implements TypeVariable, WritableType
+{
+
+ /**
+ * The bounds of this particular type variable.
+ */
+ Type[] bounds;
+
+ /**
+ * The owning program element of this type variable.
+ */
+ ProgramElementDoc owner;
+
+ /**
+ * Constructs a new type variable with the supplied name and owner.
+ *
+ * @param packageName the name of the package containing the type variable.
+ * @param typeName the name of the type variable.
+ * @param dimension the dimensions of the type variable (always "").
+ * @param owner the owning program element of the type variable.
+ */
+ TypeVariableImpl(String packageName, String typeName, String dimension,
+ ProgramElementDoc owner)
+ {
+ super(packageName, typeName, dimension);
+ this.owner = owner;
+ }
+
+ /**
+ * Set the bounds to the contents of the supplied list.
+ *
+ * @param parsedBounds a list of type bounds.
+ */
+ void setBounds(List parsedBounds)
+ {
+ bounds = (Type[]) parsedBounds.toArray(new Type[parsedBounds.size()]);
+ }
+
+ /**
+ * Returns the bounds of this type variable.
+ *
+ * @return the bounds of the variable.
+ */
+ public Type[] bounds()
+ {
+ return bounds;
+ }
+
+ /**
+ * Returns the owning program element for this type variable.
+ *
+ * @return the owning program element, whether a class, interface,
+ * constructor or method.
+ */
+ public ProgramElementDoc owner()
+ {
+ return owner;
+ }
+
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ValueTagImpl.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ValueTagImpl.java
new file mode 100644
index 000000000..024594c6a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/ValueTagImpl.java
@@ -0,0 +1,65 @@
+/* gnu.classpath.tools.gjdoc.ValueTagImpl
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.util.*;
+import java.text.*;
+
+public class ValueTagImpl extends SeeTagImpl {
+
+ public ValueTagImpl(String _text, ClassDocImpl contextClass) {
+ super(_text, contextClass);
+ }
+
+ public String name() { return "@value"; }
+
+ public Tag[] firstSentenceTags() {
+ return inlineTags();
+ }
+
+ public Tag[] inlineTags() {
+ if (null != reference && reference.trim().length() > 0) {
+ return new Tag[] { new TextTagImpl(reference) };
+ }
+ else {
+ return new Tag[0];
+ }
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/WritableType.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/WritableType.java
new file mode 100644
index 000000000..39cfb3f25
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/WritableType.java
@@ -0,0 +1,44 @@
+/* gnu.classpath.tools.gjdoc.WritableType
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+public interface WritableType extends Cloneable {
+
+ public void setDimension(String dimension);
+ public Object clone() throws CloneNotSupportedException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AdditionExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AdditionExpression.java
new file mode 100644
index 000000000..82502c431
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AdditionExpression.java
@@ -0,0 +1,86 @@
+/* gnu.classpath.tools.gjdoc.expr.AdditionExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class AdditionExpression
+ extends BinaryComputationExpression
+{
+ public AdditionExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected double compute(double leftValue, double rightValue)
+ {
+ return leftValue + rightValue;
+ }
+
+ protected float compute(float leftValue, float rightValue)
+ {
+ return leftValue + rightValue;
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue + rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue + rightValue;
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression leftValue = left.evaluate(context);
+ ConstantExpression rightValue = right.evaluate(context);
+
+ if (Type.STRING == leftValue.getType()
+ || Type.STRING == rightValue.getType()) {
+
+ return new ConstantString(leftValue.asObject().toString()
+ + rightValue.asObject().toString());
+ }
+ else {
+ return super.evaluate(leftValue, rightValue);
+ }
+
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AndExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AndExpression.java
new file mode 100644
index 000000000..ac807728b
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AndExpression.java
@@ -0,0 +1,57 @@
+/* gnu.classpath.tools.gjdoc.expr.AndExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class AndExpression
+ extends BinaryBitwiseExpression
+{
+ public AndExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue & rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue & rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.java
new file mode 100644
index 000000000..3c44ce7d8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.java
@@ -0,0 +1,68 @@
+/* gnu.classpath.tools.gjdoc.expr.BinaryBitwiseExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class BinaryBitwiseExpression
+ extends BinaryExpression
+{
+ protected BinaryBitwiseExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression leftValue = left.evaluate(context);
+ ConstantExpression rightValue = right.evaluate(context);
+
+ if (Type.LONG == leftValue.getType()
+ || Type.LONG == rightValue.getType()) {
+
+ return new ConstantLong(compute(leftValue.asNumber().longValue(),
+ rightValue.asNumber().longValue()));
+ }
+ else {
+ return new ConstantInteger(compute(leftValue.asNumber().intValue(),
+ rightValue.asNumber().intValue()));
+ }
+ }
+
+ protected abstract long compute(long leftValue, long rightValue);
+ protected abstract int compute(int leftValue, int rightValue);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.java
new file mode 100644
index 000000000..15d016e1f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.java
@@ -0,0 +1,92 @@
+/* gnu.classpath.tools.gjdoc.expr.BinaryComputationExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class BinaryComputationExpression
+ extends BinaryExpression
+{
+ protected BinaryComputationExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression leftValue = left.evaluate(context);
+ ConstantExpression rightValue = right.evaluate(context);
+
+ return evaluate(leftValue, rightValue);
+ }
+
+ protected ConstantExpression evaluate(ConstantExpression leftValue,
+ ConstantExpression rightValue)
+ throws IllegalExpressionException
+ {
+ if (Type.DOUBLE == leftValue.getType()
+ || Type.DOUBLE == rightValue.getType()) {
+
+ return new ConstantDouble(compute(leftValue.asNumber().doubleValue(),
+ rightValue.asNumber().doubleValue()));
+ }
+ else if (Type.FLOAT == leftValue.getType()
+ || Type.FLOAT == rightValue.getType()) {
+
+ return new ConstantFloat(compute(leftValue.asNumber().floatValue(),
+ rightValue.asNumber().floatValue()));
+ }
+ else if (Type.LONG == leftValue.getType()
+ || Type.LONG == rightValue.getType()) {
+
+ return new ConstantLong(compute(leftValue.asNumber().longValue(),
+ rightValue.asNumber().longValue()));
+ }
+ else if (leftValue.isNumber() && rightValue.isNumber()) {
+ return new ConstantInteger(compute(leftValue.asNumber().intValue(),
+ rightValue.asNumber().intValue()));
+ }
+ else {
+ throw new IllegalExpressionException("Operator ? cannot be applied to " + leftValue.getType() + "," + rightValue.getType());
+ }
+ }
+
+ protected abstract double compute(double leftValue, double rightValue);
+ protected abstract float compute(float leftValue, float rightValue);
+ protected abstract long compute(long leftValue, long rightValue);
+ protected abstract int compute(int leftValue, int rightValue);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.java
new file mode 100644
index 000000000..1b37c233a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.java
@@ -0,0 +1,89 @@
+/* gnu.classpath.tools.gjdoc.expr.BinaryEqualityExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class BinaryEqualityExpression
+ extends BinaryExpression
+{
+ protected BinaryEqualityExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression leftValue = left.evaluate(context);
+ ConstantExpression rightValue = right.evaluate(context);
+
+ if (Type.DOUBLE == leftValue.getType()
+ || Type.DOUBLE == rightValue.getType()) {
+
+ return new ConstantBoolean(compute(leftValue.asNumber().doubleValue(),
+ rightValue.asNumber().doubleValue()));
+ }
+ else if (Type.FLOAT == leftValue.getType()
+ || Type.FLOAT == rightValue.getType()) {
+
+ return new ConstantBoolean(compute(leftValue.asNumber().floatValue(),
+ rightValue.asNumber().floatValue()));
+ }
+ else if (Type.LONG == leftValue.getType()
+ || Type.LONG == rightValue.getType()) {
+
+ return new ConstantBoolean(compute(leftValue.asNumber().longValue(),
+ rightValue.asNumber().longValue()));
+ }
+ else if (Type.BOOLEAN == leftValue.getType()
+ && Type.BOOLEAN == rightValue.getType()) {
+
+ return new ConstantBoolean(compute(((ConstantBoolean)leftValue).booleanValue(),
+ ((ConstantBoolean)rightValue).booleanValue()));
+ }
+ else {
+ return new ConstantBoolean(compute(leftValue.asNumber().intValue(),
+ rightValue.asNumber().intValue()));
+ }
+ }
+
+ protected abstract boolean compute(double leftValue, double rightValue);
+ protected abstract boolean compute(float leftValue, float rightValue);
+ protected abstract boolean compute(long leftValue, long rightValue);
+ protected abstract boolean compute(int leftValue, int rightValue);
+ protected abstract boolean compute(boolean leftValue, boolean rightValue);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryExpression.java
new file mode 100644
index 000000000..557b514c7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryExpression.java
@@ -0,0 +1,51 @@
+/* gnu.classpath.tools.gjdoc.expr.BinaryExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class BinaryExpression
+ implements Expression
+{
+ protected Expression left;
+ protected Expression right;
+
+ protected BinaryExpression(Expression left, Expression right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.java
new file mode 100644
index 000000000..7fa51869c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.java
@@ -0,0 +1,64 @@
+/* gnu.classpath.tools.gjdoc.expr.BinaryLogicalExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class BinaryLogicalExpression
+ extends BinaryExpression
+{
+ protected BinaryLogicalExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression leftValue = left.evaluate(context);
+ ConstantExpression rightValue = right.evaluate(context);
+
+ if (leftValue.getType() != Type.BOOLEAN || rightValue.getType() != Type.BOOLEAN) {
+ throw new IllegalExpressionException("logical expression expects boolean subexpressions");
+ }
+ else {
+ return new ConstantBoolean(compute(((ConstantBoolean)leftValue).booleanValue(),
+ ((ConstantBoolean)rightValue).booleanValue()));
+ }
+ }
+
+ protected abstract boolean compute(boolean leftValue, boolean rightValue);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.java
new file mode 100644
index 000000000..f6ef45cf5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.java
@@ -0,0 +1,82 @@
+/* gnu.classpath.tools.gjdoc.expr.BinaryRelationExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class BinaryRelationExpression
+ extends BinaryExpression
+{
+ protected BinaryRelationExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression leftValue = left.evaluate(context);
+ ConstantExpression rightValue = right.evaluate(context);
+
+ if (Type.DOUBLE == leftValue.getType()
+ || Type.DOUBLE == rightValue.getType()) {
+
+ return new ConstantBoolean(compute(leftValue.asNumber().doubleValue(),
+ rightValue.asNumber().doubleValue()));
+ }
+ else if (Type.FLOAT == leftValue.getType()
+ || Type.FLOAT == rightValue.getType()) {
+
+ return new ConstantBoolean(compute(leftValue.asNumber().floatValue(),
+ rightValue.asNumber().floatValue()));
+ }
+ else if (Type.LONG == leftValue.getType()
+ || Type.LONG == rightValue.getType()) {
+
+ return new ConstantBoolean(compute(leftValue.asNumber().longValue(),
+ rightValue.asNumber().longValue()));
+ }
+ else {
+ return new ConstantBoolean(compute(leftValue.asNumber().intValue(),
+ rightValue.asNumber().intValue()));
+ }
+ }
+
+ protected abstract boolean compute(double leftValue, double rightValue);
+ protected abstract boolean compute(float leftValue, float rightValue);
+ protected abstract boolean compute(long leftValue, long rightValue);
+ protected abstract boolean compute(int leftValue, int rightValue);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.java
new file mode 100644
index 000000000..32ccea209
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.java
@@ -0,0 +1,66 @@
+/* gnu.classpath.tools.gjdoc.expr.BinaryShiftExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class BinaryShiftExpression
+ extends BinaryExpression
+{
+ protected BinaryShiftExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression leftValue = left.evaluate(context);
+ ConstantExpression rightValue = right.evaluate(context);
+
+ if (Type.LONG == leftValue.getType()) {
+ return new ConstantLong(compute(leftValue.asNumber().longValue(),
+ rightValue.asNumber().intValue()));
+ }
+ else {
+ return new ConstantInteger(compute(leftValue.asNumber().intValue(),
+ rightValue.asNumber().intValue()));
+ }
+ }
+
+ protected abstract long compute(long leftValue, int rightValue);
+ protected abstract int compute(int leftValue, int rightValue);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.java
new file mode 100644
index 000000000..eca1a5257
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.java
@@ -0,0 +1,57 @@
+/* gnu.classpath.tools.gjdoc.expr.BitShiftRightExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class BitShiftRightExpression
+ extends BinaryShiftExpression
+{
+ public BitShiftRightExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected long compute(long leftValue, int rightValue)
+ {
+ return leftValue >>> rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue >>> rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.java
new file mode 100644
index 000000000..a9bfacc89
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.java
@@ -0,0 +1,52 @@
+/* gnu.classpath.tools.gjdoc.expr.IllegalExpressionException
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+public class CircularExpressionException
+ extends IllegalExpressionException
+{
+ public CircularExpressionException(String message)
+ {
+ super(message);
+ }
+
+ public CircularExpressionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.java
new file mode 100644
index 000000000..d9532efb0
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.java
@@ -0,0 +1,74 @@
+/* gnu.classpath.tools.gjdoc.expr.ConditionalExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConditionalExpression
+ implements Expression
+{
+ private Expression condition;
+ private Expression ifTrue;
+ private Expression ifFalse;
+
+ ConditionalExpression(Expression condition, Expression ifTrue, Expression ifFalse)
+ {
+ this.condition = condition;
+ this.ifTrue = ifTrue;
+ this.ifFalse = ifFalse;
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression conditionValue = condition.evaluate(context);
+ ConstantExpression ifTrueValue = ifTrue.evaluate(context);
+ ConstantExpression ifFalseValue = ifFalse.evaluate(context);
+
+ if (Type.BOOLEAN != conditionValue.getType()) {
+ throw new IllegalExpressionException("condition must be boolean");
+ }
+ else {
+ boolean cond = ((ConstantBoolean)conditionValue).booleanValue();
+ if (cond) {
+ return ifTrueValue;
+ }
+ else {
+ return ifFalseValue;
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.java
new file mode 100644
index 000000000..83faf1f20
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.java
@@ -0,0 +1,84 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantBoolean
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantBoolean
+ extends ConstantExpression
+{
+ private boolean value;
+
+ public ConstantBoolean(String stringValue)
+ {
+ this.value = "true".equals(stringValue);
+ }
+
+ public ConstantBoolean(boolean booleanValue)
+ {
+ this.value = booleanValue;
+ }
+
+ public boolean booleanValue()
+ {
+ return value;
+ }
+
+ public Type getType()
+ {
+ return Type.BOOLEAN;
+ }
+
+ public Number asNumber()
+ {
+ return null;
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public Object asObject()
+ {
+ return new Boolean(value);
+ }
+
+ public String toString()
+ {
+ return Boolean.toString(value);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantByte.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantByte.java
new file mode 100644
index 000000000..e206e567f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantByte.java
@@ -0,0 +1,74 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantByte
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantByte
+ extends ConstantExpression
+{
+ private byte value;
+
+ public ConstantByte(byte byteValue)
+ {
+ this.value = byteValue;
+ }
+
+ public Type getType()
+ {
+ return Type.BYTE;
+ }
+
+ public Number asNumber()
+ {
+ return new Byte(value);
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public Object asObject()
+ {
+ return asNumber();
+ }
+
+ public String toString()
+ {
+ return Byte.toString(value);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantChar.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantChar.java
new file mode 100644
index 000000000..3cbeac126
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantChar.java
@@ -0,0 +1,98 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantChar
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantChar
+ extends ConstantExpression
+{
+ private char value;
+
+ public ConstantChar(String stringValue)
+ {
+ this.value = stringValue.charAt(1); // FIXME
+ if (value == '\\') {
+ switch (stringValue.charAt(2)) {
+ case 'n': value = '\n'; break;
+ case 't': value = '\t'; break;
+ case 'f': value = '\f'; break;
+ case 'r': value = '\r'; break;
+ case 'b': value = '\b'; break;
+ case 'u':
+ {
+ String stringVal = stringValue.substring(3, stringValue.length() - 1);
+ /*
+ while (stringVal.length() > 1 && stringVal.charAt(0) == '0') {
+ stringVal = stringVal.substring(1);
+ }
+ */
+ value = (char)Integer.parseInt(stringVal, 16); break;
+ }
+ }
+ }
+ }
+
+ public ConstantChar(char charValue)
+ {
+ this.value = charValue;
+ }
+
+ public Type getType()
+ {
+ return Type.CHAR;
+ }
+
+ public Number asNumber()
+ {
+ return new Integer((int)value);
+ }
+
+ public Object asObject()
+ {
+ return new Character(value);
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public String toString()
+ {
+ return Character.toString(value);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantDouble.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantDouble.java
new file mode 100644
index 000000000..5faa5a17b
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantDouble.java
@@ -0,0 +1,79 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantDouble
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantDouble
+ extends ConstantExpression
+{
+ private double value;
+
+ public ConstantDouble(String stringValue)
+ {
+ this.value = Double.parseDouble(stringValue);
+ }
+
+ public ConstantDouble(double doubleValue)
+ {
+ this.value = doubleValue;
+ }
+
+ public Type getType()
+ {
+ return Type.DOUBLE;
+ }
+
+ public Number asNumber()
+ {
+ return new Double(value);
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public Object asObject()
+ {
+ return asNumber();
+ }
+
+ public String toString()
+ {
+ return Double.toString(value);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantExpression.java
new file mode 100644
index 000000000..93923e6ae
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantExpression.java
@@ -0,0 +1,52 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class ConstantExpression
+ implements Expression
+{
+ public abstract Type getType();
+ public abstract Number asNumber();
+ public abstract Object asObject();
+ public abstract boolean isNumber();
+
+ public ConstantExpression evaluate(Context context)
+ {
+ return this;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantFloat.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantFloat.java
new file mode 100644
index 000000000..46895500d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantFloat.java
@@ -0,0 +1,79 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantFloat
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantFloat
+ extends ConstantExpression
+{
+ private float value;
+
+ public ConstantFloat(String stringValue)
+ {
+ this.value = Float.parseFloat(stringValue);
+ }
+
+ public ConstantFloat(float floatValue)
+ {
+ this.value = floatValue;
+ }
+
+ public Type getType()
+ {
+ return Type.FLOAT;
+ }
+
+ public Number asNumber()
+ {
+ return new Float(value);
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public Object asObject()
+ {
+ return asNumber();
+ }
+
+ public String toString()
+ {
+ return "ConstantFloat{" + value + "}";
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantInteger.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantInteger.java
new file mode 100644
index 000000000..10804a695
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantInteger.java
@@ -0,0 +1,79 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantInteger
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantInteger
+ extends ConstantExpression
+{
+ private long value;
+
+ public ConstantInteger(String stringValue)
+ {
+ this.value = Evaluator.parseLong(stringValue);
+ }
+
+ public ConstantInteger(int integerValue)
+ {
+ this.value = integerValue;
+ }
+
+ public Type getType()
+ {
+ return Type.INTEGER;
+ }
+
+ public Number asNumber()
+ {
+ return new Long(value);
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public Object asObject()
+ {
+ return new Integer((int)value);
+ }
+
+ public String toString()
+ {
+ return Long.toString(value);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantLong.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantLong.java
new file mode 100644
index 000000000..a0a2f4b80
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantLong.java
@@ -0,0 +1,84 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantLong
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantLong
+ extends ConstantExpression
+{
+ private long value;
+
+ public ConstantLong(String stringValue)
+ {
+ if ('l' == Character.toLowerCase(stringValue.charAt(stringValue.length() - 1))) {
+ this.value = Evaluator.parseLong(stringValue.substring(0, stringValue.length() - 1));
+ }
+ else {
+ this.value = Evaluator.parseInt(stringValue.substring(0, stringValue.length() - 1));
+ }
+ }
+
+ public ConstantLong(long longValue)
+ {
+ this.value = longValue;
+ }
+
+ public Type getType()
+ {
+ return Type.LONG;
+ }
+
+ public Number asNumber()
+ {
+ return new Long(value);
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public Object asObject()
+ {
+ return asNumber();
+ }
+
+ public String toString()
+ {
+ return Long.toString(value);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantNull.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantNull.java
new file mode 100644
index 000000000..c27b10b8a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantNull.java
@@ -0,0 +1,66 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantNull
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantNull
+ extends ConstantExpression
+{
+ public ConstantNull()
+ {
+ }
+
+ public Type getType()
+ {
+ return Type.NULL;
+ }
+
+ public Number asNumber()
+ {
+ return null;
+ }
+
+ public boolean isNumber()
+ {
+ return false;
+ }
+
+ public Object asObject()
+ {
+ return null;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantShort.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantShort.java
new file mode 100644
index 000000000..5f4f00e1c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantShort.java
@@ -0,0 +1,74 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantShort
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantShort
+ extends ConstantExpression
+{
+ private short value;
+
+ public ConstantShort(short shortValue)
+ {
+ this.value = shortValue;
+ }
+
+ public Type getType()
+ {
+ return Type.SHORT;
+ }
+
+ public Number asNumber()
+ {
+ return new Short(value);
+ }
+
+ public boolean isNumber()
+ {
+ return true;
+ }
+
+ public Object asObject()
+ {
+ return asNumber();
+ }
+
+ public String toString()
+ {
+ return Short.toString(value);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantString.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantString.java
new file mode 100644
index 000000000..4e9ecdee1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantString.java
@@ -0,0 +1,74 @@
+/* gnu.classpath.tools.gjdoc.expr.ConstantString
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ConstantString
+ extends ConstantExpression
+{
+ private String value;
+
+ public ConstantString(String value)
+ {
+ this.value = value;
+ }
+
+ public Type getType()
+ {
+ return Type.STRING;
+ }
+
+ public Number asNumber()
+ {
+ return null;
+ }
+
+ public boolean isNumber()
+ {
+ return false;
+ }
+
+ public Object asObject()
+ {
+ return value;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Context.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Context.java
new file mode 100644
index 000000000..f6d1ebc10
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Context.java
@@ -0,0 +1,62 @@
+/* gnu.classpath.tools.gjdoc.expr.Context
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+import java.util.Set;
+
+class Context
+{
+ private EvaluatorEnvironment evaluatorEnvironment;
+ private Set visitedFields;
+
+ Context(EvaluatorEnvironment evaluatorEnvironment, Set visitedFields)
+ {
+ this.evaluatorEnvironment = evaluatorEnvironment;
+ this.visitedFields = visitedFields;
+ }
+
+ public EvaluatorEnvironment getEvaluatorEnvironment()
+ {
+ return evaluatorEnvironment;
+ }
+
+ public Set getVisitedFields()
+ {
+ return visitedFields;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/DivisionExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/DivisionExpression.java
new file mode 100644
index 000000000..85206d4fb
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/DivisionExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.DivisionExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class DivisionExpression
+ extends BinaryComputationExpression
+{
+ public DivisionExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected double compute(double leftValue, double rightValue)
+ {
+ return leftValue / rightValue;
+ }
+
+ protected float compute(float leftValue, float rightValue)
+ {
+ return leftValue / rightValue;
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue / rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue / rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EqualExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EqualExpression.java
new file mode 100644
index 000000000..d7385fd7c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EqualExpression.java
@@ -0,0 +1,72 @@
+/* gnu.classpath.tools.gjdoc.expr.EqualExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class EqualExpression
+ extends BinaryEqualityExpression
+{
+ public EqualExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected boolean compute(double leftValue, double rightValue)
+ {
+ return leftValue == rightValue;
+ }
+
+ protected boolean compute(float leftValue, float rightValue)
+ {
+ return leftValue == rightValue;
+ }
+
+ protected boolean compute(long leftValue, long rightValue)
+ {
+ return leftValue == rightValue;
+ }
+
+ protected boolean compute(int leftValue, int rightValue)
+ {
+ return leftValue == rightValue;
+ }
+
+ protected boolean compute(boolean leftValue, boolean rightValue)
+ {
+ return leftValue == rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Evaluator.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Evaluator.java
new file mode 100644
index 000000000..d12da3519
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Evaluator.java
@@ -0,0 +1,148 @@
+/* gnu.classpath.tools.gjdoc.expr.Evaluator
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+import java.io.StringReader;
+import java.math.BigInteger;
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+import java.util.Set;
+
+public class Evaluator
+{
+ /**
+ * Try to evaluate the given Java expression in the context of the
+ * given environment.
+ *
+ * @param expression the Java expression to evaluate. The
+ * expression string must not include a terminating semicolon.
+ *
+ * @param source the FieldDoc (part of) whose constant field value
+ * expression is being evaluated. Used to prevent circular
+ * references.
+ *
+ * @param environment callback hook used by the Evaluator to query
+ * the value of static fields referenced in the expression.
+ *
+ * @return a Java object representing the value of the expression,
+ * or <code>null</code> if the expression evaluates to
+ * <code>null</code>.
+ *
+ * @throws IllegalExpressionException if the expression is
+ * invalid, uses unsupported syntax constructs (e.g. method calls,
+ * array access) or references unknown static fields.
+ */
+ public static Object evaluate(String expression,
+ Set visitedFields,
+ EvaluatorEnvironment environment)
+ throws IllegalExpressionException
+ {
+ try {
+ JavaLexer lexer = new JavaLexer(new StringReader(expression));
+ JavaRecognizer recognizer = new JavaRecognizer(lexer);
+ Expression e = recognizer.expression();
+ ConstantExpression value = e.evaluate(new Context(environment, visitedFields));
+ return value.asObject();
+ }
+ catch (RecognitionException e) {
+ throw new IllegalExpressionException(e);
+ }
+ catch (TokenStreamException e) {
+ throw new IllegalExpressionException(e);
+ }
+ }
+
+ static int parseInt(String stringValue)
+ {
+ int base = 10;
+
+ if (stringValue.startsWith("0x")) {
+ base = 16;
+ stringValue = stringValue.substring(2);
+ }
+ else if (stringValue.length() > 1 && stringValue.startsWith("0")) {
+ base = 8;
+ stringValue = stringValue.substring(1);
+ }
+ while (stringValue.length() > 1 && stringValue.startsWith("0")) {
+ stringValue = stringValue.substring(1);
+ }
+
+ if (10 == base) {
+ return Integer.parseInt(stringValue);
+ }
+ else {
+ long result = Long.parseLong(stringValue, base);
+
+ if (result > Integer.MAX_VALUE) {
+ result -= 0x100000000L;
+ }
+
+ if (result > Integer.MAX_VALUE) {
+ throw new NumberFormatException(result + " > " + Integer.MAX_VALUE);
+ }
+ else if (result < Integer.MIN_VALUE) {
+ throw new NumberFormatException(result + " < " + Integer.MIN_VALUE);
+ }
+ else {
+ return (int)result;
+ }
+ }
+ }
+
+ static long parseLong(String stringValue)
+ {
+ int base = 10;
+
+ if (stringValue.startsWith("0x")) {
+ base = 16;
+ stringValue = stringValue.substring(2);
+ }
+ else if (stringValue.length() > 1 && stringValue.startsWith("0")) {
+ base = 8;
+ stringValue = stringValue.substring(1);
+ }
+ while (stringValue.length() > 1 && stringValue.startsWith("0")) {
+ stringValue = stringValue.substring(1);
+ }
+
+ BigInteger bigInt = new BigInteger(stringValue, base);
+ long result = bigInt.longValue();
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.java
new file mode 100644
index 000000000..cf4df8938
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.java
@@ -0,0 +1,46 @@
+/* gnu.classpath.tools.gjdoc.expr.EvaluatorEnvironment
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+import java.util.Set;
+
+public interface EvaluatorEnvironment
+{
+ public Object getValue(String identifier, Set visitedFields)
+ throws IllegalExpressionException, UnknownIdentifierException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.java
new file mode 100644
index 000000000..eb992fc28
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.java
@@ -0,0 +1,57 @@
+/* gnu.classpath.tools.gjdoc.expr.ExclusiveOrExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ExclusiveOrExpression
+ extends BinaryBitwiseExpression
+{
+ public ExclusiveOrExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue ^ rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue ^ rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Expression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Expression.java
new file mode 100644
index 000000000..ca1ccc645
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Expression.java
@@ -0,0 +1,44 @@
+/* gnu.classpath.tools.gjdoc.expr.Expression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+interface Expression
+{
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.java
new file mode 100644
index 000000000..995f7ae80
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.GreaterThanExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class GreaterThanExpression
+ extends BinaryRelationExpression
+{
+ public GreaterThanExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected boolean compute(double leftValue, double rightValue)
+ {
+ return leftValue > rightValue;
+ }
+
+ protected boolean compute(float leftValue, float rightValue)
+ {
+ return leftValue > rightValue;
+ }
+
+ protected boolean compute(long leftValue, long rightValue)
+ {
+ return leftValue > rightValue;
+ }
+
+ protected boolean compute(int leftValue, int rightValue)
+ {
+ return leftValue > rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.java
new file mode 100644
index 000000000..4e7ca4a01
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.GreaterThanOrEqualExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class GreaterThanOrEqualExpression
+ extends BinaryRelationExpression
+{
+ public GreaterThanOrEqualExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected boolean compute(double leftValue, double rightValue)
+ {
+ return leftValue >= rightValue;
+ }
+
+ protected boolean compute(float leftValue, float rightValue)
+ {
+ return leftValue >= rightValue;
+ }
+
+ protected boolean compute(long leftValue, long rightValue)
+ {
+ return leftValue >= rightValue;
+ }
+
+ protected boolean compute(int leftValue, int rightValue)
+ {
+ return leftValue >= rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.java
new file mode 100644
index 000000000..8d254927c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.java
@@ -0,0 +1,89 @@
+/* gnu.classpath.tools.gjdoc.expr.IdentifierExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class IdentifierExpression
+ implements Expression
+{
+ private String identifier;
+
+ public IdentifierExpression(String identifier)
+ {
+ this.identifier = identifier;
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ Object value = context.getEvaluatorEnvironment().getValue(identifier, context.getVisitedFields());
+
+ if (value instanceof Byte) {
+ return new ConstantByte(((Byte)value).byteValue());
+ }
+ else if (value instanceof Short) {
+ return new ConstantShort(((Short)value).shortValue());
+ }
+ else if (value instanceof Integer) {
+ return new ConstantInteger(((Integer)value).intValue());
+ }
+ else if (value instanceof Long) {
+ return new ConstantLong(((Long)value).longValue());
+ }
+ else if (value instanceof Float) {
+ return new ConstantFloat(((Float)value).floatValue());
+ }
+ else if (value instanceof Double) {
+ return new ConstantDouble(((Double)value).doubleValue());
+ }
+ else if (value instanceof Boolean) {
+ return new ConstantBoolean(((Boolean)value).booleanValue());
+ }
+ else if (value instanceof Character) {
+ return new ConstantChar(((Character)value).charValue());
+ }
+ else if (value instanceof String) {
+ return new ConstantString((String)value);
+ }
+ else if (null != value) {
+ throw new IllegalExpressionException("Unsupported type " + value.getClass().getName() + " for identifier " + identifier);
+ }
+ else {
+ throw new IllegalExpressionException("Cannot resolve identifier " + identifier);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.java
new file mode 100644
index 000000000..65cd5da11
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.java
@@ -0,0 +1,52 @@
+/* gnu.classpath.tools.gjdoc.expr.IllegalExpressionException
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+public class IllegalExpressionException
+ extends Exception
+{
+ public IllegalExpressionException(String message)
+ {
+ super(message);
+ }
+
+ public IllegalExpressionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.java
new file mode 100644
index 000000000..2b0250133
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.java
@@ -0,0 +1,57 @@
+/* gnu.classpath.tools.gjdoc.expr.InclusiveOrExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class InclusiveOrExpression
+ extends BinaryBitwiseExpression
+{
+ public InclusiveOrExpression(Expression a, Expression b)
+ {
+ super(a, b);
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue | rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue | rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanExpression.java
new file mode 100644
index 000000000..4e784cdcc
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.LessThanExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class LessThanExpression
+ extends BinaryRelationExpression
+{
+ public LessThanExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected boolean compute(double leftValue, double rightValue)
+ {
+ return leftValue < rightValue;
+ }
+
+ protected boolean compute(float leftValue, float rightValue)
+ {
+ return leftValue < rightValue;
+ }
+
+ protected boolean compute(long leftValue, long rightValue)
+ {
+ return leftValue < rightValue;
+ }
+
+ protected boolean compute(int leftValue, int rightValue)
+ {
+ return leftValue < rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.java
new file mode 100644
index 000000000..803ad5ee3
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.LessThanOrEqualExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class LessThanOrEqualExpression
+ extends BinaryRelationExpression
+{
+ public LessThanOrEqualExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected boolean compute(double leftValue, double rightValue)
+ {
+ return leftValue <= rightValue;
+ }
+
+ protected boolean compute(float leftValue, float rightValue)
+ {
+ return leftValue <= rightValue;
+ }
+
+ protected boolean compute(long leftValue, long rightValue)
+ {
+ return leftValue <= rightValue;
+ }
+
+ protected boolean compute(int leftValue, int rightValue)
+ {
+ return leftValue <= rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.java
new file mode 100644
index 000000000..3b0409155
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.java
@@ -0,0 +1,52 @@
+/* gnu.classpath.tools.gjdoc.expr.LogicalAndExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class LogicalAndExpression
+ extends BinaryLogicalExpression
+{
+ LogicalAndExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected boolean compute(boolean leftValue, boolean rightValue)
+ {
+ return leftValue && rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.java
new file mode 100644
index 000000000..4c7bf70f7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.java
@@ -0,0 +1,60 @@
+/* gnu.classpath.tools.gjdoc.expr.LogicalNotExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class LogicalNotExpression
+ extends UnaryExpression
+{
+ protected LogicalNotExpression(Expression expr)
+ {
+ super(expr);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression value = expr.evaluate(context);
+
+ if (Type.BOOLEAN == value.getType()) {
+ return new ConstantBoolean(!((ConstantBoolean)value).booleanValue());
+ }
+ else {
+ throw new IllegalExpressionException("Operator ! cannot be applied to " + value.getType());
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.java
new file mode 100644
index 000000000..625a6e5e8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.java
@@ -0,0 +1,52 @@
+/* gnu.classpath.tools.gjdoc.expr.LogicalOrExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class LogicalOrExpression
+ extends BinaryLogicalExpression
+{
+ LogicalOrExpression(Expression a, Expression b)
+ {
+ super(a, b);
+ }
+
+ protected boolean compute(boolean leftValue, boolean rightValue)
+ {
+ return leftValue || rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ModuloExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ModuloExpression.java
new file mode 100644
index 000000000..6aca379dc
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ModuloExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.ModuloExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ModuloExpression
+ extends BinaryComputationExpression
+{
+ public ModuloExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected double compute(double leftValue, double rightValue)
+ {
+ return leftValue % rightValue;
+ }
+
+ protected float compute(float leftValue, float rightValue)
+ {
+ return leftValue % rightValue;
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue % rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue % rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.java
new file mode 100644
index 000000000..3d3071a50
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.MultiplicationExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class MultiplicationExpression
+ extends BinaryComputationExpression
+{
+ public MultiplicationExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected double compute(double leftValue, double rightValue)
+ {
+ return leftValue * rightValue;
+ }
+
+ protected float compute(float leftValue, float rightValue)
+ {
+ return leftValue * rightValue;
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue * rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue * rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NegateExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NegateExpression.java
new file mode 100644
index 000000000..5b66fecd2
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NegateExpression.java
@@ -0,0 +1,66 @@
+/* gnu.classpath.tools.gjdoc.expr.NegateExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class NegateExpression
+ extends UnaryExpression
+{
+ protected NegateExpression(Expression expr)
+ {
+ super(expr);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression value = expr.evaluate(context);
+
+ if (Type.LONG == value.getType()) {
+ return new ConstantLong(-value.asNumber().longValue());
+ }
+ else if (Type.DOUBLE == value.getType()) {
+ return new ConstantDouble(-value.asNumber().doubleValue());
+ }
+ else if (Type.FLOAT == value.getType()) {
+ return new ConstantDouble(-value.asNumber().floatValue());
+ }
+ else {
+ return new ConstantInteger(-value.asNumber().intValue());
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.java
new file mode 100644
index 000000000..eb49bc087
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.java
@@ -0,0 +1,72 @@
+/* gnu.classpath.tools.gjdoc.expr.NotEqualExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class NotEqualExpression
+ extends BinaryEqualityExpression
+{
+ public NotEqualExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected boolean compute(double leftValue, double rightValue)
+ {
+ return leftValue != rightValue;
+ }
+
+ protected boolean compute(float leftValue, float rightValue)
+ {
+ return leftValue != rightValue;
+ }
+
+ protected boolean compute(long leftValue, long rightValue)
+ {
+ return leftValue != rightValue;
+ }
+
+ protected boolean compute(int leftValue, int rightValue)
+ {
+ return leftValue != rightValue;
+ }
+
+ protected boolean compute(boolean leftValue, boolean rightValue)
+ {
+ return leftValue != rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotExpression.java
new file mode 100644
index 000000000..7359a055a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotExpression.java
@@ -0,0 +1,60 @@
+/* gnu.classpath.tools.gjdoc.expr.NotExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class NotExpression
+ extends UnaryExpression
+{
+ protected NotExpression(Expression expr)
+ {
+ super(expr);
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression value = expr.evaluate(context);
+
+ if (Type.LONG == value.getType()) {
+ return new ConstantLong(~value.asNumber().longValue());
+ }
+ else {
+ return new ConstantInteger(~value.asNumber().intValue());
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.java
new file mode 100644
index 000000000..ad72efbfb
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.java
@@ -0,0 +1,57 @@
+/* gnu.classpath.tools.gjdoc.expr.ShiftLeftExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ShiftLeftExpression
+ extends BinaryShiftExpression
+{
+ public ShiftLeftExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected long compute(long leftValue, int rightValue)
+ {
+ return leftValue << rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue << rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.java
new file mode 100644
index 000000000..f9d7820bb
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.java
@@ -0,0 +1,57 @@
+/* gnu.classpath.tools.gjdoc.expr.ShiftRightExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class ShiftRightExpression
+ extends BinaryShiftExpression
+{
+ public ShiftRightExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected long compute(long leftValue, int rightValue)
+ {
+ return leftValue >> rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue >> rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.java
new file mode 100644
index 000000000..dc0101ffc
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.java
@@ -0,0 +1,67 @@
+/* gnu.classpath.tools.gjdoc.expr.SubtractionExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class SubtractionExpression
+ extends BinaryComputationExpression
+{
+ public SubtractionExpression(Expression left, Expression right)
+ {
+ super(left, right);
+ }
+
+ protected double compute(double leftValue, double rightValue)
+ {
+ return leftValue - rightValue;
+ }
+
+ protected float compute(float leftValue, float rightValue)
+ {
+ return leftValue - rightValue;
+ }
+
+ protected long compute(long leftValue, long rightValue)
+ {
+ return leftValue - rightValue;
+ }
+
+ protected int compute(int leftValue, int rightValue)
+ {
+ return leftValue - rightValue;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Type.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Type.java
new file mode 100644
index 000000000..92382c41a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Type.java
@@ -0,0 +1,60 @@
+/* gnu.classpath.tools.gjdoc.expr.Type
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class Type
+{
+ public static final Type LONG = new Type(Long.TYPE);
+ public static final Type INTEGER = new Type(Integer.TYPE);
+ public static final Type BOOLEAN = new Type(Boolean.TYPE);
+ public static final Type DOUBLE = new Type(Double.TYPE);
+ public static final Type FLOAT = new Type(Float.TYPE);
+ public static final Type CHAR = new Type(Character.TYPE);
+ public static final Type BYTE = new Type(Byte.TYPE);
+ public static final Type SHORT = new Type(Short.TYPE);
+ public static final Type VOID = new Type(Void.TYPE);
+ public static final Type STRING = new Type(String.class);
+ public static final Type NULL = new Type(null);
+
+ private Class clazz;
+
+ private Type(Class clazz)
+ {
+ this.clazz = clazz;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.java
new file mode 100644
index 000000000..c434ae870
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.java
@@ -0,0 +1,87 @@
+/* gnu.classpath.tools.gjdoc.expr.TypeCastExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+class TypeCastExpression
+ extends UnaryExpression
+{
+ private Type type;
+
+ public TypeCastExpression(Type type, Expression expr)
+ {
+ super(expr);
+ this.type = type;
+ }
+
+ public ConstantExpression evaluate(Context context)
+ throws IllegalExpressionException
+ {
+ ConstantExpression value = expr.evaluate(context);
+
+ if (Type.BYTE == type) {
+ return new ConstantByte(value.asNumber().byteValue());
+ }
+ else if (Type.SHORT == type) {
+ return new ConstantShort(value.asNumber().shortValue());
+ }
+ else if (Type.INTEGER == type) {
+ return new ConstantInteger(value.asNumber().intValue());
+ }
+ else if (Type.LONG == type) {
+ return new ConstantLong(value.asNumber().longValue());
+ }
+ else if (Type.CHAR == type) {
+ return new ConstantChar((char)value.asNumber().intValue());
+ }
+ else if (Type.FLOAT == type) {
+ return new ConstantFloat((float)value.asNumber().intValue());
+ }
+ else if (Type.DOUBLE == type) {
+ return new ConstantDouble((float)value.asNumber().intValue());
+ }
+ else if (Type.BOOLEAN == type && Type.BOOLEAN == value.getType()) {
+ return value;
+ }
+ else if (Type.STRING == type && Type.STRING == value.getType()) {
+ return value;
+ }
+ else {
+ throw new IllegalExpressionException("Cannot cast " + value.getType() + " to " + type);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnaryExpression.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnaryExpression.java
new file mode 100644
index 000000000..33befcb84
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnaryExpression.java
@@ -0,0 +1,49 @@
+/* gnu.classpath.tools.gjdoc.expr.UnaryExpression
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+abstract class UnaryExpression
+ implements Expression
+{
+ protected Expression expr;
+
+ protected UnaryExpression(Expression expr)
+ {
+ this.expr = expr;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.java b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.java
new file mode 100644
index 000000000..894a71716
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.java
@@ -0,0 +1,47 @@
+/* gnu.classpath.tools.gjdoc.expr.UnknownIdentifierException
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc.expr;
+
+public class UnknownIdentifierException
+ extends IllegalExpressionException
+{
+ public UnknownIdentifierException(String identifier)
+ {
+ super(identifier);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/java-expression.g b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/java-expression.g
new file mode 100644
index 000000000..4a21a8618
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/java-expression.g
@@ -0,0 +1,471 @@
+/*
+ * This grammar is derived from the Java 1.3 Recognizer
+ * (http://www.antlr.org/grammar/java/java.g) by Mitchell, Parr, Lilley,
+ * Stanchfield, Mohnen, Williams, Jacobs, Messick and Pybus, Version
+ * 1.21.
+ *
+ * This grammar recognizes simple Java expressions. The following
+ * language elements are NOT supported:
+ *
+ * - type casts to non-primitive types
+ * - method calls
+ * - constructor calls
+ * - array access
+ * - comma expressions
+ * - increment and decrement operators (both prefix/postfix)
+ * - expressions involving constant classes (Abc.class)
+ */
+
+header {
+ package gnu.classpath.tools.gjdoc.expr;
+}
+
+class JavaRecognizer extends Parser;
+options {
+ k = 2; // two token lookahead
+ exportVocab=Java; // Call its vocabulary "Java"
+ codeGenMakeSwitchThreshold = 2; // Some optimizations
+ codeGenBitsetTestThreshold = 3;
+ defaultErrorHandler = false; // Don't generate parser error handlers
+ buildAST = true;
+}
+
+tokens {
+ BLOCK; MODIFIERS; OBJBLOCK; SLIST; CTOR_DEF; METHOD_DEF; VARIABLE_DEF;
+ INSTANCE_INIT; STATIC_INIT; TYPE; CLASS_DEF; INTERFACE_DEF;
+ PACKAGE_DEF; ARRAY_DECLARATOR; EXTENDS_CLAUSE; IMPLEMENTS_CLAUSE;
+ PARAMETERS; PARAMETER_DEF; LABELED_STAT; TYPECAST; INDEX_OP;
+ POST_INC; POST_DEC; METHOD_CALL; EXPR; ARRAY_INIT;
+ IMPORT; UNARY_MINUS; UNARY_PLUS; CASE_GROUP; ELIST; FOR_INIT; FOR_CONDITION;
+ FOR_ITERATOR; EMPTY_STAT; FINAL="final"; ABSTRACT="abstract";
+ STRICTFP="strictfp"; SUPER_CTOR_CALL; CTOR_CALL;
+}
+
+// A builtin type specification is a builtin type with possible brackets
+// afterwards (which would make it an array type).
+builtInTypeSpec[boolean addImagNode] returns [Type t = null]
+ : t=builtInType (lb:LBRACK^ {#lb.setType(ARRAY_DECLARATOR);} RBRACK!)*
+ {
+ if ( addImagNode ) {
+ #builtInTypeSpec = #(#[TYPE,"TYPE"], #builtInTypeSpec);
+ }
+ }
+ ;
+
+// A type name. which is either a (possibly qualified) class name or
+// a primitive (builtin) type
+type returns [Type t]
+ : t=builtInType
+ ;
+
+// The primitive types.
+builtInType returns [Type t = null]
+ : "void" {t=Type.VOID;}
+ | "boolean" {t=Type.BOOLEAN;}
+ | "byte" {t=Type.BYTE;}
+ | "char" {t=Type.CHAR;}
+ | "short" {t=Type.SHORT;}
+ | "int" {t=Type.INTEGER;}
+ | "float"{t=Type.FLOAT;}
+ | "long" {t=Type.LONG;}
+ | "double" {t=Type.DOUBLE;}
+ | "String" {t=Type.STRING;}
+ ;
+
+// A (possibly-qualified) java identifier. We start with the first IDENT
+// and expand its name by adding dots and following IDENTS
+identifier returns [String s = null;]
+ : i:IDENT {s=i.getText();} ( DOT^ i2:IDENT {s+="."+i2.getText();} )*
+ ;
+
+expression returns [Expression e = null]
+ : e=conditionalExpression EOF!
+ ;
+
+// conditional test (level 12)
+conditionalExpression returns [Expression e = null] { Expression a,b,c; }
+ : e=logicalOrExpression
+ ( QUESTION^ b=conditionalExpression COLON! c=conditionalExpression {e=new ConditionalExpression(e,b,c);} )?
+ ;
+
+
+// logical or (||) (level 11)
+logicalOrExpression returns [Expression e = null] { Expression a,b; }
+ : e=logicalAndExpression (LOR^ b=logicalAndExpression {e=new LogicalOrExpression(e,b);})*
+ ;
+
+
+// logical and (&&) (level 10)
+logicalAndExpression returns [Expression e = null] { Expression a,b; }
+ : e=inclusiveOrExpression (LAND^ b=inclusiveOrExpression {e=new LogicalAndExpression(e,b);})*
+ ;
+
+
+// bitwise or non-short-circuiting or (|) (level 9)
+inclusiveOrExpression returns [Expression e = null] { Expression a,b; }
+ : e=exclusiveOrExpression (BOR^ b=exclusiveOrExpression {e=new InclusiveOrExpression(e,b);})*
+ ;
+
+
+// exclusive or (^) (level 8)
+exclusiveOrExpression returns [Expression e = null] { Expression a,b; }
+ : e=andExpression (BXOR^ b=andExpression {e=new ExclusiveOrExpression(e,b);})*
+ ;
+
+
+// bitwise or non-short-circuiting and (&) (level 7)
+andExpression returns [Expression e = null] { Expression a,b; }
+ : e=equalityExpression (BAND^ b=equalityExpression {e=new AndExpression(e,b);})*
+ ;
+
+
+// equality/inequality (==/!=) (level 6)
+equalityExpression returns [Expression e = null] { Expression a,b; }
+ : e=relationalExpression ((NOT_EQUAL^ a=relationalExpression {e=new NotEqualExpression(e,a);} | EQUAL^ a=relationalExpression {e=new EqualExpression(e,a);}))*
+ ;
+
+
+// boolean relational expressions (level 5)
+relationalExpression returns [Expression e = null] { Expression a,b; }
+ : e=shiftExpression
+ ( ( ( LT^ a=shiftExpression {e=new LessThanExpression(e,a);}
+ | GT^ a=shiftExpression {e=new GreaterThanExpression(e,a);}
+ | LE^ a=shiftExpression {e=new LessThanOrEqualExpression(e,a);}
+ | GE^ a=shiftExpression {e=new GreaterThanOrEqualExpression(e,a);}
+ )
+
+ )*
+ )
+ ;
+
+
+// bit shift expressions (level 4)
+shiftExpression returns [Expression e = null] { Expression a,b; }
+ : e=additiveExpression ((SL^ a=additiveExpression {e=new ShiftLeftExpression(e,a);} | SR^ a=additiveExpression {e=new ShiftRightExpression(e,a);} | BSR^ a=additiveExpression {e=new BitShiftRightExpression(e,a);}))*
+ ;
+
+
+// binary addition/subtraction (level 3)
+additiveExpression returns [Expression e = null] { Expression a,b; }
+ : e=multiplicativeExpression ((PLUS^ a=multiplicativeExpression {e=new AdditionExpression(e,a);} | MINUS^ a=multiplicativeExpression {e=new SubtractionExpression(e,a);}))*
+ ;
+
+
+// multiplication/division/modulo (level 2)
+multiplicativeExpression returns [Expression e = null] { Expression a,b; }
+ : e=unaryExpression ((STAR^ a=unaryExpression {e=new MultiplicationExpression(e,a);} | DIV^ a=unaryExpression {e=new DivisionExpression(e,a);} | MOD^ a=unaryExpression {e=new ModuloExpression(e,a);} ))*
+ ;
+
+
+unaryExpression returns [Expression e = null] { Expression a,b; }
+ : MINUS^ {#MINUS.setType(UNARY_MINUS);} a=unaryExpression {e=new NegateExpression(a);}
+ | PLUS^ {#PLUS.setType(UNARY_PLUS);} e=unaryExpression
+ | e=unaryExpressionNotPlusMinus
+ ;
+
+unaryExpressionNotPlusMinus returns [Expression e = null] { Expression a; Type t; }
+ : BNOT^ a=unaryExpression {e=new NotExpression(a);}
+ | LNOT^ a=unaryExpression {e=new LogicalNotExpression(a);}
+
+ // use predicate to skip cases like: (int.class)
+ | (LPAREN builtInTypeSpec[true] RPAREN) =>
+ lpb:LPAREN^ {#lpb.setType(TYPECAST);} t=builtInTypeSpec[true] RPAREN!
+ a=unaryExpression {e=new TypeCastExpression(t,a);}
+
+ | e=primaryExpression
+ ;
+
+// the basic element of an expression
+primaryExpression returns [Expression e = null; String i = null;]
+ : e=constant
+ | i=identifier {e=new IdentifierExpression(i);}
+ | "true" { e=new ConstantBoolean(true); }
+ | "false" { e=new ConstantBoolean(false); }
+ | "null" { e=new ConstantNull(); }
+ | LPAREN! e=conditionalExpression RPAREN!
+ ;
+
+/** Match a, a.b.c refs
+ */
+identPrimary returns [Expression e = null]
+ : IDENT
+ (
+ options {
+ // .ident could match here or in postfixExpression.
+ // We do want to match here. Turn off warning.
+ greedy=true;
+ }
+ : DOT^ IDENT
+ )*
+ ;
+
+constant returns [Expression e = null]
+ : l1:NUM_INT {e=new ConstantInteger(l1.getText());}
+ | l2:CHAR_LITERAL {e=new ConstantChar(l2.getText());}
+ | l3:STRING_LITERAL {e=new ConstantString(l3.getText().substring(1, l3.getText().length()-1)); }
+ | l4:NUM_FLOAT {e=new ConstantFloat(l4.getText());}
+ | l5:NUM_LONG {e=new ConstantLong(l5.getText());}
+ | l6:NUM_DOUBLE {e=new ConstantDouble(l6.getText());}
+ ;
+
+
+//----------------------------------------------------------------------------
+// The Java scanner
+//----------------------------------------------------------------------------
+class JavaLexer extends Lexer;
+
+options {
+ exportVocab=Java; // call the vocabulary "Java"
+ testLiterals=false; // don't automatically test for literals
+ k=4; // four characters of lookahead
+ charVocabulary='\u0003'..'\uFFFF';
+ // without inlining some bitset tests, couldn't do unicode;
+ // I need to make ANTLR generate smaller bitsets; see
+ // bottom of JavaLexer.java
+ codeGenBitsetTestThreshold=20;
+}
+
+
+
+// OPERATORS
+QUESTION : '?' ;
+LPAREN : '(' ;
+RPAREN : ')' ;
+LBRACK : '[' ;
+RBRACK : ']' ;
+LCURLY : '{' ;
+RCURLY : '}' ;
+COLON : ':' ;
+COMMA : ',' ;
+//DOT : '.' ;
+ASSIGN : '=' ;
+EQUAL : "==" ;
+LNOT : '!' ;
+BNOT : '~' ;
+NOT_EQUAL : "!=" ;
+DIV : '/' ;
+DIV_ASSIGN : "/=" ;
+PLUS : '+' ;
+PLUS_ASSIGN : "+=" ;
+INC : "++" ;
+MINUS : '-' ;
+MINUS_ASSIGN : "-=" ;
+DEC : "--" ;
+STAR : '*' ;
+STAR_ASSIGN : "*=" ;
+MOD : '%' ;
+MOD_ASSIGN : "%=" ;
+SR : ">>" ;
+SR_ASSIGN : ">>=" ;
+BSR : ">>>" ;
+BSR_ASSIGN : ">>>=" ;
+GE : ">=" ;
+GT : ">" ;
+SL : "<<" ;
+SL_ASSIGN : "<<=" ;
+LE : "<=" ;
+LT : '<' ;
+BXOR : '^' ;
+BXOR_ASSIGN : "^=" ;
+BOR : '|' ;
+BOR_ASSIGN : "|=" ;
+LOR : "||" ;
+BAND : '&' ;
+BAND_ASSIGN : "&=" ;
+LAND : "&&" ;
+SEMI : ';' ;
+
+
+// Whitespace -- ignored
+WS : ( ' '
+ | '\t'
+ | '\f'
+ // handle newlines
+ | ( options {generateAmbigWarnings=false;}
+ : "\r\n" // Evil DOS
+ | '\r' // Macintosh
+ | '\n' // Unix (the right way)
+ )
+ { newline(); }
+ )+
+ { _ttype = Token.SKIP; }
+ ;
+
+// Single-line comments
+SL_COMMIT
+ : "//"
+ (~('\n'|'\r'))* ('\n'|'\r'('\n')?)
+ {$setType(Token.SKIP); newline();}
+ ;
+
+// multiple-line comments
+ML_COMMENT
+ : "/*"
+ ( /* '\r' '\n' can be matched in one alternative or by matching
+ '\r' in one iteration and '\n' in another. I am trying to
+ handle any flavor of newline that comes in, but the language
+ that allows both "\r\n" and "\r" and "\n" to all be valid
+ newline is ambiguous. Consequently, the resulting grammar
+ must be ambiguous. I'm shutting this warning off.
+ */
+ options {
+ generateAmbigWarnings=false;
+ }
+ :
+ { LA(2)!='/' }? '*'
+ | '\r' '\n' {newline();}
+ | '\r' {newline();}
+ | '\n' {newline();}
+ | ~('*'|'\n'|'\r')
+ )*
+ "*/"
+ {$setType(Token.SKIP);}
+ ;
+
+
+// character literals
+CHAR_LITERAL
+ : '\'' ( ESC | ~('\''|'\n'|'\r'|'\\') ) '\''
+ ;
+
+// string literals
+STRING_LITERAL
+ : '"' (ESC|~('"'|'\\'|'\n'|'\r'))* '"'
+ ;
+
+
+// escape sequence -- note that this is protected; it can only be called
+// from another lexer rule -- it will not ever directly return a token to
+// the parser
+// There are various ambiguities hushed in this rule. The optional
+// '0'...'9' digit matches should be matched here rather than letting
+// them go back to STRING_LITERAL to be matched. ANTLR does the
+// right thing by matching immediately; hence, it's ok to shut off
+// the FOLLOW ambig warnings.
+protected
+ESC
+ : '\\'
+ ( 'n'
+ | 'r'
+ | 't'
+ | 'b'
+ | 'f'
+ | '"'
+ | '\''
+ | '\\'
+ | ('u')+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ | '0'..'3'
+ (
+ options {
+ warnWhenFollowAmbig = false;
+ }
+ : '0'..'7'
+ (
+ options {
+ warnWhenFollowAmbig = false;
+ }
+ : '0'..'7'
+ )?
+ )?
+ | '4'..'7'
+ (
+ options {
+ warnWhenFollowAmbig = false;
+ }
+ : '0'..'7'
+ )?
+ )
+ ;
+
+
+// hexadecimal digit (again, note it's protected!)
+protected
+HEX_DIGIT
+ : ('0'..'9'|'A'..'F'|'a'..'f')
+ ;
+
+
+// a dummy rule to force vocabulary to be all characters (except special
+// ones that ANTLR uses internally (0 to 2)
+protected
+VOCAB
+ : '\3'..'\377'
+ ;
+
+
+// an identifier. Note that testLiterals is set to true! This means
+// that after we match the rule, we look in the literals table to see
+// if it's a literal or really an identifer
+IDENT
+ options {testLiterals=true;}
+ : ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'$')*
+ ;
+
+
+// a numeric literal
+NUM_INT
+ {boolean isDecimal=false; Token t=null;}
+ : '.' {_ttype = DOT;}
+ ( ('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})?
+ {
+ if (t != null && t.getText().toUpperCase().indexOf('F')>=0) {
+ _ttype = NUM_FLOAT;
+ }
+ else {
+ _ttype = NUM_DOUBLE; // assume double
+ }
+ }
+ )?
+
+ | ( '0' {isDecimal = true;} // special case for just '0'
+ ( ('x'|'X')
+ ( // hex
+ // the 'e'|'E' and float suffix stuff look
+ // like hex digits, hence the (...)+ doesn't
+ // know when to stop: ambig. ANTLR resolves
+ // it correctly by matching immediately. It
+ // is therefor ok to hush warning.
+ options {
+ warnWhenFollowAmbig=false;
+ }
+ : HEX_DIGIT
+ )+
+
+ | //float or double with leading zero
+ (('0'..'9')+ ('.'|EXPONENT|FLOAT_SUFFIX)) => ('0'..'9')+
+
+ | ('0'..'7')+ // octal
+ )?
+ | ('1'..'9') ('0'..'9')* {isDecimal=true;} // non-zero decimal
+ )
+ ( ('l'|'L') { _ttype = NUM_LONG; }
+
+ // only check to see if it's a float if looks like decimal so far
+ | {isDecimal}?
+ ( '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX {t=f2;})?
+ | EXPONENT (f3:FLOAT_SUFFIX {t=f3;})?
+ | f4:FLOAT_SUFFIX {t=f4;}
+ )
+ {
+ if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0) {
+ _ttype = NUM_FLOAT;
+ }
+ else {
+ _ttype = NUM_DOUBLE; // assume double
+ }
+ }
+ )?
+ ;
+
+
+// a couple protected methods to assist in matching floating point numbers
+protected
+EXPONENT
+ : ('e'|'E') ('+'|'-')? ('0'..'9')+
+ ;
+
+
+protected
+FLOAT_SUFFIX
+ : 'f'|'F'|'d'|'D'
+ ;
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java
new file mode 100644
index 000000000..6363157ae
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java
@@ -0,0 +1,51 @@
+/* Action.java - an action taken by the jar driver
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.io.IOException;
+
+public abstract class Action
+{
+ protected Action()
+ {
+ }
+
+ public abstract void run(Main parameters)
+ throws IOException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java
new file mode 100644
index 000000000..be8d2a16f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java
@@ -0,0 +1,251 @@
+/* Creator.java - create a new jar file
+ Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+
+public class Creator
+ extends Action
+{
+ JarOutputStream outputStream;
+ HashSet<String> writtenItems = new HashSet<String>();
+ // The manifest to use, or null if we don't want a manifest.
+ Manifest manifest;
+
+ private long copyFile(CRC32 crc, InputStream is, OutputStream output)
+ throws IOException
+ {
+ byte[] buffer = new byte[1024];
+ long size = 0;
+ while (true)
+ {
+ int len = is.read(buffer);
+ if (len == - 1)
+ break;
+ size += len;
+ output.write(buffer, 0, len);
+ crc.update(buffer, 0, len);
+ }
+ output.close();
+ return size;
+ }
+
+ protected void writeFile(boolean isDirectory, InputStream inputFile,
+ String filename, boolean verbose)
+ throws IOException
+ {
+ if (writtenItems.contains(filename))
+ {
+ if (verbose)
+ {
+ String msg = MessageFormat.format(Messages.getString("Creator.Ignoring"), //$NON-NLS-1$
+ new Object[] { filename });
+ System.err.println(msg);
+ }
+ return;
+ }
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ CRC32 crc = new CRC32();
+ long size;
+ if (isDirectory)
+ {
+ size = 0;
+ }
+ else
+ {
+ size = copyFile(crc, inputFile, out);
+ }
+
+ ZipEntry entry = new ZipEntry(filename);
+ entry.setCrc(crc.getValue());
+ entry.setSize(size);
+
+ outputStream.putNextEntry(entry);
+ out.writeTo(outputStream);
+ outputStream.closeEntry();
+ writtenItems.add(filename);
+
+ if (verbose)
+ {
+ long csize = entry.getCompressedSize();
+ long perc;
+ if (size == 0)
+ perc = 0;
+ else
+ perc = 100 - (100 * csize) / size;
+ String msg = MessageFormat.format(Messages.getString("Creator.Adding"), //$NON-NLS-1$
+ new Object[]
+ {
+ filename,
+ Long.valueOf(size),
+ Long.valueOf(entry.getSize()),
+ Long.valueOf(perc)
+ });
+ System.err.println(msg);
+ }
+ }
+
+ protected void writeFile(File file, String filename, boolean verbose)
+ throws IOException
+ {
+ boolean isDirectory = file.isDirectory();
+ if (isDirectory)
+ {
+ if (filename.charAt(filename.length() - 1) != '/')
+ filename += '/';
+ writeFile(isDirectory, null, filename, verbose);
+ }
+ else
+ {
+ InputStream inputStream = new FileInputStream(file);
+ writeFile(isDirectory, inputStream, filename, verbose);
+ inputStream.close();
+ }
+ }
+
+ private void addEntries(ArrayList<Entry> result, Entry entry)
+ {
+ if (entry.file.isDirectory())
+ {
+ String name = entry.name;
+ if (name.charAt(name.length() - 1) != '/')
+ {
+ name += '/';
+ entry = new Entry(entry.file, name);
+ }
+ result.add(entry);
+ String[] files = entry.file.list();
+ for (int i = 0; i < files.length; ++i)
+ addEntries(result, new Entry(new File(entry.file, files[i]),
+ entry.name + files[i]));
+ }
+ else
+ result.add(entry);
+ }
+
+ private ArrayList<Entry> getAllEntries(Main parameters)
+ {
+ ArrayList<Entry> allEntries = new ArrayList<Entry>();
+ for (Entry entry : parameters.entries)
+ addEntries(allEntries, entry);
+ return allEntries;
+ }
+
+ private void writeCommandLineEntries(Main parameters)
+ throws IOException
+ {
+ // We've already written the manifest, make sure to mark it.
+ writtenItems.add("META-INF/"); //$NON-NLS-1$
+ writtenItems.add(JarFile.MANIFEST_NAME);
+
+ ArrayList<Entry> allEntries = getAllEntries(parameters);
+ for (Entry entry : allEntries)
+ writeFile(entry.file, entry.name, parameters.verbose);
+ }
+
+ protected Manifest createManifest(Main parameters)
+ throws IOException
+ {
+ if (! parameters.wantManifest)
+ return null;
+ if (parameters.manifestFile != null)
+ {
+ // User specified a manifest file.
+ InputStream contents = new FileInputStream(parameters.manifestFile);
+ return new Manifest(contents);
+ }
+ return new Manifest();
+ }
+
+ protected void writeCommandLineEntries(Main parameters, OutputStream os)
+ throws IOException
+ {
+ manifest = createManifest(parameters);
+ /* If no version is specified, provide the same manifest version default
+ * as Sun's jar tool */
+ if (parameters.wantManifest)
+ {
+ Attributes attr = manifest.getMainAttributes();
+ if (attr.getValue(Attributes.Name.MANIFEST_VERSION) == null)
+ attr.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
+ attr.putValue("Created-By", System.getProperty("java.version") +
+ " (" + System.getProperty("java.vendor") + ")");
+ }
+ outputStream = new JarOutputStream(os, manifest);
+ // FIXME: this sets the method too late for the manifest file.
+ outputStream.setMethod(parameters.storageMode);
+ writeCommandLineEntries(parameters);
+ }
+
+ protected void close() throws IOException
+ {
+ outputStream.finish();
+ outputStream.close();
+ }
+
+ public void run(Main parameters) throws IOException
+ {
+ if (parameters.archiveFile == null || parameters.archiveFile.equals("-")) //$NON-NLS-1$
+ writeCommandLineEntries(parameters, System.out);
+ else
+ {
+ OutputStream os
+ = new BufferedOutputStream(new FileOutputStream(parameters.archiveFile));
+ writeCommandLineEntries(parameters, os);
+ }
+ close();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java
new file mode 100644
index 000000000..b9108798a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java
@@ -0,0 +1,70 @@
+/* Entry.java - represent a single file to write to a jar
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.io.File;
+
+public class Entry
+{
+ public File file;
+
+ public String name;
+
+ public Entry(File file, String name)
+ {
+ this.file = file;
+
+ /* Removes any './' prefixes automatically. Those caused trouble
+ * in (boot) classpath use-cases. See #32516.
+ */
+ int start = 0;
+ while (name.length() > start + 2
+ && name.codePointAt(start) == '.'
+ && name.codePointAt(start + 1) == File.separatorChar)
+ start += 2;
+
+ this.name = name.substring(start);
+ }
+
+ public Entry(File file)
+ {
+ this(file, file.toString());
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java
new file mode 100644
index 000000000..203ff0566
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java
@@ -0,0 +1,127 @@
+/* Extractor.java - action to extract from a jar file
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class Extractor
+ extends Action
+{
+ // This is a set of all the items specified on the command line.
+ private WorkSet allItems;
+
+ private void copyFile(InputStream input, File output) throws IOException
+ {
+ FileOutputStream os = new FileOutputStream(output);
+ byte[] buffer = new byte[1024];
+ while (true)
+ {
+ int len = input.read(buffer);
+ if (len == - 1)
+ break;
+ os.write(buffer, 0, len);
+ }
+ os.close();
+ }
+
+ public void run(Main parameters) throws IOException
+ {
+ // Figure out what we want to extract.
+ allItems = new WorkSet(parameters.entries);
+ // Open the input file.
+ ZipInputStream zis;
+ File zfile = parameters.archiveFile;
+ if (zfile == null || "-".equals(zfile.getName())) //$NON-NLS-1$
+ zis = new ZipInputStream(System.in);
+ else
+ {
+ InputStream ins = new BufferedInputStream(new FileInputStream(zfile));
+ zis = new ZipInputStream(ins);
+ }
+ // Extract stuff.
+ while (true)
+ {
+ ZipEntry entry = zis.getNextEntry();
+ if (entry == null)
+ break;
+ if (! allItems.contains(entry.getName()))
+ continue;
+ File file = new File(entry.getName());
+ if (entry.isDirectory())
+ {
+ if (file.mkdirs())
+ {
+ if (parameters.verbose)
+ {
+ String msg
+ = MessageFormat.format(Messages.getString("Extractor.Created"), //$NON-NLS-1$
+ new Object[] { file });
+ System.err.println(msg);
+ }
+ }
+ continue;
+ }
+
+ File parent = file.getParentFile();
+ if (parent != null)
+ parent.mkdirs();
+
+ copyFile(zis, file);
+
+ if (parameters.verbose)
+ {
+ String fmt;
+ if (entry.getMethod() == ZipEntry.STORED)
+ fmt = Messages.getString("Extractor.Extracted"); //$NON-NLS-1$
+ else
+ fmt = Messages.getString("Extractor.Inflated"); //$NON-NLS-1$
+ String msg = MessageFormat.format(fmt, new Object[] { file });
+ System.err.println(msg);
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java
new file mode 100644
index 000000000..ae79b26e9
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java
@@ -0,0 +1,142 @@
+/* Indexer.java -- add index.list file to jar
+ Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import gnu.java.net.IndexListParser;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.MessageFormat;
+import java.util.Enumeration;
+import java.util.LinkedHashSet;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+public class Indexer
+ extends Updater
+{
+ private void indexJarFile(StringBuilder result, File fileName,
+ boolean verbose)
+ throws IOException
+ {
+ if (verbose)
+ {
+ String msg = MessageFormat.format(Messages.getString("Indexer.Indexing"), //$NON-NLS-1$
+ new Object[] { fileName });
+ System.err.println(msg);
+ }
+ JarFile jf = new JarFile(fileName);
+
+ // Index the files in this jar.
+ // The results look a little better if we keep them
+ // in insertion order.
+ LinkedHashSet<String> entries = new LinkedHashSet<String>();
+ Enumeration e = jf.entries();
+ while (e.hasMoreElements())
+ {
+ JarEntry entry = (JarEntry) e.nextElement();
+ String name = entry.getName();
+ if (name.startsWith("META-INF/")) //$NON-NLS-1$
+ continue;
+ int index = name.lastIndexOf('/');
+ if (index != -1)
+ name = name.substring(0, index);
+ entries.add(name);
+ }
+ if (! entries.isEmpty())
+ {
+ result.append(fileName);
+ // Any line ending will do.
+ result.append('\n');
+ for (String s : entries)
+ {
+ result.append(s);
+ result.append('\n');
+ }
+ // Paragraph break.
+ result.append('\n');
+ }
+
+ // Now read pointed-to jars.
+ Manifest m = jf.getManifest();
+ if (m != null)
+ {
+ File parent = fileName.getParentFile();
+ Attributes attrs = m.getMainAttributes();
+ String jars = attrs.getValue(Attributes.Name.CLASS_PATH);
+ if (jars != null)
+ {
+ StringTokenizer st = new StringTokenizer(jars, " "); //$NON-NLS-1$
+ while (st.hasMoreTokens())
+ {
+ String name = st.nextToken();
+ indexJarFile(result, new File(parent, name), verbose);
+ }
+ }
+ }
+
+ jf.close();
+ }
+
+ protected void writeCommandLineEntries(Main parameters, OutputStream os)
+ throws IOException
+ {
+ // This is a pretty lame design. We know the super call will
+ // only have side effects and won't actually write anything important.
+ super.writeCommandLineEntries(parameters, os);
+
+ // Now compute our index file and write it.
+ StringBuilder contents = new StringBuilder();
+ indexJarFile(contents, parameters.archiveFile, parameters.verbose);
+ if (contents.length() != 0)
+ {
+ // Insert in reverse order to avoid computing anything.
+ contents.insert(0, "1.0\n\n"); //$NON-NLS-1$
+ contents.insert(0, IndexListParser.JAR_INDEX_VERSION_KEY);
+ ByteArrayInputStream in
+ = new ByteArrayInputStream(contents.toString().getBytes());
+ writeFile(false, in, IndexListParser.JAR_INDEX_FILE, parameters.verbose);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java
new file mode 100644
index 000000000..98275f789
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java
@@ -0,0 +1,112 @@
+/* Lister.java - action to list contents of a jar file
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class Lister
+ extends Action
+{
+ private WorkSet allItems;
+
+ private long readUntilEnd(InputStream is) throws IOException
+ {
+ byte[] buffer = new byte[5 * 1024];
+ long result = 0;
+ while (true)
+ {
+ int r = is.read(buffer);
+ if (r == -1)
+ break;
+ result += r;
+ }
+ return result;
+ }
+
+ private void listJar(ZipInputStream zis, boolean verbose) throws IOException
+ {
+ MessageFormat format = null;
+ if (verbose)
+ format = new MessageFormat(" {0,date,E M dd HH:mm:ss z yyyy} {1}");
+ while (true)
+ {
+ ZipEntry entry = zis.getNextEntry();
+ if (entry == null)
+ break;
+ if (! allItems.contains(entry.getName()))
+ continue;
+ if (verbose)
+ {
+ // Read the stream; entry.getSize() is unreliable.
+ // (Also, we're just going to read it anyway.)
+ long size = readUntilEnd(zis);
+ // No easy way to right-justify the size using
+ // MessageFormat -- how odd.
+ String s = " " + size;
+ int index = Math.min(s.length() - 5, 5);
+ System.out.print(s.substring(index));
+ Object[] values = new Object[] { new Date(entry.getTime()),
+ entry.getName() };
+ System.out.println(format.format(values));
+ }
+ else
+ System.out.println(entry.getName());
+ }
+ }
+
+ public void run(Main parameters) throws IOException
+ {
+ allItems = new WorkSet(parameters.entries);
+ File file = parameters.archiveFile;
+ ZipInputStream zis;
+ if (file == null || "-".equals(file.getName()))
+ zis = new ZipInputStream(System.in);
+ else
+ zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
+ listJar(zis, parameters.verbose);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java
new file mode 100644
index 000000000..34ef928fe
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java
@@ -0,0 +1,293 @@
+/* Main.java - jar program main()
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.zip.ZipOutputStream;
+
+public class Main
+{
+ /** The mode of operation. This is the class representing
+ * the action; we make a new instance before using it. It
+ * must be a subclass of Action. 'null' means the mode
+ * has not yet been set. */
+ Class operationMode;
+
+ /** The archive file name. */
+ File archiveFile;
+
+ /** The zip storage mode. */
+ int storageMode = ZipOutputStream.DEFLATED;
+
+ /** True if we should read file names from stdin. */
+ boolean readNamesFromStdin = false;
+
+ /** True for verbose mode. */
+ boolean verbose = false;
+
+ /** True if we want a manifest file. */
+ boolean wantManifest = true;
+
+ /** Name of manifest file to use. */
+ File manifestFile;
+
+ /** A list of Entry objects, each describing a file to write. */
+ ArrayList<Entry> entries = new ArrayList<Entry>();
+
+ /** Used only while parsing, holds the first argument for -C. */
+ String changedDirectory;
+
+ void setArchiveFile(String filename) throws OptionException
+ {
+ if (archiveFile != null)
+ {
+ String fmt = MessageFormat.format(Messages.getString("Main.ArchiveAlreadySet"), //$NON-NLS-1$
+ new Object[] { archiveFile });
+ throw new OptionException(fmt);
+ }
+ archiveFile = new File(filename);
+ }
+
+ class HandleFile
+ extends FileArgumentCallback
+ {
+ public void notifyFile(String fileArgument)
+ {
+ Entry entry;
+ if (changedDirectory != null)
+ {
+ entry = new Entry(new File(changedDirectory, fileArgument),
+ fileArgument);
+ changedDirectory = null;
+ }
+ else
+ entry = new Entry(new File(fileArgument));
+ entries.add(entry);
+ }
+ }
+
+ // An option that knows how to set the operation mode.
+ private class ModeOption
+ extends Option
+ {
+ private Class mode;
+
+ public ModeOption(char shortName, String description, Class mode)
+ {
+ super(shortName, description);
+ this.mode = mode;
+ }
+
+ public ModeOption(char shortName, String description, String argName,
+ Class mode)
+ {
+ super(shortName, description, argName);
+ this.mode = mode;
+ }
+
+ public void parsed(String argument) throws OptionException
+ {
+ if (operationMode != null)
+ throw new OptionException(Messages.getString("Main.ModeAlreaySet")); //$NON-NLS-1$
+ operationMode = mode;
+ // We know this is only the case for -i.
+ if (argument != null)
+ setArchiveFile(argument);
+ }
+ }
+
+ private class JarParser extends ClasspathToolParser
+ {
+ public JarParser(String name)
+ {
+ super(name);
+ }
+
+ protected void validate() throws OptionException
+ {
+ if (operationMode == null)
+ throw new OptionException(Messages.getString("Main.MustSpecify")); //$NON-NLS-1$
+ if (changedDirectory != null)
+ throw new OptionException(Messages.getString("Main.TwoArgsReqd")); //$NON-NLS-1$
+ if (! wantManifest && manifestFile != null)
+ throw new OptionException(Messages.getString("Main.CantHaveBoth")); //$NON-NLS-1$
+ if (operationMode == Indexer.class)
+ {
+ // Some extra validation for -i.
+ if (! entries.isEmpty())
+ throw new OptionException(Messages.getString("Main.NoFilesWithi")); //$NON-NLS-1$
+ if (! wantManifest)
+ throw new OptionException(Messages.getString("Main.NoMAndi")); //$NON-NLS-1$
+ if (manifestFile != null)
+ throw new OptionException(Messages.getString("Main.AnotherNomAndi")); //$NON-NLS-1$
+ }
+ }
+ }
+
+ private ClasspathToolParser initializeParser()
+ {
+ ClasspathToolParser p = new JarParser("jar"); //$NON-NLS-1$
+ p.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ OptionGroup grp = new OptionGroup(Messages.getString("Main.OpMode")); //$NON-NLS-1$
+ grp.add(new ModeOption('c', Messages.getString("Main.Create"), Creator.class)); //$NON-NLS-1$
+ grp.add(new ModeOption('x', Messages.getString("Main.Extract"), Extractor.class)); //$NON-NLS-1$
+ grp.add(new ModeOption('t', Messages.getString("Main.List"), Lister.class)); //$NON-NLS-1$
+ grp.add(new ModeOption('u', Messages.getString("Main.Update"), Updater.class)); //$NON-NLS-1$
+ // Note that -i works in-place and explicitly requires a file name.
+ grp.add(new ModeOption('i', Messages.getString("Main.Index"), Messages.getString("Main.FileArg"), Indexer.class)); //$NON-NLS-1$ //$NON-NLS-2$
+ p.add(grp);
+
+ grp = new OptionGroup(Messages.getString("Main.OpMods")); //$NON-NLS-1$
+ grp.add(new Option('f', Messages.getString("Main.ArchiveName"), Messages.getString("Main.FileArg2")) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ setArchiveFile(argument);
+ }
+ });
+ grp.add(new Option('0', Messages.getString("Main.NoZip")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ storageMode = ZipOutputStream.STORED;
+ }
+ });
+ grp.add(new Option('v', Messages.getString("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ grp.add(new Option('M', Messages.getString("Main.NoManifest")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ wantManifest = false;
+ }
+ });
+ grp.add(new Option('m', Messages.getString("Main.ManifestName"), Messages.getString("Main.ManifestArgName")) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ manifestFile = new File(argument);
+ }
+ });
+ // -@
+ p.add(grp);
+
+ grp = new OptionGroup(Messages.getString("Main.FileNameGroup")); //$NON-NLS-1$
+ grp.add(new Option('C', Messages.getString("Main.ChangeDir"), //$NON-NLS-1$
+ Messages.getString("Main.ChangeDirArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ changedDirectory = argument;
+ }
+ });
+ grp.add(new Option('@', Messages.getString("Main.Stdin"))
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ readNamesFromStdin = true;
+ }
+ });
+ p.add(grp);
+
+ return p;
+ }
+
+ private void readNames()
+ {
+ String line;
+ try
+ {
+ BufferedReader br
+ = new BufferedReader(new InputStreamReader(System.in));
+ while ((line = br.readLine()) != null)
+ entries.add(new Entry(new File(line)));
+ }
+ catch (IOException _)
+ {
+ // Ignore.
+ }
+ }
+
+ private void run(String[] args)
+ throws InstantiationException, IllegalAccessException, IOException
+ {
+ ClasspathToolParser p = initializeParser();
+ // Special hack to emulate old tar-style commands.
+ if (args.length > 0 && args[0].charAt(0) != '-')
+ args[0] = '-' + args[0];
+ p.parse(args, new HandleFile(), true);
+ if (readNamesFromStdin)
+ readNames();
+ Action t = (Action) operationMode.newInstance();
+ t.run(this);
+ }
+
+ public static void main(String[] args)
+ {
+ Main jarprogram = new Main();
+ try
+ {
+ jarprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java
new file mode 100644
index 000000000..ea54bd08f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for jar
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.jar.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java
new file mode 100644
index 000000000..e1df852ff
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java
@@ -0,0 +1,98 @@
+/* Updater.java - action to update a jar file
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+public class Updater
+ extends Creator
+{
+ JarFile inputJar;
+
+ protected Manifest createManifest(Main parameters) throws IOException
+ {
+ Manifest result = inputJar.getManifest();
+ if (result == null)
+ return super.createManifest(parameters);
+ if (parameters.manifestFile != null)
+ result.read(new FileInputStream(parameters.manifestFile));
+ return result;
+ }
+
+ public void run(Main parameters) throws IOException
+ {
+ // Set this early so that createManifest can use it.
+ inputJar = new JarFile(parameters.archiveFile);
+
+ // Write all the new entries to a temporary file.
+ File tmpFile = File.createTempFile("jarcopy", null,
+ parameters.archiveFile.getParentFile());
+ OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile));
+ writeCommandLineEntries(parameters, os);
+
+ // Now read the old file and copy extra entries to the new file.
+ Enumeration e = inputJar.entries();
+ while (e.hasMoreElements())
+ {
+ ZipEntry entry = (ZipEntry) e.nextElement();
+ if (writtenItems.contains(entry.getName()))
+ continue;
+ writeFile(entry.isDirectory(), inputJar.getInputStream(entry),
+ entry.getName(), parameters.verbose);
+ }
+
+ close();
+ if (!tmpFile.renameTo(parameters.archiveFile))
+ {
+ throw new IOException("Couldn't rename new JAR file " + tmpFile +
+ "to " + parameters.archiveFile);
+ }
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java b/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java
new file mode 100644
index 000000000..d4b7f1eac
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java
@@ -0,0 +1,83 @@
+/* WorkSet.java -- Helper to track what files to work on
+ Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jar;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+public class WorkSet
+{
+ private HashSet<String> allItems;
+
+ private void initSet(ArrayList<Entry> entries)
+ {
+ if (entries == null || entries.isEmpty())
+ return;
+ allItems = new HashSet<String>();
+ for (Entry entry : entries)
+ {
+ int len = entry.name.length();
+ while (len > 0 && entry.name.charAt(len - 1) == '/')
+ --len;
+ String name = entry.name.substring(0, len);
+ allItems.add(name);
+ }
+ }
+
+ public WorkSet(ArrayList<Entry> entries)
+ {
+ initSet(entries);
+ }
+
+ public boolean contains(String filename)
+ {
+ if (allItems == null)
+ return true;
+ while (filename.length() > 0)
+ {
+ if (allItems.contains(filename))
+ return true;
+ int index = filename.lastIndexOf('/');
+ if (index == -1)
+ break;
+ filename = filename.substring(0, index);
+ }
+ return false;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java
new file mode 100644
index 000000000..c9921dd70
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java
@@ -0,0 +1,124 @@
+/* Utils.java -- Utility methods for JAR file signing/verification
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jarsigner;
+
+import gnu.classpath.Configuration;
+import gnu.java.security.hash.Sha160;
+import gnu.java.util.Base64;
+import gnu.java.util.jar.JarUtils;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.logging.Logger;
+
+/**
+ * Collection of utility methods used in JAR file signing and verification.
+ */
+class HashUtils
+{
+ private static final Logger log = Logger.getLogger(HashUtils.class.getName());
+ private Sha160 sha = new Sha160();
+
+ // default 0-arguments constructor
+
+ /**
+ * @param stream the input stream to digest.
+ * @return a base-64 representation of the resulting SHA-1 digest of the
+ * contents of the designated input stream.
+ * @throws IOException if an I/O related exception occurs during the process.
+ */
+ String hashStream(InputStream stream) throws IOException
+ {
+ BufferedInputStream bis = new BufferedInputStream(stream, 4096);
+ byte[] buffer = new byte[4096];
+ int count = 0;
+ int n;
+ while ((n = bis.read(buffer)) != - 1)
+ if (n > 0)
+ {
+ sha.update(buffer, 0, n);
+ count += n;
+ }
+ byte[] hash = sha.digest();
+ if (Configuration.DEBUG)
+ log.finest("Hashed " + count + " byte(s)");
+ String result = Base64.encode(hash);
+ return result;
+ }
+
+ /**
+ * @param ba the byte array to digest.
+ * @return a base-64 representation of the resulting SHA-1 digest of the
+ * contents of the designated buffer.
+ */
+ String hashByteArray(byte[] ba) throws IOException
+ {
+ sha.update(ba);
+ byte[] hash = sha.digest();
+ if (Configuration.DEBUG)
+ log.finest("Hashed " + ba.length + " byte(s)");
+ String result = Base64.encode(hash);
+ return result;
+ }
+
+ /**
+ * @param name the JAR entry name
+ * @param entryHash the hash of the entry file which appears in the
+ * manifest.
+ * @return the base-64 encoded form of the hash of the corresponding Manifest
+ * JAR entry which will appear in the SF file under the entry with the
+ * same name.
+ * @throws UnsupportedEncodingException If UTF-8 character encoding is not
+ * supported on this platform.
+ */
+ String hashManifestEntry(String name, String entryHash)
+ throws UnsupportedEncodingException
+ {
+ sha.update((JarUtils.NAME + ": " + name).getBytes("UTF-8"));
+ sha.update(JarUtils.CRLF);
+ sha.update((Main.DIGEST + ": " + entryHash).getBytes("UTF-8"));
+ sha.update(JarUtils.CRLF);
+ sha.update(JarUtils.CRLF);
+ byte[] sfHash = sha.digest();
+ String result = Base64.encode(sfHash);
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
new file mode 100644
index 000000000..87db8b952
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
@@ -0,0 +1,173 @@
+/* JarSigner.java -- The signing handler of the gjarsigner tool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jarsigner;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.java.util.jar.JarUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.logging.Logger;
+
+/**
+ * The JAR signing handler of the <code>gjarsigner</code> tool.
+ */
+public class JarSigner
+{
+ private static final Logger log = Logger.getLogger(JarSigner.class.getName());
+ /** The owner tool of this handler. */
+ private Main main;
+
+ JarSigner(Main main)
+ {
+ super();
+
+ this.main = main;
+ }
+
+ void start() throws Exception
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ JarFile jarFile = new JarFile(main.getJarFileName());
+ SFHelper sfHelper = new SFHelper(jarFile);
+
+ sfHelper.startSigning();
+
+ // 1. compute the digests
+ for (Enumeration e = jarFile.entries(); e.hasMoreElements(); )
+ {
+ JarEntry je = (JarEntry) e.nextElement();
+ String jeName = je.getName();
+ if (jeName.equals(JarFile.MANIFEST_NAME)
+ || jeName.endsWith(File.separator))
+ continue;
+
+ sfHelper.updateEntry(je);
+ if (main.isVerbose())
+ System.out.println(Messages.getString("JarSigner.1") + jeName); //$NON-NLS-1$
+ }
+
+ sfHelper.finishSigning(main.isSectionsOnly());
+ if (main.isVerbose())
+ System.out.println(Messages.getString("JarSigner.2") + JarFile.MANIFEST_NAME); //$NON-NLS-1$
+
+ // 2. write jar entries and manifest
+ File signedJarFile = File.createTempFile("gcp-", ".jar"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileOutputStream fos = new FileOutputStream(signedJarFile);
+ JarOutputStream outSignedJarFile = new JarOutputStream(fos,
+ sfHelper.getManifest());
+ for (Enumeration e = jarFile.entries(); e.hasMoreElements(); )
+ {
+ JarEntry je = (JarEntry) e.nextElement();
+ String jeName = je.getName();
+ if (jeName.equals(JarFile.MANIFEST_NAME)
+ || jeName.endsWith(File.separator))
+ continue;
+
+ log.finest("Processing " + jeName); //$NON-NLS-1$
+ JarEntry newEntry = new JarEntry(jeName);
+ newEntry.setTime(je.getTime());
+ outSignedJarFile.putNextEntry(newEntry);
+ InputStream jeis = jarFile.getInputStream(je);
+ copyFromTo(jeis, outSignedJarFile);
+ }
+
+ // 3. create the .SF file
+ String signaturesFileName = main.getSigFileName();
+ String sfFileName = JarUtils.META_INF + signaturesFileName
+ + JarUtils.SF_SUFFIX;
+ if (Configuration.DEBUG)
+ log.fine("Processing " + sfFileName); //$NON-NLS-1$
+ JarEntry sfEntry = new JarEntry(sfFileName);
+ sfEntry.setTime(System.currentTimeMillis());
+ outSignedJarFile.putNextEntry(sfEntry);
+ sfHelper.writeSF(outSignedJarFile);
+ if (Configuration.DEBUG)
+ log.fine("Created .SF file"); //$NON-NLS-1$
+ if (main.isVerbose())
+ System.out.println(Messages.getString("JarSigner.8") + sfFileName); //$NON-NLS-1$
+
+ // 4. create the .DSA file
+ String dsaFileName = JarUtils.META_INF + signaturesFileName
+ + JarUtils.DSA_SUFFIX;
+ if (Configuration.DEBUG)
+ log.fine("Processing " + dsaFileName); //$NON-NLS-1$
+ JarEntry dsaEntry = new JarEntry(dsaFileName);
+ dsaEntry.setTime(System.currentTimeMillis());
+ outSignedJarFile.putNextEntry(dsaEntry);
+ sfHelper.writeDSA(outSignedJarFile,
+ main.getSignerPrivateKey(),
+ main.getSignerCertificateChain(),
+ main.isInternalSF());
+ if (Configuration.DEBUG)
+ log.fine("Created .DSA file"); //$NON-NLS-1$
+ if (main.isVerbose())
+ System.out.println(Messages.getString("JarSigner.8") + dsaFileName); //$NON-NLS-1$
+
+ // cleanup
+ outSignedJarFile.close();
+ fos.close();
+ signedJarFile.renameTo(new File(main.getSignedJarFileName()));
+ if (Configuration.DEBUG)
+ log.fine("Renamed signed JAR file"); //$NON-NLS-1$
+ if (main.isVerbose())
+ System.out.println(SystemProperties.getProperty("line.separator") //$NON-NLS-1$
+ + Messages.getString("JarSigner.14")); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ private void copyFromTo(InputStream in, JarOutputStream out)
+ throws IOException
+ {
+ byte[] buffer = new byte[8192];
+ int n;
+ while ((n = in.read(buffer)) != -1)
+ if (n > 0)
+ out.write(buffer, 0, n);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java
new file mode 100644
index 000000000..b920d74c1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java
@@ -0,0 +1,343 @@
+/* JarVerifier.java -- The verification handler of the gjarsigner tool
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jarsigner;
+
+import gnu.classpath.Configuration;
+import gnu.java.security.OID;
+import gnu.java.security.Registry;
+import gnu.java.security.pkcs.PKCS7SignedData;
+import gnu.java.security.pkcs.SignerInfo;
+import gnu.java.security.sig.ISignature;
+import gnu.java.security.sig.ISignatureCodec;
+import gnu.java.security.sig.dss.DSSSignature;
+import gnu.java.security.sig.dss.DSSSignatureX509Codec;
+import gnu.java.security.sig.rsa.RSAPKCS1V1_5Signature;
+import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
+import gnu.java.security.util.Util;
+import gnu.java.util.jar.JarUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.PublicKey;
+import java.security.cert.CRLException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.logging.Logger;
+import java.util.zip.ZipException;
+
+/**
+ * The JAR verification handler of the <code>gjarsigner</code> tool.
+ */
+public class JarVerifier
+{
+ private static final Logger log = Logger.getLogger(JarVerifier.class.getName());
+ /** The owner tool of this handler. */
+ private Main main;
+ private HashUtils util = new HashUtils();
+ /** The JAR file to verify. */
+ private JarFile jarFile;
+ /** Map of jar entry names to their hash. */
+ private Map<String, String> entryHashes = new HashMap<String, String>();
+
+ JarVerifier(Main main)
+ {
+ super();
+
+ this.main = main;
+ }
+
+ void start() throws Exception
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ String jarFileName = main.getJarFileName();
+ jarFile = new JarFile(jarFileName);
+
+ // 1. find all signature (.SF) files
+ List<String> sfFiles = new ArrayList<String>();
+ for (Enumeration e = jarFile.entries(); e.hasMoreElements(); )
+ {
+ JarEntry je = (JarEntry) e.nextElement();
+ String jeName = je.getName();
+ if (! (jeName.startsWith(JarUtils.META_INF)
+ && jeName.endsWith(JarUtils.SF_SUFFIX)))
+ continue;
+
+ // only interested in .SF files in, and not deeper than, META-INF
+ String[] jeNameParts = jeName.split("/"); //$NON-NLS-1$
+ if (jeNameParts.length != 2)
+ continue;
+
+ String sfName = jeNameParts[1];
+ String sigFileName = sfName.substring(0, sfName.length() - 3);
+ sfFiles.add(sigFileName);
+ }
+
+ // 2. verify each one
+ if (sfFiles.isEmpty())
+ System.out.println(Messages.getString("JarVerifier.2")); //$NON-NLS-1$
+ else
+ {
+ int limit = sfFiles.size();
+ int count = 0;
+ for (String alias : sfFiles)
+ if (verifySF(alias))
+ if (verifySFEntries(alias))
+ count++;
+
+ if (count == 0)
+ System.out.println(Messages.getString("JarVerifier.3")); //$NON-NLS-1$
+ else if (count != limit)
+ System.out.println(Messages.getFormattedString("JarVerifier.4", //$NON-NLS-1$
+ new Integer[] {Integer.valueOf(count),
+ Integer.valueOf(limit)}));
+ else
+ System.out.println(Messages.getFormattedString("JarVerifier.7", //$NON-NLS-1$
+ Integer.valueOf(limit)));
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ /**
+ * @param sigFileName the name of the signature file; i.e. the name to use for
+ * both the .SF and .DSA files.
+ * @return <code>true</code> if the designated file-name (usually a key-store
+ * <i>alias</i> name) has been successfully checked as the signer of the
+ * corresponding <code>.SF</code> file. Returns <code>false</code> otherwise.
+ * @throws IOException
+ * @throws ZipException
+ * @throws CertificateException
+ * @throws CRLException
+ */
+ private boolean verifySF(String sigFileName) throws CRLException,
+ CertificateException, ZipException, IOException
+ {
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "verifySF"); //$NON-NLS-1$
+ log.fine("About to verify signature of " + sigFileName + "..."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ // 1. find the corresponding .DSA file for this .SF file
+ JarEntry dsaEntry = jarFile.getJarEntry(JarUtils.META_INF + sigFileName
+ + JarUtils.DSA_SUFFIX);
+ if (dsaEntry == null)
+ throw new SecurityException(Messages.getFormattedString("JarVerifier.13", //$NON-NLS-1$
+ sigFileName));
+ // 2. read the .DSA file contents as a PKCS7 SignedData
+ InputStream in = jarFile.getInputStream(dsaEntry);
+ PKCS7SignedData pkcs7SignedData = new PKCS7SignedData(in);
+
+ // 4. get the encrypted digest octet string from the first SignerInfo
+ // this octet string is the digital signature of the .SF file contents
+ Set signerInfos = pkcs7SignedData.getSignerInfos();
+ if (signerInfos == null || signerInfos.isEmpty())
+ throw new SecurityException(Messages.getString("JarVerifier.14")); //$NON-NLS-1$
+
+ SignerInfo signerInfo = (SignerInfo) signerInfos.iterator().next();
+ byte[] encryptedDigest = signerInfo.getEncryptedDigest();
+ if (encryptedDigest == null)
+ throw new SecurityException(Messages.getString("JarVerifier.16")); //$NON-NLS-1$
+
+ if (Configuration.DEBUG)
+ log.fine("\n" + Util.dumpString(encryptedDigest, "--- signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // 5. get the signer public key
+ Certificate cert = pkcs7SignedData.getCertificates()[0];
+ PublicKey verifierKey = cert.getPublicKey();
+ if (Configuration.DEBUG)
+ log.fine("--- verifier public key = " + verifierKey); //$NON-NLS-1$
+
+ // 6. verify the signature file signature
+ OID digestEncryptionAlgorithmOID = signerInfo.getDigestEncryptionAlgorithmId();
+ ISignature signatureAlgorithm;
+ ISignatureCodec signatureCodec;
+ if (digestEncryptionAlgorithmOID.equals(Main.DSA_SIGNATURE_OID))
+ {
+ signatureAlgorithm = new DSSSignature();
+ signatureCodec = new DSSSignatureX509Codec();
+ }
+ else
+ {
+ signatureAlgorithm = new RSAPKCS1V1_5Signature(Registry.MD5_HASH);
+ signatureCodec = new RSAPKCS1V1_5SignatureX509Codec();
+ }
+
+ Map signatureAttributes = new HashMap();
+ signatureAttributes.put(ISignature.VERIFIER_KEY, verifierKey);
+ signatureAlgorithm.setupVerify(signatureAttributes);
+
+ Object herSignature = signatureCodec.decodeSignature(encryptedDigest);
+
+ // 7. verify the signature file contents
+ JarEntry sfEntry = jarFile.getJarEntry(JarUtils.META_INF + sigFileName
+ + JarUtils.SF_SUFFIX);
+ in = jarFile.getInputStream(sfEntry);
+ byte[] buffer = new byte[2048];
+ int n;
+ while ((n = in.read(buffer)) != -1)
+ if (n > 0)
+ signatureAlgorithm.update(buffer, 0, n);
+
+ boolean result = signatureAlgorithm.verify(herSignature);
+ if (Configuration.DEBUG)
+ {
+ log.fine("Signature block [" + sigFileName + "] is " //$NON-NLS-1$ //$NON-NLS-2$
+ + (result ? "" : "NOT ") + "OK"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ log.exiting(this.getClass().getName(), "verifySF", Boolean.valueOf(result)); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ * This method is called after at least one signer (usually a key-store
+ * <code>alias</code> name) was found to be trusted; i.e. his/her signature
+ * block in the corresponding <code>.DSA</code> file was successfully
+ * verified using his/her public key.
+ * <p>
+ * This method, uses the contents of the corresponding <code>.SF</code> file
+ * to compute and verify the hashes of the manifest entries in the JAR file.
+ *
+ * @param alias the name of the signature file; i.e. the name to use for both
+ * the .SF and .DSA files.
+ * @return <code>true</code> if all the entries in the corresponding
+ * <code>.SF</code> file have the same hash values as their
+ * alter-ego in the <i>manifest</i> file of the JAR file inquestion.
+ * @throws IOException if an I/O related exception occurs during the process.
+ */
+ private boolean verifySFEntries(String alias) throws IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "verifySFEntries"); //$NON-NLS-1$
+ // 1. read the signature file
+ JarEntry jarEntry = jarFile.getJarEntry(JarUtils.META_INF + alias
+ + JarUtils.SF_SUFFIX);
+ InputStream in = jarFile.getInputStream(jarEntry);
+ Attributes attr = new Attributes();
+ Map<String, Attributes> entries = new HashMap<String, Attributes>();
+ JarUtils.readSFManifest(attr, entries, in);
+
+ // 2. The .SF file by default includes a header containing a hash of the
+ // entire manifest file. When the header is present, then the verification
+ // can check to see whether or not the hash in the header indeed matches
+ // the hash of the manifest file.
+ boolean result = false;
+ String hash = attr.getValue(Main.DIGEST_MANIFEST_ATTR);
+ if (hash != null)
+ result = verifyManifest(hash);
+
+ // A verification is still considered successful if none of the files that
+ // were in the JAR file when the signature was generated have been changed
+ // since then, which is the case if the hashes in the non-header sections
+ // of the .SF file equal the hashes of the corresponding sections in the
+ // manifest file.
+ //
+ // 3. Read each file in the JAR file that has an entry in the .SF file.
+ // While reading, compute the file's digest, and then compare the result
+ // with the digest for this file in the manifest section. The digests
+ // should be the same, or verification fails.
+ if (! result)
+ for (Entry<String, Attributes> me : entries.entrySet())
+ {
+ String name = me.getKey();
+ attr = me.getValue();
+ hash = attr.getValue(Main.DIGEST_ATTR);
+ result = verifySFEntry(name, hash);
+ if (! result)
+ break;
+ }
+
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "verifySFEntries", //$NON-NLS-1$
+ Boolean.valueOf(result));
+ return result;
+ }
+
+ /**
+ * @param hash Base-64 encoded form of the manifest's digest.
+ * @return <code>true</code> if our computation of the manifest's hash
+ * matches the given value; <code>false</code> otherwise.
+ * @throws IOException if unable to acquire the JAR's manifest entry.
+ */
+ private boolean verifyManifest(String hash) throws IOException
+ {
+ return verifySFEntry(JarFile.MANIFEST_NAME, hash);
+ }
+
+ /**
+ * @param name the name of a JAR entry to verify.
+ * @param hash Base-64 encoded form of the designated entry's digest.
+ * @return <code>true</code> if our computation of the JAR entry's hash
+ * matches the given value; <code>false</code> otherwise.
+ * @throws IOException if an exception occurs while returning the entry's
+ * input stream.
+ */
+ private boolean verifySFEntry(String name, String hash) throws IOException
+ {
+ String expectedValue = getEntryHash(JarFile.MANIFEST_NAME);
+ boolean result = expectedValue.equalsIgnoreCase(hash);
+ if (Configuration.DEBUG)
+ log.fine("Is " + name + " OK? " + result); //$NON-NLS-1$ //$NON-NLS-2$
+ return result;
+ }
+
+ private String getEntryHash(String entryName) throws IOException
+ {
+ String result = (String) entryHashes.get(entryName);
+ if (result == null)
+ {
+ JarEntry manifest = jarFile.getJarEntry(entryName);
+ InputStream in = jarFile.getInputStream(manifest);
+ result = util.hashStream(in);
+ entryHashes.put(entryName, result);
+ }
+
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
new file mode 100644
index 000000000..c7fb5856a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
@@ -0,0 +1,689 @@
+/* Main.java -- JAR signing and verification tool not unlike jarsigner
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jarsigner;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.common.CallbackUtil;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.common.ProviderUtil;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.java.security.OID;
+import gnu.java.security.Registry;
+import gnu.javax.security.auth.callback.ConsoleCallbackHandler;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.Security;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.jar.Attributes.Name;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The GNU Classpath implementation of the <i>jarsigner</i> tool.
+ * <p>
+ * The <i>jarsigner</i> tool is used to sign and verify JAR (Java ARchive)
+ * files.
+ * <p>
+ * This implementation is intended to be compatible with the behaviour
+ * described in the public documentation of the same tool included in JDK 1.4.
+ */
+public class Main
+{
+ protected static final Logger log = Logger.getLogger(Main.class.getName());
+ static final String KEYTOOL_TOOL = "jarsigner"; //$NON-NLS-1$
+ private static final Locale EN_US_LOCALE = new Locale("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$
+ static final String DIGEST = "SHA1-Digest"; //$NON-NLS-1$
+ static final String DIGEST_MANIFEST = "SHA1-Digest-Manifest"; //$NON-NLS-1$
+ static final Name DIGEST_ATTR = new Name(DIGEST);
+ static final Name DIGEST_MANIFEST_ATTR = new Name(DIGEST_MANIFEST);
+ static final OID DSA_SIGNATURE_OID = new OID(Registry.DSA_OID_STRING);
+ static final OID RSA_SIGNATURE_OID = new OID(Registry.RSA_OID_STRING);
+
+ protected boolean verify;
+ protected String ksURL;
+ protected String ksType;
+ protected String password;
+ protected String ksPassword;
+ protected String sigFileName;
+ protected String signedJarFileName;
+ protected boolean verbose;
+ protected boolean certs;
+ protected boolean internalSF;
+ protected boolean sectionsOnly;
+ protected String providerClassName;
+ protected String jarFileName;
+ protected String alias;
+
+ protected Provider provider;
+ private boolean providerInstalled;
+ private char[] ksPasswordChars;
+ private KeyStore store;
+ private char[] passwordChars;
+ private PrivateKey signerPrivateKey;
+ private Certificate[] signerCertificateChain;
+ /** The callback handler to use when needing to interact with user. */
+ private CallbackHandler handler;
+ /** The command line parser. */
+ private ToolParser cmdLineParser;
+ protected ArrayList<String> fileAndAlias = new ArrayList<String>();
+
+ private Main()
+ {
+ super();
+ }
+
+ public static final void main(String[] args)
+ {
+ if (Configuration.DEBUG)
+ log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
+ Main tool = new Main();
+ int result = 1;
+ try
+ {
+ tool.processArgs(args);
+ tool.start();
+ result = 0;
+ }
+ catch (SecurityException x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ System.err.println(Messages.getString("Main.7") + x.getMessage()); //$NON-NLS-1$
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ System.err.println(Messages.getString("Main.9") + x); //$NON-NLS-1$
+ }
+ finally
+ {
+ tool.teardown();
+ }
+ if (Configuration.DEBUG)
+ log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
+ System.exit(result);
+ }
+
+ /**
+ * Read the command line arguments setting the tool's parameters in
+ * preparation for the user desired action.
+ *
+ * @param args an array of options (strings).
+ * @throws Exception if an exception occurs during the process.
+ */
+ private void processArgs(String[] args) throws Exception
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
+ cmdLineParser = new ToolParser();
+ cmdLineParser.initializeParser();
+ cmdLineParser.parse(args, new ToolParserCallback());
+
+ setupCommonParams();
+ if (verify)
+ {
+ if (Configuration.DEBUG)
+ {
+ log.fine("Will verify with the following parameters:"); //$NON-NLS-1$
+ log.fine(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine("Options:"); //$NON-NLS-1$
+ log.fine(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" verbose ? " + verbose); //$NON-NLS-1$
+ log.fine(" certs ? " + certs); //$NON-NLS-1$
+ log.fine(" internalsf ? " + internalSF); //$NON-NLS-1$
+ log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+ }
+ }
+ else // sign
+ {
+ setupSigningParams();
+ if (Configuration.DEBUG)
+ {
+ log.fine("Will sign with the following parameters:"); //$NON-NLS-1$
+ log.fine(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" alias = '" + alias + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine("Options:"); //$NON-NLS-1$
+ log.fine(" keystore = '" + ksURL + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" storetype = '" + ksType + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" storepass = '" + ksPassword + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" keypass = '" + password + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" sigfile = '" + sigFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" signedjar = '" + signedJarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" verbose ? " + verbose); //$NON-NLS-1$
+ log.fine(" internalsf ? " + internalSF); //$NON-NLS-1$
+ log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+ }
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "processArgs"); //$NON-NLS-1$
+ }
+
+ /**
+ * Invokes the <code>start()</code> method of the concrete handler.
+ * <p>
+ * Depending on the result of processing the command line arguments, this
+ * handler may be one for signing the jar, or verifying it.
+ *
+ * @throws Exception if an exception occurs during the process.
+ */
+ private void start() throws Exception
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (verify)
+ {
+ JarVerifier jv = new JarVerifier(this);
+ jv.start();
+ }
+ else
+ {
+ JarSigner js = new JarSigner(this);
+ js.start();
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ /**
+ * Ensures that the underlying JVM is left in the same state as we found it
+ * when we first launched the tool. Specifically, if we have installed a new
+ * security provider then now is the time to remove it.
+ * <p>
+ * Note (rsn): this may not be necessary if we terminate the JVM; i.e. call
+ * {@link System#exit(int)} at the end of the tool's invocation. Nevertheless
+ * it's good practive to return the JVM to its initial state.
+ */
+ private void teardown()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ if (providerInstalled)
+ ProviderUtil.removeProvider(provider.getName());
+
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ }
+
+ /**
+ * After processing the command line arguments, this method is invoked to
+ * process the common parameters which may have been encountered among the
+ * actual arguments.
+ * <p>
+ * Common parameters are those which are allowed in both signing and
+ * verification modes.
+ *
+ * @throws InstantiationException if a security provider class name is
+ * specified but that class name is that of either an interface or
+ * an abstract class.
+ * @throws IllegalAccessException if a security provider class name is
+ * specified but no 0-arguments constructor is defined for that
+ * class.
+ * @throws ClassNotFoundException if a security provider class name is
+ * specified but no such class was found in the classpath.
+ * @throws IOException if the JAR file name for signing, or verifying, does
+ * not exist, exists but denotes a directory, or is not readable.
+ */
+ private void setupCommonParams() throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException, IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
+ File jar = new File(jarFileName);
+ if (! jar.exists())
+ throw new FileNotFoundException(jarFileName);
+
+ if (jar.isDirectory())
+ throw new IOException(Messages.getFormattedString("Main.70", jarFileName)); //$NON-NLS-1$
+
+ if (! jar.canRead())
+ throw new IOException(Messages.getFormattedString("Main.72", jarFileName)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (providerClassName != null && providerClassName.length() > 0)
+ {
+ provider = (Provider) Class.forName(providerClassName).newInstance();
+ // is it already installed?
+ String providerName = provider.getName();
+ Provider installedProvider = Security.getProvider(providerName);
+ if (installedProvider != null)
+ {
+ if (Configuration.DEBUG)
+ log.finer("Provider " + providerName + " is already installed"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else // install it
+ installNewProvider();
+ }
+
+ if (! verbose && certs)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Option <certs> is set but <verbose> is not. Ignored"); //$NON-NLS-1$
+ certs = false;
+ }
+
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
+ }
+
+ /**
+ * Install the user defined security provider in the underlying JVM.
+ * <p>
+ * Also record this fact so we can remove it when we exit the tool.
+ */
+ private void installNewProvider()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
+ providerInstalled = ProviderUtil.addProvider(provider) != -1;
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
+ }
+
+ /**
+ * After processing the command line arguments, this method is invoked to
+ * process the parameters which may have been encountered among the actual
+ * arguments, and which are specific to the signing action of the tool.
+ *
+ * @throws KeyStoreException if no implementation of the designated (or
+ * default type) of a key store is availabe.
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws NoSuchAlgorithmException if an implementation of an algorithm used
+ * by the key store is not available.
+ * @throws CertificateException if an exception occurs while reading a
+ * certificate from the key store.
+ * @throws UnsupportedCallbackException if no implementation of a password
+ * callback is available.
+ * @throws UnrecoverableKeyException if the wrong password was used to unlock
+ * the key store.
+ * @throws SecurityException if the designated alias is not known to the key
+ * store or is not an Alias of a Key Entry.
+ */
+ private void setupSigningParams() throws KeyStoreException, IOException,
+ NoSuchAlgorithmException, CertificateException,
+ UnsupportedCallbackException, UnrecoverableKeyException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
+ if (ksURL == null || ksURL.trim().length() == 0)
+ {
+ String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$
+ if (userHome == null || userHome.trim().length() == 0)
+ throw new SecurityException(Messages.getString("Main.85")); //$NON-NLS-1$
+
+ ksURL = "file:" + userHome.trim() + "/.keystore"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else
+ {
+ ksURL = ksURL.trim();
+ if (ksURL.indexOf(":") == -1) //$NON-NLS-1$
+ ksURL = "file:" + ksURL; //$NON-NLS-1$
+ }
+
+ if (ksType == null || ksType.trim().length() == 0)
+ ksType = KeyStore.getDefaultType();
+ else
+ ksType = ksType.trim();
+
+ store = KeyStore.getInstance(ksType);
+
+ if (ksPassword == null)
+ {
+ // ask the user to provide one
+ PasswordCallback pcb = new PasswordCallback(Messages.getString("Main.92"), //$NON-NLS-1$
+ false);
+ getCallbackHandler().handle(new Callback[] { pcb });
+ ksPasswordChars = pcb.getPassword();
+ }
+ else
+ ksPasswordChars = ksPassword.toCharArray();
+
+ URL url = new URL(ksURL);
+ InputStream stream = url.openStream();
+ store.load(stream, ksPasswordChars);
+
+ if (! store.containsAlias(alias))
+ throw new SecurityException(Messages.getFormattedString("Main.6", alias)); //$NON-NLS-1$
+
+ if (! store.isKeyEntry(alias))
+ throw new SecurityException(Messages.getFormattedString("Main.95", alias)); //$NON-NLS-1$
+
+ Key key;
+ if (password == null)
+ {
+ passwordChars = ksPasswordChars;
+ try
+ {
+ key = store.getKey(alias, passwordChars);
+ }
+ catch (UnrecoverableKeyException x)
+ {
+ // ask the user to provide one
+ String prompt = Messages.getFormattedString("Main.97", alias); //$NON-NLS-1$
+ PasswordCallback pcb = new PasswordCallback(prompt, false);
+ getCallbackHandler().handle(new Callback[] { pcb });
+ passwordChars = pcb.getPassword();
+ // take 2
+ key = store.getKey(alias, passwordChars);
+ }
+ }
+ else
+ {
+ passwordChars = password.toCharArray();
+ key = store.getKey(alias, passwordChars);
+ }
+
+ if (! (key instanceof PrivateKey))
+ throw new SecurityException(Messages.getFormattedString("Main.99", alias)); //$NON-NLS-1$
+
+ signerPrivateKey = (PrivateKey) key;
+ signerCertificateChain = store.getCertificateChain(alias);
+ if (Configuration.DEBUG)
+ log.fine(String.valueOf(signerCertificateChain));
+
+ if (sigFileName == null)
+ sigFileName = alias;
+
+ sigFileName = sigFileName.toUpperCase(EN_US_LOCALE);
+ if (sigFileName.length() > 8)
+ sigFileName = sigFileName.substring(0, 8);
+
+ char[] chars = sigFileName.toCharArray();
+ for (int i = 0; i < chars.length; i++)
+ {
+ char c = chars[i];
+ if (! (Character.isLetter(c)
+ || Character.isDigit(c)
+ || c == '_'
+ || c == '-'))
+ chars[i] = '_';
+ }
+
+ sigFileName = new String(chars);
+
+ if (signedJarFileName == null)
+ signedJarFileName = jarFileName;
+
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
+ }
+
+ boolean isVerbose()
+ {
+ return verbose;
+ }
+
+ boolean isCerts()
+ {
+ return certs;
+ }
+
+ String getSigFileName()
+ {
+ return this.sigFileName;
+ }
+
+ String getJarFileName()
+ {
+ return this.jarFileName;
+ }
+
+ boolean isSectionsOnly()
+ {
+ return this.sectionsOnly;
+ }
+
+ boolean isInternalSF()
+ {
+ return this.internalSF;
+ }
+
+ PrivateKey getSignerPrivateKey()
+ {
+ return this.signerPrivateKey;
+ }
+
+ Certificate[] getSignerCertificateChain()
+ {
+ return signerCertificateChain;
+ }
+
+ String getSignedJarFileName()
+ {
+ return this.signedJarFileName;
+ }
+
+ /**
+ * Return a CallbackHandler which uses the Console (System.in and System.out)
+ * for interacting with the user.
+ * <p>
+ * This method first finds all currently installed security providers capable
+ * of providing such service and then in turn attempts to instantiate the
+ * handler from those providers. As soon as one provider returns a non-null
+ * instance of the callback handler, the search stops and that instance is
+ * set to be used from now on.
+ * <p>
+ * If no installed providers were found, this method falls back on the GNU
+ * provider, by-passing the Security search mechanism. The default console
+ * callback handler implementation is {@link ConsoleCallbackHandler}.
+ *
+ * @return a console-based {@link CallbackHandler}.
+ */
+ protected CallbackHandler getCallbackHandler()
+ {
+ if (handler == null)
+ handler = CallbackUtil.getConsoleHandler();
+
+ return handler;
+ }
+
+ private class ToolParserCallback
+ extends FileArgumentCallback
+ {
+ public void notifyFile(String fileArgument)
+ {
+ fileAndAlias.add(fileArgument);
+ }
+ }
+
+ private class ToolParser
+ extends ClasspathToolParser
+ {
+ public ToolParser()
+ {
+ super(KEYTOOL_TOOL, true);
+ }
+
+ protected void validate() throws OptionException
+ {
+ if (fileAndAlias.size() < 1)
+ throw new OptionException(Messages.getString("Main.133")); //$NON-NLS-1$
+
+ jarFileName = (String) fileAndAlias.get(0);
+ if (! verify) // must have an ALIAS. use "mykey" if undefined
+ if (fileAndAlias.size() < 2)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Missing ALIAS argument. Will use [mykey] instead"); //$NON-NLS-1$
+ alias = "mykey"; //$NON-NLS-1$
+ }
+ else
+ alias = fileAndAlias.get(1);
+ }
+
+ public void initializeParser()
+ {
+ setHeader(Messages.getString("Main.2")); //$NON-NLS-1$
+ setFooter(Messages.getString("Main.1")); //$NON-NLS-1$
+ OptionGroup signGroup = new OptionGroup(Messages.getString("Main.0")); //$NON-NLS-1$
+ signGroup.add(new Option("keystore", //$NON-NLS-1$
+ Messages.getString("Main.101"), //$NON-NLS-1$
+ Messages.getString("Main.102")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ ksURL = argument;
+ }
+ });
+ signGroup.add(new Option("storetype", //$NON-NLS-1$
+ Messages.getString("Main.104"), //$NON-NLS-1$
+ Messages.getString("Main.105")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ ksType = argument;
+ }
+ });
+ signGroup.add(new Option("storepass", //$NON-NLS-1$
+ Messages.getString("Main.107"), //$NON-NLS-1$
+ Messages.getString("Main.108")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ ksPassword = argument;
+ }
+ });
+ signGroup.add(new Option("keypass", //$NON-NLS-1$
+ Messages.getString("Main.110"), //$NON-NLS-1$
+ Messages.getString("Main.111")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ password = argument;
+ }
+ });
+ signGroup.add(new Option("sigfile", //$NON-NLS-1$
+ Messages.getString("Main.113"), //$NON-NLS-1$
+ Messages.getString("Main.114")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ sigFileName = argument;
+ }
+ });
+ signGroup.add(new Option("signedjar", //$NON-NLS-1$
+ Messages.getString("Main.116"), //$NON-NLS-1$
+ Messages.getString("Main.117")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ signedJarFileName = argument;
+ }
+ });
+ add(signGroup);
+
+ OptionGroup verifyGroup = new OptionGroup(Messages.getString("Main.118")); //$NON-NLS-1$
+ verifyGroup.add(new Option("verify", //$NON-NLS-1$
+ Messages.getString("Main.120")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verify = true;
+ }
+ });
+ verifyGroup.add(new Option("certs", //$NON-NLS-1$
+ Messages.getString("Main.122")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ certs = true;
+ }
+ });
+ add(verifyGroup);
+
+ OptionGroup commonGroup = new OptionGroup(Messages.getString("Main.123")); //$NON-NLS-1$
+ commonGroup.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString("Main.125")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ commonGroup.add(new Option("internalsf", //$NON-NLS-1$
+ Messages.getString("Main.127")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ internalSF = true;
+ }
+ });
+ commonGroup.add(new Option("sectionsonly", //$NON-NLS-1$
+ Messages.getString("Main.129")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ sectionsOnly = true;
+ }
+ });
+ commonGroup.add(new Option("provider", //$NON-NLS-1$
+ Messages.getString("Main.131"), //$NON-NLS-1$
+ Messages.getString("Main.132")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ providerClassName = argument;
+ }
+ });
+ add(commonGroup);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
new file mode 100644
index 000000000..f27f79eae
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
@@ -0,0 +1,119 @@
+/* Messages.java -- I18N related helper class
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.jarsigner;
+
+import gnu.classpath.Configuration;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+/**
+ * An initially generated Eclipse helper class to ease the use of localized
+ * messages.
+ * <p>
+ * Enriched to handle localized message formats.
+ */
+class Messages
+{
+ private static final Logger log = Logger.getLogger(Messages.class.getName());
+ private static final String BUNDLE_NAME = "gnu.classpath.tools.jarsigner.messages";
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+ private static final Map<String, MessageFormat> CACHED_FORMATS =
+ new HashMap<String, MessageFormat>(5);
+
+ private Messages()
+ {
+ super();
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return constructMessage(key, null);
+ }
+ }
+
+ public static String getFormattedString(String key, Object args)
+ {
+ MessageFormat mf = CACHED_FORMATS.get(key);
+ if (mf == null)
+ {
+ String formatString = getString(key);
+ if (formatString.startsWith("!"))
+ return constructMessage(key, args);
+
+ mf = new MessageFormat(formatString);
+ CACHED_FORMATS.put(key, mf);
+ }
+
+ // if the argument is not an array, then build one consisting of the
+ // sole argument before passing it to the format() method
+ try
+ {
+ if (args instanceof Object[])
+ return mf.format(args);
+
+ return mf.format(new Object[] { args });
+ }
+ catch (IllegalArgumentException x)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Exception while rendering a message format keyed by ["
+ + key + "]: " + mf.toPattern());
+ return constructMessage(mf.toPattern(), args);
+ }
+ }
+
+ private static final String constructMessage(String m, Object args)
+ {
+ if (args == null)
+ return '!' + m + '!';
+
+ return '!' + m + '!' + String.valueOf(args) + '!';
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java
new file mode 100644
index 000000000..9e4882f0e
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java
@@ -0,0 +1,491 @@
+/* SFHelper -- A .SF file helper
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jarsigner;
+
+import gnu.classpath.Configuration;
+import gnu.java.security.OID;
+import gnu.java.security.Registry;
+import gnu.java.security.der.DER;
+import gnu.java.security.der.DERValue;
+import gnu.java.security.pkcs.PKCS7Data;
+import gnu.java.security.pkcs.PKCS7SignedData;
+import gnu.java.security.pkcs.SignerInfo;
+import gnu.java.security.sig.ISignature;
+import gnu.java.security.sig.ISignatureCodec;
+import gnu.java.security.sig.dss.DSSSignature;
+import gnu.java.security.sig.dss.DSSSignatureX509Codec;
+import gnu.java.security.sig.rsa.RSAPKCS1V1_5Signature;
+import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
+import gnu.java.security.util.Util;
+import gnu.java.util.jar.JarUtils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.PrivateKey;
+import java.security.cert.CRLException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.CertificateNotYetValidException;
+import java.security.cert.X509CRL;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.logging.Logger;
+
+import javax.security.auth.x500.X500Principal;
+import java.security.cert.X509Certificate;
+
+/**
+ * A helper class for the .SF file found in signed jars.
+ */
+public class SFHelper
+{
+ private static final Logger log = Logger.getLogger(SFHelper.class.getName());
+ private static final int READY = 0;
+ private static final int STARTED = 1;
+ private static final int FINISHED = 2;
+ private static final int SF_GENERATED = 3;
+ private static final int DSA_GENERATED = 4;
+ /** http://asn1.elibel.tm.fr/cgi-bin/oid/display?oid=1.3.14.3.2.26&action=display */
+ private static final OID hashAlgorithmIdentifierSHA1 = new OID("1.3.14.3.2.26"); //$NON-NLS-1$
+
+ private int state;
+ private JarFile jar;
+ private Manifest manifest;
+ private Attributes sfMainAttributes;
+ private Map<String, Attributes> sfEntries;
+ private byte[] sfBytes;
+ private HashUtils util;
+
+ /**
+ * @param jar the JAR archive the .SF file belongs to.
+ */
+ public SFHelper(JarFile jar)
+ {
+ super();
+
+ this.jar = jar;
+ this.state = READY;
+ }
+
+ /**
+ * Writes the contents of the <code>.SF</code> file to the designated JAR
+ * output stream. Line-endings are platform-independent and consist of the
+ * 2-codepoint sequence <code>0x0D</code> and <code>0x0A</code>.
+ *
+ * @param jar the JAR output stream to write a <code>.SF</code> file to.
+ * @throws IOException if an I/O related exception occurs during the process.
+ */
+ void writeSF(JarOutputStream jar) throws IOException
+ {
+ if (this.state != FINISHED)
+ throw new IllegalStateException(Messages.getString("SFHelper.1")); //$NON-NLS-1$
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ JarUtils.writeSFManifest(sfMainAttributes, sfEntries, baos);
+ sfBytes = baos.toByteArray();
+ if (Configuration.DEBUG)
+ log.fine("\n" + Util.dumpString(sfBytes, "+++ sfBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+ jar.write(sfBytes);
+ jar.flush();
+
+ this.state = SF_GENERATED;
+ }
+
+ /**
+ * The contents of the .DSA file is the DER encoded form of a PKCS#7
+ * ContentInfo of the type SignedData.
+ * <p>
+ * The ContentInfo ASN.1 syntax is as described in the "PKCS#7 Cryptographic
+ * Message Syntax Standard" (RSA Labs) specifications:
+ * <pre>
+ * ContentInfo ::= SEQUENCE {
+ * contentType ContentType,
+ * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
+ * }
+ *
+ * ContentType ::= OBJECT IDENTIFIER
+ * </pre>
+ * <p>
+ * The ContentType is an OID which determines the type of the contents field
+ * that follows it. For the .DSA file the OID is "1.2.840.113549.1.7.2", while
+ * the content field is the byte array representing the DER encoded form of a
+ * SignedData content-type. The ASN.1 syntax of the SignedData type is as
+ * follows:
+ * <pre>
+ * SignedData ::= SEQUENCE {
+ * version Version, -- always 1 for PKCS#7 1.5
+ * digestAlgorithms DigestAlgorithmIdentifiers,
+ * contentInfo ContentInfo,
+ * certificates [0] IMPLICIT ExtendedCertificatesAndCertificates OPTIONAL,
+ * crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
+ * signerInfos SignerInfos
+ * }
+ *
+ * DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
+ *
+ * SignerInfos ::= SET OF SignerInfo
+ * </pre>
+ * <p>
+ * Finally the SignerInfo is a per-signer structure. Its ASN.1 syntax looks
+ * like so:
+ * <pre>
+ * SignerInfo ::= SEQUENCE {
+ * version Version, -- always 1 for PKCS#7 1.5
+ * issuerAndSerialNumber IssuerAndSerialNumber,
+ * digestAlgorithm DigestAlgorithmIdentifier,
+ * authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,
+ * digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,
+ * encryptedDigest EncryptedDigest,
+ * unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
+ * }
+ *
+ * EncryptedDigest ::= OCTET STRING
+ * </pre>
+ *
+ * @param jar the JAR output stream to write a <code>.DSA</code> file to.
+ * @param signerKey the private key to sign with.
+ * @param certificates the possibly null signer certificate chain.
+ * @param internalSF if <code>true</code> then include the .SF file contents
+ * in the signed .DSA file; otherwise don't.
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws CRLException
+ * @throws CertificateEncodingException
+ */
+ void writeDSA(JarOutputStream jar, PrivateKey signerKey,
+ Certificate[] certificates, boolean internalSF)
+ throws IOException, CertificateEncodingException, CRLException
+ {
+ if (this.state != SF_GENERATED)
+ throw new IllegalStateException(Messages.getString("SFHelper.4")); //$NON-NLS-1$
+
+ if (Configuration.DEBUG)
+ log.fine("+++ signer private key = " + signerKey); //$NON-NLS-1$
+ ISignature signatureAlgorithm;
+ ISignatureCodec signatureCodec;
+ OID digestEncryptionAlgorithmOID;
+ if (signerKey instanceof DSAPrivateKey)
+ {
+ signatureAlgorithm = new DSSSignature();
+ signatureCodec = new DSSSignatureX509Codec();
+ digestEncryptionAlgorithmOID = Main.DSA_SIGNATURE_OID;
+ }
+ else if (signerKey instanceof RSAPrivateKey)
+ {
+ signatureAlgorithm = new RSAPKCS1V1_5Signature(Registry.MD5_HASH);
+ signatureCodec = new RSAPKCS1V1_5SignatureX509Codec();
+ digestEncryptionAlgorithmOID = Main.RSA_SIGNATURE_OID;
+ }
+ else
+ throw new SecurityException(Messages.getString("SFHelper.6")); //$NON-NLS-1$
+
+ Map signatureAttributes = new HashMap();
+ signatureAttributes.put(ISignature.SIGNER_KEY, signerKey);
+ signatureAlgorithm.setupSign(signatureAttributes);
+ signatureAlgorithm.update(sfBytes, 0, sfBytes.length);
+ Object signature = signatureAlgorithm.sign();
+ byte[] signedSFBytes = signatureCodec.encodeSignature(signature);
+ if (Configuration.DEBUG)
+ log.fine("\n" + Util.dumpString(signedSFBytes, "+++ signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Set<DERValue> digestAlgorithms = new HashSet<DERValue>();
+ List<DERValue> digestAlgorithm = new ArrayList<DERValue>(2);
+ DERValue derDigestAlgorithmOID = new DERValue(DER.OBJECT_IDENTIFIER,
+ hashAlgorithmIdentifierSHA1);
+ DERValue derDigestAlgorithmParams = new DERValue(DER.NULL, null);
+ digestAlgorithm.add(derDigestAlgorithmOID);
+ digestAlgorithm.add(derDigestAlgorithmParams);
+ DERValue derDigestAlgorithm = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+ digestAlgorithm);
+ digestAlgorithms.add(derDigestAlgorithm);
+
+ // TODO (rsn): test with internalsf == true
+ PKCS7Data data = internalSF ? new PKCS7Data(sfBytes) : null;
+
+ X509CRL[] crls = null;
+
+ Set<SignerInfo> signerInfos = new HashSet<SignerInfo>();
+ X509Certificate cert = (X509Certificate) certificates[0];
+ try
+ {
+ cert.checkValidity();
+ }
+ catch (CertificateExpiredException x)
+ {
+ String issuerName = getIssuerName(cert);
+ String subjectName = getSubjectName(cert);
+ Date notAfterDate = getNotAfterDate(cert);
+ System.out.println(Messages.getFormattedString("SFHelper.0", //$NON-NLS-1$
+ new Object[] { issuerName,
+ subjectName,
+ notAfterDate }));
+ }
+ catch (CertificateNotYetValidException x)
+ {
+ String issuerName = getIssuerName(cert);
+ String subjectName = getSubjectName(cert);
+ Date notBeforeDate = getNotBeforeDate(cert);
+ System.out.println(Messages.getFormattedString("SFHelper.11", //$NON-NLS-1$
+ new Object[] { issuerName,
+ subjectName,
+ notBeforeDate }));
+ }
+ X500Principal issuer = cert.getIssuerX500Principal();
+ BigInteger serialNumber = cert.getSerialNumber();
+ byte[] authenticatedAttributes = null;
+ byte[] encryptedDigest = signedSFBytes;
+ byte[] unauthenticatedAttributes = null;
+ SignerInfo signerInfo = new SignerInfo(issuer,
+ serialNumber,
+ hashAlgorithmIdentifierSHA1,
+ authenticatedAttributes,
+ digestEncryptionAlgorithmOID,
+ encryptedDigest,
+ unauthenticatedAttributes);
+ signerInfos.add(signerInfo);
+
+ PKCS7SignedData dsaContents = new PKCS7SignedData(digestAlgorithms,
+ data,
+ certificates,
+ crls,
+ signerInfos);
+ dsaContents.encode(jar);
+
+ jar.flush();
+ this.state = DSA_GENERATED;
+ }
+
+ Manifest getManifest()
+ {
+ return this.manifest;
+ }
+
+ void startSigning() throws IOException
+ {
+ if (this.state != READY)
+ throw new IllegalStateException(Messages.getString("SFHelper.9")); //$NON-NLS-1$
+
+ Manifest oldManifest = jar.getManifest();
+ this.manifest = oldManifest == null ? new Manifest()
+ : new Manifest(oldManifest);
+ this.sfMainAttributes = new Attributes();
+ this.sfEntries = new HashMap<String, Attributes>();
+ util = new HashUtils();
+
+ this.state = STARTED;
+ }
+
+ /**
+ * Hashes the designated JAR entry (the file itself); adds the resulting hash
+ * as an attribute to the manifest, and computes the hash of the added (to
+ * the Manifest) two headers and add the result as an attribute of the
+ * corresponding entry in the .SF file.
+ */
+ void updateEntry(JarEntry entry) throws IOException
+ {
+ if (this.state != STARTED)
+ throw new IllegalStateException(Messages.getString("SFHelper.10")); //$NON-NLS-1$
+
+ String name = entry.getName();
+ InputStream jeis = jar.getInputStream(entry);
+ String hash = util.hashStream(jeis);
+ if (Configuration.DEBUG)
+ log.fine("Hash of " + name + " = " + hash); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Attributes mainfestAttributes = manifest.getAttributes(name);
+ if (mainfestAttributes == null)
+ {
+ mainfestAttributes = new Attributes();
+ manifest.getEntries().put(name, mainfestAttributes);
+ }
+
+ mainfestAttributes.putValue(Main.DIGEST, hash);
+
+ // hash the newly added 2-header block and add it as an attribute to .SF
+
+ String sfHash = util.hashManifestEntry(name, hash);
+ Attributes sfAttributes = sfEntries.get(name);
+ if (sfAttributes == null)
+ {
+ sfAttributes = new Attributes();
+ sfEntries.put(name, sfAttributes);
+ }
+
+ sfAttributes.putValue(Main.DIGEST, sfHash);
+ if (Configuration.DEBUG)
+ {
+ log.fine("Name: " + name); //$NON-NLS-1$
+ log.fine(Main.DIGEST + ": " + sfHash); //$NON-NLS-1$
+ log.fine(""); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @param sectionsOnly whether to compute, in addition to the files, the hash
+ * of the mainfest itself (<code>false</code>) or not (<code>true</code>).
+ */
+ void finishSigning(boolean sectionsOnly) throws IOException
+ {
+ if (state != STARTED)
+ throw new IllegalStateException(Messages.getString("SFHelper.10")); //$NON-NLS-1$
+
+ if (sectionsOnly)
+ return;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ manifest.write(baos);
+ baos.flush();
+ String manifestHash = util.hashByteArray(baos.toByteArray());
+ if (Configuration.DEBUG)
+ log.fine("Hashed Manifest " + manifestHash); //$NON-NLS-1$
+ sfMainAttributes.putValue(Main.DIGEST_MANIFEST, manifestHash);
+
+ this.state = FINISHED;
+ }
+
+ /**
+ * Given an X.509 certificate this method returns the string representation of
+ * the Issuer Distinguished Name.
+ *
+ * @param cert an X.509 certificate.
+ * @return the string representation of the Issuer's DN.
+ */
+ private String getIssuerName(X509Certificate cert)
+ {
+ X500Principal xp = cert.getIssuerX500Principal();
+ if (xp == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null Issuer. Return [unknown]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.14"); //$NON-NLS-1$
+ }
+ String result = xp.getName();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has an Issuer with null DN. Return [unnamed]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.17"); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ * Given an X.509 certificate this method returns the string representation of
+ * the Subject Distinguished Name.
+ *
+ * @param cert an X.509 certificate.
+ * @return the string representation of the Subject's DN.
+ */
+ private String getSubjectName(X509Certificate cert)
+ {
+ X500Principal xp = cert.getSubjectX500Principal();
+ if (xp == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null Subject. Return [unknown]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.14"); //$NON-NLS-1$
+ }
+ String result = xp.getName();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has a Subject with null DN. Return [unnamed]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.17"); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ * Given an X.509 certificate this method returns the end validity date of
+ * this certificate.
+ *
+ * @param cert an X.509 certificate.
+ * @return the date when this certificate stops being valid.
+ */
+ private Date getNotAfterDate(X509Certificate cert)
+ {
+ Date result = cert.getNotAfter();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null start-validity date. Return epoch"); //$NON-NLS-1$
+ return new Date(0);
+ }
+ return result;
+ }
+
+ /**
+ * Given an X.509 certificate this method returns the start validity date of
+ * this certificate.
+ *
+ * @param cert an X.509 certificate.
+ * @return the date when this certificate starts being valid.
+ */
+ private Date getNotBeforeDate(X509Certificate cert)
+ {
+ Date result = cert.getNotBefore();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null end-validity date. Return epoch"); //$NON-NLS-1$
+ return new Date(0);
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/java2xhtml/Java2xhtml.java b/libjava/classpath/tools/gnu/classpath/tools/java2xhtml/Java2xhtml.java
new file mode 100644
index 000000000..90c6d4c38
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/java2xhtml/Java2xhtml.java
@@ -0,0 +1,1354 @@
+/* gnu.classpath.tools.java2xhtml.Java2xhtml
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+/** Java2xhtml.java Version 0.9
+ * Produces an XHTML file from Java source code with syntax highlighting,
+ * includes additional options (line numbering, tab spacing, etc.)
+ * <P>
+ * NOTE: Common java naming structure is assumed
+ * Capitalize the first letter that appears in a class or interface name
+ * Use lowercase for the first letter in a method or variable name
+ * Use only uppercase letters when naming constants
+ *
+ * @version 0.9, March 2003
+ * @author Shayne Steele
+ */
+package gnu.classpath.tools.java2xhtml;
+
+import java.io.*;
+import java.util.*;
+
+public class Java2xhtml
+{
+ //--- define CSS classes for individual output elements
+
+ private static final String sourceCodeStyle = "source";
+ private static final String lineNumberStyle = "line-number even";
+ private static final String modulusLineNumberStyle = "line-number odd";
+
+ private static final String keywordStyle = "keyword";
+ private static final String methodStyle = "method member";
+ private static final String variableStyle = "variable member";
+ private static final String singleLineCommentStyle = "line comment";
+ private static final String traditionalCommentStyle = "c comment";
+ private static final String javadocCommentStyle = "javadoc comment";
+ private static final String javadocTagStyle = "javadoc tag";
+ private static final String importNameStyle = "import header type";
+ private static final String packageNameStyle = "package header type";
+ private static final String primitiveTypeStyle = "primitive type";
+ private static final String nonPrimitiveTypeStyle = "non-primitive type";
+ private static final String constructorStyle = "constructor member";
+ private static final String constantStyle = "constant member";
+ private static final String doubleQuoteStyle = "double quote";
+ private static final String singleQuoteStyle = "single quote";
+ private static final String numericLiteralStyle = "numeric literal";
+ private static final String primitiveLiteralStyle = "primitive literal";
+
+ private static final String iconStyle = "icon";
+
+
+
+ // parse the command line arguments
+ // give a decent responce for bad input
+ // call the HTMLifier on good input
+ public static void main(String args[])
+ {
+ // parse the invokation arguments
+ if (args.length < 1 || args.length > 3) // invoked program incorrectly
+ {
+ System.out.println("Java2xhtml Version 0.9 (C) 2005 Free Software Foundation");
+ System.out.println(" Produces an XHTML file of Java source" +
+ " code with syntax highlighting,");
+ System.out.println(" includes additional options " +
+ "(line numbering, tab spacing, etc.)");
+ System.out.println(" This tool is part of GNU Classpath.");
+ System.out.println(" GNU Classpath is free software; you can redistribute it and/or modify");
+ System.out.println(" it under the terms of the GNU General Public License as published by");
+ System.out.println(" the Free Software Foundation; either version 2, or (at your option)");
+ System.out.println(" any later version.");
+ System.out.println(" NOTE: Common java naming structure is " +
+ "assumed");
+ System.out.println("");
+ System.out.println("USAGE:");
+ System.out.println("java [java options] Java2xhtml " +
+ "source.java [options file] " +
+ "[output file]");
+ System.out.println("");
+ System.out.println(" - java is the name of the Java interpreter");
+ System.out.println(" - [java options] are the optional options " +
+ "of the Java interpreter");
+ System.out.println(" - Java2xhtml is the name of this " +
+ "application");
+ System.out.println(" - source is a file or the directory to the " +
+ "Java source file(s)");
+ System.out.println(" - [options file] is the optional " +
+ "path of a file with");
+ System.out.println(" a structure like this:");
+ System.out.println(" externalStyleSheetName=file_name" +
+ " (default style.css)");
+ System.out.println(" tabSize=integer (default value is 4)");
+ System.out.println(" extraIndentation=integer " +
+ "(default value is 0)");
+ System.out.println(" lineModulus=integer (default value 5)");
+ System.out.println(" isCodeSnippet=boolean" +
+ " (default false)");
+ System.out.println(" isXHTML_1_1=boolean" +
+ " (default true)");
+ System.out.println(" hasInternalStyleSheet=boolean" +
+ " (default true)");
+ System.out.println(" hasExternalStyleSheet=boolean" +
+ " (default true)");
+ System.out.println(" hasTitle=boolean" +
+ " (default false)");
+ System.out.println(" hasLegend=boolean" +
+ " (default false)");
+ System.out.println(" hasAllBoldSourceCode=boolean" +
+ " (default false)");
+ System.out.println(" hasLineNumbers=boolean" +
+ " (default false)");
+ System.out.println(" hasLineModulusDrawnLines=boolean" +
+ " (default false)");
+ System.out.println(" hasLineModulusCodeBlocks=boolean" +
+ " (default false)");
+ System.out.println(" hasFooter=boolean" +
+ " (default false)");
+ System.out.println(" hasFooterIcons=boolean" +
+ " (default false)");
+ System.out.println(" hasFooterDate=boolean" +
+ " (default true)");
+ System.out.println(" NOTE: filename must end with '.prop'");
+ System.out.println(" Default [options file] is " +
+ "options.prop");
+ System.out.println(" - [output file] is name of the XHTML file " +
+ "that is produced");
+ System.out.println(" Default [output file] is source_java.html");
+ System.out.println("");
+ System.out.println("Output: source.java --> [output file]");
+ System.out.println(" Default Output is ");
+ System.out.println(" source.java --> source_java.html");
+ System.out.println("");
+ System.out.println("Examples of calling the program:");
+ System.out.println(" process one file (say Java2xhtml.java):");
+ System.out.println(" java Java2xhtml Java2xhtml.java");
+ System.out.println(" process one directory (say C:\\HOME):");
+ System.out.println(" java Java2xhtml C:\\HOME");
+ System.out.println(" process one directory (say C:\\HOME with a " +
+ "given options file (options.prop)):");
+ System.out.println(" java Java2xhtml C:\\HOME options.prop");
+ }
+ else
+ {
+ // invoked program correctly, now get command line arguments
+ // get the source file name
+ String sourceName;
+ sourceName = args[0];
+ // make sure that the source file exist and if so HTMLify it
+ File sourceFilePath = new File(sourceName);
+ if (sourceFilePath.exists())
+ {
+ // good pathname so HTMLify it
+ // get the default html options file name
+ String propertiesFileName = "options.prop";
+ // create a unique default html file name,
+ // bubba.java -> bubba_java.html
+ String htmlFileName = sourceName.replace('.', '_') + ".html";
+ if (args.length == 2 || args.length == 3)
+ {
+ if (args[1].endsWith(".prop"))
+ {
+ // get the user supplied html options file name
+ propertiesFileName = args[1];
+ }
+ else
+ {
+ // get the user supplied html outputfile name
+ htmlFileName = args[1];
+ }
+ }
+ if (args.length == 3)
+ {
+ if (args[2].endsWith(".prop"))
+ {
+ // get the user supplied html options file name
+ propertiesFileName = args[2];
+ }
+ else
+ {
+ // get the user supplied html outputfile name
+ htmlFileName = args[2];
+ }
+ }
+ new Java2xhtml(propertiesFileName, sourceFilePath,
+ htmlFileName);
+ }
+ else // source file does not exist, print message and exit normally
+ {
+ System.out.println("The source parameter must be an existent" +
+ " file or directory");
+ System.out.println("Run Java2xHtml without parameters for " +
+ "help");
+ }
+ }
+ }
+
+ // collect various sets of keywords
+ static Collection keywordCollection;
+ static Collection primitiveTypeCollection;
+ static Collection primitiveLiteralCollection;
+ static Collection javadocTagCollection;
+
+ // all these variables are changeable by a options file
+ int extraIndentation = 0;
+ int tabSize = 4;
+ int lineModulus = 5;
+ boolean hasLegend = false;
+ boolean hasLineNumbers = false;
+ boolean hasLineModulusDrawnLines = false;
+ boolean hasLineModulusCodeBlocks = false;
+ boolean hasFooter = false;
+ boolean hasFooterIcons = false;
+ boolean hasFooterDate = true;
+ boolean isCodeSnippet = false;
+ boolean isXHTML_1_1 = true;
+ boolean hasTitle = false;
+ boolean hasAllBoldSourceCode = false;
+ boolean hasInternalStyleSheet = true;
+ boolean hasExternalStyleSheet = true;
+ String externalStyleSheetName = "style.css";
+
+ static
+ {
+ // collection type is Hashset for unique elements and fast retieval
+ String keywordArray[] =
+ {
+ "abstract", "default", "if", "private",
+ "do", "implements", "protected", "throws",
+ "break", "import", "public", "transient",
+ "else", "instanceof", "return", "try",
+ "case", "extends", "throw", "static",
+ "catch", "final", "interface", "while",
+ "volatile", "finally", "super", "synchronized",
+ "class", "native", "switch", "package",
+ "const", "for", "new", "goto",
+ "continue", "this", "assert", "strictfp"
+ };
+ keywordCollection = new HashSet(Arrays.asList(keywordArray));
+ String primitiveTypeArray[] =
+ {
+ "boolean", "char", "byte", "short", "int",
+ "long", "float", "double", "void"
+ };
+ primitiveTypeCollection =
+ new HashSet(Arrays.asList(primitiveTypeArray));
+ String primitiveLiteralArray[]=
+ {
+ "false", "null", "true"
+ };
+ primitiveLiteralCollection =
+ new HashSet(Arrays.asList(primitiveLiteralArray));
+ String javadocTagArray[]=
+ {
+ "see", "author", "version", "param", "return", "exception",
+ "deprecated", "throws", "link", "since", "serial",
+ "serialField","serialData", "beaninfo"
+ };
+ javadocTagCollection = new HashSet(Arrays.asList(javadocTagArray));
+ }
+
+ public Java2xhtml()
+ {
+ }
+
+ // create the various keyword collections
+ // parse the html options file
+ Java2xhtml(String propertiesFileName, File sourceFilePath,
+ String htmlFileName)
+ {
+ // get html properties (use defaults if necessary)
+ File propertiesFilePath = new File (propertiesFileName);
+ if (propertiesFilePath.exists())
+ {
+ // html properies file exist try parsing it
+ try
+ {
+ InputStream propertiesFile =
+ new FileInputStream(propertiesFileName);
+ Properties htmlProperties = new Properties();
+ htmlProperties.load(propertiesFile);
+ propertiesFile.close();
+ setProperties(htmlProperties);
+ }
+ catch (IOException exception)
+ {
+ System.out.println(exception);
+ }
+ }
+ if (sourceFilePath.isFile())
+ {
+ // process the file
+ processFile(sourceFilePath, htmlFileName);
+ }
+ else if (sourceFilePath.isDirectory())
+ {
+ // process a directory
+ File [] sourceFilePathArray = sourceFilePath.listFiles();
+ for (int i = 0; i < sourceFilePathArray.length; i++)
+ {
+ if (((sourceFilePathArray[i]).getName()).endsWith(".java"))
+ {
+ // process each file that ends in .java
+ // create a unique default html file name,
+ // bubba.java -> bubba_java.html
+ htmlFileName = ((sourceFilePathArray[i]).getName()).replace(
+ '.', '_') + ".html";
+ processFile(sourceFilePathArray[i], htmlFileName);
+ }
+ }
+ }
+ }
+
+ public void setProperties(Properties htmlProperties)
+ {
+ hasLegend
+ = Boolean.valueOf(htmlProperties.getProperty("hasLegend",
+ "false")).booleanValue();
+ extraIndentation
+ = Integer.parseInt(htmlProperties.getProperty("extraIndentation", "0"));
+ tabSize
+ = Integer.parseInt(htmlProperties.getProperty("tabSize", "4"));
+ hasLineNumbers
+ = Boolean.valueOf(htmlProperties.getProperty("hasLineNumbers",
+ "false")).booleanValue();
+ lineModulus
+ = Integer.parseInt(htmlProperties.getProperty("lineModulus", "5"));
+ hasLineModulusDrawnLines
+ = Boolean.valueOf(htmlProperties.getProperty("hasLineModulusDrawnLines",
+ "false")).booleanValue();
+ hasLineModulusCodeBlocks
+ = Boolean.valueOf(htmlProperties.getProperty("hasLineModulusCodeBlocks",
+ "false")).booleanValue();
+ hasFooter
+ = Boolean.valueOf(htmlProperties.getProperty("hasFooter",
+ "false")).booleanValue();
+ hasFooterIcons
+ = Boolean.valueOf(htmlProperties.getProperty("hasFooterIcons",
+ "false")).booleanValue();
+ hasFooterDate
+ = Boolean.valueOf(htmlProperties.getProperty("hasFooterDate",
+ "true")).booleanValue();
+ isXHTML_1_1
+ = Boolean.valueOf(htmlProperties.getProperty("isXHTML_1_1",
+ "true")).booleanValue();
+ isCodeSnippet
+ = Boolean.valueOf(htmlProperties.getProperty("isCodeSnippet",
+ "false")).booleanValue();
+ hasTitle
+ = Boolean.valueOf(htmlProperties.getProperty("hasTitle",
+ "false")).booleanValue();
+ hasAllBoldSourceCode
+ = Boolean.valueOf(htmlProperties.getProperty("hasAllBoldSourceCode",
+ "false")).booleanValue();
+ hasInternalStyleSheet
+ = Boolean.valueOf(htmlProperties.getProperty("hasInternalStyleSheet",
+ "true")).booleanValue();
+ hasExternalStyleSheet
+ = Boolean.valueOf(htmlProperties.getProperty("hasExternalStyleSheet",
+ "true")).booleanValue();
+ externalStyleSheetName
+ = htmlProperties.getProperty("externalStyleSheetName", "style.css");
+ }
+
+
+ // read the file and put it into a stringbuffer
+ void processFile(File sourceFilePath, String htmlFileName)
+ {
+ // open the file, copy it to a Stringbuffer , process into an
+ // HTMLified String and convert result into an HTML file
+ try
+ {
+ BufferedReader sourceReader =
+ new BufferedReader(new FileReader(sourceFilePath));
+ StringBuffer bufferIn = new StringBuffer();
+ int readInInt = 0;
+ char presentChar = 0;
+ // copy file into a Stringbuffer
+ while (readInInt != -1) // -1 value means end of stream/file
+ {
+ // put the file into a Stringbuffer
+ readInInt= sourceReader.read();
+ presentChar = ((readInInt >= 0) ? (char) readInInt : 0);
+ bufferIn.append(presentChar);
+ }
+ sourceReader.close();
+ BufferedWriter tempBufferedWriter =
+ new BufferedWriter(new FileWriter(htmlFileName));
+ tempBufferedWriter.write(makeHTML(bufferIn,
+ sourceFilePath.getName()));
+ tempBufferedWriter.close();
+ System.out.println(sourceFilePath.getName() + " --> " +
+ htmlFileName);
+ }
+ catch (IOException exception)
+ {
+ System.out.println(exception);
+ }
+ }
+
+ // constant 'States' java source code can be in
+ public final static class State
+ {
+ public final static State TEXT = new State();
+ public final static State IMPORT_NAME = new State();
+ public final static State PARAM_VARIABLE = new State();
+ public final static State JAVADOC = new State();
+ public final static State PACKAGE_NAME = new State();
+ public final static State DOUBLE_QUOTE = new State();
+ public final static State SINGLE_QUOTE = new State();
+ public final static State TRADITIONAL_COMMENT = new State();
+ public final static State LINE_COMMENT = new State();
+
+ // empty constructor
+ private State()
+ {
+ // empty body
+ }
+ }
+
+ // Convert java source code StringBufffer into colorized (and tab spaced)
+ // HTML String .
+ // Assumes that Java naming convention is used
+ // Uses a very basic state machine design.
+ public String makeHTML(StringBuffer bufferIn, String sourceFileName)
+ {
+ int codeLineNumber = 0;
+ boolean isNewLine = true;
+ boolean isNewBlock = true;
+ int identifierLength = 0;
+ int qualifiedIdentifierLength = 0;
+ int presentIndex = -1;
+ int spaceLength = 0;
+ int saveIndex = 0;
+ char presentChar = 0;
+ State presentState = State.TEXT;
+ StringBuffer bufferOut = new StringBuffer(8192);
+ if (!isCodeSnippet)
+ {
+ bufferOut.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
+ if (isXHTML_1_1)
+ {
+ bufferOut.append("<!DOCTYPE html PUBLIC " +
+ "\"-//W3C//DTD XHTML 1.1//EN\"\r\n");
+ bufferOut.append(" \"http://www.w3.org/TR/xhtml11/DTD/" +
+ "xhtml11.dtd\">\r\n");
+ bufferOut.append("<html xmlns=\"http://www.w3.org/1999/xhtml\""+
+ " xml:lang=\"en\">\r\n");
+ }
+ else
+ {
+ bufferOut.append("<!DOCTYPE html PUBLIC " +
+ "\"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n");
+ bufferOut.append(" \"http://www.w3.org/TR/xhtml1/DTD/" +
+ "xhtml1-strict.dtd\">\r\n");
+ bufferOut.append("<html xmlns=\"http://www.w3.org/1999/xhtml\""+
+ " xml:lang=\"en\" lang=\"en\">\r\n");
+ }
+ bufferOut.append(" <head>\r\n");
+ bufferOut.append(" <title>\r\n");
+ bufferOut.append(" " + sourceFileName + "\r\n");
+ bufferOut.append(" </title>\r\n");
+ bufferOut.append(" <meta name=\"generator\"\r\n");
+ bufferOut.append(" content=\"Java2xhtml 0.9\" />\r\n");
+ if (hasInternalStyleSheet)
+ {
+ bufferOut.append(" <style type=\"text/css\">\r\n");
+ bufferOut.append(" <!-- /* <![CDATA[ */\r\n");
+ bufferOut.append(" ." + sourceCodeStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #000000;\r\n");
+ bufferOut.append(" background-color: #FFFFFF;\r\n");
+ if (hasAllBoldSourceCode)
+ {
+ bufferOut.append(" font-weight: bold;\r\n");
+ }
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + lineNumberStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" font-weight: normal;\r\n");
+ bufferOut.append(" color: #000000;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ if (lineModulus > 0)
+ {
+ bufferOut.append(" ." + modulusLineNumberStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" font-weight: bold;\r\n");
+ bufferOut.append(" color: #000000;\r\n");
+ bufferOut.append(" background-color: ");
+ bufferOut.append("transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ if (hasLineModulusDrawnLines)
+ {
+ bufferOut.append(" .modulusLineStyle\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" text-decoration: ");
+ bufferOut.append("line-through;\r\n");
+ bufferOut.append(" color: #000000;\r\n");
+ bufferOut.append(" background-color: ");
+ bufferOut.append("transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ }
+ if (hasLineModulusCodeBlocks)
+ {
+ bufferOut.append(" .modulusBlockPREStyle\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" margin: 0em\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" .modulusBlockStyle\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #000000;\r\n");
+ bufferOut.append(" background-color: ");
+ bufferOut.append("#CCCCCC;\r\n");
+ bufferOut.append(" }\r\n");
+ }
+ }
+ bufferOut.append(" ." + keywordStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #9900FF;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + methodStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #0000FF;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + variableStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #CC9933;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + singleLineCommentStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #CC3333;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + traditionalCommentStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #FF0000;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + javadocCommentStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #CC0033;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + javadocTagStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #0099CC;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + importNameStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #33CCCC;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + packageNameStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #339999;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + primitiveTypeStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #009900;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + nonPrimitiveTypeStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #009966;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + constructorStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #3300CC;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + constantStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #666666;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + doubleQuoteStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #996633;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" font-style: italic;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + singleQuoteStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #663333;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" font-style: oblique;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + numericLiteralStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #333300;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" ." + primitiveLiteralStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" color: #006600;\r\n");
+ bufferOut.append(" background-color: transparent;\r\n");
+ bufferOut.append(" }\r\n");
+ if (hasFooterIcons)
+ {
+ bufferOut.append(" ." + iconStyle + "\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" border-style: none;\r\n");
+ bufferOut.append(" }\r\n");
+ }
+ if (hasTitle)
+ {
+ bufferOut.append(" #title\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" text-align: center;\r\n");
+ bufferOut.append(" font-size: xx-large;\r\n");
+ bufferOut.append(" }\r\n");
+ }
+ if (hasLegend)
+ {
+ bufferOut.append(" #legendTitle\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" text-align: center;\r\n");
+ bufferOut.append(" font-size: x-large;\r\n");
+ bufferOut.append(" }\r\n");
+ bufferOut.append(" #legend\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" font-family: monospace;\r\n");
+ bufferOut.append(" font-size: large;\r\n");
+ bufferOut.append(" }\r\n");
+ }
+ if (hasFooter)
+ {
+ bufferOut.append(" #footer\r\n");
+ bufferOut.append(" {\r\n");
+ bufferOut.append(" font-size: xx-small;\r\n");
+ bufferOut.append(" }\r\n");
+ }
+ bufferOut.append(" /* ]]> */ -->\r\n");
+ bufferOut.append(" </style>\r\n");
+ }
+
+ if (hasExternalStyleSheet)
+ {
+ bufferOut.append(" <link rel=\"stylesheet\" " +
+ "type=\"text/css\" href=\"" +
+ externalStyleSheetName + "\" />\r\n");
+ }
+ bufferOut.append(" </head>\r\n");
+ bufferOut.append(" <body>\r\n");
+ }
+ if (hasTitle)
+ {
+ bufferOut.append(" <div id=\"title\">\r\n");
+ bufferOut.append(" " + sourceFileName + "\r\n");
+ bufferOut.append(" </div>\r\n");
+ bufferOut.append(" <hr />\r\n");
+ }
+ if (hasLegend)
+ {
+ bufferOut.append(" <div id=\"legendTitle\">\r\n");
+ bufferOut.append(" Legend\r\n");
+ bufferOut.append(" </div>\r\n");
+ bufferOut.append(" <div class=\"" + sourceCodeStyle + "\">\r\n");
+ bufferOut.append(" <div id=\"legend\">\r\n");
+ bufferOut.append(" <span class=\"" + keywordStyle + "\">");
+ bufferOut.append("keyword</span>\r\n");
+ bufferOut.append(" <span class=\"" + methodStyle + "\">");
+ bufferOut.append("method</span>\r\n");
+ bufferOut.append(" <span class=\"" + variableStyle + "\">variable" +
+ "</span>\r\n");
+ bufferOut.append(" <span class=\"" + singleLineCommentStyle + "\">" +
+ "singleLineComment</span>\r\n");
+ bufferOut.append(" <span class=\"" + traditionalCommentStyle + "\">" +
+ "traditionalComment</span>\r\n");
+ bufferOut.append(" <span class=\"" + javadocCommentStyle + "\">" +
+ "javadocComment</span>\r\n");
+ bufferOut.append(" <span class=\"" + javadocTagStyle + "\">javadocTag" +
+ "</span>\r\n");
+ bufferOut.append(" <span class=\"" + importNameStyle + "\">" +
+ "importName</span>\r\n");
+ bufferOut.append(" <span class=\"" + packageNameStyle + "\">" +
+ "packageName</span>\r\n");
+ bufferOut.append(" <span class=\"" + primitiveTypeStyle + "\">" +
+ "primitiveType</span>\r\n");
+ bufferOut.append(" <span class=\"" + nonPrimitiveTypeStyle + "\">" +
+ "nonPrimitiveType</span>\r\n");
+ bufferOut.append(" <span class=\"" + constructorStyle + "\">" +
+ "constructor</span>\r\n");
+ bufferOut.append(" <span class=\"" + constantStyle + "\">" +
+ "constant</span>\r\n");
+ bufferOut.append(" <span class=\"" + doubleQuoteStyle + "\">" +
+ "doubleQuote</span>\r\n");
+ bufferOut.append(" <span class=\"" + singleQuoteStyle + "\">" +
+ "singleQuote</span>\r\n");
+ bufferOut.append(" <span class=\"" + numericLiteralStyle + "\">" +
+ "numericLiteral</span>\r\n");
+ bufferOut.append(" <span class=\"" + primitiveLiteralStyle + "\">" +
+ "primitiveLiteral</span>\r\n");
+ bufferOut.append(" </div>\r\n");
+ bufferOut.append(" </div>\r\n");
+ bufferOut.append(" <hr />\r\n");
+ }
+ bufferOut.append(" <div class=\"" + sourceCodeStyle + "\">\r\n");
+ if (hasLineModulusCodeBlocks)
+ {
+ bufferOut.append("<pre class=\"modulusBlockPREStyle\">\r\n");
+ }
+ else
+ {
+ bufferOut.append("<pre>\r\n");
+ }
+ // process the input Java code Stringbuffer
+ // subtract 2 from the bufferIn.length() to get EOF marker
+ while (presentIndex++ < (bufferIn.length() - 2))
+ {
+ for (int i = 0; i < extraIndentation; i++)
+ {
+ bufferOut.append(" ");
+ }
+ if ((hasLineNumbers || hasLineModulusCodeBlocks) && isNewLine)
+ {
+ // add line numbers if desired
+ // line numbers are 1 - 9999 then rotate line numbers
+ codeLineNumber = (++codeLineNumber)%10000;
+ if ((lineModulus > 0) && hasLineModulusCodeBlocks &&
+ (codeLineNumber%lineModulus == 1))
+ {
+ if (isNewBlock)
+ {
+ if ((State.TRADITIONAL_COMMENT == presentState) ||
+ (State.JAVADOC == presentState))
+ {
+ bufferOut.insert((bufferOut.length() -
+ ("\r\n").length()),
+ "</span>");
+ }
+ bufferOut.append("</pre>\r\n");
+ bufferOut.append(" <div class=");
+ bufferOut.append("\"modulusBlockStyle\">");
+ bufferOut.append("\r\n<pre class=\"");
+ bufferOut.append("modulusBlockPREStyle\">\r\n");
+ if (State.TRADITIONAL_COMMENT == presentState)
+ {
+ bufferOut.append("<span class=" +
+ "\"" + traditionalCommentStyle + "\">");
+ }
+ if (State.JAVADOC == presentState)
+ {
+ bufferOut.append("<span class=" +
+ "\"" + javadocCommentStyle + "\">");
+ }
+ }
+ isNewBlock = !isNewBlock;
+ }
+ // make straight columns of line numbers
+ if (codeLineNumber < 1000)
+ {
+ bufferOut.append(" ");
+ }
+ if (codeLineNumber < 100)
+ {
+ bufferOut.append(" ");
+ }
+ if (codeLineNumber < 10)
+ {
+ bufferOut.append(" ");
+ }
+ bufferOut.append("<a name=\"line.");
+ bufferOut.append(codeLineNumber);
+ bufferOut.append("\">");
+
+ if (hasLineNumbers)
+ {
+ if ((lineModulus > 0) && (codeLineNumber%lineModulus == 0))
+ {
+ bufferOut.append("<span class=" +
+ "\"" + modulusLineNumberStyle + "\">");
+ bufferOut.append(codeLineNumber);
+ bufferOut.append(": </span>");
+ if (hasLineModulusDrawnLines)
+ {
+ // compute spaceLength so a line can be drawn
+ while ((presentIndex != (bufferIn.length() - 1)) &&
+ ((Character.isSpaceChar(
+ bufferIn.charAt(presentIndex))) ||
+ (bufferIn.charAt(presentIndex) == '\t')))
+ {
+ // for each tab, insert tabSize spaces
+ if (bufferIn.charAt(presentIndex) == '\t')
+ {
+ for (int i = 0; i < tabSize; i++)
+ {
+ bufferIn.insert(presentIndex + 1, " ");
+ }
+ presentIndex++;
+ continue;
+ }
+ if (' ' == bufferIn.charAt(presentIndex))
+ {
+ // read a space so place a space
+ bufferOut.append(" ");
+ spaceLength += (" ").length();
+ }
+ else
+ {
+ // a white space character was read
+ bufferOut.append(bufferIn.charAt(
+ presentIndex));
+ ++spaceLength;
+ }
+ presentIndex++;
+ }
+ // check if line is empty
+ // (no printable characters on line)
+ if ((presentIndex == (bufferIn.length() - 1)) ||
+ (Character.isWhitespace(bufferIn.charAt(
+ presentIndex))))
+ {
+ spaceLength = 0;
+ }
+ // draw the line
+ if (spaceLength > 1)
+ {
+ bufferOut.insert((bufferOut.length() -
+ spaceLength), "<span class=" +
+ "\"modulusLineStyle\">");
+ bufferOut.insert((bufferOut.length() -
+ (" ").length()), "</span>");
+ }
+ spaceLength = 0;
+ }
+ }
+ else
+ {
+ // line numbers are in lineNumberColor
+ bufferOut.append("<span class=\"" + lineNumberStyle + "\">");
+ bufferOut.append(codeLineNumber);
+ bufferOut.append(":</span> ");
+ }
+ }
+ isNewLine = false;
+
+ bufferOut.append("</a>");
+ }
+ // a state machine
+ presentChar = bufferIn.charAt(presentIndex);
+ if ((Character.isJavaIdentifierPart(presentChar)) ||
+ ((State.IMPORT_NAME == presentState) && (presentChar == '*')))
+ {
+ // this is an identifier
+ bufferOut.append(presentChar);
+ identifierLength++;
+ continue; // keep adding characters until identifier is done
+ }
+ if (identifierLength > 0)
+ {
+ // identifier
+ qualifiedIdentifierLength =
+ qualifiedIdentifierLength + identifierLength;
+ if (bufferIn.charAt(presentIndex) == '.')
+ {
+ // qualified identifier
+ bufferOut.append(presentChar);
+ qualifiedIdentifierLength++;
+ identifierLength = 0;
+ continue; // keep adding characters to qualified identifier
+ }
+ String identifier =
+ bufferOut.substring(bufferOut.length() -
+ identifierLength);
+ if ((State.PARAM_VARIABLE == presentState))
+ {
+ // any identifier after a param in a javadoc is assumed to
+ // be a variable
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + variableStyle + "\">");
+ bufferOut.append("</span>");
+ presentState = State.JAVADOC;
+ }
+ else if (State.JAVADOC == presentState)
+ {
+ // in javadoc state
+ if ((javadocTagCollection.contains(identifier)) &&
+ (bufferIn.charAt(presentIndex -
+ (identifierLength + 1)) == '@'))
+ {
+ // identifier is a javadocTag
+ bufferOut.insert(bufferOut.length() - identifierLength,
+ "<span class=\"" + javadocTagStyle + "\">");
+ bufferOut.append("</span>");
+ if (("param").equals(identifier))
+ {
+ // any identifier after a param is assumed to
+ // be a variable, get into a state to do this
+ presentState = State.PARAM_VARIABLE;
+ }
+ }
+ }
+ else if (State.IMPORT_NAME == presentState)
+ {
+ // import identifier
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + importNameStyle + "\">");
+ bufferOut.append("</span>");
+ presentState = State.TEXT;
+ }
+ else if (State.PACKAGE_NAME == presentState)
+ {
+ // package identifier
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + packageNameStyle + "\">");
+ bufferOut.append("</span>");
+ presentState = State.TEXT;
+ }
+ else if (State.TEXT == presentState)
+ {
+ if (keywordCollection.contains(identifier))
+ {
+ // identifier is a keyword
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + keywordStyle + "\">");
+ bufferOut.append("</span>");
+ if (("import").equals(identifier))
+ {
+ // anything after an import in text mode must be
+ // an import name, so enter state to process this
+ presentState = State.IMPORT_NAME;
+ }
+ else if (("package").equals(identifier))
+ {
+ // anything after an package in text mode must be
+ // an package name, so enter state to process this
+ presentState = State.PACKAGE_NAME;
+ }
+ }
+ else if (primitiveTypeCollection.contains(identifier))
+ {
+ // identifier is a primitive type
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + primitiveTypeStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ else if ((identifier.equals(identifier.toUpperCase())) &&
+ (!(Character.isDigit(identifier.charAt(0)))))
+ {
+ // identifier is a constant
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + constantStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ else if (Character.isUpperCase(identifier.charAt(0)))
+ {
+ // identifier is a constructor or non-primitive type
+ // eat white space
+ saveIndex = presentIndex;
+ while (Character.isWhitespace(
+ bufferIn.charAt(saveIndex++)))
+ {
+ //empty body
+ }
+ if (bufferIn.charAt(--saveIndex) == '(')
+ { // identifier is a constructor
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=" +
+ "\"" + constructorStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ else
+ {
+ // identifier is a non-primitive type
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=" +
+ "\"" + nonPrimitiveTypeStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ }
+ else if (!(Character.isDigit(identifier.charAt(0)) ||
+ primitiveLiteralCollection.contains(identifier)))
+ {
+ // identifier is a method or a variable
+ // eat white space
+ saveIndex = presentIndex;
+ while (Character.isWhitespace(
+ bufferIn.charAt(saveIndex++)))
+ {
+ // empty body
+ }
+ --saveIndex;
+ // identifier is a method
+ if (bufferIn.charAt(saveIndex) == '(')
+ {
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + methodStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ else if (bufferIn.charAt(saveIndex) == ',')
+ {
+ // comma seperated variables
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + variableStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ else
+ {
+ // a variable
+ // take care of cases such as array[index].variable
+ if (bufferIn.charAt(presentIndex -
+ (qualifiedIdentifierLength
+ + 1)) == '.')
+ {
+ qualifiedIdentifierLength++;
+ }
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=\"" + variableStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ }
+ else
+ {
+ if (primitiveLiteralCollection.contains(identifier))
+ {
+ // primitiveLiteral (boolean or null)
+ bufferOut.insert(bufferOut.length() -
+ identifierLength, "<span class=" +
+ "\"" + primitiveLiteralStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ // a numeric literal
+ else
+ {
+ if (((presentIndex -
+ (qualifiedIdentifierLength + 1)) > 0) &&
+ (bufferIn.charAt(presentIndex -
+ (qualifiedIdentifierLength + 1)) == '.'))
+ {
+ qualifiedIdentifierLength++;
+ }
+ bufferOut.insert(bufferOut.length() -
+ qualifiedIdentifierLength,
+ "<span class=" +
+ "\"" + numericLiteralStyle + "\">");
+ bufferOut.append("</span>");
+ }
+ }
+ }
+ qualifiedIdentifierLength = 0;
+ identifierLength = 0;
+ }
+ // process characters NOT in identifiers
+ switch (presentChar)
+ {
+ case '&': //ampersand
+ bufferOut.append("&amp;"); // HTMLify character
+ break;
+ case '<': // less than sign
+ bufferOut.append("&lt;"); // HTMLify character
+ break;
+ case '>': // greater than sign
+ bufferOut.append("&gt;"); // HTMLify character
+ break;
+ case '\"': // double quote
+ bufferOut.append("&quot;"); // HTMLify character
+ if (State.TEXT == presentState)
+ {
+ presentState = State.DOUBLE_QUOTE;
+ bufferOut.insert(bufferOut.length()-("&quot;").length(),
+ "<span class=\"" + doubleQuoteStyle + "\">");
+ }
+ else if (State.DOUBLE_QUOTE == presentState)
+ {
+ presentState = State.TEXT;
+ bufferOut.append("</span>");
+ }
+ break;
+ case '\'': // single quote
+ bufferOut.append("\'");
+ if (State.TEXT == presentState)
+ {
+ presentState = State.SINGLE_QUOTE;
+ bufferOut.insert(bufferOut.length() - ("\'").length(),
+ "<span class=\"" + singleQuoteStyle + "\">");
+ }
+ else if (State.SINGLE_QUOTE == presentState)
+ {
+ presentState = State.TEXT;
+ bufferOut.append("</span>");
+ }
+ break;
+ case '\\': // backslash
+ bufferOut.append("\\");
+ if ((State.DOUBLE_QUOTE == presentState) ||
+ (State.SINGLE_QUOTE == presentState))
+ {
+ // treat as a character escape sequence
+ bufferOut.append(bufferIn.charAt(++presentIndex));
+ }
+ break;
+ case '\t': // tab
+ // replace tabs with tabsize number of spaces
+ for (int i = 0; i < tabSize; i++)
+ {
+ bufferOut.append(' ');
+ }
+ break;
+ case '*': // star
+ bufferOut.append("*");
+ if ((State.TEXT == presentState) &&
+ (bufferIn.charAt(presentIndex - 1) == '/'))
+ {
+ if (((bufferIn.length() - 1) > presentIndex) &&
+ (bufferIn.charAt(presentIndex + 1) == '*'))
+ {
+ presentState = State.JAVADOC;
+ bufferOut.insert(bufferOut.length() -
+ ("/*").length(), "<span class=" +
+ "\"" + javadocCommentStyle + "\">");
+ }
+ else
+ {
+ presentState = State.TRADITIONAL_COMMENT;
+ bufferOut.insert(bufferOut.length() -
+ ("/*").length(), "<span class=" +
+ "\"" + traditionalCommentStyle + "\">");
+ }
+ }
+ break;
+ case '/': // foward slash
+ bufferOut.append("/");
+ if (((State.TRADITIONAL_COMMENT == presentState) ||
+ (State.JAVADOC == presentState)) &&
+ (bufferIn.charAt(presentIndex - 1) == '*'))
+ {
+ bufferOut.append("</span>");
+ presentState = State.TEXT;
+ }
+ if ((State.TEXT == presentState) &&
+ (presentIndex > 0) &&
+ (bufferIn.charAt(presentIndex - 1) == '/'))
+ {
+ bufferOut.insert(bufferOut.length() - ("//").length(),
+ "<span class=" +
+ "\"" + singleLineCommentStyle + "\">");
+ presentState = State.LINE_COMMENT;
+ }
+ break;
+ case '\r': // carriage return
+ // fall through
+ case '\n': // line feed
+ // all HTML lines end in \r\n
+ if ((bufferIn.charAt(presentIndex) == '\r') &&
+ ((bufferIn.length() - 1) > presentIndex) &&
+ (bufferIn.charAt(presentIndex + 1) == '\n'))
+ {
+ ++presentIndex;
+ }
+ // end single line comments
+ if (State.LINE_COMMENT == presentState)
+ {
+ bufferOut.append("</span>");
+ presentState = State.TEXT;
+ }
+ // end of block
+ if ((lineModulus > 0) && hasLineModulusCodeBlocks &&
+ ((codeLineNumber%lineModulus == 0) && !isNewBlock))
+ {
+ // end multi-line spanning states
+ if ((State.TRADITIONAL_COMMENT == presentState) ||
+ (State.JAVADOC == presentState))
+ {
+ bufferOut.append("</span>");
+ }
+ bufferOut.append("\r\n");
+ bufferOut.append("</pre>\r\n");
+ bufferOut.append(" </div>\r\n");
+ bufferOut.append("<pre class=\"");
+ bufferOut.append("modulusBlockPREStyle\">\r\n");
+ // restart multi-line spanning states
+ if (State.TRADITIONAL_COMMENT == presentState)
+ {
+ bufferOut.append("<span class=" +
+ "\"" + traditionalCommentStyle + "\">");
+ }
+ if (State.JAVADOC == presentState)
+ {
+ bufferOut.append("<span class=" +
+ "\"" + javadocCommentStyle + "\">");
+ }
+ }
+ else
+ {
+ // div automatically starts new line
+ bufferOut.append("\r\n");
+ }
+ isNewLine = true;
+ break;
+ case 0: // nul character
+ if ((State.LINE_COMMENT == presentState) &&
+ (presentIndex == (bufferIn.length() - 1)))
+ {
+ bufferOut.append("</span>");
+ }
+ break;
+ default: // everything else
+ bufferOut.append(presentChar);
+ }
+ qualifiedIdentifierLength = 0;
+ }
+ if (presentState == State.LINE_COMMENT) {
+ bufferOut.append("</span>\r\n");
+ }
+
+ bufferOut.append("</pre>\r\n");
+ // end block early if no more source code
+ if ((lineModulus > 0) && hasLineModulusCodeBlocks && !isNewBlock &&
+ (codeLineNumber%lineModulus != 0))
+ {
+ bufferOut.append(" </div>\r\n");
+ }
+ bufferOut.append(" </div>\r\n"); // end div of sourceCodeStyle
+ // if code snippet then don't add ending tags of xhtml page
+ if (!isCodeSnippet)
+ {
+ // if footer mode then add a footer
+ if (hasFooter)
+ {
+ bufferOut.append(" <hr />\r\n");
+ bufferOut.append(" <div id=\"footer\">\r\n");
+ if (hasFooterIcons)
+ {
+ if (hasFooterDate)
+ {
+ bufferOut.append(" <script type=\"text/javaScript\"");
+ bufferOut.append(">\r\n");
+ bufferOut.append(" <!-- // <![CDATA[\r\n");
+ bufferOut.append(" document.write(\"Document last");
+ bufferOut.append(" modified on \"");
+ bufferOut.append(" + document.lastModified + ");
+ bufferOut.append("\"<br />\");\r\n");
+ bufferOut.append(" // ]]> -->\r\n");
+ bufferOut.append(" </script>\r\n");
+ }
+ bufferOut.append(" <a href=\"");
+ bufferOut.append("http://validator.w3.org/check/referer");
+ bufferOut.append("\">\r\n");
+ bufferOut.append(" <img class=\"" + iconStyle + "\" src=\"");
+ bufferOut.append("http://www.w3.org/Icons/");
+ if (isXHTML_1_1)
+ {
+ bufferOut.append("valid-xhtml11\"\r\n");
+ bufferOut.append(" alt=\"Valid XHTML 1.1!\"");
+ }
+ else
+ {
+ bufferOut.append("valid-xhtml10\"\r\n");
+ bufferOut.append(" alt=\"Valid XHTML 1.0!\"");
+ }
+ bufferOut.append(" height=\"31\" ");
+ bufferOut.append("width=\"88\" />\r\n");
+ bufferOut.append(" </a>\r\n");
+ bufferOut.append(" &#160;\r\n");
+ bufferOut.append(" <a href=\"");
+ bufferOut.append("http://jigsaw.w3.org");
+ bufferOut.append("/css-validator/check/referer");
+ bufferOut.append("\">\r\n");
+ bufferOut.append(" <img class=\"" + iconStyle + "\" src=\"");
+ bufferOut.append("http://jigsaw.w3.org/");
+ bufferOut.append("css-validator/images/vcss");
+ bufferOut.append("\"\r\n");
+ bufferOut.append(" alt=\"Valid CSS!\"");
+ bufferOut.append(" height=\"31\" width=\"88\" />\r\n");
+ bufferOut.append(" </a>\r\n");
+ }
+ else
+ {
+ bufferOut.append(" This is a valid\r\n");
+ bufferOut.append(" <a href=\"http://");
+ bufferOut.append("validator.w3.org/check/referer");
+ if (isXHTML_1_1)
+ {
+ bufferOut.append("\">XHTML 1.1</a>\r\n");
+ }
+ else
+ {
+ bufferOut.append("\">XHTML 1.0</a>\r\n");
+ }
+ bufferOut.append(" with\r\n");
+ bufferOut.append(" <a href=\"http://");
+ bufferOut.append("jigsaw.w3.org");
+ bufferOut.append("/css-validator/check/referer");
+ bufferOut.append("\">CSS</a>\r\n");
+ bufferOut.append(" document \r\n");
+ if (hasFooterDate)
+ {
+ bufferOut.append(" <script type=\"text/javaScript\"");
+ bufferOut.append(">\r\n");
+ bufferOut.append(" <!-- // <![CDATA[\r\n");
+ bufferOut.append(" document.write(\"last modified");
+ bufferOut.append(" on \" + document.lastModified);");
+ bufferOut.append("\r\n");
+ bufferOut.append(" // ]]> -->\r\n");
+ bufferOut.append(" </script>\r\n");
+ }
+ }
+ bufferOut.append(" </div>\r\n");
+ }
+ bufferOut.append(" </body>\r\n");
+ bufferOut.append("</html>\r\n");
+ }
+ return bufferOut.toString();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java
new file mode 100644
index 000000000..ffecac35c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java
@@ -0,0 +1,376 @@
+/* ClassWrapper.java - wrap ASM class objects
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.objectweb.asm.tree.ClassNode;
+import org.objectweb.asm.tree.FieldNode;
+import org.objectweb.asm.tree.MethodNode;
+
+public class ClassWrapper
+ extends ClassNode
+{
+ Main classpath;
+
+ ClassWrapper superClass;
+
+ ArrayList<ClassWrapper> interfaceClasses;
+
+ // The virtual table for this class.
+ ArrayList<MethodNode> vtable;
+
+ // A set of all the bridge method targets we've found.
+ HashSet<String> bridgeTargets;
+
+ // A set of all the method names in this class.
+ HashSet<String> methodNames = new HashSet<String>();
+
+ // This maps a method name + descriptor, e.g. "method()V", to the
+ // name chosen for the method. This is used when computing the
+ // names of bridge method targets.
+ HashMap<String,String> methodNameMap = new HashMap<String,String>();
+
+ public ClassWrapper(Main classpath)
+ {
+ this.classpath = classpath;
+ }
+
+ public boolean hasNativeMethod()
+ {
+ Iterator<?> i = methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode method = (MethodNode) i.next();
+ if (Modifier.isNative(method.access))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isThrowable() throws IOException
+ {
+ linkSupers();
+ ClassWrapper self = this;
+ while (self != null)
+ {
+ if (self.name.equals("java/lang/Throwable"))
+ return true;
+ self = self.superClass;
+ }
+ return false;
+ }
+
+ void linkSupers() throws IOException
+ {
+ if (superName == null)
+ {
+ // Object, do nothing.
+ return;
+ }
+ if (superClass == null)
+ {
+ superClass = classpath.getClass(superName);
+ assert interfaceClasses == null;
+ interfaceClasses = new ArrayList<ClassWrapper>();
+ for (int i = 0; i < interfaces.size(); ++i)
+ {
+ String ifname = (String) interfaces.get(i);
+ ClassWrapper iface = classpath.getClass(ifname);
+ iface.linkSupers();
+ interfaceClasses.add(iface);
+ }
+ }
+ superClass.linkSupers();
+ }
+
+ private int findSlot(MethodNode method)
+ {
+ for (int i = vtable.size() - 1; i >= 0; --i)
+ {
+ MethodNode base = vtable.get(i);
+ if (MethodHelper.overrides(method, base))
+ return i;
+ }
+ return - 1;
+ }
+
+ private void addInterfaceMethods(ClassWrapper iface)
+ {
+ Iterator<?> i = iface.methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode im = (MethodNode) i.next();
+ int slot = findSlot(im);
+ if (slot == - 1)
+ {
+ vtable.add(im);
+ // Also add it to our local methods.
+ methods.add(im);
+ }
+ }
+ addInterfaces(iface);
+ }
+
+ private void addInterfaces(ClassWrapper base)
+ {
+ if (base.interfaceClasses == null)
+ return;
+ Iterator<?> i = base.interfaceClasses.iterator();
+ while (i.hasNext())
+ {
+ ClassWrapper iface = (ClassWrapper) i.next();
+ addInterfaceMethods(iface);
+ }
+ }
+
+ private void addLocalMethods()
+ {
+ Iterator<?> i = methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode meth = (MethodNode) i.next();
+ methodNames.add(meth.name);
+ if (Modifier.isStatic(meth.access))
+ continue;
+ int slot = findSlot(meth);
+ if (slot == - 1)
+ vtable.add(meth);
+ else
+ vtable.set(slot, meth);
+ }
+ }
+
+ private void makeVtable() throws IOException
+ {
+ if (vtable != null)
+ return;
+ if (superClass != null)
+ {
+ superClass.makeVtable();
+ vtable = new ArrayList<MethodNode>(superClass.vtable);
+ bridgeTargets = new HashSet<String>(superClass.bridgeTargets);
+ methodNameMap = new HashMap<String,String>(superClass.methodNameMap);
+ }
+ else
+ {
+ // Object.
+ vtable = new ArrayList<MethodNode>();
+ bridgeTargets = new HashSet<String>();
+ methodNameMap = new HashMap<String,String>();
+ }
+ addLocalMethods();
+ addInterfaces(this);
+
+ // Make a set of all the targets of bridge methods. We rename
+ // bridge target methods to avoid problems with C++. You might
+ // think we could rename the bridge methods themselves, but bridge
+ // methods by definition override a method from the superclass --
+ // and we have to consider the superclass' header as an
+ // unchangeable entity.
+ Iterator<?> i = methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode m = (MethodNode) i.next();
+ String desc = MethodHelper.getBridgeTarget(m);
+ if (desc != null)
+ {
+ String sum = m.name + desc;
+ boolean newTarget = bridgeTargets.add(sum);
+ if (newTarget)
+ {
+ // Bridge target that is new in this class.
+ String cname = this.name;
+ int index = cname.lastIndexOf('/');
+ cname = cname.substring(index + 1);
+ methodNameMap.put(sum, cname + "$" + m.name);
+ }
+ }
+ }
+ }
+
+ private void printFields(CniPrintStream out)
+ {
+ Iterator<?> i = fields.iterator();
+ ClassWrapper self = superClass;
+ while (i.hasNext())
+ {
+ FieldNode f = (FieldNode) i.next();
+ boolean hasMethodName = methodNames.contains(f.name);
+ if (FieldHelper.print(out, f, self, hasMethodName))
+ self = null;
+ }
+ }
+
+ private void printMethods(CniPrintStream out) throws IOException
+ {
+ makeVtable();
+
+ // A given method is either static, overrides a super method, or
+ // is already in vtable order.
+ Iterator<?> i = methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode m = (MethodNode) i.next();
+ String nameToUse;
+ String sum = m.name + m.desc;
+ if (bridgeTargets.contains(sum))
+ nameToUse = (String) methodNameMap.get(sum);
+ else
+ nameToUse = m.name;
+ methodNameMap.put(sum, nameToUse);
+ MethodHelper.print(out, m, this, nameToUse);
+ }
+ }
+
+ private void printTextList(PrintStream out, int what, ArrayList<Text> textList)
+ {
+ if (textList == null)
+ return;
+ Iterator<Text> i = textList.iterator();
+ boolean first = true;
+ while (i.hasNext())
+ {
+ Text item = i.next();
+ if (item.type == what)
+ {
+ if (first)
+ {
+ out.println();
+ first = false;
+ }
+ if (what == Text.FRIEND)
+ out.print(" friend ");
+ out.println(item.text);
+ }
+ }
+ }
+
+ public void print(CniPrintStream out)
+ {
+ out.print("::");
+ out.printName(name);
+ }
+
+ // This prints the body of a class to a CxxPrintStream.
+ private void printContents(CniPrintStream out, ArrayList<Text> textList)
+ throws IOException
+ {
+ printTextList(out, Text.PREPEND, textList);
+ out.println();
+
+ out.print("class ");
+ // Don't use our print() -- we don't want the leading "::".
+ out.printName(name);
+ if (superClass != null)
+ {
+ out.print(" : public ");
+ superClass.print(out);
+ }
+ out.println();
+ out.println("{");
+
+ printTextList(out, Text.ADD, textList);
+ out.println();
+
+ // Note: methods must come first, as we build the list
+ // of method names while printing them.
+ printMethods(out);
+ printFields(out);
+
+ out.setModifiers(Modifier.PUBLIC);
+ out.println(" static ::java::lang::Class class$;");
+
+ printTextList(out, Text.FRIEND, textList);
+
+ out.print("}");
+ if (Modifier.isInterface(access))
+ out.print(" __attribute__ ((java_interface))");
+ out.println(";");
+
+ printTextList(out, Text.APPEND, textList);
+ }
+
+ public void printFully(PrintStream out) throws IOException
+ {
+ linkSupers();
+
+ ArrayList<Text> textList = classpath.getClassTextList(name);
+
+ out.println("// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-");
+ out.println();
+ String xname = "__" + name.replaceAll("/", "_") + "__";
+ out.println("#ifndef " + xname);
+ out.println("#define " + xname);
+ out.println();
+ out.println("#pragma interface");
+ out.println();
+
+ if (superClass != null)
+ {
+ out.print("#include <");
+ out.print(superName);
+ out.println(".h>");
+ }
+
+ // Write the body of the stream here. This lets
+ // us emit the namespaces without a second pass.
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ CniPrintStream cxxOut = new CniPrintStream(bytes);
+ cxxOut.addClass(this);
+ printContents(cxxOut, textList);
+ cxxOut.printNamespaces(out);
+ bytes.writeTo(out);
+
+ out.println();
+ out.println("#endif // " + xname);
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
new file mode 100644
index 000000000..8861541a5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
@@ -0,0 +1,80 @@
+/* CniIncludePrinter.java - generate CNI header files
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+public class CniIncludePrinter
+ extends Printer
+{
+ protected CniIncludePrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
+
+ protected void writePreambleImpl(PrintStream ps)
+ {
+ // does nothing
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new PrintStream(fos);
+ }
+
+ public void printClass(File file, ClassWrapper klass) throws IOException
+ {
+ // Never write Object or Class. This is a hack, maybe
+ // the user would like to see what they look like...
+ if (klass.name.equals("java/lang/Object")
+ || klass.name.equals("java/lang/Class"))
+ return;
+ PrintStream ps = getPrintStream(file + ".h", klass);
+ if (ps == null)
+ return;
+ ps.println();
+ klass.printFully(ps);
+ ps.close();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java b/libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java
new file mode 100644
index 000000000..df2b723e7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java
@@ -0,0 +1,274 @@
+/* CniPrintStream.java - PrintStream that emits CNI declarations
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.objectweb.asm.Type;
+
+public class CniPrintStream
+ extends PrintStream
+{
+ int currentModifiers = Modifier.PRIVATE;
+
+ // True if we saw an array type.
+ boolean sawArray;
+
+ // All the classes referenced by this header.
+ HashSet<String> allClasses = new HashSet<String>();
+
+ String[] previousPackage = new String[0];
+
+ public CniPrintStream(OutputStream out)
+ {
+ super(out);
+ }
+
+ public void addClass(ClassWrapper cw)
+ {
+ allClasses.add(cw.name);
+ }
+
+ public void setModifiers(int newMods)
+ {
+ newMods &= (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE);
+ if (newMods != currentModifiers)
+ {
+ switch (newMods)
+ {
+ case Modifier.PUBLIC:
+ println("public:");
+ break;
+ case Modifier.PROTECTED:
+ println("public: // actually protected");
+ break;
+ case Modifier.PRIVATE:
+ println("private:");
+ break;
+ default:
+ println("public: // actually package-private");
+ break;
+ }
+ currentModifiers = newMods;
+ }
+ }
+
+ private String getName(Type type)
+ {
+ if (type == Type.BOOLEAN_TYPE)
+ return "jboolean";
+ else if (type == Type.BYTE_TYPE)
+ return "jbyte";
+ else if (type == Type.CHAR_TYPE)
+ return "jchar";
+ else if (type == Type.SHORT_TYPE)
+ return "jshort";
+ else if (type == Type.INT_TYPE)
+ return "jint";
+ else if (type == Type.LONG_TYPE)
+ return "jlong";
+ else if (type == Type.FLOAT_TYPE)
+ return "jfloat";
+ else if (type == Type.DOUBLE_TYPE)
+ return "jdouble";
+ else
+ {
+ assert type == Type.VOID_TYPE;
+ return "void";
+ }
+ }
+
+ public String getClassName(Type type)
+ {
+ String name = type.toString();
+ name = name.substring(1, name.length() - 1);
+ // Add the plain class name; we'll handle it when
+ // we process namespaces.
+ allClasses.add(name);
+ return name;
+ }
+
+ // Print the C++ form of TYPE, mangling C++ keywords.
+ public void print(Type type)
+ {
+ int arrayCount = 0;
+ if (type.getSort() == Type.ARRAY)
+ {
+ arrayCount = type.getDimensions();
+ for (int i = 0; i < arrayCount; ++i)
+ print("JArray< ");
+ type = type.getElementType();
+ sawArray = true;
+ }
+ if (type.getSort() == Type.OBJECT)
+ {
+ print("::");
+ printName(getClassName(type));
+ print(" *");
+ }
+ else
+ {
+ print(getName(type));
+ }
+ if (arrayCount > 0)
+ {
+ while (arrayCount-- > 0)
+ {
+ print(" > *");
+ }
+ }
+ }
+
+ // Print NAME, converting into C++ syntax and mangling C++ keywords
+ // as we go.
+ public final static void printName(PrintStream out, String name)
+ {
+ String[] parts = name.split("::|/");
+ for (int i = 0; i < parts.length; i++)
+ {
+ if (i != 0)
+ out.print("::");
+ out.print(Keywords.getCxxName(parts[i]));
+ }
+ }
+
+ // Println NAME, converting into C++ syntax and mangling C++
+ // keywords as we go.
+ public final static void printlnName(PrintStream out, String name)
+ {
+ printName(out, name);
+ out.println();
+ }
+
+ // Print NAME, converting into C++ syntax and mangling C++ keywords
+ // as we go.
+ final void printName(String name)
+ {
+ printName(this, name);
+ }
+
+ private void indent(PrintStream out, int n)
+ {
+ for (int i = 0; i < n; ++i)
+ {
+ out.print(" ");
+ }
+ }
+
+ private void moveToPackage(PrintStream out, String[] pkgParts)
+ {
+ // Find greatest common part.
+ int commonIndex;
+ for (commonIndex = 0; commonIndex < previousPackage.length; ++commonIndex)
+ {
+ if (commonIndex >= pkgParts.length)
+ break;
+ if (! previousPackage[commonIndex].equals(pkgParts[commonIndex]))
+ break;
+ }
+ // Close old parts after the common part.
+ for (int j = previousPackage.length - 1; j >= commonIndex; --j)
+ {
+ indent(out, j + 1);
+ out.println("}");
+ }
+ // Open new parts.
+ for (int j = commonIndex; j < pkgParts.length; ++j)
+ {
+ indent(out, j + 1);
+ out.print("namespace ");
+ printlnName(out, pkgParts[j]);
+ indent(out, j + 1);
+ out.println("{");
+ }
+ previousPackage = pkgParts;
+ }
+
+ private void writeClass(PrintStream out, String klass)
+ {
+ int index = klass.lastIndexOf('/');
+ String pkg = index == -1 ? "" : klass.substring(0, index);
+ String[] pkgParts = index == -1 ? new String[0] : pkg.split("/");
+ String className = index == -1 ? klass : klass.substring(index + 1);
+ moveToPackage(out, pkgParts);
+ indent(out, pkgParts.length + 2);
+ out.print("class ");
+ printName(out, className);
+ out.println(";");
+ }
+
+ public void printNamespaces(PrintStream out)
+ {
+ if (sawArray)
+ {
+ out.println("#include <gcj/array.h>");
+ out.println();
+ }
+
+ String[] classes = allClasses.toArray(new String[0]);
+ Arrays.sort(classes);
+
+ boolean first = true;
+ boolean seen = false;
+ for (int i = 0; i < classes.length; ++i)
+ {
+ String klass = classes[i];
+ if (klass.startsWith("java/lang/") || klass.startsWith("java/io/")
+ || klass.startsWith("java/util/"))
+ continue;
+ if (first)
+ {
+ out.println("extern \"Java\"");
+ out.println("{");
+ first = false;
+ seen = true;
+ }
+ writeClass(out, klass);
+ }
+ if (seen)
+ {
+ moveToPackage(out, new String[0]);
+ out.println("}");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java
new file mode 100644
index 000000000..9b5dc2c36
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java
@@ -0,0 +1,129 @@
+/* CniStubPrinter.java - Generate a CNI stub file
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.MethodNode;
+
+public class CniStubPrinter
+ extends Printer
+{
+ protected CniStubPrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
+
+ private void printDecl(CniPrintStream out, String className, MethodNode method)
+ {
+ out.printName(className);
+ out.print("::");
+ out.printName(method.name);
+ out.print("(");
+ Type[] argTypes = Type.getArgumentTypes(method.desc);
+ for (int j = 0; j < argTypes.length; ++j)
+ {
+ if (j > 0)
+ out.print(", ");
+ out.print(argTypes[j]);
+ }
+ out.print(")");
+ }
+
+ protected void writePreambleImpl(PrintStream out)
+ {
+ out.println("// This file is intended to give you a head start on implementing native");
+ out.println("// methods using CNI.");
+ out.println("// Be aware: running 'gcjh -stubs' once more for this class may");
+ out.println("// overwrite any edits you have made to this file.");
+ out.println();
+ out.println("#include <gcj/cni.h>");
+ out.println("#include <java/lang/UnsupportedOperationException.h>");
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new CniPrintStream(fos);
+ }
+
+ public void printClass(File filename, ClassWrapper klass) throws IOException
+ {
+ if (! klass.hasNativeMethod())
+ return;
+ String className = klass.name.replaceAll("/", "::");
+ CniPrintStream out = (CniPrintStream) getPrintStream(filename + ".cc",
+ klass);
+ if (out == null)
+ return;
+ out.println();
+ out.println("#include <" + klass.name + ".h>");
+ out.println();
+
+ Iterator<?> i = klass.methods.iterator();
+ boolean first = true;
+ while (i.hasNext())
+ {
+ MethodNode method = (MethodNode) i.next();
+ if (! Modifier.isNative(method.access))
+ continue;
+ if (! first)
+ out.println();
+ first = false;
+ out.print(Type.getReturnType(method.desc));
+ out.println();
+ printDecl(out, className, method);
+ out.println();
+ out.println("{");
+ out.print(" throw new ::java::lang::UnsupportedOperationException(");
+ out.print("JvNewStringLatin1 (\"");
+ printDecl(out, className, method);
+ out.println("\"));");
+ out.println("}");
+ }
+ out.close();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java
new file mode 100644
index 000000000..84b1fce8b
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java
@@ -0,0 +1,99 @@
+/* FieldHelper.java - field helper methods for CNI
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.lang.reflect.Modifier;
+
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.FieldNode;
+
+public class FieldHelper
+{
+ public static boolean print(CniPrintStream out, FieldNode field,
+ ClassWrapper superType, boolean hasMethodName)
+ {
+ out.setModifiers(field.access);
+ out.print(" ");
+ if (Modifier.isStatic(field.access))
+ out.print("static ");
+ if ((field.value instanceof Integer) || (field.value instanceof Long))
+ out.print("const ");
+ out.print(Type.getType(field.desc));
+ out.print(" ");
+ if (Modifier.isVolatile(field.access))
+ out.print("volatile ");
+ boolean result = false;
+ if (superType != null && ! Modifier.isStatic(field.access))
+ {
+ out.print("__attribute__((aligned(__alignof__( ");
+ superType.print(out);
+ out.print(")))) ");
+ result = true;
+ }
+ out.printName(field.name);
+ if (hasMethodName)
+ out.print("__");
+ if (Modifier.isStatic(field.access))
+ {
+ if (field.value instanceof Integer)
+ {
+ out.print(" = ");
+ int val = ((Integer) field.value).intValue();
+ if (val == Integer.MIN_VALUE)
+ out.print("-" + Integer.MAX_VALUE + " - 1");
+ else
+ out.print(val);
+ }
+ else if (field.value instanceof Long)
+ {
+ out.print(" = ");
+ long val = ((Long) field.value).longValue();
+ if (val == Long.MIN_VALUE)
+ out.print("-" + Long.MAX_VALUE + "LL - 1");
+ else
+ {
+ out.print(val);
+ out.print("LL");
+ }
+ }
+ }
+ out.println(";");
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/GcjhMain.java b/libjava/classpath/tools/gnu/classpath/tools/javah/GcjhMain.java
new file mode 100644
index 000000000..bf466484d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/GcjhMain.java
@@ -0,0 +1,153 @@
+/* GcjhMain.java - gcjh main program
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class GcjhMain extends Main
+{
+ ArrayList<Text> commands = new ArrayList<Text>();
+
+ public GcjhMain()
+ {
+ cni = true;
+ }
+
+ protected String getName()
+ {
+ return "gcjh";
+ }
+
+ protected ClasspathToolParser getParser()
+ {
+ ClasspathToolParser result = super.getParser();
+
+ result.setHeader("usage: gcjh [OPTION]... CLASS...");
+
+ OptionGroup text = new OptionGroup("CNI text options");
+ text.add(new Option("add", "Insert TEXT into class body", "TEXT")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ commands.add(new Text(Text.ADD, arg));
+ }
+ });
+ text.add(new Option("append", "Append TEXT after class declaration",
+ "TEXT")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ commands.add(new Text(Text.APPEND, arg));
+ }
+ });
+ text.add(new Option("friend", "Insert TEXT as a 'friend' declaration",
+ "TEXT")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ commands.add(new Text(Text.FRIEND, arg));
+ }
+ });
+ text.add(new Option("prepend", "Insert TEXT before start of class", "TEXT")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ commands.add(new Text(Text.PREPEND, arg));
+ }
+ });
+ result.add(text);
+
+ OptionGroup compat = new OptionGroup("Compatibility options (unused)");
+ // gcjh itself had compatibility options -old and -trace. I
+ // didn't add them here since they should really be unused by now.
+ compat.add(new Option("td", "Unused compatibility option", "DIRECTORY")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ }
+ });
+ // I don't believe anyone ever used these options.
+ compat.add(new Option("M", "Unused compatibility option")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ }
+ });
+ compat.add(new Option("MM", "Unused compatibility option")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ }
+ });
+ compat.add(new Option("MD", "Unused compatibility option")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ }
+ });
+ compat.add(new Option("MMD", "Unused compatibility option")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ }
+ });
+
+ result.add(compat);
+
+ return result;
+ }
+
+ protected void postParse(String[] names)
+ {
+ for (int i = 0; i < names.length; ++i)
+ textMap.put(names[i].replace('.', '/'), commands);
+ }
+
+ public static void main(String[] args) throws IOException
+ {
+ new GcjhMain().run(args);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/JniHelper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/JniHelper.java
new file mode 100644
index 000000000..9225444be
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/JniHelper.java
@@ -0,0 +1,120 @@
+/* JniHelper.java - name mangling and other JNI support
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.IOException;
+
+import org.objectweb.asm.Type;
+
+public class JniHelper
+{
+ public static String getName(Main classpath, Type type) throws IOException
+ {
+ if (type == Type.BOOLEAN_TYPE)
+ return "jboolean";
+ else if (type == Type.BYTE_TYPE)
+ return "jbyte";
+ else if (type == Type.CHAR_TYPE)
+ return "jchar";
+ else if (type == Type.SHORT_TYPE)
+ return "jshort";
+ else if (type == Type.INT_TYPE)
+ return "jint";
+ else if (type == Type.LONG_TYPE)
+ return "jlong";
+ else if (type == Type.FLOAT_TYPE)
+ return "jfloat";
+ else if (type == Type.DOUBLE_TYPE)
+ return "jdouble";
+ else if (type == Type.VOID_TYPE)
+ return "void";
+
+ if (type.getSort() == Type.ARRAY)
+ {
+ Type elt = type.getElementType();
+ int eltSort = elt.getSort();
+ if (type.getDimensions() == 1 && eltSort != Type.OBJECT)
+ return getName(classpath, elt) + "Array";
+ return "jobjectArray";
+ }
+
+ // assert type.getSort() == Type.OBJECT;
+ String className = type.getClassName();
+ // FIXME: is this correct?
+ if (className.equals("java/lang/Class")
+ || className.equals("java.lang.Class"))
+ return "jclass";
+ if (className.equals("java/lang/String")
+ || className.equals("java.lang.String"))
+ return "jstring";
+
+ ClassWrapper klass = classpath.getClass(className);
+ if (klass.isThrowable())
+ return "jthrowable";
+ return "jobject";
+ }
+
+ public static String mangle(String name)
+ {
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < name.length(); ++i)
+ {
+ char c = name.charAt(i);
+ if (c == '_')
+ result.append("_1");
+ else if (c == ';')
+ result.append("_2");
+ else if (c == '[')
+ result.append("_3");
+ else if (c == '/')
+ result.append("_");
+ else if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z'))
+ result.append(c);
+ else
+ {
+ result.append("_0");
+ // Sigh.
+ String hex = "0000" + Integer.toHexString(c);
+ result.append(hex.substring(hex.length() - 4));
+ }
+ }
+ return result.toString();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
new file mode 100644
index 000000000..cb8bcd8d9
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
@@ -0,0 +1,169 @@
+/* JniIncludePrinter.java - Generate a JNI header file
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.FieldNode;
+import org.objectweb.asm.tree.MethodNode;
+
+public class JniIncludePrinter
+ extends Printer
+{
+ protected JniIncludePrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
+
+ private void writeFields(ClassWrapper klass, JniPrintStream out)
+ throws IOException
+ {
+ klass.linkSupers();
+ boolean wroteAny = false;
+ for (; klass != null; klass = klass.superClass)
+ {
+ Iterator<?> i = klass.fields.iterator();
+ while (i.hasNext())
+ {
+ FieldNode field = (FieldNode) i.next();
+ if (! Modifier.isStatic(field.access)
+ || ! Modifier.isFinal(field.access))
+ continue;
+ if (! (field.value instanceof Integer)
+ && ! (field.value instanceof Long))
+ continue;
+
+ // Note that we don't want to mangle the field name.
+ String name = (JniHelper.mangle(klass.name) + "_" + field.name);
+ out.print("#undef ");
+ out.println(name);
+ out.print("#define ");
+ out.print(name);
+ out.print(" ");
+ out.print(field.value);
+ if (field.value instanceof Integer)
+ out.print("L");
+ else if (field.value instanceof Long)
+ out.print("LL");
+ out.println();
+ wroteAny = true;
+ }
+ }
+ if (wroteAny)
+ out.println();
+ }
+
+ protected void writePreambleImpl(PrintStream out)
+ {
+ out.println("/* DO NOT EDIT THIS FILE - it is machine generated */");
+ out.println();
+ out.println("#include <jni.h>");
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new JniPrintStream(classpath, fos, klass);
+ }
+
+ public void printClass(File file, ClassWrapper klass) throws IOException
+ {
+ // Note that we ignore the filename here.
+ String xname = JniHelper.mangle(klass.name);
+
+ // mangle the filename a bit
+ String filename = klass.name;
+
+ filename = filename.replace('/', '_');
+ filename = filename.replace('$', '_');
+ filename = filename + ".h";
+
+ JniPrintStream out = (JniPrintStream) getPrintStream(filename, klass);
+
+ if (out == null)
+ return;
+
+ out.println();
+ out.print("#ifndef __");
+ out.print(xname);
+ out.println("__");
+ out.print("#define __");
+ out.print(xname);
+ out.println("__");
+ out.println();
+ out.println("#ifdef __cplusplus");
+ out.println("extern \"C\"");
+ out.println("{");
+ out.println("#endif");
+ out.println();
+
+ Iterator<?> i = klass.methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode method = (MethodNode) i.next();
+ if (! Modifier.isNative(method.access))
+ continue;
+ out.print("JNIEXPORT ");
+ out.print(Type.getReturnType(method.desc));
+ out.print(" JNICALL ");
+ out.print(method, xname);
+ out.println(";");
+ }
+
+ out.println();
+
+ writeFields(klass, out);
+
+ out.println("#ifdef __cplusplus");
+ out.println("}");
+ out.println("#endif");
+ out.println();
+ out.print("#endif /* __");
+ out.print(xname);
+ out.println("__ */");
+ out.close();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/JniPrintStream.java b/libjava/classpath/tools/gnu/classpath/tools/javah/JniPrintStream.java
new file mode 100644
index 000000000..96f9e7d1a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/JniPrintStream.java
@@ -0,0 +1,115 @@
+/* JniPrintStream.java - PrintStream that emits JNI declarations
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.MethodNode;
+
+public class JniPrintStream
+ extends PrintStream
+{
+ Main classpath;
+
+ // This is used to determine whether a method has an overload.
+ HashMap<String,Integer> methodNameMap = new HashMap<String,Integer>();
+
+ public JniPrintStream(Main classpath, OutputStream out, ClassWrapper klass)
+ {
+ super(out);
+ this.classpath = classpath;
+ computeOverloads(klass);
+ }
+
+ private void computeOverloads(ClassWrapper klass)
+ {
+ Iterator<?> i = klass.methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode method = (MethodNode) i.next();
+ if (! Modifier.isNative(method.access))
+ continue;
+ if (methodNameMap.containsKey(method.name))
+ {
+ Integer val = methodNameMap.get(method.name);
+ methodNameMap.put(method.name, Integer.valueOf(val.intValue() + 1));
+ }
+ else
+ methodNameMap.put(method.name, Integer.valueOf(1));
+ }
+ }
+
+ public void print(Type type) throws IOException
+ {
+ print(JniHelper.getName(classpath, type));
+ }
+
+ public void print(MethodNode method, String className) throws IOException
+ {
+ print("Java_");
+ print(className);
+ print("_");
+ print(JniHelper.mangle(method.name));
+ Integer overloadCount = (Integer) methodNameMap.get(method.name);
+ if (overloadCount.intValue() > 1)
+ {
+ print("__");
+ int lastOffset = method.desc.lastIndexOf(')');
+ print(JniHelper.mangle(method.desc.substring(1, lastOffset)));
+ }
+ print(" (JNIEnv *env");
+ if (Modifier.isStatic(method.access))
+ print(", jclass");
+ else
+ print(", jobject");
+ Type[] types = Type.getArgumentTypes(method.desc);
+ for (int i = 0; i < types.length; ++i)
+ {
+ print(", ");
+ print(types[i]);
+ }
+ print(")");
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java
new file mode 100644
index 000000000..4a1803a27
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java
@@ -0,0 +1,109 @@
+/* JniStubPrinter.java - Generate JNI stub files
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.MethodNode;
+
+public class JniStubPrinter
+ extends Printer
+{
+ protected JniStubPrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
+
+ protected void writePreambleImpl(PrintStream out)
+ {
+ out.println("/* This file is intended to give you a head start on implementing native");
+ out.println(" methods using JNI.");
+ out.println(" Be aware: running gcjh or compatible tool with '-stubs' option once more");
+ out.println(" for the same input may overwrite any edits you have made to this file. */");
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new JniPrintStream(classpath, fos, klass);
+ }
+
+ public void printClass(File filename, ClassWrapper klass) throws IOException
+ {
+ // Note that we ignore the filename here.
+ if (! klass.hasNativeMethod())
+ return;
+ String xname = JniHelper.mangle(klass.name);
+ JniPrintStream out
+ = (JniPrintStream) getPrintStream(klass.name.replace('/', '_') + ".c",
+ klass);
+ if (out == null)
+ return;
+ out.println();
+ out.print("#include <");
+ out.print(klass.name.replace('/', '_'));
+ out.println(".h>");
+
+ Iterator<?> i = klass.methods.iterator();
+ while (i.hasNext())
+ {
+ MethodNode method = (MethodNode) i.next();
+ if (! Modifier.isNative(method.access))
+ continue;
+ out.println();
+ out.print(Type.getReturnType(method.desc));
+ out.println();
+ out.print(method, xname);
+ out.println();
+ out.println("{");
+ out.print(" (*env)->FatalError (env, \"");
+ out.print(method, xname);
+ out.println(" not implemented\");");
+ out.println("}");
+ }
+ out.close();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java b/libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java
new file mode 100644
index 000000000..9c76a3660
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java
@@ -0,0 +1,172 @@
+/* Keywords.java - List of C++ keywords
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.util.HashSet;
+
+public class Keywords
+{
+/* A sorted list of all C++ keywords. This is identical to the list
+ in gcc/java/mangle.c. */
+ private static final String[] words =
+ {
+ "_Complex",
+ "__alignof",
+ "__alignof__",
+ "__asm",
+ "__asm__",
+ "__attribute",
+ "__attribute__",
+ "__builtin_va_arg",
+ "__complex",
+ "__complex__",
+ "__const",
+ "__const__",
+ "__extension__",
+ "__imag",
+ "__imag__",
+ "__inline",
+ "__inline__",
+ "__label__",
+ "__null",
+ "__real",
+ "__real__",
+ "__restrict",
+ "__restrict__",
+ "__signed",
+ "__signed__",
+ "__typeof",
+ "__typeof__",
+ "__volatile",
+ "__volatile__",
+ "and",
+ "and_eq",
+ "asm",
+ "auto",
+ "bitand",
+ "bitor",
+ "bool",
+ "break",
+ "case",
+ "catch",
+ "char",
+ "class",
+ "compl",
+ "const",
+ "const_cast",
+ "continue",
+ "default",
+ "delete",
+ "do",
+ "double",
+ "dynamic_cast",
+ "else",
+ "enum",
+ "explicit",
+ "export",
+ "extern",
+ "false",
+ "float",
+ "for",
+ "friend",
+ "goto",
+ "if",
+ "inline",
+ "int",
+ "long",
+ "mutable",
+ "namespace",
+ "new",
+ "not",
+ "not_eq",
+ "operator",
+ "or",
+ "or_eq",
+ "private",
+ "protected",
+ "public",
+ "register",
+ "reinterpret_cast",
+ "return",
+ "short",
+ "signed",
+ "sizeof",
+ "static",
+ "static_cast",
+ "struct",
+ "switch",
+ "template",
+ "this",
+ "throw",
+ "true",
+ "try",
+ "typedef",
+ "typeid",
+ "typename",
+ "typeof",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "void",
+ "volatile",
+ "wchar_t",
+ "while",
+ "xor",
+ "xor_eq"
+ };
+
+ private static final HashSet<String> keywords;
+ static
+ {
+ keywords = new HashSet<String>();
+ for (int i = 0; i < words.length; ++i)
+ keywords.add(words[i]);
+ }
+
+ public static String getCxxName(String name)
+ {
+ int i;
+ for (i = name.length() - 1; i >= 0 && name.charAt(i) == '$'; --i)
+ ;
+ if (keywords.contains(name.substring(0, i + 1)))
+ return name + "$";
+ return name;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java b/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java
new file mode 100644
index 000000000..bec04f00d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java
@@ -0,0 +1,468 @@
+/* Main.java - javah main program
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.objectweb.asm.ClassReader;
+
+public class Main
+{
+ // This is an option group for classpath-related options,
+ // and also is used for loading classes.
+ PathOptionGroup classpath = new PathOptionGroup();
+
+ // The output directory.
+ String outputDir;
+
+ // The output file name used if/when -o option is used.
+ String outFileName;
+
+ // The loader that we use to load class files.
+ URLClassLoader loader;
+
+ // In -all mode, the name of the directory to scan.
+ String allDirectory;
+
+ // True for verbose mode.
+ boolean verbose;
+
+ // True if we're emitting stubs.
+ boolean stubs;
+
+ // True if we're emitting CNI code.
+ boolean cni;
+
+ // True if we've seen -cni or -jni.
+ boolean cniOrJniSeen;
+
+ // True if output files should always be written.
+ boolean force;
+
+ // Map class names to class wrappers.
+ HashMap<String,ClassWrapper> classMap = new HashMap<String,ClassWrapper>();
+
+ // Map class names to lists of Text objects.
+ HashMap<String,ArrayList<Text>> textMap = new HashMap<String,ArrayList<Text>>();
+
+ void readCommandFile(String textFileName) throws OptionException
+ {
+ FileInputStream fis;
+ try
+ {
+ fis = new FileInputStream(textFileName);
+ }
+ catch (FileNotFoundException ignore)
+ {
+ throw new OptionException("file \"" + textFileName + "\" not found");
+ }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
+ String currentClass = null;
+ ArrayList<Text> currentValues = null;
+ while (true)
+ {
+ String line;
+ try
+ {
+ line = reader.readLine();
+ }
+ catch (IOException _)
+ {
+ break;
+ }
+ if (line == null)
+ break;
+ line = line.trim();
+ if (line.length() == 0 || line.charAt(0) == '#')
+ continue;
+ int index = line.indexOf(' ');
+ String cmd = line.substring(0, index);
+ String value = line.substring(index + 1);
+ int cmdValue;
+ if ("class".equals(cmd))
+ {
+ if (currentClass != null)
+ {
+ textMap.put(currentClass, currentValues);
+ }
+ currentClass = value;
+ currentValues = new ArrayList<Text>();
+ continue;
+ }
+ if (currentClass == null)
+ throw new OptionException("no class set");
+ if ("add".equals(cmd))
+ cmdValue = Text.ADD;
+ else if ("append".equals(cmd))
+ cmdValue = Text.APPEND;
+ else if ("prepend".equals(cmd))
+ cmdValue = Text.PREPEND;
+ else if ("friend".equals(cmd))
+ cmdValue = Text.FRIEND;
+ else
+ throw new OptionException("unrecognized command: " + cmd);
+ currentValues.add(new Text(cmdValue, value));
+ }
+ if (currentClass != null)
+ {
+ textMap.put(currentClass, currentValues);
+ }
+ }
+
+ void scanDirectory(File dir, final HashSet<Object> results)
+ {
+ File[] files = dir.listFiles(new FileFilter()
+ {
+ public boolean accept(File pathname)
+ {
+ if (pathname.isDirectory())
+ {
+ scanDirectory(pathname, results);
+ return false;
+ }
+ return pathname.getName().endsWith(".class");
+ }
+ });
+ if (files != null)
+ results.addAll(Arrays.asList(files));
+ }
+
+ protected String getName()
+ {
+ return "javah";
+ }
+
+ protected ClasspathToolParser getParser()
+ {
+ ClasspathToolParser result = new ClasspathToolParser(getName(), true);
+ result.setHeader("usage: javah [OPTIONS] CLASS...");
+ result.add(classpath);
+ result.add(new Option('d', "Set output directory", "DIR")
+ {
+ public void parsed(String dir) throws OptionException
+ {
+ if (outputDir != null)
+ throw new OptionException("-d already seen");
+ if (outFileName != null)
+ throw new OptionException("only one of -d or -o may be used");
+ outputDir = dir;
+ }
+ });
+ result.add(new Option('o',
+ "Set output file (only one of -d or -o may be used)",
+ "FILE")
+ {
+ public void parsed(String fileName) throws OptionException
+ {
+ if (outFileName != null)
+ throw new OptionException("-o already seen");
+ if (outputDir != null)
+ throw new OptionException("only one of -d or -o may be used");
+ outFileName = fileName;
+ }
+ });
+ result.add(new Option("cmdfile", "Read command file", "FILE")
+ {
+ public void parsed(String file) throws OptionException
+ {
+ readCommandFile(file);
+ }
+ });
+ result.add(new Option("all", "Operate on all class files under directory",
+ "DIR")
+ {
+ public void parsed(String arg) throws OptionException
+ {
+ // FIXME: lame restriction...
+ if (allDirectory != null)
+ throw new OptionException("-all already specified");
+ allDirectory = arg;
+ }
+ });
+ result.add(new Option("stubs", "Emit stub implementation")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ stubs = true;
+ }
+ });
+ result.add(new Option("jni", "Emit JNI stubs or header (default)")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ if (cniOrJniSeen && cni)
+ throw new OptionException("only one of -jni or -cni may be used");
+ cniOrJniSeen = true;
+ cni = false;
+ }
+ });
+ result.add(new Option("cni", "Emit CNI stubs or header (default JNI)")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ if (cniOrJniSeen && ! cni)
+ throw new OptionException("only one of -jni or -cni may be used");
+ cniOrJniSeen = true;
+ cni = true;
+ }
+ });
+ result.add(new Option("verbose", 'v', "Set verbose mode")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(new Option("force", "Output files should always be written")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ force = true;
+ }
+ });
+ return result;
+ }
+
+ private File makeOutputDirectory() throws IOException
+ {
+ File outputFile;
+ if (outputDir == null)
+ outputFile = new File(".");
+ else
+ outputFile = new File(outputDir);
+ return outputFile;
+ }
+
+ /**
+ * @return The {@link File} object where the generated code will be written.
+ * Returns <code>null</code> if the option <code>-force</code> was
+ * specified on the command line and the designated file already
+ * exists.
+ * @throws IOException if <code>outFileName</code> is not a writable file.
+ */
+ private File makeOutputFile() throws IOException
+ {
+ File result = new File(outFileName);
+ if (result.exists())
+ {
+ if (! result.isFile())
+ throw new IOException("'" + outFileName + "' is not a file");
+ if (! force)
+ {
+ if (verbose)
+ System.err.println("["+ outFileName
+ + " already exists. Use -force to overwrite]");
+ return null;
+ }
+ if (! result.delete())
+ throw new IOException("Was unable to delete existing file: "
+ + outFileName);
+ }
+ return result;
+ }
+
+ private void writeHeaders(HashMap<File,ClassWrapper> klasses, Printer printer)
+ throws IOException
+ {
+ Iterator<Map.Entry<File,ClassWrapper>> i = klasses.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry<File,ClassWrapper> e = i.next();
+ File file = e.getKey();
+ ClassWrapper klass = e.getValue();
+ if (verbose)
+ System.err.println("[writing " + klass + " as " + file + "]");
+ printer.printClass(file, klass);
+ }
+ }
+
+ protected void postParse(String[] names)
+ {
+ // Nothing here.
+ }
+
+ protected void run(String[] args) throws IOException
+ {
+ ClasspathToolParser p = getParser();
+ String[] classNames = p.parse(args, true);
+ postParse(classNames);
+ loader = classpath.getLoader();
+
+ boolean isDirectory = outFileName == null;
+ File outputFile = isDirectory ? makeOutputDirectory() : makeOutputFile();
+ if (outputFile == null)
+ return;
+
+ Printer printer;
+ if (! cni)
+ {
+ if (stubs)
+ printer = new JniStubPrinter(this, outputFile, isDirectory, force);
+ else
+ printer = new JniIncludePrinter(this, outputFile, isDirectory, force);
+ }
+ else
+ {
+ if (stubs)
+ printer = new CniStubPrinter(this, outputFile, isDirectory, force);
+ else
+ printer = new CniIncludePrinter(this, outputFile, isDirectory, force);
+ }
+
+ // First we load all of the files. That way if
+ // there are references between the files we will
+ // be loading the set that the user asked for.
+ HashSet<Object> klasses = new HashSet<Object>();
+ if (allDirectory != null)
+ scanDirectory(new File(allDirectory), klasses);
+ // Add the command-line arguments. We use the type of
+ // an item in 'klasses' to decide how to load each class.
+ for (int i = 0; i < classNames.length; ++i)
+ {
+ if (classNames[i].endsWith(".class"))
+ {
+ klasses.add(new File(classNames[i]));
+ }
+ else
+ {
+ klasses.add(classNames[i]);
+ }
+ }
+
+ Iterator<Object> i = klasses.iterator();
+ HashMap<File,ClassWrapper> results = new HashMap<File,ClassWrapper>();
+ while (i.hasNext())
+ {
+ // Let user specify either kind of class name or a
+ // file name.
+ Object item = i.next();
+ ClassWrapper klass;
+ File filename;
+ if (item instanceof File)
+ {
+ // Load class from file.
+ if (verbose)
+ System.err.println("[reading file " + item + "]");
+ klass = getClass((File) item);
+ filename = new File(klass.name);
+ }
+ else
+ {
+ // Load class given the class name.
+ String className = ((String) item).replace('.', '/');
+ if (verbose)
+ System.err.println("[reading class " + className + "]");
+ // Use the name the user specified, even if it is
+ // different from the ultimate class name.
+ filename = new File(className);
+ klass = getClass(className);
+ }
+ results.put(filename, klass);
+ }
+
+ writeHeaders(results, printer);
+ }
+
+ public ArrayList<Text> getClassTextList(String name)
+ {
+ return textMap.get(name);
+ }
+
+ private ClassWrapper readClass(InputStream is) throws IOException
+ {
+ ClassReader r = new ClassReader(is);
+ ClassWrapper result = new ClassWrapper(this);
+ r.accept(result, true);
+ is.close();
+ return result;
+ }
+
+ private ClassWrapper getClass(File fileName) throws IOException
+ {
+ InputStream is = new FileInputStream(fileName);
+ ClassWrapper result = readClass(is);
+ if (classMap.containsKey(result.name))
+ throw new IllegalArgumentException("class " + result.name
+ + " already loaded");
+ classMap.put(result.name, result);
+ return result;
+ }
+
+ public ClassWrapper getClass(String name) throws IOException
+ {
+ if (! classMap.containsKey(name))
+ {
+ String resource = name.replace('.', '/') + ".class";
+ URL url = loader.findResource(resource);
+ if (url == null)
+ throw new IOException("can't find class file " + resource
+ + " in " + loader);
+ InputStream is = url.openStream();
+ ClassWrapper result = readClass(is);
+ classMap.put(name, result);
+ }
+ return (ClassWrapper) classMap.get(name);
+ }
+
+ public static void main(String[] args) throws IOException
+ {
+ Main m = new Main();
+ m.run(args);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java
new file mode 100644
index 000000000..d65cc93d7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java
@@ -0,0 +1,122 @@
+/* MethodHelper.java - helper class for manipulating methods
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+import org.objectweb.asm.tree.MethodNode;
+
+public class MethodHelper
+{
+
+ public static boolean overrides(MethodNode derived, MethodNode base)
+ {
+ if (! derived.name.equals(base.name))
+ return false;
+ if (! derived.desc.equals(base.desc))
+ return false;
+ // FIXME: permission madness?
+ return true;
+ }
+
+ public static String getBridgeTarget(MethodNode meth)
+ {
+ if ((meth.access & Opcodes.ACC_BRIDGE) == 0)
+ return null;
+ Iterator<?> i = meth.instructions.iterator();
+ while (i.hasNext())
+ {
+ AbstractInsnNode insn = (AbstractInsnNode) i.next();
+ if (! (insn instanceof MethodInsnNode))
+ continue;
+ return ((MethodInsnNode) insn).desc;
+ }
+ return null;
+ }
+
+ public static void print(CniPrintStream out, MethodNode meth,
+ ClassWrapper declarer, String realMethodName)
+ {
+ if ("<clinit>".equals(meth.name))
+ return;
+ boolean isInit = "<init>".equals(meth.name);
+ out.setModifiers(meth.access);
+ out.print(" ");
+ if (Modifier.isStatic(meth.access))
+ out.print("static ");
+ // If a class is final then we might as well skip 'virtual'.
+ // The reason here is that it is safe in this case for C++
+ // ABI code to generate a direct call. The method does end
+ // up in the vtable (for BC code) but we don't care. Also,
+ // the class can't be derived from anyway.
+ else if (! isInit && ! Modifier.isPrivate(meth.access)
+ && ! Modifier.isFinal(declarer.access))
+ out.print("virtual ");
+ if (! isInit)
+ {
+ out.print(Type.getReturnType(meth.desc));
+ out.print(" ");
+ out.printName(realMethodName);
+ }
+ else
+ {
+ String name = declarer.name;
+ int index = name.lastIndexOf('/');
+ name = name.substring(index + 1);
+ out.printName(name);
+ }
+ out.print("(");
+ Type[] argTypes = Type.getArgumentTypes(meth.desc);
+ for (int i = 0; i < argTypes.length; ++i)
+ {
+ if (i > 0)
+ out.print(", ");
+ out.print(argTypes[i]);
+ }
+ out.print(")");
+ if (Modifier.isAbstract(meth.access))
+ out.print(" = 0");
+ out.println(";");
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/PackageWrapper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/PackageWrapper.java
new file mode 100644
index 000000000..11b38b20f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/PackageWrapper.java
@@ -0,0 +1,54 @@
+/* PackageWrapper.java - represent a package
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+public class PackageWrapper
+{
+ // This is null if there is no parent package.
+ PackageWrapper parent;
+
+ // Name of this package relative to its parent's name.
+ String name;
+
+ public PackageWrapper(PackageWrapper parent, String name)
+ {
+ this.parent = parent;
+ this.name = name;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/PathOptionGroup.java b/libjava/classpath/tools/gnu/classpath/tools/javah/PathOptionGroup.java
new file mode 100644
index 000000000..8eec4cc60
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/PathOptionGroup.java
@@ -0,0 +1,147 @@
+/* PathOptionGroup.java - handle classpath-setting options
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+public class PathOptionGroup
+ extends OptionGroup
+{
+ ArrayList<String> classpath = new ArrayList<String>();
+
+ ArrayList<String> bootclasspath = new ArrayList<String>();
+
+ void setPath(ArrayList<String> list, String path)
+ {
+ list.clear();
+ StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
+ while (st.hasMoreTokens())
+ {
+ list.add(st.nextToken());
+ }
+ }
+
+ void addExtDirs(ArrayList<String> list, String path)
+ {
+ StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
+ while (tok.hasMoreTokens())
+ {
+ File dir = new File(tok.nextToken());
+ list.addAll(Arrays.asList(dir.list(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.endsWith(".zip") || name.endsWith(".jar");
+ }
+ })));
+ }
+ }
+
+ public PathOptionGroup()
+ {
+ super("Class path options");
+
+ // Use the VM's built-in boot class path by default.
+ String boot = System.getProperty("sun.boot.class.path");
+ if (boot != null)
+ setPath(bootclasspath, boot);
+
+ add(new Option("classpath", "Set the class path", "PATH")
+ {
+ public void parsed(String path) throws OptionException
+ {
+ setPath(classpath, path);
+ }
+ });
+ add(new Option("cp", "Set the class path", "PATH")
+ {
+ public void parsed(String path) throws OptionException
+ {
+ setPath(classpath, path);
+ }
+ });
+ add(new Option('I', "Add directory to class path", "DIR", true)
+ {
+ public void parsed(String path) throws OptionException
+ {
+ classpath.add(path);
+ }
+ });
+ add(new Option("bootclasspath", "Set the boot class path", "PATH")
+ {
+ public void parsed(String path) throws OptionException
+ {
+ setPath(bootclasspath, path);
+ }
+ });
+ add(new Option("extdirs", "Set the extension directory path", "PATH")
+ {
+ public void parsed(String path) throws OptionException
+ {
+ addExtDirs(classpath, path);
+ }
+ });
+ }
+
+ public URLClassLoader getLoader() throws MalformedURLException
+ {
+ ArrayList<URL> urls = new ArrayList<URL>();
+ classpath.addAll(bootclasspath);
+ Iterator<String> i = classpath.iterator();
+ while (i.hasNext())
+ {
+ String f = i.next();
+ urls.add(new File(f).toURL());
+ }
+ URL[] urlArray = urls.toArray(new URL[0]);
+ return new URLClassLoader(urlArray);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java b/libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java
new file mode 100644
index 000000000..7a896cf62
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java
@@ -0,0 +1,139 @@
+/* Print.java - abstract base class for printing classes
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+public abstract class Printer
+{
+ protected Main classpath;
+
+ /**
+ * The {@link File} object that denotes either a directory (when the
+ * <code>-d</code> option was used), or a file (when the <code>-o</code>
+ * option was used) on the command line.
+ */
+ protected File outputFileObject;
+
+ /**
+ * Set to <code>true</code> if the field <code>outputFileObject</code> denotes
+ * a directory; i.e. for each input class file, one JNI header file will be
+ * generated in that directory.
+ * <p>
+ * Set to <code>false</code> if the field <code>outputFileObject</code>
+ * denotes a file; i.e. all generated headers will be written to that file.
+ */
+ protected boolean isDirectory;
+
+ /**
+ * Set to <code>true</code> if the output file(s) should always be written.
+ * <p>
+ * When set to <code>false</code>, the contents of the header/stub are only
+ * written to the file if it does not already exist.
+ */
+ protected boolean force;
+
+ /**
+ * Set to <code>true</code> if all output is directed to one file, and the
+ * common preamble text has already been generated.
+ */
+ protected boolean wrotePreamble;
+
+ protected Printer(Main classpath, File outFile, boolean isDir, boolean force)
+ {
+ this.classpath = classpath;
+ if (outFile == null)
+ throw new IllegalArgumentException("File argument MUST NOT be null");
+ outputFileObject = outFile;
+ isDirectory = isDir;
+ if (! isDirectory)
+ {
+ File parent = outputFileObject.getParentFile();
+ if (parent != null)
+ parent.mkdirs();
+ }
+ this.force = force;
+ }
+
+ public abstract void printClass(File filename, ClassWrapper klass)
+ throws IOException;
+
+ protected abstract void writePreambleImpl(PrintStream ps);
+
+ protected abstract PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass);
+
+ protected PrintStream getPrintStream(String fullName, ClassWrapper klass)
+ throws FileNotFoundException
+ {
+ PrintStream result;
+ FileOutputStream fos;
+ if (isDirectory)
+ {
+ File outFile = new File(outputFileObject, fullName);
+ if (outFile.exists() && ! force)
+ return null;
+ File parent = outFile.getParentFile();
+ if (parent != null)
+ parent.mkdirs();
+ fos = new FileOutputStream(outFile);
+ result = getPrintStreamImpl(fos, klass);
+ writePreamble(result);
+ }
+ else
+ {
+ // the first time we open this file, wrotePreamble is false
+ fos = new FileOutputStream(outputFileObject, wrotePreamble);
+ result = getPrintStreamImpl(fos, klass);
+ if (! wrotePreamble)
+ writePreamble(result);
+ }
+ return result;
+ }
+
+ protected void writePreamble(PrintStream out)
+ {
+ writePreambleImpl(out);
+ wrotePreamble = true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/Text.java b/libjava/classpath/tools/gnu/classpath/tools/javah/Text.java
new file mode 100644
index 000000000..37a1ad669
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/javah/Text.java
@@ -0,0 +1,60 @@
+/* Text.java - convenience class for CNI header text insertions
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.javah;
+
+public class Text
+{
+ public static final int ADD = 0;
+
+ public static final int APPEND = 1;
+
+ public static final int FRIEND = 2;
+
+ public static final int PREPEND = 3;
+
+ public int type;
+
+ public String text;
+
+ public Text(int type, String text)
+ {
+ this.type = type;
+ this.text = text;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java
new file mode 100644
index 000000000..603385d19
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java
@@ -0,0 +1,313 @@
+/* CACertCmd.java -- GNU specific cacert handler
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.util.logging.Logger;
+
+/**
+ * The <code>-cacert</code> keytol command handler is used to import a CA
+ * trusted X.509 certificate into a key store.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-file FILE_NAME</dt>
+ * <dd>The fully qualified path of the file containing the trusted CA
+ * certificate to import. If omitted, the tool will process STDIN.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+public class CACertCmd
+ extends Command
+{
+ private static final Logger log = Logger.getLogger(CACertCmd.class.getName());
+ /** Pathname of the file containing the CA certificate to import. */
+ protected String _certFileName;
+ /** Type of the key store to use. */
+ protected String _ksType;
+ /** The URL to the keystore where the trusted certificates will be added. */
+ protected String _ksURL;
+ /** The password protecting the keystore. */
+ protected String _ksPassword;
+ /** Class name of a security provider to use. */
+ protected String _providerClassName;
+ /** Reference to the X.509 factory. */
+ private CertificateFactory x509Factory;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param pathName the fully qualified path name of the file to process. */
+ public void setFile(String pathName)
+ {
+ this._certFileName = pathName;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see gnu.classpath.tools.keytool.Command#setup()
+ */
+ void setup() throws Exception
+ {
+ setInputStreamParam(_certFileName);
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-cacert handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws CertificateException, KeyStoreException,
+ NoSuchAlgorithmException, IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ alias = getAliasFromFileName(_certFileName);
+ if (store.containsAlias(alias))
+ throw new IllegalArgumentException(Messages.getFormattedString("CACertCmd.0", //$NON-NLS-1$
+ alias));
+ x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
+ Certificate certificate = x509Factory.generateCertificate(inStream);
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
+ store.setCertificateEntry(alias, certificate);
+ saveKeyStore();
+ if (verbose)
+ System.out.println(Messages.getFormattedString("CACertCmd.1", //$NON-NLS-1$
+ new Object[] { _certFileName,
+ alias }));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see gnu.classpath.tools.keytool.Command#getParser()
+ */
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.CACERT_CMD, true);
+ result.setHeader(Messages.getString("CACertCmd.2")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("CACertCmd.3")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("CACertCmd.4")); //$NON-NLS-1$
+ options.add(new Option(Main.FILE_OPT,
+ Messages.getString("CACertCmd.5"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _certFileName = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("CACertCmd.7"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("CACertCmd.9"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.10")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("CACertCmd.11"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("CACertCmd.13"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.14")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("CACertCmd.15")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Construct an Alias string from the name of the file containing the
+ * certificate to import. This method first removes the last dot (".")
+ * character and any subsequent characters from the input name, and then
+ * replaces any space and dot characters with underscores. For example the
+ * input string <code>brasil.gov.br.cert</code> will result in
+ * <code>brasil_gov_br</code> as its alias.
+ *
+ * @param fileName the name of the file containing the CA certificate
+ * @return a string which can, and will, be used as the Alias of this CA
+ * certificate.
+ */
+ private String getAliasFromFileName(String fileName)
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getAliasFromFileName", fileName); //$NON-NLS-1$
+ // get the basename
+ fileName = new File(fileName).getName();
+ // remove '.' if at start
+ if (fileName.startsWith(".")) //$NON-NLS-1$
+ fileName = fileName.substring(1);
+
+ // remove last \..+
+ int ndx = fileName.lastIndexOf('.');
+ if (ndx > 0)
+ fileName = fileName.substring(0, ndx);
+ // replace spaces and dots with underscores
+ char[] chars = fileName.toCharArray();
+ for (int i = 0; i < chars.length; i++)
+ {
+ char c = chars[i];
+ if (c == ' ' || c == '.')
+ chars[i] = '_';
+ }
+ String result = new String(chars);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getAliasFromFileName", result); //$NON-NLS-1$
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
new file mode 100644
index 000000000..e14fa4916
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
@@ -0,0 +1,475 @@
+/* CertReqCmd.java -- The certreq command handler of the keytool
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.OID;
+import gnu.java.security.der.BitString;
+import gnu.java.security.der.DER;
+import gnu.java.security.der.DERReader;
+import gnu.java.security.der.DERValue;
+import gnu.java.security.der.DERWriter;
+import gnu.java.util.Base64;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.x500.X500Principal;
+
+/**
+ * The <b>-certreq</b> keytool command handler is used to generate a Certificate
+ * Signing Request (CSR) in PKCS#10 format.
+ * <p>
+ * The ASN.1 specification of a CSR, as stated in RFC-2986 is as follows:
+ * <p>
+ * <pre>
+ * CertificationRequest ::= SEQUENCE {
+ * certificationRequestInfo CertificationRequestInfo,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signature BIT STRING
+ * }
+ *
+ * CertificationRequestInfo ::= SEQUENCE {
+ * version INTEGER -- v1(0)
+ * subject Name,
+ * subjectPKInfo SubjectPublicKeyInfo,
+ * attributes [0] IMPLICIT Attributes -- see note later
+ * }
+ *
+ * SubjectPublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * subjectPublicKey BIT STRING
+ * }
+ * </pre>
+ * <b>IMPORTANT</b>: Some documentation (e.g. RSA examples) claims that the
+ * <code>attributes</code> field is <i>OPTIONAL</i> while <i>RFC-2986</i>
+ * implies the opposite. This implementation considers this field, by default,
+ * as <i>OPTIONAL</i>, unless the option <code>-attributes</code> is included
+ * on the command line.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-sigalg ALGORITHM</dt>
+ * <dd>The canonical name of the digital signature algorithm to use for
+ * signing the certificate. If this option is omitted, a default value will
+ * be chosen based on the type of the private key associated with the
+ * designated <i>Alias</i>. If the private key is a <code>DSA</code> one,
+ * the value for the signature algorithm will be <code>SHA1withDSA</code>.
+ * If on the other hand the private key is an <code>RSA</code> one, then
+ * the tool will use <code>MD5withRSA</code> as the signature algorithm.
+ * <p></dd>
+ *
+ * <dt>-file FILE_NAME</dt>
+ *
+ * <dt>-keypass PASSWORD</dt>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.
+ * <p></dd>
+ *
+ * <dt>-attributes</dt>
+ * <dd>Use this option to force the tool to encode a NULL DER value in the
+ * CSR as the value of the Attributes field.</dd>
+ * </dl>
+ */
+class CertReqCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(CertReqCmd.class.getName());
+ private static final String ATTRIBUTES_OPT = "attributes"; //$NON-NLS-1$
+ protected String _alias;
+ protected String _sigAlgorithm;
+ protected String _certReqFileName;
+ protected String _password;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ protected boolean nullAttributes;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /**
+ * @param algorithm the canonical name of the digital signature algorithm to
+ * use.
+ */
+ public void setSigalg(String algorithm)
+ {
+ this._sigAlgorithm = algorithm;
+ }
+
+ /** @param pathName the fully qualified path name of the file to process. */
+ public void setFile(String pathName)
+ {
+ this._certReqFileName = pathName;
+ }
+
+ /** @param password the (private) key password to use. */
+ public void setKeypass(String password)
+ {
+ this._password = password;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ /**
+ * @param flag whether to use, or not, a <code>NULL</code> DER value for
+ * the certificate's Attributes field.
+ */
+ public void setAttributes(String flag)
+ {
+ this.nullAttributes = Boolean.valueOf(flag).booleanValue();
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setOutputStreamParam(_certReqFileName);
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setAliasParam(_alias);
+ setKeyPasswordNoPrompt(_password);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-certreq handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
+ log.fine(" -file=" + _certReqFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ log.fine(" -attributes=" + nullAttributes); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
+ UnsupportedCallbackException, UnrecoverableKeyException,
+ InvalidKeyException, SignatureException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ // 1. get the key entry and certificate chain associated to alias
+ Key privateKey = getAliasPrivateKey();
+ Certificate[] chain = store.getCertificateChain(alias);
+
+ // 2. get alias's DN and public key to use in the CSR
+ X509Certificate bottomCertificate = (X509Certificate) chain[0];
+ X500Principal aliasName = bottomCertificate.getIssuerX500Principal();
+ PublicKey publicKey = bottomCertificate.getPublicKey();
+
+ // 3. generate the CSR
+ setSignatureAlgorithmParam(_sigAlgorithm, privateKey);
+ byte[] derBytes = getCSR(aliasName, publicKey, (PrivateKey) privateKey);
+
+ // 4. encode it in base-64 and write it to outStream
+ String encoded = Base64.encode(derBytes, 72);
+ PrintWriter writer = new PrintWriter(outStream, true);
+ writer.println("-----BEGIN NEW CERTIFICATE REQUEST-----"); //$NON-NLS-1$
+ writer.println(encoded);
+ writer.println("-----END NEW CERTIFICATE REQUEST-----"); //$NON-NLS-1$
+
+ if (verbose)
+ {
+ if (! systemOut)
+ System.out.println(Messages.getFormattedString("CertReqCmd.27", //$NON-NLS-1$
+ _certReqFileName));
+ System.out.println(Messages.getString("CertReqCmd.28")); //$NON-NLS-1$
+ }
+
+ writer.close();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.CERTREQ_CMD, true);
+ result.setHeader(Messages.getString("CertReqCmd.25")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("CertReqCmd.24")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("CertReqCmd.23")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("CertReqCmd.22"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.21")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.SIGALG_OPT,
+ Messages.getString("CertReqCmd.20"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.19")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _sigAlgorithm = argument;
+ }
+ });
+ options.add(new Option(Main.FILE_OPT,
+ Messages.getString("CertReqCmd.18"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.17")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _certReqFileName = argument;
+ }
+ });
+ options.add(new Option(Main.KEYPASS_OPT,
+ Messages.getString("CertReqCmd.16"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.9")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _password = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("CertReqCmd.14"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.13")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("CertReqCmd.12"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.11")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("CertReqCmd.10"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.9")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("CertReqCmd.8"), //$NON-NLS-1$
+ Messages.getString("CertReqCmd.7")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("CertReqCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ options.add(new Option(ATTRIBUTES_OPT,
+ Messages.getString("CertReqCmd.5")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ nullAttributes = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * @param aliasName
+ * @param publicKey
+ * @param privateKey
+ * @return the DER encoded Certificate Signing Request.
+ * @throws IOException
+ * @throws InvalidKeyException
+ * @throws SignatureException
+ */
+ private byte[] getCSR(X500Principal aliasName, PublicKey publicKey,
+ PrivateKey privateKey)
+ throws IOException, InvalidKeyException, SignatureException
+ {
+ DERValue derVersion = new DERValue(DER.INTEGER, BigInteger.ZERO);
+ DERValue derSubject = new DERReader(aliasName.getEncoded()).read();
+ DERValue derSubjectPKInfo = new DERReader(publicKey.getEncoded()).read();
+ byte[] b = nullAttributes ? new byte[] { 0x05, 0x00 } : new byte[0];
+ DERValue derAttributes = new DERValue(DER.CONSTRUCTED | DER.CONTEXT | 0,
+ b.length, b, null);
+ ArrayList certRequestInfo = new ArrayList(4);
+ certRequestInfo.add(derVersion);
+ certRequestInfo.add(derSubject);
+ certRequestInfo.add(derSubjectPKInfo);
+ certRequestInfo.add(derAttributes);
+ DERValue derCertRequestInfo = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+ certRequestInfo);
+
+ OID sigAlgorithmID = getSignatureAlgorithmOID();
+ DERValue derSigAlgorithmID = new DERValue(DER.OBJECT_IDENTIFIER,
+ sigAlgorithmID);
+ ArrayList sigAlgorithm = new ArrayList(2);
+ sigAlgorithm.add(derSigAlgorithmID);
+ if (! sigAlgorithmID.equals(Command.SHA1_WITH_DSA)) // it's an RSA-based
+ sigAlgorithm.add(new DERValue(DER.NULL, null));
+
+ sigAlgorithm.trimToSize();
+ DERValue derSignatureAlgorithm = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+ sigAlgorithm);
+
+ signatureAlgorithm.initSign(privateKey);
+ signatureAlgorithm.update(derCertRequestInfo.getEncoded());
+ byte[] sigBytes = signatureAlgorithm.sign();
+ DERValue derSignature = new DERValue(DER.BIT_STRING, new BitString(sigBytes));
+
+ ArrayList csr = new ArrayList(3);
+ csr.add(derCertRequestInfo);
+ csr.add(derSignatureAlgorithm);
+ csr.add(derSignature);
+ DERValue derCSR = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, csr);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DERWriter.write(baos, derCSR);
+ byte[] result = baos.toByteArray();
+
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
new file mode 100644
index 000000000..050e75b37
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
@@ -0,0 +1,1228 @@
+/* Command.java -- Abstract implementation of a keytool command handler
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.common.CallbackUtil;
+import gnu.classpath.tools.common.ProviderUtil;
+import gnu.classpath.tools.common.SecurityProviderInfo;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.OID;
+import gnu.java.security.Registry;
+import gnu.java.security.der.BitString;
+import gnu.java.security.der.DER;
+import gnu.java.security.der.DERReader;
+import gnu.java.security.der.DERValue;
+import gnu.java.security.der.DERWriter;
+import gnu.java.security.hash.IMessageDigest;
+import gnu.java.security.hash.MD5;
+import gnu.java.security.hash.Sha160;
+import gnu.java.security.util.Util;
+import gnu.java.security.x509.X500DistinguishedName;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.math.BigInteger;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.InvalidKeyException;
+import java.security.InvalidParameterException;
+import java.security.Key;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.DSAKey;
+import java.security.interfaces.RSAKey;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.logging.Logger;
+import java.util.prefs.Preferences;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * A base class of the keytool command to facilitate implementation of concrete
+ * keytool Handlers.
+ */
+abstract class Command
+{
+ // Fields and constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(Command.class.getName());
+ /** Default value for the ALIAS argument. */
+ private static final String DEFAULT_ALIAS = "mykey"; //$NON-NLS-1$
+ /** Default algorithm for key-pair generation. */
+ private static final String DEFAULT_KEY_ALGORITHM = "DSA"; //$NON-NLS-1$
+ /** Default DSA digital signature algorithm to use with DSA keys. */
+ private static final String DSA_SIGNATURE_ALGORITHM = "SHA1withDSA"; //$NON-NLS-1$
+ /** Default RSA digital signature algorithm to use with RSA keys. */
+ private static final String RSA_SIGNATURE_ALGORITHM = "MD5withRSA"; //$NON-NLS-1$
+ /** Default validity (in days) of newly generated certificates. */
+ private static final int DEFAULT_VALIDITY = 90;
+ /** OID of SHA1withDSA signature algorithm as stated in RFC-2459. */
+ protected static final OID SHA1_WITH_DSA = new OID("1.2.840.10040.4.3"); //$NON-NLS-1$
+ /** OID of MD2withRSA signature algorithm as stated in RFC-2459. */
+ private static final OID MD2_WITH_RSA = new OID("1.2.840.113549.1.1.2"); //$NON-NLS-1$
+ /** OID of MD5withRSA signature algorithm as stated in RFC-2459. */
+ private static final OID MD5_WITH_RSA = new OID("1.2.840.113549.1.1.4"); //$NON-NLS-1$
+ /** OID of SHA1withRSA signature algorithm as stated in RFC-2459. */
+ private static final OID SHA1_WITH_RSA = new OID("1.2.840.113549.1.1.5"); //$NON-NLS-1$
+ /** Number of milliseconds in one day. */
+ private static final long MILLIS_IN_A_DAY = 24 * 60 * 60 * 1000L;
+
+ /** The Alias to use. */
+ protected String alias;
+ /** The password characters protecting a Key Entry. */
+ protected char[] keyPasswordChars;
+ /** A security provider to add. */
+ protected Provider provider;
+ /** The key store type. */
+ protected String storeType;
+ /** The password characters protecting the key store. */
+ protected char[] storePasswordChars;
+ /** The key store URL. */
+ protected URL storeURL;
+ /** The input stream from the key store URL. */
+ protected InputStream storeStream;
+ /** The key store instance to use. */
+ protected KeyStore store;
+ /** The output stream the concrete handler will use. */
+ protected OutputStream outStream;
+ /** Whether we are printing to System.out. */
+ protected boolean systemOut;
+ /** The key-pair generation algorithm instance to use. */
+ protected KeyPairGenerator keyPairGenerator;
+ /** The digital signature algorithm instance to use. */
+ protected Signature signatureAlgorithm;
+ /** Validity period, in number of days, to use when generating certificates. */
+ protected int validityInDays;
+ /** The input stream the concrete handler will use. */
+ protected InputStream inStream;
+ /** Whether verbose output is required or not. */
+ protected boolean verbose;
+
+ /** MD5 hash to use when generating certificate fingerprints. */
+ private IMessageDigest md5 = new MD5();
+ /** SHA1 hash to use when generating certificate fingerprints. */
+ private IMessageDigest sha = new Sha160();
+ /** The new position of a user-defined provider if it is not already installed. */
+ private int providerNdx = -2;
+ /** The callback handler to use when needing to interact with user. */
+ private CallbackHandler handler;
+ /** The shutdown hook. */
+ private ShutdownHook shutdownThread;
+
+ // Constructor(s) -----------------------------------------------------------
+
+ protected Command()
+ {
+ super();
+ shutdownThread = new ShutdownHook();
+ Runtime.getRuntime().addShutdownHook(shutdownThread);
+ }
+
+ // Methods ------------------------------------------------------------------
+
+ /**
+ * A public method to allow using any keytool command handler programmatically
+ * by using a JavaBeans style of parameter(s) initialization. The user is
+ * assumed to have set individually the required options through their
+ * respective setters before invoking this method.
+ * <p>
+ * If an exception is encountered during the processing of the command, this
+ * implementation attempts to release any resources that may have been
+ * allocated at the time the exception occurs, before re-throwing that
+ * exception.
+ *
+ * @throws Exception if an exception occurs during the processing of this
+ * command. For a more comprehensive list of exceptions that may
+ * occur, see the documentation of the {@link #setup()} and
+ * {@link #start()} methods.
+ */
+ public void doCommand() throws Exception
+ {
+ try
+ {
+ setup();
+ start();
+ }
+ finally
+ {
+ teardown();
+ if (shutdownThread != null)
+ Runtime.getRuntime().removeShutdownHook(shutdownThread);
+ }
+ }
+
+ /**
+ * @param flag whether to use, or not, more verbose output while processing
+ * the command.
+ */
+ public void setVerbose(String flag)
+ {
+ this.verbose = Boolean.valueOf(flag).booleanValue();
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ /**
+ * Given a potential sub-array of options for this concrete handler, starting
+ * at position <code>startIndex + 1</code>, potentially followed by other
+ * commands and their options, this method sets up this concrete command
+ * handler with its own options and returns the index of the first unprocessed
+ * argument in the array.
+ * <p>
+ * The general contract of this method is that it is invoked with the
+ * <code>startIndex</code> argument pointing to the keyword argument that
+ * uniquelly identifies the command itself; e.g. <code>-genkey</code> or
+ * <code>-list</code>, etc...
+ *
+ * @param args an array of options for this handler and possibly other
+ * commands and their options.
+ * @return the remaining un-processed <code>args</code>.
+ */
+ String[] processArgs(String[] args)
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
+ Parser cmdOptionsParser = getParser();
+ String[] result = cmdOptionsParser.parse(args);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "processArgs", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Initialize this concrete command handler for later invocation of the
+ * {@link #start()} or {@link #doCommand()} methods.
+ * <p>
+ * Handlers usually initialize their local variables and resources within the
+ * scope of this call.
+ *
+ * @throws IOException if an I/O related exception, such as opening an input
+ * stream, occurs during the execution of this method.
+ * @throws UnsupportedCallbackException if a requested callback handler
+ * implementation was not found, or was found but encountered an
+ * exception during its processing.
+ * @throws ClassNotFoundException if a designated security provider class was
+ * not found.
+ * @throws IllegalAccessException no 0-arguments constructor for the
+ * designated security provider class was found.
+ * @throws InstantiationException the designated security provider class is
+ * not instantiable.
+ * @throws KeyStoreException if an exception occurs during the instantiation
+ * of the KeyStore.
+ * @throws CertificateException if a certificate related exception, such as
+ * expiry, occurs during the loading of the KeyStore.
+ * @throws NoSuchAlgorithmException if no current security provider can
+ * provide a needed algorithm referenced by the KeyStore or one of
+ * its Key Entries or Certificates.
+ */
+ abstract void setup() throws Exception;
+
+ /**
+ * Do the real work this handler is supposed to do.
+ * <p>
+ * The code in this (abstract) class throws a <i>Not implemented yet</i>
+ * runtime exception. Concrete implementations MUST override this method.
+ *
+ * @throws CertificateException If no concrete implementation was found for a
+ * certificate Factory of a designated type. In this tool, the type
+ * is usually X.509 v1.
+ * @throws KeyStoreException if a keys-store related exception occurs; e.g.
+ * the key store has not been initialized.
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws SignatureException if a digital signature related exception occurs.
+ * @throws InvalidKeyException if the genereated keys are invalid.
+ * @throws UnrecoverableKeyException if the password used to unlock a key in
+ * the key store was invalid.
+ * @throws NoSuchAlgorithmException if a concrete implementation of an
+ * algorithm used to store a Key Entry was not found at runtime.
+ * @throws UnsupportedCallbackException if a requested callback handler
+ * implementation was not found, or was found but encountered an
+ * exception during its processing.
+ */
+ void start() throws Exception
+ {
+ throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
+ }
+
+ /**
+ * Tear down the handler, releasing any resources which may have been
+ * allocated at setup time.
+ */
+ void teardown()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ if (storeStream != null)
+ try
+ {
+ storeStream.close();
+ }
+ catch (IOException ignored)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Exception while closing key store URL stream. Ignored: " //$NON-NLS-1$
+ + ignored);
+ }
+
+ if (outStream != null)
+ {
+ try
+ {
+ outStream.flush();
+ }
+ catch (IOException ignored)
+ {
+ }
+
+ if (! systemOut)
+ try
+ {
+ outStream.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+
+ if (inStream != null)
+ try
+ {
+ inStream.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+
+ if (providerNdx > 0)
+ ProviderUtil.removeProvider(provider.getName());
+
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ }
+
+ // parameter setup and validation methods -----------------------------------
+
+ /**
+ * @return a {@link Parser} that knows how to parse the concrete command's
+ * options.
+ */
+ abstract Parser getParser();
+
+ /**
+ * Convenience method to setup the key store given its type, its password, its
+ * location and portentially a specialized security provider.
+ * <p>
+ * Calls the method with the same name and 5 arguments passing
+ * <code>false</code> to the first argument implying that no attempt to
+ * create the keystore will be made if one was not found at the designated
+ * location.
+ *
+ * @param className the potentially null fully qualified class name of a
+ * security provider to add at runtime, if no installed provider is
+ * able to provide a key store implementation of the desired type.
+ * @param type the potentially null type of the key store to request from the
+ * key store factory.
+ * @param password the potentially null password protecting the key store.
+ * @param url the URL of the key store.
+ */
+ protected void setKeyStoreParams(String className, String type,
+ String password, String url)
+ throws IOException, UnsupportedCallbackException, KeyStoreException,
+ NoSuchAlgorithmException, CertificateException
+ {
+ setKeyStoreParams(false, className, type, password, url);
+ }
+
+ /**
+ * Convenience method to setup the key store given its type, its password, its
+ * location and portentially a specialized security provider.
+ *
+ * @param createIfNotFound if <code>true</code> then create the keystore if
+ * it was not found; otherwise do not.
+ * @param className the potentially null fully qualified class name of a
+ * security provider to add at runtime, if no installed provider is
+ * able to provide a key store implementation of the desired type.
+ * @param type the potentially null type of the key store to request from the
+ * key store factory.
+ * @param password the potentially null password protecting the key store.
+ * @param url the URL of the key store.
+ */
+ protected void setKeyStoreParams(boolean createIfNotFound, String className,
+ String type, String password, String url)
+ throws IOException, UnsupportedCallbackException, KeyStoreException,
+ NoSuchAlgorithmException, CertificateException
+ {
+ setProviderClassNameParam(className);
+ setKeystoreTypeParam(type);
+ setKeystoreURLParam(createIfNotFound, url, password);
+ }
+
+ /**
+ * Set a security provider class name to (install and) use for key store
+ * related operations.
+ *
+ * @param className the possibly null, fully qualified class name of a
+ * security provider to add, if it is not already installed, to the
+ * set of available providers.
+ */
+ private void setProviderClassNameParam(String className)
+ {
+ if (Configuration.DEBUG)
+ log.fine("setProviderClassNameParam(" + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (className != null && className.trim().length() > 0)
+ {
+ className = className.trim();
+ SecurityProviderInfo spi = ProviderUtil.addProvider(className);
+ provider = spi.getProvider();
+ if (provider == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Was unable to add provider from class " + className);
+ }
+ providerNdx = spi.getPosition();
+ }
+ }
+
+ /**
+ * Set the type of key store to initialize, load and use.
+ *
+ * @param type the possibly null type of the key store. if this argument is
+ * <code>null</code>, or is an empty string, then this method sets
+ * the type of the key store to be the default value returned from
+ * the invocation of the {@link KeyStore#getDefaultType()} method.
+ * For GNU Classpath this is <i>gkr</i> which stands for the "Gnu
+ * KeyRing" specifications.
+ */
+ private void setKeystoreTypeParam(String type)
+ {
+ if (Configuration.DEBUG)
+ log.fine("setKeystoreTypeParam(" + type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (type == null || type.trim().length() == 0)
+ storeType = KeyStore.getDefaultType();
+ else
+ storeType = type.trim();
+ }
+
+ /**
+ * Set the key password given a command line option argument. If no value was
+ * present on the command line then prompt the user to provide one.
+ *
+ * @param password a possibly null key password gleaned from the command line.
+ * @throws IOException if an I/O related exception occurs.
+ * @throws UnsupportedCallbackException if no concrete implementation of a
+ * password callback was found at runtime.
+ */
+ protected void setKeyPasswordParam(String password) throws IOException,
+ UnsupportedCallbackException
+ {
+ setKeyPasswordNoPrompt(password);
+ if (keyPasswordChars == null)
+ setKeyPasswordParam();
+ }
+
+ /**
+ * Set the Alias to use when associating Key Entries and Trusted Certificates
+ * in the current key store.
+ *
+ * @param name the possibly null alias to use. If this arfument is
+ * <code>null</code>, then a default value of <code>mykey</code>
+ * will be used instead.
+ */
+ protected void setAliasParam(String name)
+ {
+ alias = name == null ? DEFAULT_ALIAS : name.trim();
+ }
+
+ /**
+ * Set the key password given a command line option argument.
+ *
+ * @param password a possibly null key password gleaned from the command line.
+ */
+ protected void setKeyPasswordNoPrompt(String password)
+ {
+ if (password != null)
+ keyPasswordChars = password.toCharArray();
+ }
+
+ /**
+ * Prompt the user to provide a password to protect a Key Entry in the key
+ * store.
+ *
+ * @throws IOException if an I/O related exception occurs.
+ * @throws UnsupportedCallbackException if no concrete implementation of a
+ * password callback was found at runtime.
+ * @throws SecurityException if no password is available, even after prompting
+ * the user.
+ */
+ private void setKeyPasswordParam() throws IOException,
+ UnsupportedCallbackException
+ {
+ String prompt = Messages.getFormattedString("Command.21", alias); //$NON-NLS-1$
+ PasswordCallback pcb = new PasswordCallback(prompt, false);
+ getCallbackHandler().handle(new Callback[] { pcb });
+ keyPasswordChars = pcb.getPassword();
+ pcb.clearPassword();
+ if (keyPasswordChars == null)
+ throw new SecurityException(Messages.getString("Command.23")); //$NON-NLS-1$
+ }
+
+ private void setKeystorePasswordParam(String password) throws IOException,
+ UnsupportedCallbackException
+ {
+ if (password != null)
+ storePasswordChars = password.toCharArray();
+ else // ask the user to provide one
+ {
+ String prompt = Messages.getString("Command.24"); //$NON-NLS-1$
+ PasswordCallback pcb = new PasswordCallback(prompt, false);
+ getCallbackHandler().handle(new Callback[] { pcb });
+ storePasswordChars = pcb.getPassword();
+ pcb.clearPassword();
+ }
+ }
+
+ /**
+ * Set the key store URL to use.
+ *
+ * @param createIfNotFound when <code>true</code> an attempt to create a
+ * keystore at the designated location will be made. If
+ * <code>false</code> then no file creation is carried out, which
+ * may cause an exception to be thrown later.
+ * @param url the full, or partial, URL to the keystore location.
+ * @param password an eventually null string to use when loading the keystore.
+ * @throws IOException
+ * @throws KeyStoreException
+ * @throws UnsupportedCallbackException
+ * @throws NoSuchAlgorithmException
+ * @throws CertificateException
+ */
+ private void setKeystoreURLParam(boolean createIfNotFound, String url,
+ String password) throws IOException,
+ KeyStoreException, UnsupportedCallbackException, NoSuchAlgorithmException,
+ CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.fine("setKeystoreURLParam(" + url + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (url == null || url.trim().length() == 0)
+ {
+ String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$
+ if (userHome == null || userHome.trim().length() == 0)
+ throw new InvalidParameterException(Messages.getString("Command.36")); //$NON-NLS-1$
+
+ url = userHome.trim() + "/.keystore"; //$NON-NLS-1$
+ // if it does not exist create it if required
+ if (createIfNotFound)
+ new File(url).createNewFile();
+ url = "file:" + url; //$NON-NLS-1$
+ }
+ else
+ {
+ url = url.trim();
+ if (url.indexOf(":") == -1) // if it does not exist create it //$NON-NLS-1$
+ {
+ if (createIfNotFound)
+ new File(url).createNewFile();
+ }
+ url = "file:" + url; //$NON-NLS-1$
+ }
+
+ boolean newKeyStore = false;
+ storeURL = new URL(url);
+ storeStream = storeURL.openStream();
+ if (storeStream.available() == 0)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Store is empty. Will use <null> when loading, to create it"); //$NON-NLS-1$
+ newKeyStore = true;
+ }
+
+ try
+ {
+ store = KeyStore.getInstance(storeType);
+ }
+ catch (KeyStoreException x)
+ {
+ if (provider != null)
+ throw x;
+
+ if (Configuration.DEBUG)
+ log.fine("Exception while getting key store with default provider(s)." //$NON-NLS-1$
+ + " Will prompt user for another provider and continue"); //$NON-NLS-1$
+ String prompt = Messages.getString("Command.40"); //$NON-NLS-1$
+ NameCallback ncb = new NameCallback(prompt);
+ getCallbackHandler().handle(new Callback[] { ncb });
+ String className = ncb.getName();
+ setProviderClassNameParam(className); // we may have a Provider
+ if (provider == null)
+ {
+ x.fillInStackTrace();
+ throw x;
+ }
+ // try again
+ store = KeyStore.getInstance(storeType, provider);
+ }
+
+ setKeystorePasswordParam(password);
+
+ // now we have a KeyStore instance. load it
+ // KeyStore public API claims: "...In order to create an empty keystore,
+ // you pass null as the InputStream argument to the load method.
+ if (newKeyStore)
+ store.load(null, storePasswordChars);
+ else
+ store.load(storeStream, storePasswordChars);
+
+ // close the stream
+ try
+ {
+ storeStream.close();
+ storeStream = null;
+ }
+ catch (IOException x)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Exception while closing the key store input stream: " + x //$NON-NLS-1$
+ + ". Ignore"); //$NON-NLS-1$
+ }
+ }
+
+ protected void setOutputStreamParam(String fileName) throws SecurityException,
+ IOException
+ {
+ if (fileName == null || fileName.trim().length() == 0)
+ {
+ outStream = System.out;
+ systemOut = true;
+ }
+ else
+ {
+ fileName = fileName.trim();
+ File outFile = new File(fileName);
+ if (! outFile.exists())
+ {
+ boolean ok = outFile.createNewFile();
+ if (!ok)
+ throw new InvalidParameterException(Messages.getFormattedString("Command.19", //$NON-NLS-1$
+ fileName));
+ }
+ else
+ {
+ if (! outFile.isFile())
+ throw new InvalidParameterException(Messages.getFormattedString("Command.42", //$NON-NLS-1$
+ fileName));
+ if (! outFile.canWrite())
+ throw new InvalidParameterException(Messages.getFormattedString("Command.44", //$NON-NLS-1$
+ fileName));
+ }
+ outStream = new FileOutputStream(outFile);
+ }
+ }
+
+ protected void setInputStreamParam(String fileName)
+ throws FileNotFoundException
+ {
+ if (fileName == null || fileName.trim().length() == 0)
+ inStream = System.in;
+ else
+ {
+ fileName = fileName.trim();
+ File inFile = new File(fileName);
+ if (! (inFile.exists() && inFile.isFile() && inFile.canRead()))
+ throw new InvalidParameterException(Messages.getFormattedString("Command.46", //$NON-NLS-1$
+ fileName));
+ inStream = new FileInputStream(inFile);
+ }
+ }
+
+ /**
+ * Set both the key-pair generation algorithm, and the digital signature
+ * algorithm instances to use when generating new entries.
+ *
+ * @param kpAlg the possibly null name of a key-pair generator algorithm.
+ * if this argument is <code>null</code> or is an empty string, the
+ * "DSS" algorithm will be used.
+ * @param sigAlg the possibly null name of a digital signature algorithm.
+ * If this argument is <code>null</code> or is an empty string, this
+ * method uses the "SHA1withDSA" (Digital Signature Standard, a.k.a.
+ * DSA, with the Secure Hash Algorithm function) as the default
+ * algorithm if, and only if, the key-pair generation algorithm ends
+ * up being "DSS"; otherwise, if the key-pair generation algorithm
+ * was "RSA", then the "MD5withRSA" signature algorithm will be used.
+ * If the key-pair generation algorithm is neither "DSS" (or its
+ * alias "DSA"), nor is it "RSA", then an exception is thrown.
+ * @throws NoSuchAlgorithmException if no concrete implementation of the
+ * designated algorithm is available.
+ */
+ protected void setAlgorithmParams(String kpAlg, String sigAlg)
+ throws NoSuchAlgorithmException
+ {
+ if (kpAlg == null || kpAlg.trim().length() == 0)
+ kpAlg = DEFAULT_KEY_ALGORITHM;
+ else
+ kpAlg = kpAlg.trim().toLowerCase();
+
+ keyPairGenerator = KeyPairGenerator.getInstance(kpAlg);
+
+ if (sigAlg == null || sigAlg.trim().length() == 0)
+ if (kpAlg.equalsIgnoreCase(Registry.DSS_KPG)
+ || kpAlg.equalsIgnoreCase(Registry.DSA_KPG))
+ sigAlg = DSA_SIGNATURE_ALGORITHM;
+ else if (kpAlg.equalsIgnoreCase(Registry.RSA_KPG))
+ sigAlg = RSA_SIGNATURE_ALGORITHM;
+ else
+ throw new IllegalArgumentException(
+ Messages.getFormattedString("Command.20", //$NON-NLS-1$
+ new String[] { sigAlg, kpAlg }));
+ else
+ sigAlg = sigAlg.trim().toLowerCase();
+
+ signatureAlgorithm = Signature.getInstance(sigAlg);
+ }
+
+ /**
+ * Set the signature algorithm to use when digitally signing private keys,
+ * certificates, etc...
+ * <p>
+ * If the designated algorithm name is <code>null</code> or is an empty
+ * string, this method checks the private key (the second argument) and based
+ * on its type decides which algorithm to use. The keytool public
+ * specification states that if the private key is a DSA key, then the
+ * signature algorithm will be <code>SHA1withDSA</code>, otherwise if it is
+ * an RSA private key, then the signature algorithm will be
+ * <code>MD5withRSA</code>. If the private key is neither a private DSA nor
+ * a private RSA key, then this method throws an
+ * {@link IllegalArgumentException}.
+ *
+ * @param algorithm the possibly null name of a digital signature algorithm.
+ * @param privateKey an instance of a private key to use as a fal-back option
+ * when <code>algorithm</code> is invalid.
+ * @throws NoSuchAlgorithmException if no concrete implementation of the
+ * designated, or default, signature algorithm is available.
+ */
+ protected void setSignatureAlgorithmParam(String algorithm, Key privateKey)
+ throws NoSuchAlgorithmException
+ {
+ if (algorithm == null || algorithm.trim().length() == 0)
+ if (privateKey instanceof DSAKey)
+ algorithm = DSA_SIGNATURE_ALGORITHM;
+ else if (privateKey instanceof RSAKey)
+ algorithm = RSA_SIGNATURE_ALGORITHM;
+ else
+ throw new InvalidParameterException(Messages.getString("Command.48")); //$NON-NLS-1$
+ else
+ algorithm = algorithm.trim();
+
+ signatureAlgorithm = Signature.getInstance(algorithm);
+ }
+
+ /**
+ * Set the validity period, in number of days, to use when issuing new
+ * certificates.
+ *
+ * @param days the number of days, as a string, the generated certificate will
+ * be valid for, starting from today's date. if this argument is
+ * <code>null</code>, a default value of <code>90</code> days
+ * will be used.
+ * @throws NumberFormatException if the designated string is not a decimal
+ * integer.
+ * @throws InvalidParameterException if the integer value of the non-null
+ * string is not greater than zero.
+ */
+ protected void setValidityParam(String days)
+ {
+ if (days == null || days.trim().length() == 0)
+ validityInDays = DEFAULT_VALIDITY;
+ else
+ {
+ days = days.trim();
+ validityInDays = Integer.parseInt(days);
+ if (validityInDays < 1)
+ throw new InvalidParameterException(Messages.getString("Command.51")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * RFC-2459 (http://rfc.net/rfc2459.html) fully describes the structure and
+ * semantics of X.509 certificates. The ASN.1 structures below are gleaned
+ * from that reference.
+ *
+ * <pre>
+ * Certificate ::= SEQUENCE {
+ * tbsCertificate TBSCertificate,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signatureValue BIT STRING
+ * }
+ *
+ * TBSCertificate ::= SEQUENCE {
+ * version [0] EXPLICIT Version DEFAULT v1,
+ * serialNumber CertificateSerialNumber,
+ * signature AlgorithmIdentifier,
+ * issuer Name,
+ * validity Validity,
+ * subject Name,
+ * subjectPublicKeyInfo SubjectPublicKeyInfo
+ * }
+ *
+ * Version ::= INTEGER { v1(0), v2(1), v3(2) }
+ *
+ * CertificateSerialNumber ::= INTEGER
+ *
+ * Validity ::= SEQUENCE {
+ * notBefore Time,
+ * notAfter Time
+ * }
+ *
+ * Time ::= CHOICE {
+ * utcTime UTCTime,
+ * generalTime GeneralizedTime
+ * }
+ *
+ * UniqueIdentifier ::= BIT STRING
+ *
+ * SubjectPublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * subjectPublicKey BIT STRING
+ * }
+ * </pre>
+ *
+ * @param distinguishedName the X.500 Distinguished Name to use as both the
+ * Issuer and Subject of the self-signed certificate to generate.
+ * @param publicKey the public key of the issuer/subject.
+ * @param privateKey the private key of the issuer/signer.
+ * @return the DER encoded form of a self-signed X.509 v1 certificate.
+ * @throws IOException If an I/O related exception occurs during the process.
+ * @throws SignatureException If a digital signature related exception occurs.
+ * @throws InvalidKeyException if the designated private key is invalid.
+ * @throws InvalidParameterException if the concrete signature algorithm does
+ * not know its name, no OID is known/supported for that name, or we
+ * were unable to match the name to a known string for which we can
+ * use a standard OID.
+ */
+ protected byte[] getSelfSignedCertificate(X500DistinguishedName distinguishedName,
+ PublicKey publicKey,
+ PrivateKey privateKey)
+ throws IOException, SignatureException, InvalidKeyException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getSelfSignedCertificate", //$NON-NLS-1$
+ new Object[] { distinguishedName, publicKey, privateKey });
+ byte[] versionBytes = new DERValue(DER.INTEGER, BigInteger.ZERO).getEncoded();
+ DERValue derVersion = new DERValue(DER.CONSTRUCTED | DER.CONTEXT | 0,
+ versionBytes.length, versionBytes, null);
+
+ // NOTE (rsn): the next 3 lines should be atomic but they're not.
+ Preferences prefs = Preferences.systemNodeForPackage(this.getClass());
+ int lastSerialNumber = prefs.getInt(Main.LAST_SERIAL_NUMBER, 0) + 1;
+ prefs.putInt(Main.LAST_SERIAL_NUMBER, lastSerialNumber);
+ DERValue derSerialNumber = new DERValue(DER.INTEGER,
+ BigInteger.valueOf(lastSerialNumber));
+
+ OID signatureID = getSignatureAlgorithmOID();
+ DERValue derSignatureID = new DERValue(DER.OBJECT_IDENTIFIER, signatureID);
+ ArrayList signature = new ArrayList(1);
+ signature.add(derSignatureID);
+ // rfc-2459 states the following:
+ //
+ // for the DSA signature:
+ // ...Where the id-dsa-with-sha1 algorithm identifier appears as the
+ // algorithm field in an AlgorithmIdentifier, the encoding shall omit
+ // the parameters field. That is, the AlgorithmIdentifier shall be a
+ // SEQUENCE of one component - the OBJECT IDENTIFIER id-dsa-with-sha1.
+ //
+ // for RSA signatures:
+ // ...When any of these three OIDs (i.e. xxxWithRSAEncryption) appears
+ // within the ASN.1 type AlgorithmIdentifier, the parameters component of
+ // that type shall be the ASN.1 type NULL.
+ if (! signatureID.equals(SHA1_WITH_DSA))
+ signature.add(new DERValue(DER.NULL, null));
+
+ DERValue derSignature = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+ signature);
+
+ DERValue derIssuer = new DERReader(distinguishedName.getDer()).read();
+
+ long notBefore = System.currentTimeMillis();
+ long notAfter = notBefore + validityInDays * MILLIS_IN_A_DAY;
+
+ ArrayList validity = new ArrayList(2);
+ validity.add(new DERValue(DER.UTC_TIME, new Date(notBefore)));
+ validity.add(new DERValue(DER.UTC_TIME, new Date(notAfter)));
+ DERValue derValidity = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+ validity);
+
+ // for a self-signed certificate subject and issuer are identical
+ DERValue derSubject = derIssuer;
+
+ DERValue derSubjectPublicKeyInfo = new DERReader(publicKey.getEncoded()).read();
+
+ ArrayList tbsCertificate = new ArrayList(7);
+ tbsCertificate.add(derVersion);
+ tbsCertificate.add(derSerialNumber);
+ tbsCertificate.add(derSignature);
+ tbsCertificate.add(derIssuer);
+ tbsCertificate.add(derValidity);
+ tbsCertificate.add(derSubject);
+ tbsCertificate.add(derSubjectPublicKeyInfo);
+ DERValue derTBSCertificate = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+ tbsCertificate);
+
+ // The 'signature' field MUST contain the same algorithm identifier as the
+ // 'signatureAlgorithm' field in the sequence Certificate.
+ DERValue derSignatureAlgorithm = derSignature;
+
+ signatureAlgorithm.initSign(privateKey);
+ signatureAlgorithm.update(derTBSCertificate.getEncoded());
+ byte[] sigBytes = signatureAlgorithm.sign();
+ DERValue derSignatureValue = new DERValue(DER.BIT_STRING,
+ new BitString(sigBytes));
+
+ ArrayList certificate = new ArrayList(3);
+ certificate.add(derTBSCertificate);
+ certificate.add(derSignatureAlgorithm);
+ certificate.add(derSignatureValue);
+ DERValue derCertificate = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+ certificate);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DERWriter.write(baos, derCertificate);
+ byte[] result = baos.toByteArray();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getSelfSignedCertificate"); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * This method attempts to find, and return, an OID representing the digital
+ * signature algorithm used to sign the certificate. The OIDs returned are
+ * those described in RFC-2459. They are listed here for the sake of
+ * completness.
+ *
+ * <pre>
+ * id-dsa-with-sha1 OBJECT IDENTIFIER ::= {
+ * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3
+ * }
+ *
+ * md2WithRSAEncryption OBJECT IDENTIFIER ::= {
+ * iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 2
+ * }
+ *
+ * md5WithRSAEncryption OBJECT IDENTIFIER ::= {
+ * iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 4
+ * }
+ *
+ * sha-1WithRSAEncryption OBJECT IDENTIFIER ::= {
+ * iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 5
+ * }
+ * </pre>
+ *
+ * <b>IMPORTANT</b>: This method checks the signature algorithm name against
+ * (a) The GNU algorithm implementation's name, and (b) publicly referenced
+ * names of the same algorithm. In other words this search is not
+ * comprehensive and may fail for uncommon names of the same algorithms.
+ *
+ * @return the OID of the signature algorithm in use.
+ * @throws InvalidParameterException if the concrete signature algorithm does
+ * not know its name, no OID is known/supported for that name, or we
+ * were unable to match the name to a known string for which we can
+ * return an OID.
+ */
+ protected OID getSignatureAlgorithmOID()
+ {
+ String algorithm = signatureAlgorithm.getAlgorithm();
+ // if we already have a non-null signature then the name was valid. the
+ // only case where algorithm is invalid would be if the implementation is
+ // flawed. check anyway
+ if (algorithm == null || algorithm.trim().length() == 0)
+ throw new InvalidParameterException(Messages.getString("Command.52")); //$NON-NLS-1$
+
+ algorithm = algorithm.trim();
+ if (algorithm.equalsIgnoreCase(Registry.DSS_SIG)
+ || algorithm.equalsIgnoreCase("SHA1withDSA")) //$NON-NLS-1$
+ return SHA1_WITH_DSA;
+
+ if (algorithm.equalsIgnoreCase(Registry.RSA_PKCS1_V1_5_SIG + "-" //$NON-NLS-1$
+ + Registry.MD2_HASH)
+ || algorithm.equalsIgnoreCase("MD2withRSA")) //$NON-NLS-1$
+ return MD2_WITH_RSA;
+
+ if (algorithm.equalsIgnoreCase(Registry.RSA_PKCS1_V1_5_SIG + "-" //$NON-NLS-1$
+ + Registry.MD5_HASH)
+ || algorithm.equalsIgnoreCase("MD5withRSA") //$NON-NLS-1$
+ || algorithm.equalsIgnoreCase("rsa")) //$NON-NLS-1$
+ return MD5_WITH_RSA;
+
+ if (algorithm.equalsIgnoreCase(Registry.RSA_PKCS1_V1_5_SIG + "-" //$NON-NLS-1$
+ + Registry.SHA160_HASH)
+ || algorithm.equalsIgnoreCase("SHA1withRSA")) //$NON-NLS-1$
+ return SHA1_WITH_RSA;
+
+ throw new InvalidParameterException(Messages.getFormattedString("Command.60", //$NON-NLS-1$
+ algorithm));
+ }
+
+ /**
+ * Saves the key store using the designated password. This operation is called
+ * by handlers if/when the key store password has changed, or amendements have
+ * been made to the contents of the store; e.g. addition of a new Key Entry or
+ * a Trusted Certificate.
+ *
+ * @param password the password protecting the key store.
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws CertificateException if any of the certificates in the current key
+ * store could not be persisted.
+ * @throws NoSuchAlgorithmException if a required data integrity algorithm
+ * implementation was not found.
+ * @throws KeyStoreException if the key store has not been loaded previously.
+ */
+ protected void saveKeyStore(char[] password) throws IOException,
+ KeyStoreException, NoSuchAlgorithmException, CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
+ URLConnection con = storeURL.openConnection();
+ con.setDoOutput(true);
+ con.setUseCaches(false);
+ OutputStream out = con.getOutputStream();
+ if (verbose)
+ System.out.println(Messages.getFormattedString("Command.63", storeURL.getPath())); //$NON-NLS-1$
+
+ store.store(out, password);
+ out.flush();
+ out.close();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
+ }
+
+ /**
+ * Convenience method. Calls the method with the same name passing it the
+ * same password characters used to initially load the key-store.
+ *
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws KeyStoreException if the key store has not been loaded previously.
+ * @throws NoSuchAlgorithmException if a required data integrity algorithm
+ * implementation was not found.
+ * @throws CertificateException if any of the certificates in the current key
+ * store could not be persisted.
+ */
+ protected void saveKeyStore() throws IOException, KeyStoreException,
+ NoSuchAlgorithmException, CertificateException
+ {
+ saveKeyStore(storePasswordChars);
+ }
+
+ /**
+ * Prints a human-readable form of the designated certificate to a designated
+ * {@link PrintWriter}.
+ *
+ * @param certificate the certificate to process.
+ * @param writer where to print it.
+ * @throws CertificateEncodingException if an exception occurs while obtaining
+ * the DER encoded form <code>certificate</code>.
+ */
+ protected void printVerbose(Certificate certificate, PrintWriter writer)
+ throws CertificateEncodingException
+ {
+ X509Certificate x509 = (X509Certificate) certificate;
+ writer.println(Messages.getFormattedString("Command.66", x509.getSubjectDN())); //$NON-NLS-1$
+ writer.println(Messages.getFormattedString("Command.67", x509.getIssuerDN())); //$NON-NLS-1$
+ writer.println(Messages.getFormattedString("Command.68", x509.getSerialNumber())); //$NON-NLS-1$
+ writer.println(Messages.getFormattedString("Command.69", x509.getNotBefore())); //$NON-NLS-1$
+ writer.println(Messages.getFormattedString("Command.70", x509.getNotAfter())); //$NON-NLS-1$
+ writer.println(Messages.getString("Command.71")); //$NON-NLS-1$
+ byte[] derBytes = certificate.getEncoded();
+ writer.println(Messages.getFormattedString("Command.72", digest(md5, derBytes))); //$NON-NLS-1$
+ writer.println(Messages.getFormattedString("Command.73", digest(sha, derBytes))); //$NON-NLS-1$
+ }
+
+ /**
+ * Convenience method. Prints a human-readable form of the designated
+ * certificate to <code>System.out</code>.
+ *
+ * @param certificate the certificate to process.
+ * @throws CertificateEncodingException if an exception occurs while obtaining
+ * the DER encoded form <code>certificate</code>.
+ */
+ protected void printVerbose(Certificate certificate)
+ throws CertificateEncodingException
+ {
+ printVerbose(certificate, new PrintWriter(System.out, true));
+ }
+
+ /**
+ * Digest the designated contents with MD5 and return a string representation
+ * suitable for use as a fingerprint; i.e. sequence of hexadecimal pairs of
+ * characters separated by a colon.
+ *
+ * @param contents the non-null contents to digest.
+ * @return a sequence of hexadecimal pairs of characters separated by colons.
+ */
+ protected String digestWithMD5(byte[] contents)
+ {
+ return digest(md5, contents);
+ }
+
+ private String digest(IMessageDigest hash, byte[] encoded)
+ {
+ hash.update(encoded);
+ byte[] b = hash.digest();
+ StringBuilder sb = new StringBuilder().append(Util.toString(b, 0, 1));
+ for (int i = 1; i < b.length; i++)
+ sb.append(":").append(Util.toString(b, i, 1)); //$NON-NLS-1$
+
+ String result = sb.toString();
+ return result;
+ }
+
+ /**
+ * Ensure that the currently set Alias is contained in the currently set key
+ * store; otherwise throw an exception.
+ *
+ * @throws KeyStoreException if the keystore has not been loaded.
+ * @throws IllegalArgumentException if the currently set alias is not known to
+ * the currently set key store.
+ */
+ protected void ensureStoreContainsAlias() throws KeyStoreException
+ {
+ if (! store.containsAlias(alias))
+ throw new IllegalArgumentException(Messages.getFormattedString("Command.75", //$NON-NLS-1$
+ alias));
+ }
+
+ /**
+ * Ensure that the currently set Alias is associated with a Key Entry in the
+ * currently set key store; otherwise throw an exception.
+ *
+ * @throws KeyStoreException if the keystore has not been loaded.
+ * @throws SecurityException if the currently set alias is not a Key Entry in
+ * the currently set key store.
+ */
+ protected void ensureAliasIsKeyEntry() throws KeyStoreException
+ {
+ if (! store.isKeyEntry(alias))
+ throw new SecurityException(Messages.getFormattedString("Command.77", //$NON-NLS-1$
+ alias));
+ }
+
+ protected Key getAliasPrivateKey() throws KeyStoreException,
+ NoSuchAlgorithmException, IOException, UnsupportedCallbackException,
+ UnrecoverableKeyException
+ {
+ ensureAliasIsKeyEntry();
+ Key result;
+ if (keyPasswordChars == null)
+ try
+ {
+ result = store.getKey(alias, storePasswordChars);
+ // it worked. assign to keyPasswordChars for later use
+ keyPasswordChars = storePasswordChars;
+ }
+ catch (UnrecoverableKeyException x)
+ {
+ // prompt the user to provide one
+ setKeyPasswordParam();
+ result = store.getKey(alias, keyPasswordChars);
+ }
+ else
+ result = store.getKey(alias, keyPasswordChars);
+
+ return result;
+ }
+
+ /**
+ * Return a CallbackHandler which uses the Console (System.in and System.out)
+ * for interacting with the user.
+ * <p>
+ * This method first finds all currently installed security providers capable
+ * of providing such service and then in turn attempts to instantiate the
+ * handler from those providers. As soon as one provider returns a non-null
+ * instance of the callback handler, the search stops and that instance is
+ * set to be used from now on.
+ * <p>
+ * If no installed providers were found, this method falls back on the GNU
+ * provider, by-passing the Security search mechanism. The default console
+ * callback handler implementation is
+ * {@link gnu.javax.security.auth.callback.ConsoleCallbackHandler}.
+ *
+ * @return a console-based {@link CallbackHandler}.
+ */
+ protected CallbackHandler getCallbackHandler()
+ {
+ if (handler == null)
+ handler = CallbackUtil.getConsoleHandler();
+
+ return handler;
+ }
+
+ // Inner class(es) ==========================================================
+
+ private class ShutdownHook
+ extends Thread
+ {
+ public void run()
+ {
+ teardown();
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
new file mode 100644
index 000000000..5a9cbfd1f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
@@ -0,0 +1,280 @@
+/* DeleteCmd.java -- The delete command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-delete</b> keytool command handler is used to delete from the key
+ * store the entry associated with a designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class DeleteCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(DeleteCmd.class.getName());
+ protected String _alias;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setTheAlias(_alias);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-delete handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, NoSuchAlgorithmException,
+ CertificateException, IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ ensureStoreContainsAlias();
+ store.deleteEntry(alias);
+ saveKeyStore();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.DELETE_CMD, true);
+ result.setHeader(Messages.getString("DeleteCmd.18")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("DeleteCmd.17")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("DeleteCmd.16")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("DeleteCmd.15"), //$NON-NLS-1$
+ Messages.getString("DeleteCmd.14")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("DeleteCmd.13"), //$NON-NLS-1$
+ Messages.getString("DeleteCmd.12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("DeleteCmd.11"), //$NON-NLS-1$
+ Messages.getString("DeleteCmd.10")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("DeleteCmd.9"), //$NON-NLS-1$
+ Messages.getString("DeleteCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("DeleteCmd.7"), //$NON-NLS-1$
+ Messages.getString("DeleteCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("DeleteCmd.5")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Set the alias to delete from the key store.
+ * <p>
+ * Unlike in other keytool handlers, the default value (<i>mykey</i>) for the
+ * Alias is not used. Instead, if an alias was not found on the command line,
+ * the user is prompted to enter one.
+ *
+ * @param anAlias a possibly null Alias gleaned from the command line.
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws UnsupportedCallbackException if no implementation of a password
+ * callback handler was found.
+ */
+ private void setTheAlias(String anAlias) throws IOException,
+ UnsupportedCallbackException
+ {
+ if (anAlias == null || anAlias.trim().length() == 0)
+ {
+ String prompt = Messages.getString("DeleteCmd.19"); //$NON-NLS-1$
+ NameCallback ncb = new NameCallback(prompt);
+ getCallbackHandler().handle(new Callback[] { ncb });
+ anAlias = ncb.getName();
+ if (anAlias == null || anAlias.trim().length() == 0)
+ throw new SecurityException(Messages.getString("DeleteCmd.20")); //$NON-NLS-1$
+ }
+ alias = anAlias.trim();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
new file mode 100644
index 000000000..035fbab6a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
@@ -0,0 +1,328 @@
+/* ExportCmd.java -- The export command handler of the keytool
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.util.Base64;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.KeyStoreException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.util.logging.Logger;
+
+/**
+ * The <b>-export</b> keytool command handler is used to read the certificate
+ * associated with a designated alias from the key store, and write it to a
+ * designated file.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-file FILE_NAME</dt>
+ * <dd>The fully qualified path of the file where the certificate will be
+ * exported to. If omitted, STDOUT will be used instead.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-rfc</dt>
+ * <dd>Use RFC-1421 specifications when encoding the output.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Output the certificate in binary DER encoding. This is the default
+ * output format of the command if neither <code>-rfc</code> nor
+ * <code>-v</code> options were detected on the command line. If both this
+ * option and the <code>-rfc</code> option are detected on the command
+ * line, the tool will opt for the RFC-1421 style encoding.</dd>
+ * </dl>
+ */
+class ExportCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(ExportCmd.class.getName());
+ protected String _alias;
+ protected String _certFileName;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ protected boolean rfc;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /** @param pathName the fully qualified path name of the file to process. */
+ public void setFile(String pathName)
+ {
+ this._certFileName = pathName;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ /**
+ * @param flag whether to use, or not, RFC-1421 format when exporting the
+ * certificate(s).
+ */
+ public void setRfc(String flag)
+ {
+ this.rfc = Boolean.valueOf(flag).booleanValue();
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setOutputStreamParam(_certFileName);
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setAliasParam(_alias);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-export handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -rfc=" + rfc); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, CertificateEncodingException,
+ IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ ensureStoreContainsAlias();
+ Certificate certificate;
+ if (store.isCertificateEntry(alias))
+ {
+ if (Configuration.DEBUG)
+ log.fine("Alias [" + alias + "] is a trusted certificate"); //$NON-NLS-1$ //$NON-NLS-2$
+ certificate = store.getCertificate(alias);
+ }
+ else
+ {
+ if (Configuration.DEBUG)
+ log.fine("Alias [" + alias + "] is a key entry"); //$NON-NLS-1$ //$NON-NLS-2$
+ Certificate[] chain = store.getCertificateChain(alias);
+ certificate = chain[0];
+ }
+
+ byte[] derBytes = certificate.getEncoded();
+ if (rfc)
+ {
+ String encoded = Base64.encode(derBytes, 72);
+ PrintWriter pw = new PrintWriter(outStream, true);
+ pw.println("-----BEGIN CERTIFICATE-----"); //$NON-NLS-1$
+ pw.println(encoded);
+ pw.println("-----END CERTIFICATE-----"); //$NON-NLS-1$
+ }
+ else
+ outStream.write(derBytes);
+
+ // stream is closed in Command.teardown()
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.EXPORT_CMD, true);
+ result.setHeader(Messages.getString("ExportCmd.17")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("ExportCmd.18")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("ExportCmd.19")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("ExportCmd.20"), //$NON-NLS-1$
+ Messages.getString("ExportCmd.21")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.FILE_OPT,
+ Messages.getString("ExportCmd.22"), //$NON-NLS-1$
+ Messages.getString("ExportCmd.23")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _certFileName = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("ExportCmd.24"), //$NON-NLS-1$
+ Messages.getString("ExportCmd.25")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("ExportCmd.26"), //$NON-NLS-1$
+ Messages.getString("ExportCmd.27")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("ExportCmd.28"), //$NON-NLS-1$
+ Messages.getString("ExportCmd.29")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("ExportCmd.30"), //$NON-NLS-1$
+ Messages.getString("ExportCmd.31")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.RFC_OPT,
+ Messages.getString("ExportCmd.32")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ rfc = true;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("ExportCmd.33")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
new file mode 100644
index 000000000..b892ca794
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
@@ -0,0 +1,602 @@
+/* GenKeyCmd.java -- The genkey command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.util.Util;
+import gnu.java.security.x509.X500DistinguishedName;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-genkey</b> keytool command handler is used to generate a key pair (a
+ * public, and associated private keys). It then generates a self-signed X509 v1
+ * certificate (authenticating the public key) and stores this certificate and
+ * the private key in the key store associating both to a designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-keyalg ALGORITHM</dt>
+ * <dd>Use this option to specify the canonical name of the key-pair
+ * generation algorithm. The default value for this option is
+ * <code>DSS</code> (a synonym for the Digital Signature Algorithm also
+ * known as <code>DSA</code>).
+ * <p></dd>
+ *
+ * <dt>-keysize KEY_SIZE</dt>
+ * <dd>Use this option to specify the number of bits of the shared modulus
+ * (for both the public and private keys) to use when generating new keys.
+ * A default value of <code>1024</code> will be used if this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-sigalg ALGORITHM</dt>
+ * <dd>The canonical name of the digital signature algorithm to use for
+ * signing certificates. If this option is omitted, a default value will be
+ * chosen based on the type of the key-pair; i.e. the algorithm that ends
+ * up being used by the <code>-keyalg</code> option. If the key-pair
+ * generation algorithm is <code>DSA</code>, the value for the signature
+ * algorithm will be <code>SHA1withDSA</code>. If on the other hand the
+ * key-pair generation algorithm is <code>RSA</code>, then the tool will
+ * use <code>MD5withRSA</code> as the signature algorithm.
+ * <p></dd>
+ *
+ * <dt>-dname NAME</dt>
+ * <dd>This a mandatory value for this command. If this option is omitted
+ * the tool will prompt you to enter a <i>Distinguished Name</i> to use as
+ * both the <i>Owner</i> and <i>Issuer</i> of the generated self-signed
+ * certificate.
+ * <p>
+ * The syntax of a valid value for this option MUST follow RFC-2253
+ * specifications. Namely the following components (with their accepted
+ * meaning) will be recognized. Note that the component name is case-
+ * insensitive:
+ * <dl>
+ * <dt>CN</dt>
+ * <dd>The Common Name; e.g. "host.domain.com"</dd>
+ *
+ * <dt>OU</dt>
+ * <dd>The Organizational Unit; e.g. "IT Department"</dd>
+ *
+ * <dt>O</dt>
+ * <dd>The Organization Name; e.g. "The Sample Company"</dd>
+ *
+ * <dt>L</dt>
+ * <dd>The Locality Name; e.g. "Sydney"</dd>
+ *
+ * <dt>ST</dt>
+ * <dd>The State Name; e.g. "New South Wales"</dd>
+ *
+ * <dt>C</dt>
+ * <dd>The 2-letter Country identifier; e.g. "AU"</dd>
+ * </dl>
+ * <p>
+ * When specified with a <code>-dname</code> option, each pair of component
+ * / value will be separated from the other with a comma. Each component
+ * and value pair MUST be separated by an equal sign. For example, the
+ * following is a valid DN value:
+ * <pre>
+ * CN=host.domain.com, O=The Sample Company, L=Sydney, ST=NSW, C=AU
+ * </pre>
+ * If this option is omitted, the tool will prompt you to enter the
+ * information through the console.
+ * <p></dd>
+ *
+ * <dt>-keypass PASSWORD</dt>
+ * <dd>Use this option to specify the password which the tool will use to
+ * protect the newly created Key Entry.
+ * <p>
+ * If this option is omitted, you will be prompted to provide a password.
+ * <p></dd>
+ *
+ * <dt>-validity DAY_COUNT</dt>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class GenKeyCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(GenKeyCmd.class.getName());
+ /** Default key size in bits. */
+ private static final int DEFAULT_KEY_SIZE = 1024;
+
+ protected String _alias;
+ protected String _keyAlgorithm;
+ protected String _keySizeStr;
+ protected String _sigAlgorithm;
+ protected String _dName;
+ protected String _password;
+ protected String _validityStr;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ private int keySize;
+ private X500DistinguishedName distinguishedName;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /** @param algorithm the canonical name of the key-pair algorithm to use. */
+ public void setKeyalg(String algorithm)
+ {
+ this._keyAlgorithm = algorithm;
+ }
+
+ /**
+ * @param bits the string representation of the number of bits (a decimal
+ * positive integer) the modulus of the generated keys (private and
+ * public) should have.
+ */
+ public void setKeysize(String bits)
+ {
+ this._validityStr = bits;
+ }
+
+ /**
+ * @param algorithm the canonical name of the digital signature algorithm to
+ * use.
+ */
+ public void setSigalg(String algorithm)
+ {
+ this._sigAlgorithm = algorithm;
+ }
+
+ /** @param name the distiniguished name to use. */
+ public void setDname(String name)
+ {
+ this._dName = name;
+ }
+
+ /** @param password the (private) key password to use. */
+ public void setKeypass(String password)
+ {
+ this._password = password;
+ }
+
+ /**
+ * @param days the string representation of the number of days (a decimal,
+ * positive integer) to assign to the generated certificate.
+ */
+ public void setValidity(String days)
+ {
+ this._validityStr = days;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
+ setAliasParam(_alias);
+ setKeyPasswordParam(_password);
+ setAlgorithmParams(_keyAlgorithm, _sigAlgorithm);
+ setKeySize(_keySizeStr);
+ setDName(_dName);
+ setValidityParam(_validityStr);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-genkey handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -keyalg=" + keyPairGenerator.getAlgorithm()); //$NON-NLS-1$
+ log.fine(" -keysize=" + keySize); //$NON-NLS-1$
+ log.fine(" -sigalg=" + signatureAlgorithm.getAlgorithm()); //$NON-NLS-1$
+ log.fine(" -dname=" + distinguishedName); //$NON-NLS-1$
+ log.fine(" -validity=" + validityInDays); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws CertificateException, KeyStoreException,
+ InvalidKeyException, SignatureException, IOException,
+ NoSuchAlgorithmException
+ {
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ log.fine("About to generate key-pair..."); //$NON-NLS-1$
+ }
+ // 1. generate a new key-pair
+ keyPairGenerator.initialize(keySize);
+ KeyPair kp = keyPairGenerator.generateKeyPair();
+ PublicKey publicKey = kp.getPublic();
+ PrivateKey privateKey = kp.getPrivate();
+
+ // 2. generate a self-signed certificate
+ if (Configuration.DEBUG)
+ log.fine("About to generate a self-signed certificate..."); //$NON-NLS-1$
+ byte[] derBytes = getSelfSignedCertificate(distinguishedName,
+ publicKey,
+ privateKey);
+ if (Configuration.DEBUG)
+ log.fine(Util.dumpString(derBytes, "derBytes ")); //$NON-NLS-1$
+ CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509);
+ ByteArrayInputStream bais = new ByteArrayInputStream(derBytes);
+ Certificate certificate = x509Factory.generateCertificate(bais);
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
+
+ // 3. store it, w/ its private key, associating them to alias
+ Certificate[] chain = new Certificate[] { certificate };
+ if (Configuration.DEBUG)
+ log.fine("About to store newly generated material in key store..."); //$NON-NLS-1$
+ store.setKeyEntry(alias, privateKey, keyPasswordChars, chain);
+
+ // 4. persist the key store
+ saveKeyStore();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.GENKEY_CMD, true);
+ result.setHeader(Messages.getString("GenKeyCmd.57")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("GenKeyCmd.58")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("GenKeyCmd.59")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("GenKeyCmd.60"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.61")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.KEYALG_OPT,
+ Messages.getString("GenKeyCmd.62"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.63")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _keyAlgorithm = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSIZE_OPT,
+ Messages.getString("GenKeyCmd.64"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.65")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _keySizeStr = argument;
+ }
+ });
+ options.add(new Option(Main.SIGALG_OPT,
+ Messages.getString("GenKeyCmd.66"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.63")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _sigAlgorithm = argument;
+ }
+ });
+ options.add(new Option(Main.DNAME_OPT,
+ Messages.getString("GenKeyCmd.68"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.69")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _dName = argument;
+ }
+ });
+ options.add(new Option(Main.KEYPASS_OPT,
+ Messages.getString("GenKeyCmd.70"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.71")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _password = argument;
+ }
+ });
+ options.add(new Option(Main.VALIDITY_OPT,
+ Messages.getString("GenKeyCmd.72"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.73")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _validityStr = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("GenKeyCmd.74"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.75")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("GenKeyCmd.76"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.77")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("GenKeyCmd.78"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.71")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("GenKeyCmd.80"), //$NON-NLS-1$
+ Messages.getString("GenKeyCmd.81")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("GenKeyCmd.82")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * @param size the desired key size as a string.
+ * @throws NumberFormatException if the string does not represent a valid
+ * decimal integer value.
+ */
+ private void setKeySize(String size)
+ {
+ if (size == null || size.trim().length() == 0)
+ this.keySize = DEFAULT_KEY_SIZE;
+ else
+ {
+ size = size.trim();
+ keySize = Integer.parseInt(size);
+ // When generating a DSA key pair, the key size must be in the range
+ // from 512 to 1024 bits, and must be a multiple of 64. The default
+ // key size for any algorithm is 1024 bits
+ if (keySize < 1)
+ throw new IllegalArgumentException(Messages.getString("GenKeyCmd.54")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @param name the X.500 distinguished name of the principal for whom the
+ * key/certificate are being generated.
+ * @throws UnsupportedCallbackException if no implementation of a name
+ * callback is available.
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws IllegalArgumentException if the designated, or captured, value is
+ * not a valid X.500 distinguished name.
+ */
+ private void setDName(String name) throws IOException,
+ UnsupportedCallbackException
+ {
+ if (name != null && name.trim().length() > 0)
+ name = name.trim();
+ else
+ {
+ // prompt user to provide one
+ String dnTxt = Messages.getString("GenKeyCmd.0"); //$NON-NLS-1$
+ String oDefault = Messages.getString("GenKeyCmd.6"); //$NON-NLS-1$
+ String lDefault = Messages.getString("GenKeyCmd.7"); //$NON-NLS-1$
+ String stDefault = Messages.getString("GenKeyCmd.8"); //$NON-NLS-1$
+ String cDefault = Messages.getString("GenKeyCmd.9"); //$NON-NLS-1$
+ String cnPrompt = Messages.getString("GenKeyCmd.10"); //$NON-NLS-1$
+ String oPrompt = Messages.getFormattedString("GenKeyCmd.11", oDefault); //$NON-NLS-1$
+ String ouPrompt = Messages.getString("GenKeyCmd.13"); //$NON-NLS-1$
+ String lPrompt = Messages.getFormattedString("GenKeyCmd.14", lDefault); //$NON-NLS-1$
+ String stPrompt = Messages.getFormattedString("GenKeyCmd.16", stDefault); //$NON-NLS-1$
+ String cPrompt = Messages.getFormattedString("GenKeyCmd.18", cDefault); //$NON-NLS-1$
+
+ TextOutputCallback dnCB = new TextOutputCallback(TextOutputCallback.INFORMATION,
+ dnTxt);
+ TextInputCallback cnCB = new TextInputCallback(cnPrompt);
+ TextInputCallback oCB = new TextInputCallback(oPrompt, oDefault);
+ TextInputCallback ouCB = new TextInputCallback(ouPrompt);
+ TextInputCallback lCB = new TextInputCallback(lPrompt, lDefault);
+ TextInputCallback sCB = new TextInputCallback(stPrompt, stDefault);
+ TextInputCallback cCB = new TextInputCallback(cPrompt, cDefault);
+ getCallbackHandler().handle(new Callback[] { dnCB, cnCB, oCB, ouCB, lCB, sCB, cCB });
+ StringBuilder sb = new StringBuilder();
+
+ // handle CN
+ name = parseUserPrompt(cnCB);
+ if (name != null && name.length() > 0)
+ sb.append("CN=").append(name); //$NON-NLS-1$
+
+ // handle O
+ name = parseUserPrompt(oCB);
+ if (name != null && name.length() > 0)
+ sb.append(",O=").append(name); //$NON-NLS-1$
+
+ // handle OU
+ name = parseUserPrompt(ouCB);
+ if (name != null && name.length() > 0)
+ sb.append(",OU=").append(name.trim()); //$NON-NLS-1$
+
+ // handle L
+ name = parseUserPrompt(lCB);
+ if (name != null && name.length() > 0)
+ sb.append(",L=").append(name.trim()); //$NON-NLS-1$
+
+ // handle ST
+ name = parseUserPrompt(sCB);
+ if (name != null && name.length() > 0)
+ sb.append(",ST=").append(name.trim()); //$NON-NLS-1$
+
+ // handle C
+ name = parseUserPrompt(cCB);
+ if (name != null && name.length() > 0)
+ sb.append(",C=").append(name.trim()); //$NON-NLS-1$
+
+ name = sb.toString().trim();
+ }
+ if (Configuration.DEBUG)
+ log.fine("dName=[" + name + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+ distinguishedName = new X500DistinguishedName(name);
+ }
+
+ private String parseUserPrompt(TextInputCallback ticb)
+ {
+ String result = ticb.getText();
+ if (result == null || result.trim().length() == 0)
+ result = ticb.getDefaultText();
+ else if (result.trim().equals(".")) //$NON-NLS-1$
+ result = null;
+ else
+ result = result.trim();
+
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
new file mode 100644
index 000000000..e52c90299
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
@@ -0,0 +1,232 @@
+/* IdentityDBCmd.java -- The identitydb command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.util.logging.Logger;
+
+/**
+ * <b>NOT IMPLEMENTED YET</b>
+ * <p>
+ * The <b>-identitydb</b> keytool command handler is used to read the JDK 1.1.x-
+ * style identity database and add its entries to the key store. If a key store
+ * does not exist, it is created.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-file FILE_NAME</dt>
+ * <dd>The fully qualified path of the identity file to import. If this
+ * option is omitted, the tool will process STDIN.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class IdentityDBCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(IdentityDBCmd.class.getName());
+ protected String _idbFileName;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param pathName the fully qualified path name of the file to process. */
+ public void setFile(String pathName)
+ {
+ this._idbFileName = pathName;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setInputStreamParam(_idbFileName);
+ setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-identitydb handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -file=" + _idbFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.IDENTITYDB_CMD, true);
+ result.setHeader(Messages.getString("IdentityDBCmd.7")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("IdentityDBCmd.8")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("IdentityDBCmd.9")); //$NON-NLS-1$
+ options.add(new Option(Main.FILE_OPT,
+ Messages.getString("IdentityDBCmd.10"), //$NON-NLS-1$
+ Messages.getString("IdentityDBCmd.11")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _idbFileName = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("IdentityDBCmd.12"), //$NON-NLS-1$
+ Messages.getString("IdentityDBCmd.13")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("IdentityDBCmd.14"), //$NON-NLS-1$
+ Messages.getString("IdentityDBCmd.15")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("IdentityDBCmd.16"), //$NON-NLS-1$
+ Messages.getString("IdentityDBCmd.17")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("IdentityDBCmd.18"), //$NON-NLS-1$
+ Messages.getString("IdentityDBCmd.19")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("IdentityDBCmd.20")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
new file mode 100644
index 000000000..b68760d09
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
@@ -0,0 +1,930 @@
+/* ImportCmd.java -- The import command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.x509.X509CertPath;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Principal;
+import java.security.PublicKey;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertPathValidator;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.PKIXCertPathValidatorResult;
+import java.security.cert.PKIXParameters;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.RSAPublicKey;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <code>-import</code> keytool command handler is used to read an X.509
+ * certificate, or a PKCS#7 Certificate Reply from a designated input source and
+ * incorporate the certificates into the key store.
+ * <p>
+ * If the <i>Alias</i> does not already exist in the key store, the tool treats
+ * the certificate read from the input source as a new Trusted Certificate. It
+ * then attempts to discover a chain-of-trust, starting from that certificate
+ * and ending at another <i>Trusted Certificate</i>, already stored in the key
+ * store. If the <code>-trustcacerts</code> option is present, an additional
+ * key store, of type <code>JKS</code> named <code>cacerts</code>, and assumed
+ * to be present in <code>${JAVA_HOME}/lib/security</code> will also be
+ * consulted if found --<code>${JAVA_HOME}</code> refers to the location of an
+ * installed Java Runtime Environment (JRE). If no chain-of-trust can be
+ * established, and unless the <code>-noprompt</code> option has been specified,
+ * the certificate is printed to STDOUT and the user is prompted for a
+ * confirmation.
+ * <p>
+ * If <i>Alias</i> exists in the key store, the tool will treat the
+ * certificate(s) read from the input source as a <i>Certificate Reply</i>,
+ * which can be a chain of certificates, that eventually would replace the chain
+ * of certificates associated with the <i>Key Entry</i> of that <i>Alias</i>.
+ * The substitution of the certificates only occurs if a chain-of-trust can be
+ * established between the bottom certificate of the chain read from the input
+ * file and the <i>Trusted Certificates</i> already present in the key store.
+ * Again, if the <code>-trustcacerts</code> option is specified, additional
+ * <i>Trusted Certificates</i> in the same <code>cacerts</code> key store will
+ * be considered. If no chain-of-trust can be established, the operation will
+ * abort.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-file FILE_NAME</dt>
+ * <dd>The fully qualified path of the file to read from. If omitted, the
+ * tool will process STDIN.
+ * <p></dd>
+ *
+ * <dt>-keypass PASSWORD</dt>
+ * <dd>Use this option to specify the password which the tool will use to
+ * protect the <i>Key Entry</i> associated with the designated <i>Alias</i>,
+ * when replacing this <i>Alias</i>' chain of certificates with that found
+ * in the certificate reply.
+ * <p>
+ * If this option is omitted, and the chain-of-trust for the certificate
+ * reply has been established, the tool will first attempt to unlock the
+ * <i>Key Entry</i> using the same password protecting the key store. If
+ * this fails, you will then be prompted to provide a password.
+ * <p></dd>
+ *
+ * <dt>-noprompt</dt>
+ * <dd>Use this option to prevent the tool from prompting the user.
+ * <p></dd>
+ *
+ * <dt>-trustcacerts</dt>
+ * <dd>Use this option to indicate to the tool that a key store, of type
+ * <code>JKS</code>, named <code>cacerts</code>, and usually located in
+ * <code>lib/security</code> in an installed Java Runtime Environment
+ * should be considered when trying to establish chain-of-trusts.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class ImportCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(ImportCmd.class.getName());
+ private static final String GKR = "gkr"; //$NON-NLS-1$
+ private static final String JKS = "jks"; //$NON-NLS-1$
+ private static final String LIB = "lib"; //$NON-NLS-1$
+ private static final String SECURITY = "security"; //$NON-NLS-1$
+ private static final String CACERTS = "cacerts"; //$NON-NLS-1$
+ private static final String CACERTS_GKR = CACERTS + "." + GKR; //$NON-NLS-1$
+ protected String _alias;
+ protected String _certFileName;
+ protected String _password;
+ protected boolean noPrompt;
+ protected boolean trustCACerts;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ private CertificateFactory x509Factory;
+ /**
+ * Pathname to a GKR-type cacerts file to use when trustCACerts is true. This
+ * is usually a file named "cacerts.gkr" located in lib/security in the folder
+ * specified by the system-property "gnu.classpath.home".
+ */
+ private String gkrCaCertsPathName;
+ /**
+ * Pathname to a JKS-type cacerts file to use when trustCACerts is true. This
+ * is usually a file named "cacerts" located in lib/security in the folder
+ * specified by the system-property "java.home".
+ */
+ private String jksCaCertsPathName;
+ /** Alias self-signed certificate. used when importing certificate replies. */
+ private X509Certificate selfSignedCertificate;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the existing alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /** @param pathName the fully qualified path name of the file to process. */
+ public void setFile(String pathName)
+ {
+ this._certFileName = pathName;
+ }
+
+ /** @param password the existing (private) key password to use. */
+ public void setKeypass(String password)
+ {
+ this._password = password;
+ }
+
+ /**
+ * @param flag whether to prompt, or not, the user to verify certificate
+ * fingerprints.
+ */
+ public void setNoprompt(String flag)
+ {
+ this.noPrompt = Boolean.valueOf(flag).booleanValue();
+ }
+
+ /**
+ * @param flag whether to trust, or not, certificates found in the
+ * <code>cacerts</code> key store.
+ */
+ public void setTrustcacerts(String flag)
+ {
+ this.trustCACerts = Boolean.valueOf(flag).booleanValue();
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setInputStreamParam(_certFileName);
+ setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
+ setAliasParam(_alias);
+ setKeyPasswordNoPrompt(_password);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-import handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -noprompt=" + noPrompt); //$NON-NLS-1$
+ log.fine(" -trustcacerts=" + trustCACerts); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws CertificateException, KeyStoreException, IOException,
+ UnsupportedCallbackException, NoSuchAlgorithmException,
+ CertPathValidatorException, UnrecoverableKeyException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (trustCACerts)
+ {
+ String fs = SystemProperties.getProperty("file.separator"); //$NON-NLS-1$
+ String classpathHome = SystemProperties.getProperty("gnu.classpath.home"); //$NON-NLS-1$
+ gkrCaCertsPathName = new StringBuilder(classpathHome).append(fs)
+ .append(LIB).append(fs)
+ .append(SECURITY).append(fs)
+ .append(CACERTS_GKR).toString();
+ String javaHome = SystemProperties.getProperty("java.home"); //$NON-NLS-1$
+ jksCaCertsPathName = new StringBuilder(javaHome).append(fs)
+ .append(LIB).append(fs)
+ .append(SECURITY).append(fs)
+ .append(CACERTS).toString();
+ }
+ x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
+ // the alias will tell us whether we're dealing with
+ // a new trusted certificate or a certificate reply
+ if (! store.containsAlias(alias))
+ importNewTrustedCertificate();
+ else
+ {
+ ensureAliasIsKeyEntry();
+ importCertificateReply();
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.IMPORT_CMD, true);
+ result.setHeader(Messages.getString("ImportCmd.27")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("ImportCmd.26")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("ImportCmd.25")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("ImportCmd.24"), //$NON-NLS-1$
+ Messages.getString("ImportCmd.23")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.FILE_OPT,
+ Messages.getString("ImportCmd.22"), //$NON-NLS-1$
+ Messages.getString("ImportCmd.21")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _certFileName = argument;
+ }
+ });
+ options.add(new Option(Main.KEYPASS_OPT,
+ Messages.getString("ImportCmd.20"), //$NON-NLS-1$
+ Messages.getString("ImportCmd.19")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _password = argument;
+ }
+ });
+ options.add(new Option("noprompt", //$NON-NLS-1$
+ Messages.getString("ImportCmd.18")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ noPrompt = true;
+ }
+ });
+ options.add(new Option("trustcacerts", //$NON-NLS-1$
+ Messages.getString("ImportCmd.17")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ trustCACerts = true;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("ImportCmd.16"), //$NON-NLS-1$
+ Messages.getString("ImportCmd.15")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("ImportCmd.14"), //$NON-NLS-1$
+ Messages.getString("ImportCmd.13")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("ImportCmd.12"), //$NON-NLS-1$
+ Messages.getString("ImportCmd.11")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("ImportCmd.10"), //$NON-NLS-1$
+ Messages.getString("ImportCmd.9")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("ImportCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * When importing a new trusted certificate, <i>alias</i> MUST NOT yet exist
+ * in the key store.
+ * <p>
+ * Before adding the certificate to the key store and associate it with the
+ * designated Alias, this method tries to verify it by attempting to construct
+ * a chain of trust from that certificate to a self-signed certificate
+ * (belonging to a root CA), using (already) trusted certificates that are
+ * available in the key store.
+ * <p>
+ * If the <code>-trustcacerts</code> option was detected on the command
+ * line, additional trusted certificates are considered for establishing the
+ * chain of trust. Those additional certificates are assumed to be in a key
+ * store, of type <code>JKS</code> named <code>cacerts</code> and usually
+ * located in <code>${JAVA_HOME}/lib/security</code>, where
+ * <code>${JAVA_HOME}</code> is the root folder location of a Java runtime.
+ * <p>
+ * If this method fails to establish a trust path from the certificate to be
+ * imported up to a trusted self-signed certificate, the certificate is
+ * printed to <code>STDOUT</code>, and the user is prompted to verify it,
+ * with the option of aborting the import operation. If however the option
+ * <code>-noprompt</code> was detected on the command line, no interaction
+ * with the user will take place and the import operation will abort.
+ *
+ * @throws CertificateException
+ * @throws KeyStoreException
+ * @throws NoSuchAlgorithmException
+ * @throws UnsupportedCallbackException
+ * @throws IOException
+ * @throws UnrecoverableKeyException
+ * @throws CertPathValidatorException
+ */
+ private void importNewTrustedCertificate() throws CertificateException,
+ KeyStoreException, NoSuchAlgorithmException, IOException,
+ UnsupportedCallbackException, CertPathValidatorException,
+ UnrecoverableKeyException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
+ Certificate certificate = x509Factory.generateCertificate(inStream);
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
+ LinkedList orderedReply = new LinkedList();
+ orderedReply.addLast(certificate);
+
+ if (findTrustAndUpdate(orderedReply, ! noPrompt))
+ {
+ store.setCertificateEntry(alias, certificate);
+ System.out.println(Messages.getString("ImportCmd.29")); //$NON-NLS-1$
+ saveKeyStore();
+ }
+ else
+ System.out.println(Messages.getString("ImportCmd.28")); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
+ }
+
+ /**
+ * A certificate reply is a certificate, whose Owner is stored in the key
+ * store associated to the designated Alias, and now signed by supposedly a
+ * trusted CA (Certificate Authority). In other words, the Subject in this
+ * certificate reply is Alias's own and the Issuer is a CA.
+ * <p>
+ * When importing a certificate reply, the reply is validated using trusted
+ * certificates from the key store, and optionally (if the option
+ * <code>-trustcacerts</code> was detected on the command line) certificates
+ * found in the key store, of type <code>JKS</code> named <code>cacerts</code>
+ * located in <code>${JAVA_HOME}/lib/security</code>, where
+ * <code>${JAVA_HOME}</code> is the root folder location of a Java runtime.
+ *
+ * @throws CertificateException
+ * @throws UnsupportedCallbackException
+ * @throws IOException
+ * @throws KeyStoreException
+ * @throws CertPathValidatorException
+ * @throws NoSuchAlgorithmException
+ * @throws UnrecoverableKeyException
+ */
+ private void importCertificateReply() throws CertificateException,
+ IOException, UnsupportedCallbackException, KeyStoreException,
+ NoSuchAlgorithmException, CertPathValidatorException,
+ UnrecoverableKeyException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
+ Collection certificates = x509Factory.generateCertificates(inStream);
+ ensureReplyIsOurs(certificates);
+ // we now have established that the public keys are the same.
+ // find a chain-of-trust if one exists
+ if (certificates.size() == 1)
+ importCertificate((Certificate) certificates.iterator().next());
+ else
+ importChain(certificates);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
+ }
+
+ /**
+ * If the reply is a single X.509 certificate, keytool attempts to establish a
+ * trust chain, starting at the certificate reply and ending at a self-signed
+ * certificate (belonging to a root CA). The certificate reply and the
+ * hierarchy of certificates used to authenticate the certificate reply form
+ * the new certificate chain of alias. If a trust chain cannot be established,
+ * the certificate reply is not imported. In this case, keytool does not print
+ * out the certificate, nor does it prompt the user to verify it. This is
+ * because it is very hard (if not impossible) for a user to determine the
+ * authenticity of the certificate reply.
+ *
+ * @param certificate the certificate reply to import into the key store.
+ * @throws NoSuchAlgorithmException
+ * @throws CertPathValidatorException
+ * @throws UnsupportedCallbackException
+ * @throws IOException
+ * @throws UnrecoverableKeyException
+ * @throws KeyStoreException
+ * @throws CertificateException
+ */
+ private void importCertificate(Certificate certificate)
+ throws NoSuchAlgorithmException, CertPathValidatorException,
+ KeyStoreException, UnrecoverableKeyException, IOException,
+ UnsupportedCallbackException, CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importCertificate", certificate); //$NON-NLS-1$
+ LinkedList reply = new LinkedList();
+ reply.addLast(certificate);
+
+ if (! findTrustAndUpdate(reply, false))
+ throw new CertPathValidatorException(Messages.getString("ImportCmd.34")); //$NON-NLS-1$
+
+ Certificate[] newChain = (Certificate[]) reply.toArray(new Certificate[0]);
+ Key privateKey = getAliasPrivateKey();
+ store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain);
+ saveKeyStore();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importCertificate"); //$NON-NLS-1$
+ }
+
+ /**
+ * If the reply is a PKCS#7 formatted certificate chain, the chain is first
+ * ordered (with the user certificate first and the self-signed root CA
+ * certificate last), before keytool attempts to match the root CA certificate
+ * provided in the reply with any of the trusted certificates in the key store
+ * or the "cacerts" keystore file (if the -trustcacerts option was specified).
+ * If no match can be found, the information of the root CA certificate is
+ * printed out, and the user is prompted to verify it, e.g., by comparing the
+ * displayed certificate fingerprints with the fingerprints obtained from some
+ * other (trusted) source of information, which might be the root CA itself.
+ * The user then has the option of aborting the import operation. If the
+ * -noprompt option is given, however, there will be no interaction with the
+ * user.
+ *
+ * @param chain the collection of certificates parsed from the user
+ * designated input.
+ * @throws UnsupportedCallbackException
+ * @throws IOException
+ * @throws UnrecoverableKeyException
+ * @throws KeyStoreException
+ * @throws CertPathValidatorException
+ * @throws NoSuchAlgorithmException
+ * @throws CertificateException
+ */
+ private void importChain(Collection chain) throws NoSuchAlgorithmException,
+ CertPathValidatorException, KeyStoreException, UnrecoverableKeyException,
+ IOException, UnsupportedCallbackException, CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importChain", chain); //$NON-NLS-1$
+ LinkedList reply = orderChain(chain);
+ if (findTrustAndUpdate(reply, ! noPrompt))
+ {
+ Certificate[] newChain = (Certificate[]) reply.toArray(new Certificate[0]);
+ Key privateKey = getAliasPrivateKey();
+ store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain);
+ saveKeyStore();
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importChain"); //$NON-NLS-1$
+ }
+
+ /**
+ * Check to ensure that alias's public key is the subject of the first
+ * certificate in the passed certificate collection. Throws an exception if
+ * the public keys do not match.
+ *
+ * @param certificates a {@link Collection} of certificate replies (either a
+ * signle certificate reply, or a PKCS#7 certificate reply chain)
+ * usually sent by a CA as a response to a Certificate Signing
+ * Request (CSR).
+ * @throws IOException
+ * @throws UnsupportedCallbackException
+ * @throws KeyStoreException
+ */
+ private void ensureReplyIsOurs(Collection certificates) throws IOException,
+ UnsupportedCallbackException, KeyStoreException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
+ Certificate certificate = (Certificate) certificates.iterator().next();
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
+ Certificate[] chain = store.getCertificateChain(alias);
+ if (chain == null)
+ throw new IllegalArgumentException(Messages.getFormattedString("ImportCmd.37", //$NON-NLS-1$
+ alias));
+ selfSignedCertificate = (X509Certificate) chain[0];
+ PublicKey anchorPublicKey = selfSignedCertificate.getPublicKey();
+ PublicKey certPublicKey = certificate.getPublicKey();
+ boolean sameKey;
+ if (anchorPublicKey instanceof DSAPublicKey)
+ {
+ DSAPublicKey pk1 = (DSAPublicKey) anchorPublicKey;
+ if (!(certPublicKey instanceof DSAPublicKey))
+ throw new IllegalArgumentException(Messages.getString("ImportCmd.38")); //$NON-NLS-1$
+
+ sameKey = areEqual(pk1, (DSAPublicKey) certPublicKey);
+ }
+ else if (anchorPublicKey instanceof RSAPublicKey)
+ {
+ RSAPublicKey pk1 = (RSAPublicKey) anchorPublicKey;
+ if (!(certPublicKey instanceof RSAPublicKey))
+ throw new IllegalArgumentException(Messages.getString("ImportCmd.38")); //$NON-NLS-1$
+
+ sameKey = areEqual(pk1, (RSAPublicKey) certPublicKey);
+ }
+ else
+ throw new IllegalArgumentException(
+ Messages.getFormattedString("ImportCmd.40", //$NON-NLS-1$
+ new String[] { alias,
+ anchorPublicKey.getClass().getName() }));
+ if (! sameKey)
+ throw new IllegalArgumentException(Messages.getString("ImportCmd.41")); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
+ }
+
+ private boolean areEqual(DSAPublicKey pk1, DSAPublicKey pk2)
+ {
+ if (pk1.getY().compareTo(pk2.getY()) != 0)
+ return false;
+
+ DSAParams p1 = pk1.getParams();
+ DSAParams p2 = pk2.getParams();
+ if (p1.getG().compareTo(p2.getG()) != 0)
+ return false;
+
+ if (p1.getP().compareTo(p2.getP()) != 0)
+ return false;
+
+ return p1.getQ().compareTo(p2.getQ()) == 0;
+ }
+
+ private boolean areEqual(RSAPublicKey pk1, RSAPublicKey pk2)
+ {
+ if (pk1.getPublicExponent().compareTo(pk2.getPublicExponent()) != 0)
+ return false;
+
+ return pk1.getModulus().compareTo(pk2.getModulus()) == 0;
+ }
+
+ /**
+ * Given a collection of certificates returned as a certificate-reply, this
+ * method sorts the certificates in the collection so that the <i>Issuer</i>
+ * of the certificate at position <code>i</code> is the <i>Subject</i> of
+ * the certificate at position <code>i + 1</code>.
+ * <p>
+ * This method uses <code>selfSignedCertificate</code> to discover the first
+ * certificate in the chain. The <i>Trust Anchor</i> of the chain; i.e. the
+ * self-signed CA certificate, if it exsits, will be discovered/established
+ * later by an appropriate <i>Certificate Path Validator</i>.
+ * <p>
+ * An exception is thrown if (a) no initial certificate is found in the
+ * designated collection which can be used as the start of the chain, or (b)
+ * if a chain can not be constructed using all the certificates in the
+ * designated collection.
+ *
+ * @param chain a collection of certificates, not necessarily ordered, but
+ * assumed to include a CA certificate authenticating our alias
+ * public key, which is the subject of the alias self-signed
+ * certificate.
+ * @return the input collection, ordered with own certificate first, and CA's
+ * self-signed certificate last.
+ */
+ private LinkedList orderChain(Collection chain)
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "orderChain"); //$NON-NLS-1$
+ LinkedList in = new LinkedList(chain);
+ int initialCount = in.size();
+ LinkedList result = new LinkedList();
+ Principal issuer = selfSignedCertificate.getIssuerDN();
+ ListIterator it;
+ outer: while (in.size() > 0)
+ {
+ for (it = in.listIterator(); it.hasNext();)
+ {
+ X509Certificate certificate = (X509Certificate) it.next();
+ if (issuer.equals(certificate.getSubjectDN()))
+ {
+ it.remove();
+ result.addLast(certificate);
+ issuer = certificate.getIssuerDN();
+ continue outer;
+ }
+ }
+ throw new IllegalArgumentException(
+ Messages.getFormattedString(Messages.getString("ImportCmd.7"), //$NON-NLS-1$
+ new Object[] { Integer.valueOf(result.size()),
+ Integer.valueOf(initialCount) }));
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "orderChain", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Given an ordered list of certificates, this method attempts to validate the
+ * chain, and if successful, updates the key store entry for the designated
+ * alias. The list of certificates is expected to be ordered as a chain, where
+ * the first is the alias's own certificate and the last being a self-signed
+ * CA certificate.
+ * <p>
+ * if <code>promptUser</code> is <code>true</code>, then even if no
+ * anchor trust certificate is found, the user is prompted to approve, or not,
+ * the import operation. On the other hand if the <code>promptUser</code>
+ * parameter is <code>false</code> then this method will throw an exception
+ * if no trust anchor is to be found.
+ *
+ * @param reply an ordered certificate path, where the last entry is the CA's
+ * self-signed certificate.
+ * @param promptUser a boolean flag indicating whether or not to prompt the
+ * user for explicit trust in a CA certificate.
+ * @return <code>true</code> if the validation succeeds; or <code>false</code>
+ * otherwise.
+ * @throws NoSuchAlgorithmException
+ * @throws CertPathValidatorException
+ * @throws UnsupportedCallbackException
+ * @throws IOException
+ * @throws UnrecoverableKeyException
+ * @throws KeyStoreException
+ * @throws CertificateEncodingException
+ */
+ private boolean findTrustAndUpdate(LinkedList reply, boolean promptUser)
+ throws IOException, NoSuchAlgorithmException, CertPathValidatorException,
+ KeyStoreException, UnrecoverableKeyException, UnsupportedCallbackException,
+ CertificateEncodingException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "findTrustAndUpdate"); //$NON-NLS-1$
+ CertPathValidator validator = CertPathValidator.getInstance("PKIX"); //$NON-NLS-1$
+ X509CertPath certPath = new X509CertPath(reply);
+ PKIXCertPathValidatorResult cpvr = findTrustInStore(certPath, validator);
+ if (cpvr == null && trustCACerts) // try cacerts.gkr - a GKR key store
+ {
+ PKIXParameters params = getCertPathParameters(GKR, gkrCaCertsPathName);
+ cpvr = validate(validator, certPath, params);
+ if (cpvr == null) // try cacerts - a JKS key store
+ {
+ params = getCertPathParameters(JKS, jksCaCertsPathName);
+ cpvr = validate(validator, certPath, params);
+ }
+ }
+ boolean result = false;
+ if (cpvr == null)
+ {
+ if (promptUser)
+ {
+ printVerbose((Certificate) reply.getLast());
+ ConfirmationCallback ccb;
+ ccb = new ConfirmationCallback(Messages.getString("ImportCmd.32"), //$NON-NLS-1$
+ ConfirmationCallback.INFORMATION,
+ ConfirmationCallback.YES_NO_OPTION,
+ ConfirmationCallback.NO);
+ getCallbackHandler().handle(new Callback[] { ccb });
+ int answer = ccb.getSelectedIndex();
+ result = answer == ConfirmationCallback.YES;
+ }
+ }
+ else
+ {
+ TrustAnchor anchor = cpvr.getTrustAnchor();
+ log.fine("Found a chain-of-trust anchored by " + anchor); //$NON-NLS-1$
+ Certificate trustedCert = anchor.getTrustedCert();
+ reply.addLast(trustedCert);
+ result = true;
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "findTrustAndUpdate", //$NON-NLS-1$
+ Boolean.valueOf(result));
+ return result;
+ }
+
+ private PKIXCertPathValidatorResult findTrustInStore(X509CertPath certPath,
+ CertPathValidator validator)
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "findTrustInStore"); //$NON-NLS-1$
+ PKIXCertPathValidatorResult result;
+ try
+ {
+ PKIXParameters params = new PKIXParameters(store);
+ result = (PKIXCertPathValidatorResult) validator.validate(certPath, params);
+ }
+ catch (Exception x)
+ {
+ log.log(Level.FINE,
+ "Exception in findTrustInStore(). Ignore + Return NULL", //$NON-NLS-1$
+ x);
+ result = null;
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "findTrustInStore", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Return an instance of {@link PKIXParameters} constructed using a key store
+ * of the designated type and located at the designated path.
+ *
+ * @param type the type of the key-store to load.
+ * @param pathName the local File System fully qualified path name to the key
+ * store.
+ * @return an instance of <code>CertPathParameters</code> to use for
+ * validating certificates and certificate replies.
+ */
+ private PKIXParameters getCertPathParameters(String type, String pathName)
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getCertPathParameters", //$NON-NLS-1$
+ new Object[] { type, pathName });
+ FileInputStream stream = null;
+ PKIXParameters result = null;
+ try
+ {
+ KeyStore cacerts = KeyStore.getInstance(type);
+ stream = new FileInputStream(pathName);
+ cacerts.load(stream, "changeit".toCharArray()); //$NON-NLS-1$
+ result = new PKIXParameters(cacerts);
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in getCertPathParameters(). Ignore", x); //$NON-NLS-1$
+ }
+ finally
+ {
+ if (stream != null)
+ try
+ {
+ stream.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getCertPathParameters", result); //$NON-NLS-1$
+ return result;
+ }
+
+ private PKIXCertPathValidatorResult validate(CertPathValidator validator,
+ X509CertPath certPath,
+ PKIXParameters params)
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "validate"); //$NON-NLS-1$
+ PKIXCertPathValidatorResult result = null;
+ if (params != null)
+ try
+ {
+ result = (PKIXCertPathValidatorResult) validator.validate(certPath,
+ params);
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in validate(). Ignore", x); //$NON-NLS-1$
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "validate", result); //$NON-NLS-1$
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
new file mode 100644
index 000000000..a05a5962f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
@@ -0,0 +1,407 @@
+/* KeyCloneCmd.java -- The keyclone command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-keyclone</b> keytool command handler is used to clone an existing
+ * key store entry associated with a designated alias, with its private key and
+ * chain of certificates.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-dest ALIAS</dt>
+ * <dd>Use this option to specify the new <i>Alias</i> which will be used
+ * to identify the cloned copy of the <i>Key Entry</i>.
+ * <p></dd>
+ *
+ * <dt>-keypass PASSWORD</dt>
+ * <dd>Use this option to specify the password which the tool will use to
+ * unlock the <i>Key Entry</i> associated with the designated <i>Alias</i>.
+ * <p>
+ * If this option is omitted, the tool will first attempt to unlock the
+ * <i>Key Entry</i> using the same password protecting the key store. If
+ * this fails, you will then be prompted to provide a password.
+ * <p></dd>
+ *
+ * <dt>-new PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the private key
+ * material of the newly cloned copy of the <i>Key Entry</i>.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class KeyCloneCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(KeyCloneCmd.class.getName());
+ protected String _alias;
+ protected String _destAlias;
+ protected String _password;
+ protected String _newPassword;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ private String destinationAlias;
+ private char[] newKeyPasswordChars;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the existing alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /** @param alias the new alias to use. */
+ public void setDest(String alias)
+ {
+ this._destAlias = alias;
+ }
+
+ /** @param password the existing (private) key password to use. */
+ public void setKeypass(String password)
+ {
+ this._password = password;
+ }
+
+ /** @param password the new (private) key password to use. */
+ public void setNew(String password)
+ {
+ this._newPassword = password;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setAliasParam(_alias);
+ setKeyPasswordNoPrompt(_password);
+ setDestinationAlias(_destAlias);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-keyclone handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -dest=" + destinationAlias); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
+ UnsupportedCallbackException, UnrecoverableKeyException,
+ CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (store.containsAlias(destinationAlias))
+ throw new SecurityException(Messages.getString("KeyCloneCmd.23")); //$NON-NLS-1$
+
+ Key privateKey = getAliasPrivateKey();
+
+ setNewKeyPassword(_newPassword);
+ Certificate[] chain = store.getCertificateChain(alias);
+
+ store.setKeyEntry(destinationAlias, privateKey, newKeyPasswordChars, chain);
+
+ saveKeyStore();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.KEYCLONE_CMD, true);
+ result.setHeader(Messages.getString("KeyCloneCmd.22")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("KeyCloneCmd.21")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("KeyCloneCmd.20")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("KeyCloneCmd.19"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.16")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.DEST_OPT,
+ Messages.getString("KeyCloneCmd.17"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.16")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _destAlias = argument;
+ }
+ });
+ options.add(new Option(Main.KEYPASS_OPT,
+ Messages.getString("KeyCloneCmd.15"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _password = argument;
+ }
+ });
+ options.add(new Option(Main.NEW_OPT,
+ Messages.getString("KeyCloneCmd.13"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _newPassword = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("KeyCloneCmd.11"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.10")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("KeyCloneCmd.9"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("KeyCloneCmd.7"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("KeyCloneCmd.5"), //$NON-NLS-1$
+ Messages.getString("KeyCloneCmd.4")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("KeyCloneCmd.3")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ private void setDestinationAlias(String name) throws IOException,
+ UnsupportedCallbackException
+ {
+ if (name == null || name.trim().length() == 0) // ask user to provide one
+ {
+ NameCallback ncb = new NameCallback(Messages.getString("KeyCloneCmd.26")); //$NON-NLS-1$
+ getCallbackHandler().handle(new Callback[] { ncb });
+ name = ncb.getName();
+ if (name == null || name.trim().length() == 0)
+ throw new IllegalArgumentException(Messages.getString("KeyCloneCmd.27")); //$NON-NLS-1$
+ }
+
+ destinationAlias = name.trim();
+ }
+
+ private void setNewKeyPassword(String password) throws IOException,
+ UnsupportedCallbackException
+ {
+ if (password != null)
+ newKeyPasswordChars = password.toCharArray();
+ else // ask user to provide one
+ {
+ boolean ok = false;
+ Callback[] prompts = new Callback[1];
+ Callback[] errors = new Callback[1];
+ for (int i = 0; i < 3; i++)
+ if (prompt4NewPassword(getCallbackHandler(), prompts, errors))
+ {
+ ok = true;
+ break;
+ }
+ if (! ok)
+ throw new SecurityException(Messages.getString("StorePasswdCmd.19")); //$NON-NLS-1$
+ }
+ }
+
+ private boolean prompt4NewPassword(CallbackHandler handler,
+ Callback[] prompts, Callback[] errors)
+ throws IOException, UnsupportedCallbackException
+ {
+ String p = Messages.getFormattedString("KeyCloneCmd.28", //$NON-NLS-1$
+ new String[] { destinationAlias,
+ String.valueOf(keyPasswordChars) });
+ PasswordCallback pcb = new PasswordCallback(p, false);
+ prompts[0] = pcb;
+ handler.handle(prompts);
+ char[] pwd1 = pcb.getPassword();
+ pcb.clearPassword();
+ if (pwd1 == null || pwd1.length == 0)
+ {
+ newKeyPasswordChars = (char[]) keyPasswordChars.clone();
+ return true;
+ }
+
+ if (pwd1.length < 6)
+ {
+ errors[0] = new TextOutputCallback(TextOutputCallback.ERROR,
+ Messages.getString("StorePasswdCmd.21")); //$NON-NLS-1$
+ handler.handle(errors);
+ return false;
+ }
+
+ newKeyPasswordChars = pwd1;
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
new file mode 100644
index 000000000..7652cc843
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
@@ -0,0 +1,395 @@
+/* KeyPasswdCmd.java -- The keypasswd command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-keypasswd</b> keytool command handler is used to change the password
+ * protecting the private key associated to a designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-keypass PASSWORD</dt>
+ * <dd>Use this option to specify the password which the tool will use to
+ * unlock the <i>Key Entry</i> associated with the designated <i>Alias</i>.
+ * <p>
+ * If this option is omitted, the tool will first attempt to unlock the
+ * <i>Key Entry</i> using the same password protecting the key store. If
+ * this fails, you will then be prompted to provide a password.
+ * <p></dd>
+ *
+ * <dt>-new PASSWORD</dt>
+ * <dd>The new, and different, password which will be used to protect the
+ * private key material of the designated Key Entry.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class KeyPasswdCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(KeyPasswdCmd.class.getName());
+ protected String _alias;
+ protected String _password;
+ protected String _newPassword;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ private char[] newPasswordChars;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /** @param password the existing (private) key password to use. */
+ public void setKeypass(String password)
+ {
+ this._password = password;
+ }
+
+ /** @param password the new (private) key password to use. */
+ public void setNew(String password)
+ {
+ this._newPassword = password;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setAliasParam(_alias);
+ setKeyPasswordNoPrompt(_password);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-keypasswd handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -new=" + _newPassword); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
+ UnsupportedCallbackException, UnrecoverableKeyException,
+ CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ // 1. get the key entry and certificate chain associated to alias
+ Key privateKey = getAliasPrivateKey();
+ Certificate[] chain = store.getCertificateChain(alias);
+
+ // 2. replace the old entry
+ setNewKeyPassword(_newPassword);
+ store.setKeyEntry(alias, privateKey, newPasswordChars, chain);
+
+ // 3. persist the key store
+ saveKeyStore();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.KEYPASSWD_CMD, true);
+ result.setHeader(Messages.getString("KeyPasswdCmd.23")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("KeyPasswdCmd.22")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("KeyPasswdCmd.21")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("KeyPasswdCmd.20"), //$NON-NLS-1$
+ Messages.getString("KeyPasswdCmd.19")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.KEYPASS_OPT,
+ Messages.getString("KeyPasswdCmd.18"), //$NON-NLS-1$
+ Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _password = argument;
+ }
+ });
+ options.add(new Option(Main.NEW_OPT,
+ Messages.getString("KeyPasswdCmd.16"), //$NON-NLS-1$
+ Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _newPassword = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("KeyPasswdCmd.14"), //$NON-NLS-1$
+ Messages.getString("KeyPasswdCmd.13")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("KeyPasswdCmd.12"), //$NON-NLS-1$
+ Messages.getString("KeyPasswdCmd.11")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("KeyPasswdCmd.10"), //$NON-NLS-1$
+ Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("KeyPasswdCmd.8"), //$NON-NLS-1$
+ Messages.getString("KeyPasswdCmd.7")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("KeyPasswdCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Set the new password to use for protecting Alias's private key.
+ *
+ * @param password the new key password. if <code>null</code> prompt the
+ * user to provide one. When prompting, the password is entered twice
+ * and compared for a match.
+ * @throws IOException if an I/O related exception occurs during the process.
+ * @throws UnsupportedCallbackException if no implementation of a password
+ * callback handler was found.
+ */
+ private void setNewKeyPassword(String password) throws IOException,
+ UnsupportedCallbackException
+ {
+ if (password != null)
+ newPasswordChars = password.toCharArray();
+ else
+ {
+ boolean ok = false;
+ Callback[] prompts = new Callback[1];
+ Callback[] errors = new Callback[1];
+ for (int i = 0; i < 3; i++)
+ if (prompt4NewPassword(getCallbackHandler(), prompts, errors))
+ {
+ ok = true;
+ break;
+ }
+ if (! ok)
+ throw new SecurityException(Messages.getString("StorePasswdCmd.19")); //$NON-NLS-1$
+ }
+ }
+
+ private boolean prompt4NewPassword(CallbackHandler handler,
+ Callback[] prompts, Callback[] errors)
+ throws IOException, UnsupportedCallbackException
+ {
+ // prompt user (1st time) to provide one
+ String p = Messages.getFormattedString("KeyPasswdCmd.24", alias); //$NON-NLS-1$
+ PasswordCallback pcb = new PasswordCallback(p, false);
+ prompts[0] = pcb;
+ handler.handle(prompts);
+ char[] pwd1 = pcb.getPassword();
+ pcb.clearPassword();
+ String ls = SystemProperties.getProperty("line.separator"); //$NON-NLS-1$
+ if (pwd1 == null || pwd1.length < 6)
+ {
+ String m = Messages.getString("StorePasswdCmd.21") + ls; //$NON-NLS-1$
+ errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+ handler.handle(errors);
+ return false;
+ }
+
+ if (Arrays.equals(keyPasswordChars, pwd1))
+ {
+ String m = Messages.getString("StorePasswdCmd.22") + ls; //$NON-NLS-1$
+ errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+ handler.handle(errors);
+ return false;
+ }
+
+ // prompt user (2nd time) for confirmation
+ p = Messages.getFormattedString("KeyPasswdCmd.28", alias); //$NON-NLS-1$
+ pcb = new PasswordCallback(p, false);
+ prompts[0] = pcb;
+ handler.handle(prompts);
+ char[] pwd2 = pcb.getPassword();
+ pcb.clearPassword();
+ if (! Arrays.equals(pwd1, pwd2))
+ {
+ String m = Messages.getString("StorePasswdCmd.24") + ls; //$NON-NLS-1$
+ errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+ handler.handle(errors);
+ return false;
+ }
+
+ newPasswordChars = pwd2;
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
new file mode 100644
index 000000000..55c8c7683
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
@@ -0,0 +1,432 @@
+/* ListCmd.java -- The list command handler of the keytool
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.util.Base64;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.KeyStoreException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.util.Enumeration;
+import java.util.logging.Logger;
+
+/**
+ * The <b>-list</b> keytool command handler is used to output one or all key
+ * store entries.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-rfc</dt>
+ * <dd>Use RFC-1421 specifications when encoding the output.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Output the certificate in human-readable format. If both this option
+ * and the <code>-rfc</code> option are detected on the command line, the
+ * tool will opt for the human-readable form and will not abort the
+ * command.</dd>
+ * </dl>
+ */
+class ListCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(ListCmd.class.getName());
+ protected String _alias;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ protected boolean rfc;
+ private boolean all;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ /**
+ * @param flag whether to use, or not, RFC-1421 format when listing the
+ * certificate(s).
+ */
+ public void setRfc(String flag)
+ {
+ this.rfc = Boolean.valueOf(flag).booleanValue();
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setOutputStreamParam(null); // use stdout
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ all = _alias == null;
+ if (! all)
+ setAliasParam(_alias);
+
+ if (verbose & rfc)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Both -v and -rfc options were found on the command line. " //$NON-NLS-1$
+ + "Only the former will be considered"); //$NON-NLS-1$
+ rfc = false;
+ }
+ if (Configuration.DEBUG)
+ {
+ log.fine("-list handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ log.fine(" -rfc=" + rfc); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, CertificateEncodingException,
+ IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ PrintWriter writer = new PrintWriter(outStream, true);
+ writer.println(Messages.getFormattedString("ListCmd.21", store.getType())); //$NON-NLS-1$
+ writer.println(Messages.getFormattedString("ListCmd.22", //$NON-NLS-1$
+ store.getProvider().getName()));
+ if (all)
+ {
+ if (Configuration.DEBUG)
+ log.fine("About to list all aliases in key store..."); //$NON-NLS-1$
+ writer.println();
+ writer.println(Messages.getFormattedString("ListCmd.24", //$NON-NLS-1$
+ Integer.valueOf(store.size())));
+ for (Enumeration e = store.aliases(); e.hasMoreElements(); )
+ {
+ String anAlias = (String) e.nextElement();
+ if (anAlias != null)
+ list1Alias(anAlias, writer);
+ }
+ }
+ else
+ list1Alias(alias, writer);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.LIST_CMD, true);
+ result.setHeader(Messages.getString("ListCmd.20")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("ListCmd.19")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("ListCmd.18")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("ListCmd.17"), //$NON-NLS-1$
+ Messages.getString("ListCmd.16")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("ListCmd.15"), //$NON-NLS-1$
+ Messages.getString("ListCmd.14")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("ListCmd.13"), //$NON-NLS-1$
+ Messages.getString("ListCmd.12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("ListCmd.11"), //$NON-NLS-1$
+ Messages.getString("ListCmd.10")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("ListCmd.9"), //$NON-NLS-1$
+ Messages.getString("ListCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("ListCmd.7")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ options.add(new Option(Main.RFC_OPT,
+ Messages.getString("ListCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ rfc = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Prints the certificate(s) associated with the designated alias.
+ *
+ * @param anAlias a non-null string denoting an alias in the key-store.
+ * @param writer where to print.
+ * @throws KeyStoreException if an exception occurs while obtaining the
+ * certificate associated to the designated alias.
+ * @throws CertificateEncodingException if an exception occurs while obtaining
+ * the DER encoded form of the certificate.
+ * @throws IOException if an I/O related exception occurs during the process.
+ */
+ private void list1Alias(String anAlias, PrintWriter writer)
+ throws KeyStoreException, CertificateEncodingException, IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "list1Alias", anAlias); //$NON-NLS-1$
+ writer.println();
+ writer.println(Messages.getFormattedString("ListCmd.30", anAlias)); //$NON-NLS-1$
+ writer.println(Messages.getFormattedString("ListCmd.31", //$NON-NLS-1$
+ store.getCreationDate(anAlias)));
+ if (store.isCertificateEntry(anAlias))
+ {
+ writer.println(Messages.getString("ListCmd.32")); //$NON-NLS-1$
+ Certificate certificate = store.getCertificate(anAlias);
+ print1Certificate(certificate, writer);
+ }
+ else if (store.isKeyEntry(anAlias))
+ {
+ writer.println(Messages.getString("ListCmd.33")); //$NON-NLS-1$
+ Certificate[] chain = store.getCertificateChain(anAlias);
+ print1Chain(chain, writer);
+ }
+ else
+ throw new IllegalArgumentException(Messages.getFormattedString("ListCmd.34", //$NON-NLS-1$
+ anAlias));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "list1Alias"); //$NON-NLS-1$
+ }
+
+ /**
+ * Prints the designated certificate chain, or a fingerprint of the first
+ * certificate (bottom) in the chain, depending on the values of the flags
+ * <code>v</code> (for verbose) and <code>rfc</code>.
+ * <p>
+ * If both flags are <code>false</code>, only the fingerprint is generated,
+ * otherwise, if the <code>v</code> flag is set, then a human readable output
+ * is generated. If <code>rfc</code> is set, then an RFC-1421 like output
+ * is generated.
+ * <p>Note that both <code>v</code> and <code>rfc</code> cannot both be
+ * <code>true</code> at the same time.
+ *
+ * @param chain the certificate chain to process.
+ * @param writer where to print.
+ * @throws CertificateEncodingException if an exception occurs while obtaining
+ * the DER encoded form of the certificate.
+ */
+ private void print1Chain(Certificate[] chain, PrintWriter writer)
+ throws CertificateEncodingException
+ {
+ if (! verbose && ! rfc)
+ fingerprint(chain[0], writer);
+ else
+ {
+ int limit = chain.length;
+ writer.println(Messages.getFormattedString("ListCmd.38", //$NON-NLS-1$
+ Integer.valueOf(limit)));
+ writer.println(Messages.getString("ListCmd.39")); //$NON-NLS-1$
+ print1Certificate(chain[0], writer);
+ for (int i = 1; i < limit; i++)
+ {
+ writer.println();
+ writer.println(Messages.getFormattedString("ListCmd.40", //$NON-NLS-1$
+ Integer.valueOf(i + 1)));
+ print1Certificate(chain[i], writer);
+ }
+ writer.println();
+ writer.println(Messages.getString("ListCmd.42")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Prints the designated certificate, or its fingerprint, depending on the
+ * values of the flags <code>v</code> (for verbose) and <code>rfc</code>.
+ * <p>
+ * If both flags are <code>false</code>, only a fingerprint is generated,
+ * otherwise, if the <code>v</code> flag is set, then a human readable output
+ * is generated. If <code>rfc</code> is set, then an RFC-1421 like output
+ * is generated.
+ * <p>Note that both <code>v</code> and <code>rfc</code> cannot both be
+ * <code>true</code> at the same time.
+ *
+ * @param certificate the certificate to process.
+ * @param writer where to print.
+ * @throws CertificateEncodingException if an exception occurs while obtaining
+ * the DER encoded form of the certificate.
+ */
+ private void print1Certificate(Certificate certificate, PrintWriter writer)
+ throws CertificateEncodingException
+ {
+ if (verbose)
+ printVerbose(certificate, writer);
+ else if (rfc)
+ printRFC1421(certificate, writer);
+ else
+ fingerprint(certificate, writer);
+ }
+
+ private void printRFC1421(Certificate certificate, PrintWriter writer)
+ throws CertificateEncodingException
+ {
+ byte[] derBytes = certificate.getEncoded();
+ String encoded = Base64.encode(derBytes, 72);
+ writer.println(Messages.getString("ListCmd.43")); //$NON-NLS-1$
+ writer.println(encoded);
+ writer.println(Messages.getString("ListCmd.44")); //$NON-NLS-1$
+ }
+
+ private void fingerprint(Certificate certificate, PrintWriter writer)
+ throws CertificateEncodingException
+ {
+ byte[] derBytes = certificate.getEncoded();
+ String fingerPrint = digestWithMD5(derBytes);
+ writer.println(Messages.getFormattedString("ListCmd.45", fingerPrint)); //$NON-NLS-1$
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
new file mode 100644
index 000000000..2d5234ad0
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
@@ -0,0 +1,329 @@
+/* Main.java -- Implementation of the keytool security tool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.common.ProviderUtil;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.Registry;
+import gnu.javax.crypto.jce.GnuCrypto;
+import gnu.javax.security.auth.callback.GnuCallbacks;
+
+import java.util.logging.Logger;
+
+/**
+ * The GNU Classpath implementation of the keytool security tool.
+ * <p>
+ * Except for the <code>-identitydb</code> command, available for importing
+ * JDK 1.1 <i>identities</i> into a key store, this implementation is intended
+ * to be compatible with the behaviour described in the public documentation of
+ * the same tool included in JDK 1.4.
+ */
+public class Main
+{
+ private static final Logger log = Logger.getLogger(Main.class.getName());
+ static final String KEYTOOL_TOOL = "keytool"; //$NON-NLS-1$
+ static final String GENKEY_CMD = "genkey"; //$NON-NLS-1$
+ static final String IMPORT_CMD = "import"; //$NON-NLS-1$
+ static final String SELFCERT_CMD = "selfcert"; //$NON-NLS-1$
+ static final String IDENTITYDB_CMD = "identitydb"; //$NON-NLS-1$
+ static final String CERTREQ_CMD = "certreq"; //$NON-NLS-1$
+ static final String EXPORT_CMD = "export"; //$NON-NLS-1$
+ static final String LIST_CMD = "list"; //$NON-NLS-1$
+ static final String PRINTCERT_CMD = "printcert"; //$NON-NLS-1$
+ static final String KEYCLONE_CMD = "keyclone"; //$NON-NLS-1$
+ static final String STOREPASSWD_CMD = "storepasswd"; //$NON-NLS-1$
+ static final String KEYPASSWD_CMD = "keypasswd"; //$NON-NLS-1$
+ static final String DELETE_CMD = "delete"; //$NON-NLS-1$
+ static final String CACERT_CMD = "cacert"; //$NON-NLS-1$
+
+ static final String _GENKEY = "-" + GENKEY_CMD; //$NON-NLS-1$
+ static final String _IMPORT = "-" + IMPORT_CMD; //$NON-NLS-1$
+ static final String _SELFCERT = "-" + SELFCERT_CMD; //$NON-NLS-1$
+ static final String _IDENTITYDB = "-" + IDENTITYDB_CMD; //$NON-NLS-1$
+ static final String _CERTREQ = "-" + CERTREQ_CMD; //$NON-NLS-1$
+ static final String _EXPORT = "-" + EXPORT_CMD; //$NON-NLS-1$
+ static final String _LIST = "-" + LIST_CMD; //$NON-NLS-1$
+ static final String _PRINTCERT = "-" + PRINTCERT_CMD; //$NON-NLS-1$
+ static final String _KEYCLONE = "-" + KEYCLONE_CMD; //$NON-NLS-1$
+ static final String _STOREPASSWD = "-" + STOREPASSWD_CMD; //$NON-NLS-1$
+ static final String _KEYPASSWD = "-" + KEYPASSWD_CMD; //$NON-NLS-1$
+ static final String _DELETE = "-" + DELETE_CMD; //$NON-NLS-1$
+ static final String _HELP = "-help"; //$NON-NLS-1$
+ static final String _CACERT = "-" + CACERT_CMD; //$NON-NLS-1$
+
+ static final String ALIAS_OPT = "alias"; //$NON-NLS-1$
+ static final String SIGALG_OPT = "sigalg"; //$NON-NLS-1$
+ static final String KEYALG_OPT = "keyalg"; //$NON-NLS-1$
+ static final String KEYSIZE_OPT = "keysize"; //$NON-NLS-1$
+ static final String KEYPASS_OPT = "keypass"; //$NON-NLS-1$
+ static final String VALIDITY_OPT = "validity"; //$NON-NLS-1$
+ static final String STORETYPE_OPT = "storetype"; //$NON-NLS-1$
+ static final String STOREPASS_OPT = "storepass"; //$NON-NLS-1$
+ static final String KEYSTORE_OPT = "keystore"; //$NON-NLS-1$
+ static final String PROVIDER_OPT = "provider"; //$NON-NLS-1$
+ static final String FILE_OPT = "file"; //$NON-NLS-1$
+ static final String VERBOSE_OPT = "v"; //$NON-NLS-1$
+ static final String DEST_OPT = "dest"; //$NON-NLS-1$
+ static final String NEW_OPT = "new"; //$NON-NLS-1$
+ static final String RFC_OPT = "rfc"; //$NON-NLS-1$
+ static final String DNAME_OPT = "dname"; //$NON-NLS-1$
+
+ /** The Preferences key name for the last issued certificate serial nbr. */
+ static final String LAST_SERIAL_NUMBER = "lastSerialNumber"; //$NON-NLS-1$
+ /** Constant denoting the X.509 certificate type. */
+ static final String X_509 = "X.509"; //$NON-NLS-1$
+
+ /** Whether we have already printed the help text or not. */
+ private boolean helpPrinted;
+ /** The new position of GnuCRYPTO provider if it is not already installed. */
+ private int gnuCryptoProviderNdx = -2;
+ /** The new position of GNU Callbacks provider if it is not already installed. */
+ private int gnuCallbacksNdx = -2;
+ /** The command line parser. */
+ private Parser cmdLineParser;
+ /** The shutdown hook. */
+ private ShutdownHook shutdownThread;
+
+ private Main()
+ {
+ super();
+ shutdownThread = new ShutdownHook();
+ Runtime.getRuntime().addShutdownHook(shutdownThread);
+ }
+
+ public static final void main(String[] args)
+ {
+ if (Configuration.DEBUG)
+ log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
+ Main tool = new Main();
+ int result = 1;
+ try
+ {
+ tool.setup();
+ tool.start(args);
+ result = 0;
+ }
+ catch (OptionException x)
+ {
+ System.err.println(x.getMessage());
+ if (tool.cmdLineParser != null)
+ tool.cmdLineParser.printHelp();
+ }
+ catch (SecurityException x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ System.err.println(Messages.getFormattedString("Main.6", //$NON-NLS-1$
+ x.getMessage()));
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ System.err.println(Messages.getFormattedString("Main.8", x)); //$NON-NLS-1$
+ }
+ finally
+ {
+ tool.teardown();
+ if (tool.shutdownThread != null)
+ Runtime.getRuntime().removeShutdownHook(tool.shutdownThread);
+ }
+ if (Configuration.DEBUG)
+ log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
+ System.exit(result);
+ }
+
+ // helper methods -----------------------------------------------------------
+
+ private void setup()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$
+ cmdLineParser = getParser();
+ gnuCryptoProviderNdx = ProviderUtil.addProvider(new GnuCrypto());
+ gnuCallbacksNdx = ProviderUtil.addProvider(new GnuCallbacks());
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$
+ }
+
+ private void start(String[] args) throws Exception
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (args == null || args.length == 0)
+ throw new OptionException(""); //$NON-NLS-1$
+
+ String opt;
+ Command cmd;
+ while (args.length > 0)
+ {
+ opt = args[0];
+ cmd = null;
+ if (_GENKEY.equals(opt))
+ cmd = new GenKeyCmd();
+ else if (_IMPORT.equals(opt))
+ cmd = new ImportCmd();
+ else if (_SELFCERT.equals(opt))
+ cmd = new SelfCertCmd();
+ else if (_IDENTITYDB.equals(opt))
+ cmd = new IdentityDBCmd();
+ else if (_CERTREQ.equals(opt))
+ cmd = new CertReqCmd();
+ else if (_EXPORT.equals(opt))
+ cmd = new ExportCmd();
+ else if (_LIST.equals(opt))
+ cmd = new ListCmd();
+ else if (_PRINTCERT.equals(opt))
+ cmd = new PrintCertCmd();
+ else if (_KEYCLONE.equals(opt))
+ cmd = new KeyCloneCmd();
+ else if (_STOREPASSWD.equals(opt))
+ cmd = new StorePasswdCmd();
+ else if (_KEYPASSWD.equals(opt))
+ cmd = new KeyPasswdCmd();
+ else if (_DELETE.equals(opt))
+ cmd = new DeleteCmd();
+ else if (_CACERT.equals(opt))
+ cmd = new CACertCmd();
+ else if (_HELP.equals(opt))
+ throw new OptionException(""); //$NON-NLS-1$
+ else
+ throw new OptionException(Messages.getFormattedString("Main.18", //$NON-NLS-1$
+ opt));
+
+ String[] cmdArgs = new String[args.length - 1];
+ System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
+ args = cmd.processArgs(cmdArgs);
+ cmd.doCommand();
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ private Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(KEYTOOL_TOOL, true);
+ result.setHeader(Messages.getString("Main.19")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("Main.20")); //$NON-NLS-1$
+ OptionGroup cmdGroup = new OptionGroup(Messages.getString("Main.21")); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(GENKEY_CMD,
+ Messages.getString("Main.22"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(IMPORT_CMD,
+ Messages.getString("Main.23"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(SELFCERT_CMD,
+ Messages.getString("Main.24"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(IDENTITYDB_CMD,
+ Messages.getString("Main.25"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(CERTREQ_CMD,
+ Messages.getString("Main.26"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(EXPORT_CMD,
+ Messages.getString("Main.27"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(LIST_CMD,
+ Messages.getString("Main.28"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(PRINTCERT_CMD,
+ Messages.getString("Main.29"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(KEYCLONE_CMD,
+ Messages.getString("Main.30"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(STOREPASSWD_CMD,
+ Messages.getString("Main.31"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(KEYPASSWD_CMD,
+ Messages.getString("Main.32"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(DELETE_CMD,
+ Messages.getString("Main.33"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(CACERT_CMD,
+ Messages.getString("Main.5"))); //$NON-NLS-1$
+ result.add(cmdGroup);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ void teardown()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ // if we added our own providers remove them
+ if (gnuCryptoProviderNdx > 0)
+ ProviderUtil.removeProvider(Registry.GNU_CRYPTO);
+
+ if (gnuCallbacksNdx > 0)
+ ProviderUtil.removeProvider("GNU-CALLBACKS"); //$NON-NLS-1$
+
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ }
+
+ // Inner class(es)
+ // ==========================================================================
+
+ private class NoParseOption
+ extends Option
+ {
+ public NoParseOption(String name, String description)
+ {
+ super(name, description);
+ }
+
+ public NoParseOption(String name, String description, String param)
+ {
+ super(name, description, param);
+ }
+
+ public void parsed(String argument) throws OptionException
+ {
+ // do nothing
+ }
+ }
+
+ private class ShutdownHook
+ extends Thread
+ {
+ public void run()
+ {
+ teardown();
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
new file mode 100644
index 000000000..ea2825f10
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
@@ -0,0 +1,118 @@
+/* Messages.java -- I18N related helper class
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+/**
+ * An initially generated Eclipse helper class to ease the use of localized
+ * messages.
+ * <p>
+ * Enriched to handle localized message formats.
+ */
+class Messages
+{
+ private static final Logger log = Logger.getLogger(Messages.class.getName());
+ private static final String BUNDLE_NAME = "gnu.classpath.tools.keytool.messages";
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+ private static final Map CACHED_FORMATS = new HashMap(5);
+
+ private Messages()
+ {
+ super();
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return constructMessage(key, null);
+ }
+ }
+
+ public static String getFormattedString(String key, Object args)
+ {
+ MessageFormat mf = (MessageFormat) CACHED_FORMATS.get(key);
+ if (mf == null)
+ {
+ String formatString = getString(key);
+ if (formatString.startsWith("!"))
+ return constructMessage(key, args);
+
+ mf = new MessageFormat(formatString);
+ CACHED_FORMATS.put(key, mf);
+ }
+
+ // if the argument is not an array, then build one consisting of the
+ // sole argument before passing it to the format() method
+ try
+ {
+ if (args instanceof Object[])
+ return mf.format(args);
+
+ return mf.format(new Object[] { args });
+ }
+ catch (IllegalArgumentException x)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Exception while rendering a message format keyed by ["
+ + key + "]: " + mf.toPattern());
+ return constructMessage(mf.toPattern(), args);
+ }
+ }
+
+ private static final String constructMessage(String m, Object args)
+ {
+ if (args == null)
+ return '!' + m + '!';
+
+ return '!' + m + '!' + String.valueOf(args) + '!';
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
new file mode 100644
index 000000000..cb9d03513
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
@@ -0,0 +1,143 @@
+/* PrintCertCmd.java -- The printcert command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.PrintWriter;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.util.logging.Logger;
+
+/**
+ * The <b>-printcert</b> keytool command handler is used to read a certificate
+ * from a designated file, and print its contents in a human-readable format.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-file FILE_NAME</dt>
+ * <dd>The fully qualified path of the file to read the certificate from.
+ * If this option is omitted, the tool will process STDIN.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class PrintCertCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(PrintCertCmd.class.getName());
+ protected String _certFileName;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param pathName the fully qualified path name of the file to process. */
+ public void setFile(String pathName)
+ {
+ this._certFileName = pathName;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setInputStreamParam(_certFileName);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-printcert handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.entering(getClass().getName(), "start"); //$NON-NLS-1$
+ CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509);
+ Certificate certificate = x509Factory.generateCertificate(inStream);
+ PrintWriter writer = new PrintWriter(System.out, true);
+ writer.println();
+ printVerbose(certificate, writer);
+ if (Configuration.DEBUG)
+ log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.PRINTCERT_CMD, true);
+ result.setHeader(Messages.getString("PrintCertCmd.5")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("PrintCertCmd.6")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("PrintCertCmd.7")); //$NON-NLS-1$
+ options.add(new Option(Main.FILE_OPT,
+ Messages.getString("PrintCertCmd.8"), //$NON-NLS-1$
+ Messages.getString("PrintCertCmd.9")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _certFileName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("PrintCertCmd.10")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
new file mode 100644
index 000000000..395bfe2cd
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
@@ -0,0 +1,440 @@
+/* SelfCertCmd.java -- The selfcert command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.x509.X500DistinguishedName;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.x500.X500Principal;
+
+/**
+ * The <b>-selfcert</b> keytool command handler is used to generate a self-
+ * signed X.509 version 1 certificate using key store credentials stored under a
+ * designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-alias ALIAS</dt>
+ * <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ * Certificate</i>, in a key store is uniquely identified by a user-defined
+ * <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ * when referring to an entry in the key store. Unless specified otherwise,
+ * a default value of <code>mykey</code> shall be used when this option is
+ * omitted from the command line.
+ * <p></dd>
+ *
+ * <dt>-sigalg ALGORITHM</dt>
+ * <dd>The canonical name of the digital signature algorithm to use for
+ * signing the certificate. If this option is omitted, a default value will
+ * be chosen based on the type of the private key associated with the
+ * designated <i>Alias</i>. If the private key is a <code>DSA</code> one,
+ * the value for the signature algorithm will be <code>SHA1withDSA</code>.
+ * If on the other hand the private key is an <code>RSA</code> one, then
+ * the tool will use <code>MD5withRSA</code> as the signature algorithm.
+ * <p></dd>
+ *
+ * <dt>-dname NAME</dt>
+ * <dd>Use this option to specify the <i>Distinguished Name</i> of the
+ * newly generated self-signed certificate. If this option is omitted, the
+ * existing <i>Distinguished Name</i> of the base certificate in the chain
+ * associated with the designated <i>Alias</i> will be used instead.
+ * <p>
+ * The syntax of a valid value for this option MUST follow RFC-2253
+ * specifications. Namely the following components (with their accepted
+ * meaning) will be recognized. Note that the component name is case-
+ * insensitive:
+ * <dl>
+ * <dt>CN</dt>
+ * <dd>The Common Name; e.g. "host.domain.com"</dd>
+ *
+ * <dt>OU</dt>
+ * <dd>The Organizational Unit; e.g. "IT Department"</dd>
+ *
+ * <dt>O</dt>
+ * <dd>The Organization Name; e.g. "The Sample Company"</dd>
+ *
+ * <dt>L</dt>
+ * <dd>The Locality Name; e.g. "Sydney"</dd>
+ *
+ * <dt>ST</dt>
+ * <dd>The State Name; e.g. "New South Wales"</dd>
+ *
+ * <dt>C</dt>
+ * <dd>The 2-letter Country identifier; e.g. "AU"</dd>
+ * </dl>
+ * <p>
+ * When specified with a <code>-dname</code> option, each pair of component
+ * / value will be separated from the other with a comma. Each component
+ * and value pair MUST be separated by an equal sign. For example, the
+ * following is a valid DN value:
+ * <pre>
+ * CN=host.domain.com, O=The Sample Company, L=Sydney, ST=NSW, C=AU
+ * </pre>
+ * <p></dd>
+ *
+ * <dt>-validity DAY_COUNT</dt>
+ *
+ * <dt>-keypass PASSWORD</dt>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class SelfCertCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(SelfCertCmd.class.getName());
+ protected String _alias;
+ protected String _sigAlgorithm;
+ protected String _dName;
+ protected String _password;
+ protected String _validityStr;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ private X500DistinguishedName distinguishedName;
+ private int validityInDays;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param alias the alias to use. */
+ public void setAlias(String alias)
+ {
+ this._alias = alias;
+ }
+
+ /**
+ * @param algorithm the canonical name of the digital signature algorithm to
+ * use.
+ */
+ public void setSigalg(String algorithm)
+ {
+ this._sigAlgorithm = algorithm;
+ }
+
+ /**
+ * @param name the distiniguished name of both the issuer and subject (since
+ * we are dealing with a self-signed certificate) to use.
+ */
+ public void setDname(String name)
+ {
+ this._dName = name;
+ }
+
+ /**
+ * @param days the string representation of the number of days (a decimal,
+ * positive integer) to assign to the generated (self-signed)
+ * certificate.
+ */
+ public void setValidity(String days)
+ {
+ this._validityStr = days;
+ }
+
+ /** @param password the (private) key password to use. */
+ public void setKeypass(String password)
+ {
+ this._password = password;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setAliasParam(_alias);
+ setKeyPasswordNoPrompt(_password);
+ setValidityParam(_validityStr);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-selfcert handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
+ log.fine(" -dname=" + _dName); //$NON-NLS-1$
+ log.fine(" -validity=" + validityInDays); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, NoSuchAlgorithmException,
+ UnrecoverableKeyException, IOException, UnsupportedCallbackException,
+ InvalidKeyException, SignatureException, CertificateException
+ {
+ if (Configuration.DEBUG)
+ log.entering(getClass().getName(), "start"); //$NON-NLS-1$
+ // 1. get the key entry and certificate chain associated to alias
+ Key privateKey = getAliasPrivateKey();
+ Certificate[] chain = store.getCertificateChain(alias);
+
+ // 2. if the user has not supplied a DN use one from the certificate chain
+ X509Certificate bottomCertificate = (X509Certificate) chain[0];
+ X500Principal defaultPrincipal = bottomCertificate.getIssuerX500Principal();
+ setDName(_dName, defaultPrincipal);
+
+ // 4. get alias's public key from certificate's SubjectPublicKeyInfo
+ PublicKey publicKey = bottomCertificate.getPublicKey();
+
+ // 5. issue the self-signed certificate
+ setSignatureAlgorithmParam(_sigAlgorithm, privateKey);
+
+ byte[] derBytes = getSelfSignedCertificate(distinguishedName,
+ publicKey,
+ (PrivateKey) privateKey);
+ CertificateFactory x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
+ ByteArrayInputStream bais = new ByteArrayInputStream(derBytes);
+ Certificate certificate = x509Factory.generateCertificate(bais);
+
+ // 6. store it, w/ its private key, associating them to alias
+ chain = new Certificate[] { certificate };
+ store.setKeyEntry(alias, privateKey, keyPasswordChars, chain);
+
+ // 7. persist the key store
+ saveKeyStore();
+ if (Configuration.DEBUG)
+ log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.SELFCERT_CMD, true);
+ result.setHeader(Messages.getString("SelfCertCmd.14")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("SelfCertCmd.15")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("SelfCertCmd.16")); //$NON-NLS-1$
+ options.add(new Option(Main.ALIAS_OPT,
+ Messages.getString("SelfCertCmd.17"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.18")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _alias = argument;
+ }
+ });
+ options.add(new Option(Main.SIGALG_OPT,
+ Messages.getString("SelfCertCmd.19"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.20")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _sigAlgorithm = argument;
+ }
+ });
+ options.add(new Option(Main.DNAME_OPT,
+ Messages.getString("SelfCertCmd.21"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.22")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _dName = argument;
+ }
+ });
+ options.add(new Option(Main.KEYPASS_OPT,
+ Messages.getString("SelfCertCmd.23"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.24")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _password = argument;
+ }
+ });
+ options.add(new Option(Main.VALIDITY_OPT,
+ Messages.getString("SelfCertCmd.25"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.26")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _validityStr = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("SelfCertCmd.27"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.28")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("SelfCertCmd.29"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.30")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("SelfCertCmd.31"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.32")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("SelfCertCmd.33"), //$NON-NLS-1$
+ Messages.getString("SelfCertCmd.34")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("SelfCertCmd.35")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ private void setDName(String name, X500Principal defaultName)
+ {
+ if (name != null && name.trim().length() > 0)
+ name = name.trim();
+ else
+ {
+ // If dname is supplied at the command line, it is used as the X.500
+ // Distinguished Name for both the issuer and subject of the certificate.
+ // Otherwise, the X.500 Distinguished Name associated with alias (at the
+ // bottom of its existing certificate chain) is used.
+ name = defaultName.toString().trim();
+ }
+
+ distinguishedName = new X500DistinguishedName(name);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
new file mode 100644
index 000000000..24a4b0fa1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
@@ -0,0 +1,318 @@
+/* StorePasswdCmd.java -- The storepasswd command handler of the keytool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-storepasswd</b> keytool command handler is used to change the
+ * password which protects the integrity of the key store.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-new PASSWORD</dt>
+ * <dd>The new, and different, password which will be used to protect the
+ * designated key store.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class StorePasswdCmd extends Command
+{
+ private static final Logger log = Logger.getLogger(StorePasswdCmd.class.getName());
+ protected String _newPassword;
+ protected String _ksType;
+ protected String _ksURL;
+ protected String _ksPassword;
+ protected String _providerClassName;
+ private char[] newStorePasswordChars;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param password the new key-store password to use. */
+ public void setNew(String password)
+ {
+ this._newPassword = password;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ void setup() throws Exception
+ {
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setNewKeystorePassword(_newPassword);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-storepasswd handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws KeyStoreException, NoSuchAlgorithmException,
+ CertificateException, IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ saveKeyStore(newStorePasswordChars);
+ if (Configuration.DEBUG)
+ log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.STOREPASSWD_CMD, true);
+ result.setHeader(Messages.getString("StorePasswdCmd.18")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("StorePasswdCmd.17")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("StorePasswdCmd.16")); //$NON-NLS-1$
+ options.add(new Option(Main.NEW_OPT,
+ Messages.getString("StorePasswdCmd.15"), //$NON-NLS-1$
+ Messages.getString("StorePasswdCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _newPassword = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("StorePasswdCmd.13"), //$NON-NLS-1$
+ Messages.getString("StorePasswdCmd.12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("StorePasswdCmd.11"), //$NON-NLS-1$
+ Messages.getString("StorePasswdCmd.10")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("StorePasswdCmd.9"), //$NON-NLS-1$
+ Messages.getString("StorePasswdCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("StorePasswdCmd.7"), //$NON-NLS-1$
+ Messages.getString("StorePasswdCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("StorePasswdCmd.5")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ protected void setNewKeystorePassword(String password) throws IOException,
+ UnsupportedCallbackException
+ {
+ if (password != null)
+ newStorePasswordChars = password.toCharArray();
+ else
+ {
+ boolean ok = false;
+ Callback[] prompts = new Callback[1];
+ Callback[] errors = new Callback[1];
+ for (int i = 0; i < 3; i++)
+ if (prompt4NewPassword(getCallbackHandler(), prompts, errors))
+ {
+ ok = true;
+ break;
+ }
+ if (! ok)
+ throw new SecurityException(Messages.getString("StorePasswdCmd.19")); //$NON-NLS-1$
+ }
+ }
+
+ private boolean prompt4NewPassword(CallbackHandler handler,
+ Callback[] prompts, Callback[] errors)
+ throws IOException, UnsupportedCallbackException
+ {
+ // prompt user (1st time) to provide one
+ String p = Messages.getString("StorePasswdCmd.20"); //$NON-NLS-1$
+ PasswordCallback pcb = new PasswordCallback(p, false);
+ prompts[0] = pcb;
+ handler.handle(prompts);
+ char[] pwd1 = pcb.getPassword();
+ pcb.clearPassword();
+ String ls = SystemProperties.getProperty("line.separator"); //$NON-NLS-1$
+ if (pwd1 == null || pwd1.length < 6)
+ {
+ String m = Messages.getString("StorePasswdCmd.21") + ls; //$NON-NLS-1$
+ errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+ handler.handle(errors);
+ return false;
+ }
+
+ if (Arrays.equals(storePasswordChars, pwd1))
+ {
+ String m = Messages.getString("StorePasswdCmd.22") + ls; //$NON-NLS-1$
+ errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+ handler.handle(errors);
+ return false;
+ }
+
+ // prompt user (2nd time) for confirmation
+ pcb = new PasswordCallback(Messages.getString("StorePasswdCmd.23"), false); //$NON-NLS-1$
+ prompts[0] = pcb;
+ handler.handle(prompts);
+ char[] pwd2 = pcb.getPassword();
+ pcb.clearPassword();
+ if (! Arrays.equals(pwd1, pwd2))
+ {
+ String m = Messages.getString("StorePasswdCmd.24") + ls; //$NON-NLS-1$
+ errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+ handler.handle(errors);
+ return false;
+ }
+
+ newStorePasswordChars = pwd2;
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java
new file mode 100644
index 000000000..4c6bae4dc
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- translation support for native2ascii
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.native2ascii;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.native2ascii.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
new file mode 100644
index 000000000..524796d3b
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
@@ -0,0 +1,194 @@
+/* Native2ASCII.java - native2ascii program
+ Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.native2ascii;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+/**
+ * Native2ASCII main program.
+ * @author Ito Kazumitsu <kaz@maczuka.gcd.org>
+ */
+public class Native2ASCII
+{
+ // Input file.
+ String input;
+ // Output file.
+ String output;
+ // Encoding to use.
+ String encoding;
+ // True for reverse operation.
+ boolean reversed;
+
+ private class HandleFile extends FileArgumentCallback
+ {
+ public HandleFile()
+ {
+ }
+
+ public void notifyFile(String fileArgument)
+ throws OptionException
+ {
+ if (input == null)
+ input = fileArgument;
+ else if (output == null)
+ output = fileArgument;
+ else
+ throw new OptionException(Messages.getString("Native2ASCII.TooManyFiles")); //$NON-NLS-1$
+ }
+ }
+
+ private Parser createParser()
+ {
+ Parser result = new ClasspathToolParser("native2ascii", true); //$NON-NLS-1$
+ result.setHeader(Messages.getString("Native2ASCII.Usage")); //$NON-NLS-1$
+
+ result.add(new Option("encoding", Messages.getString("Native2ASCII.EncodingHelp"), Messages.getString("Native2ASCII.EncodingArgName")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ if (encoding != null)
+ throw new OptionException(Messages.getString("Native2ASCII.EncodingSpecified")); //$NON-NLS-1$
+ encoding = argument;
+ }
+ });
+ result.add(new Option("reverse", Messages.getString("Native2ASCII.ReverseHelp")) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ reversed = true;
+ }
+ });
+
+ // We mistakenly added the extra "d" in "reversed"; now we don't
+ // want to remove it, for backward compatibility.
+ result.add(new Option("reversed", Messages.getString("Native2ASCII.ReversedHelpCompat")) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ reversed = true;
+ }
+ });
+
+ return result;
+ }
+
+ private void run(String[] args)
+ {
+ Parser argParser = createParser();
+ argParser.parse(args, new HandleFile());
+
+ if (encoding == null)
+ encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
+ try
+ {
+ InputStream is = (input == null ? System.in
+ : new FileInputStream(input));
+ OutputStream os = (output == null ? (OutputStream) System.out
+ : new FileOutputStream(output));
+
+ BufferedReader rdr = new BufferedReader(new InputStreamReader(is,
+ encoding));
+ PrintWriter wtr = new PrintWriter(
+ new BufferedWriter(
+ new OutputStreamWriter(
+ os,
+ encoding)));
+ while (true)
+ {
+ String s = rdr.readLine();
+ if (s == null)
+ break;
+ StringBuilder sb = new StringBuilder(s.length() + 80);
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ if (reversed
+ && i + 6 <= s.length()
+ && s.charAt(i) == '\\'
+ && s.charAt(i + 1) == 'u')
+ {
+ int num = Integer.parseInt(s.substring(i + 2, i + 6), 16);
+ sb.append((char) num);
+ i += 5;
+ }
+ else if ((int)c <= 127 || reversed)
+ {
+ sb.append(c);
+ }
+ else
+ {
+ sb.append("\\u"); //$NON-NLS-1$
+ if ((int)c <= 0xff)
+ sb.append("00"); //$NON-NLS-1$
+ else if ((int)c <= 0xfff)
+ sb.append("0"); //$NON-NLS-1$
+ sb.append(Integer.toHexString((int) c));
+ }
+ }
+ wtr.println(sb.toString());
+ }
+ rdr.close();
+ wtr.flush();
+ wtr.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ new Native2ASCII().run(args);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/orbd/Main.java b/libjava/classpath/tools/gnu/classpath/tools/orbd/Main.java
new file mode 100644
index 000000000..7e970adfb
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/orbd/Main.java
@@ -0,0 +1,226 @@
+/* NamingServicePersistent.java -- The persistent naming service.
+ Copyright (C) 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.orbd;
+
+import gnu.CORBA.OrbFunctional;
+import gnu.CORBA.IOR;
+import gnu.CORBA.NamingService.Ext;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import org.omg.CosNaming.NamingContextExt;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * The server for the GNU Classpath persistent naming service.
+ *
+ * GNU Classpath currently works with this naming service and is also
+ * interoperable with the Sun Microsystems naming services from releases 1.3 and
+ * 1.4, both transient <i>tnameserv</i> and persistent <i>orbd</i>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Main
+{
+ /**
+ * The default port (900), on that the naming service starts if no
+ * -ORBInitialPort is specified in the command line.
+ */
+ public static final int PORT = 900;
+
+ private int port = PORT;
+ private String iorf;
+ private boolean cold;
+ private String directory = "";
+
+ /**
+ * Get the object key for the naming service. The default key is the string
+ * "NameService" in ASCII.
+ *
+ * @return the byte array.
+ */
+ public static byte[] getDefaultKey()
+ {
+ try
+ { // NameService
+ return "NameService".getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ throw new InternalError("UTF-8 unsupported");
+ }
+ }
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("orbd", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("ORBInitialPort", //$NON-NLS-1$
+ Messages.getString("Main.ORBInitialPort"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ parser.add(new Option("ior", //$NON-NLS-1$
+ Messages.getString("Main.IOR"), //$NON-NLS-1$
+ Messages.getString("Main.IORFile")) //$NON-NLS-1$
+ {
+ public void parsed(String fileArgument) throws OptionException
+ {
+ iorf = fileArgument;
+ }
+ });
+ parser.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ cold = true;
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser parser = initializeParser();
+ parser.parse(args);
+
+ try
+ {
+ // Create and initialize the ORB
+ final OrbFunctional orb = new OrbFunctional();
+ OrbFunctional.setPort(port);
+
+ // Create the servant and register it with the ORB
+ File dataDirectory = new File(directory);
+ System.out.println("Persistent data stored at "
+ + dataDirectory.getAbsolutePath());
+ dataDirectory.mkdirs();
+
+ // / TODO support more starting modes.
+ NamingContextExt namer = new Ext(
+ new PersistentContext(
+ orb,
+ dataDirectory,
+ cold));
+
+ // Case with the key "NameService".
+ orb.connect(namer, "NameService".getBytes());
+
+ // Storing the IOR reference.
+ String ior = orb.object_to_string(namer);
+ IOR iorr = IOR.parse(ior);
+ if (iorf != null)
+ {
+ FileOutputStream f = new FileOutputStream(iorf);
+ PrintStream p = new PrintStream(f);
+ p.print(ior);
+ p.close();
+ }
+
+ System.out.println("GNU Classpath persistent naming service "
+ + "started at " + iorr.Internet.host + ":"
+ + iorr.Internet.port + " key 'NameService'.\n\n"
+ + "Copyright (C) 2011 Free Software Foundation\n"
+ + "This tool comes with ABSOLUTELY NO WARRANTY. "
+ + "This is free software, and you are\nwelcome to "
+ + "redistribute it under conditions, defined in "
+ + "GNU Classpath license.\n\n" + ior);
+
+ new Thread()
+ {
+ public void run()
+ {
+ // Wait for invocations from clients.
+ orb.run();
+ }
+ }.start();
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ // Restore the default value for allocating ports for the subsequent
+ // objects.
+ OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
+ }
+ }
+
+ /**
+ * The persistent naming service entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main orbdprogram = new Main();
+ try
+ {
+ orbdprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/orbd/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/orbd/Messages.java
new file mode 100644
index 000000000..c9bb371ad
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/orbd/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for orbd
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.orbd.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContext.java b/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContext.java
new file mode 100644
index 000000000..4526813b8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContext.java
@@ -0,0 +1,152 @@
+/* PersistentContext.java -- The persistent naming context.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import gnu.CORBA.NamingService.NameTransformer;
+import gnu.CORBA.NamingService.TransientContext;
+
+import java.io.File;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * This class implements the persistent naming service, defined by
+ * {@link NamingContext}. The 'persistent' means that the service remembers the
+ * mappings, stored between restarts.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PersistentContext
+ extends TransientContext
+{
+ /**
+ * Use serial version UID for interoperability.
+ */
+ private static final long serialVersionUID = 2;
+
+ /**
+ * The folder, where the persistent context information is stored.
+ */
+ File contextFolder;
+
+ /**
+ * The uinque context identifier.
+ */
+ static long num = System.currentTimeMillis();
+
+ /**
+ * The naming service orb.
+ */
+ ORB orb;
+
+ /**
+ * Create the persistent naming context that will store the files in the given
+ * folder of the local file system. This method also connects object to the
+ * passed ORB.
+ *
+ * @param an_orb the naming service ORB, used to obtain and produce the object
+ * stringified references.
+ * @param folder the folder, where the persistent information is stored.
+ * @param reset if true, the previous naming data are discarded. If false
+ * (normally expected), they are loaded from the persistent memory to
+ * provide the persistence.
+ */
+ public PersistentContext(ORB an_orb, File folder, boolean reset)
+ {
+ super(
+ new PersistentContextMap(an_orb, new File(folder, "contexts.txt"), reset),
+ new PersistentMap(an_orb, new File(folder, "objects.txt"), reset));
+ contextFolder = folder;
+ folder.mkdirs();
+ orb = an_orb;
+ orb.connect(this);
+ }
+
+ /**
+ * Get the unique context number;
+ *
+ * @return the context number
+ */
+ static synchronized String getNum()
+ {
+ return Long.toHexString(num++);
+ }
+
+ /**
+ * Create new persistent context.
+ */
+ public NamingContext new_context()
+ {
+ File ctxFolder = new File(contextFolder, "ctx_"+getNum());
+ return new PersistentContext(orb, ctxFolder, true);
+ }
+
+ /**
+ * Create a new context and give it a given name (bound it) in the current
+ * context. The method benefits from passing the better readable context name.
+ *
+ * @param a_name the name being given to the new context.
+ * @return the newly created context.
+ * @throws AlreadyBound if the name is already in use.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public NamingContext bind_new_context(NameComponent[] a_name)
+ throws NotFound, AlreadyBound, CannotProceed, InvalidName
+ {
+ if (named_contexts.containsKey(a_name[0])
+ || named_objects.containsKey(a_name[0]))
+ throw new AlreadyBound();
+
+ NameTransformer transformer = new NameTransformer();
+
+ File ctxFolder = new File(contextFolder,
+ transformer.toString(a_name).replace('/', '.')
+ + ".v" + getNum());
+
+ NamingContext child = new PersistentContext(orb, ctxFolder, true);
+ bind_context(a_name, child);
+ return child;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContextMap.java b/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContextMap.java
new file mode 100644
index 000000000..d83f2bf4c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContextMap.java
@@ -0,0 +1,87 @@
+/* PersistentContextMap.java -- The persistent context naming map
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import java.io.File;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+
+/**
+ * The persistent context naming map for the persistent naming service.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PersistentContextMap extends PersistentMap
+{
+ /**
+ * Create the persistent context map that stores information in the given
+ * file.
+ *
+ * @param an_orb the naming service ORB, used to obtain and produce the object
+ * stringified references.
+ * @param mapFile the file, where the persistent information is stored.
+ * @param reset if true, the previous naming data are discarded. If false
+ * (normally expected), they are loaded from the persistent memory to
+ * provide the persistence.
+ */
+ public PersistentContextMap(ORB an_orb, File mapFile, boolean reset)
+ {
+ super(an_orb, mapFile, reset);
+ }
+
+ /**
+ * This method expects the PersistentContext as its parameter. The returned
+ * description line is the name of the context parent folder.
+ */
+ protected String object_to_string(Object object)
+ {
+ PersistentContext pc = (PersistentContext) object;
+ return pc.contextFolder.getAbsolutePath();
+ }
+
+ /**
+ * This method restores the PersistenContext. The description line is
+ * interpreted as the folder name, absolute path.
+ */
+ protected Object string_to_object(String description)
+ {
+ return new PersistentContext(orb, new File(description), reset);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentMap.java b/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentMap.java
new file mode 100644
index 000000000..a39ff28ba
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentMap.java
@@ -0,0 +1,454 @@
+/* PersistentMap.java -- The persistent object naming map
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import gnu.CORBA.NamingService.NamingMap;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+
+/**
+ * The persistent object naming map for the persistent naming service. The
+ * inherited (super.) naming map implementation is transient and is used as a
+ * cache. During the normal work, the naming map does not read from the disk,
+ * just stores the changes there. Map only reads from the disk when it starts.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PersistentMap
+ extends NamingMap
+{
+ /**
+ * The data entry.
+ */
+ public static class Entry
+ {
+ String id;
+
+ String kind;
+
+ String ior;
+
+ /**
+ * Get the name component node.
+ */
+ public NameComponent getComponent()
+ {
+ return new NameComponent(id, kind);
+ }
+
+ /**
+ * Write the naming map entry to the output stream.
+ */
+ public void write(OutputStream out) throws IOException
+ {
+ // Format: id.kind <eoln> ior <eoln><eoln>
+ out.write(getKey(id, kind).getBytes());
+ out.write('\n');
+ out.write(ior.getBytes());
+ out.write('\n');
+ out.close();
+ }
+
+ /**
+ * Read the name component from the input stream
+ */
+ public boolean read(BufferedReader in) throws IOException
+ {
+ String key = in.readLine();
+ String xior = in.readLine();
+
+ if (key != null && xior != null)
+ {
+ if (key.length() < 2)
+ {
+ // A single char key cannot have the kind part.
+ id = key;
+ kind = "";
+ }
+ else
+ {
+ // Search for the id/kind splitter, dot:
+ int iks = - 1;
+ for (int i = 1; i < key.length(); i++)
+ {
+ if (key.charAt(i) == '.')
+ // The id is separated from kind by dot, unless preceeded by
+ // the
+ // escape character, \.
+ if (key.charAt(i - 1) != '\\')
+ {
+ iks = i;
+ break;
+ }
+ }
+
+ // May also end by dot, if the kind field is missing.
+ if (iks < 0)
+ {
+ id = key;
+ kind = "";
+ }
+ else if (iks == key.length() - 1)
+ {
+ id = key.substring(0, key.length() - 1);
+ kind = "";
+ }
+ else
+ {
+ id = key.substring(0, iks);
+ kind = key.substring(iks + 1);
+ }
+ }
+ ior = xior;
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the key value from the name component.
+ *
+ * @param id the component id
+ * @param kind the component kind
+ * @return the key value
+ */
+ public String getKey(String id, String kind)
+ {
+ StringBuilder b = new StringBuilder(id.length() + 8);
+ appEscaping(b, id);
+ b.append('.');
+ if (kind != null && kind.length() > 0)
+ appEscaping(b, kind);
+ return b.toString();
+ }
+
+ /**
+ * Append the contents of the string to this string buffer, inserting the
+ * escape sequences, where required.
+ *
+ * @param b a buffer to append the contents to.
+ * @param s a string to append.
+ */
+ void appEscaping(StringBuilder b, String s)
+ {
+ char c;
+ for (int i = 0; i < s.length(); i++)
+ {
+ c = s.charAt(i);
+ switch (c)
+ {
+ case '.':
+ case '/':
+ case '\\':
+ b.append('\\');
+ b.append(c);
+ break;
+
+ default:
+ b.append(c);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * The file, where the persistent naming map stores the information. The
+ * format of this file is n*(id LF kind LF ior LFLF).
+ */
+ public final File file;
+
+ /**
+ * The naming service ORB, used to obtain and produce the object stringified
+ * references.
+ */
+ ORB orb;
+
+ /**
+ * If true, all existing data on the file system are discarded.
+ */
+ boolean reset;
+
+ /**
+ * Create the persistent map that stores information in the given file.
+ *
+ * @param an_orb the naming service ORB, used to obtain and produce the object
+ * stringified references.
+ * @param mapFile the file, where the persistent information is stored.
+ * @param a_reset if true, the previous naming data are discarded. If false
+ * (normally expected), they are loaded from the persistent memory to
+ * provide the persistence.
+ */
+ public PersistentMap(ORB an_orb, File mapFile, boolean a_reset)
+ {
+ super();
+ orb = an_orb;
+ file = mapFile;
+ reset = a_reset;
+
+ // Initialise the persistent map with existing data.
+ if (file.exists() && ! reset)
+ {
+
+ BufferedReader in;
+ try
+ {
+ FileInputStream fin = new FileInputStream(file);
+ in = new BufferedReader(new InputStreamReader(fin));
+ Entry e = new Entry();
+ boolean ok;
+
+ while (e.read(in))
+ {
+ org.omg.CORBA .Object object = string_to_object(e.ior);
+ orb.connect(object);
+ map.put(e.getComponent(), object);
+ }
+ }
+ catch (Exception ex)
+ {
+ InternalError ierr = new InternalError(file.getAbsolutePath());
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ }
+ }
+
+ /**
+ * Restore object from its string description.
+ *
+ * @param description the string, describing the object
+ *
+ * @return the object.
+ */
+ protected org.omg.CORBA.Object string_to_object(String description)
+ {
+ return orb.string_to_object(description);
+ }
+
+ /**
+ * Convert the object to its string description
+ *
+ * @param object the object to convert
+ * @return the string description of the object
+ */
+ protected String object_to_string(org.omg.CORBA .Object object)
+ {
+ return orb.object_to_string(object);
+ }
+
+ /**
+ * Put the given GIOP object, specifying the given name as a key. If the entry
+ * with the given name already exists, or if the given object is already
+ * mapped under another name, the {@link AlreadyBound} exception will be
+ * thrown.
+ *
+ * @param name the name
+ * @param object the object
+ */
+ public void bind(NameComponent name, org.omg.CORBA.Object object)
+ throws AlreadyBound, InvalidName
+ {
+ if (!containsKey(name))
+ {
+ super.bind(name, object);
+ register(name, object);
+ }
+ else
+ throw new AlreadyBound(name.id + "." + name.kind);
+ }
+
+ /**
+ * Put the given CORBA object, specifying the given name as a key. Remove all
+ * pre - existing mappings for the given name and object.
+ *
+ * @param name the name.
+ * @param object the object
+ */
+ public void rebind(NameComponent name, org.omg.CORBA.Object object)
+ throws InvalidName
+ {
+ if (containsKey(name))
+ {
+ org.omg.CORBA.Object existing = get(name);
+ String ior = object_to_string(object);
+ String xior = object_to_string(existing);
+
+ // Same name and same ior - nothing to do.
+ if (ior.equals(xior))
+ return;
+ else
+ remove(name);
+ }
+
+ Iterator iter = entries().iterator();
+ Map.Entry item;
+
+ // Remove the existing mapping for the given object, if present.
+ while (iter.hasNext())
+ {
+ item = (Map.Entry) iter.next();
+ if (item.getValue().equals(object))
+ iter.remove();
+ }
+
+ map.put(name, object);
+ register(name, object);
+ }
+
+ /**
+ * Removes the given name, if present.
+ *
+ * @param name a name to remove.
+ */
+ public void remove(NameComponent name)
+ {
+ super.remove(name);
+ unregister(name);
+ }
+
+ /**
+ * Register this name - object pair in the persistent storage.
+ *
+ * @param name the name.
+ * @param object the object
+ */
+ public void register(NameComponent name, org.omg.CORBA.Object object)
+ {
+ // If this key is already known, and this is the same object,
+ // then return without action.
+ String ior = object_to_string(object);
+
+ synchronized (file)
+ {
+ try
+ {
+ FileOutputStream fou;
+
+ if (! file.exists())
+ fou = new FileOutputStream(file);
+ else
+ fou = new FileOutputStream(file, true);
+
+ Entry e = new Entry();
+ e.id = name.id;
+ e.kind = name.kind;
+ e.ior = ior;
+ e.write(fou);
+ fou.close();
+ }
+ catch (Exception e)
+ {
+ InternalError ierr = new InternalError(file.getAbsolutePath());
+ ierr.initCause(e);
+ throw ierr;
+ }
+ }
+ }
+
+ /**
+ * Remove this name from the persistent storage.
+ *
+ * @param name the name to remove
+ */
+ public void unregister(NameComponent name)
+ {
+ synchronized (file)
+ {
+ try
+ {
+ File nf = new File(file.getParent(), file.getName() + "_t");
+ FileInputStream fin = new FileInputStream(file);
+ FileOutputStream fou = new FileOutputStream(nf);
+ BufferedOutputStream ou = new BufferedOutputStream(fou);
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(fin));
+ String s;
+ String nk = name.kind;
+ if (nk == null)
+ nk = "";
+
+ Entry e = new Entry();
+
+ while (e.read(in))
+ {
+ if (e.id.equals(name.id) && e.kind.equals(nk))
+ {
+ // Do nothing - skip.
+ }
+ else
+ {
+ e.write(ou);
+ }
+ }
+
+ File deleteIt = new File(file.getParent(), file.getName() + "_d");
+ if (deleteIt.exists())
+ deleteIt.delete();
+
+ if (! file.renameTo(deleteIt))
+ throw new IOException(file.getAbsolutePath() + " rename failed");
+
+ if (! nf.renameTo(file))
+ throw new IOException(file.getAbsolutePath() + " rename failed");
+ }
+ catch (Exception e)
+ {
+ InternalError ierr = new InternalError(file.getAbsolutePath());
+ ierr.initCause(e);
+ throw ierr;
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java
new file mode 100644
index 000000000..7c6b7222f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java
@@ -0,0 +1,53 @@
+/* AbstractMethodGenerator.java -- the abstract method generator
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+public interface AbstractMethodGenerator
+{
+ /**
+ * Generate this method for the Stub (remote caller) class.
+ */
+ String generateStubMethod();
+
+ /**
+ * Generate this method for the Tie (remote servant) class.
+ */
+ String generateTieMethod();
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java
new file mode 100644
index 000000000..9ac103c75
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java
@@ -0,0 +1,1834 @@
+/* ClassRmicCompiler.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmic;
+
+import gnu.java.rmi.server.RMIHashes;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.MarshalException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.UnmarshalException;
+import java.rmi.server.Operation;
+import java.rmi.server.RemoteCall;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.server.Skeleton;
+import java.rmi.server.SkeletonMismatchException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Type;
+
+public class ClassRmicCompiler
+ implements RmicBackend
+{
+ private String[] args;
+ private int next;
+ private List errors = new ArrayList();
+ private boolean keep = false;
+ private boolean need11Stubs = true;
+ private boolean need12Stubs = true;
+ private boolean compile = true;
+ private boolean verbose;
+ private boolean noWrite;
+ private String destination;
+ private String classpath;
+ private ClassLoader loader;
+ private int errorCount = 0;
+
+ private Class clazz;
+ private String classname;
+ private String classInternalName;
+ private String fullclassname;
+ private MethodRef[] remotemethods;
+ private String stubname;
+ private String skelname;
+ private List mRemoteInterfaces;
+
+ /**
+ * @return true if run was successful
+ */
+ public boolean run(String[] inputFiles)
+ {
+ args = inputFiles;
+
+ if (next >= args.length)
+ return false;
+
+ for (int i = next; i < args.length; i++)
+ {
+ try
+ {
+ if (verbose)
+ System.out.println("[Processing class " + args[i] + ".class]");
+ processClass(args[i].replace(File.separatorChar, '.'));
+ }
+ catch (IOException e)
+ {
+ errors.add(e);
+ }
+ catch (RMICException e)
+ {
+ errors.add(e);
+ }
+ }
+ if (errors.size() > 0)
+ {
+ for (Iterator it = errors.iterator(); it.hasNext(); )
+ {
+ Exception ex = (Exception) it.next();
+ logError(ex);
+ }
+ }
+
+ return errorCount == 0;
+ }
+
+ private void processClass(String cls) throws IOException, RMICException
+ {
+ // reset class specific vars
+ clazz = null;
+ classname = null;
+ classInternalName = null;
+ fullclassname = null;
+ remotemethods = null;
+ stubname = null;
+ skelname = null;
+ mRemoteInterfaces = new ArrayList();
+
+ analyzeClass(cls);
+ generateStub();
+ if (need11Stubs)
+ generateSkel();
+ }
+
+ private void analyzeClass(String cname)
+ throws RMICException
+ {
+ if (verbose)
+ System.out.println("[analyze class " + cname + "]");
+ int p = cname.lastIndexOf('.');
+ if (p != -1)
+ classname = cname.substring(p + 1);
+ else
+ classname = cname;
+ fullclassname = cname;
+
+ findClass();
+ findRemoteMethods();
+ }
+
+ /**
+ * @deprecated
+ */
+ public Exception getException()
+ {
+ return errors.size() == 0 ? null : (Exception) errors.get(0);
+ }
+
+ private void findClass()
+ throws RMICException
+ {
+ ClassLoader cl = (loader == null
+ ? ClassLoader.getSystemClassLoader()
+ : loader);
+ try
+ {
+ clazz = Class.forName(fullclassname, false, cl);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RMICException
+ ("Class " + fullclassname + " not found in classpath", cnfe);
+ }
+
+ if (! Remote.class.isAssignableFrom(clazz))
+ {
+ throw new RMICException
+ ("Class " + clazz.getName()
+ + " does not implement a remote interface.");
+ }
+ }
+
+ private static Type[] typeArray(Class[] cls)
+ {
+ Type[] t = new Type[cls.length];
+ for (int i = 0; i < cls.length; i++)
+ {
+ t[i] = Type.getType(cls[i]);
+ }
+
+ return t;
+ }
+
+ private static String[] internalNameArray(Type[] t)
+ {
+ String[] s = new String[t.length];
+ for (int i = 0; i < t.length; i++)
+ {
+ s[i] = t[i].getInternalName();
+ }
+
+ return s;
+ }
+
+ private static String[] internalNameArray(Class[] c)
+ {
+ return internalNameArray(typeArray(c));
+ }
+
+ private static final String forName = "class$";
+
+ private static Object param(Method m, int argIndex)
+ {
+ List l = new ArrayList();
+ l.add(m);
+ l.add(new Integer(argIndex));
+ return l;
+ }
+
+ private static void generateClassForNamer(ClassVisitor cls)
+ {
+ MethodVisitor cv =
+ cls.visitMethod
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_SYNTHETIC, forName,
+ Type.getMethodDescriptor
+ (Type.getType(Class.class), new Type[] { Type.getType(String.class) }),
+ null, null);
+
+ Label start = new Label();
+ cv.visitLabel(start);
+ cv.visitVarInsn(Opcodes.ALOAD, 0);
+ cv.visitMethodInsn
+ (Opcodes.INVOKESTATIC,
+ Type.getInternalName(Class.class),
+ "forName",
+ Type.getMethodDescriptor
+ (Type.getType(Class.class), new Type[] { Type.getType(String.class) }));
+ cv.visitInsn(Opcodes.ARETURN);
+
+ Label handler = new Label();
+ cv.visitLabel(handler);
+ cv.visitVarInsn(Opcodes.ASTORE, 1);
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(NoClassDefFoundError.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitVarInsn(Opcodes.ALOAD, 1);
+ cv.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(ClassNotFoundException.class),
+ "getMessage",
+ Type.getMethodDescriptor(Type.getType(String.class), new Type[] {}));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(NoClassDefFoundError.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ cv.visitInsn(Opcodes.ATHROW);
+ cv.visitTryCatchBlock
+ (start, handler, handler,
+ Type.getInternalName(ClassNotFoundException.class));
+ cv.visitMaxs(-1, -1);
+ }
+
+ private void generateClassConstant(MethodVisitor cv, Class cls) {
+ if (cls.isPrimitive())
+ {
+ Class boxCls;
+ if (cls.equals(Boolean.TYPE))
+ boxCls = Boolean.class;
+ else if (cls.equals(Character.TYPE))
+ boxCls = Character.class;
+ else if (cls.equals(Byte.TYPE))
+ boxCls = Byte.class;
+ else if (cls.equals(Short.TYPE))
+ boxCls = Short.class;
+ else if (cls.equals(Integer.TYPE))
+ boxCls = Integer.class;
+ else if (cls.equals(Long.TYPE))
+ boxCls = Long.class;
+ else if (cls.equals(Float.TYPE))
+ boxCls = Float.class;
+ else if (cls.equals(Double.TYPE))
+ boxCls = Double.class;
+ else if (cls.equals(Void.TYPE))
+ boxCls = Void.class;
+ else
+ throw new IllegalArgumentException("unknown primitive type " + cls);
+
+ cv.visitFieldInsn
+ (Opcodes.GETSTATIC, Type.getInternalName(boxCls), "TYPE",
+ Type.getDescriptor(Class.class));
+ return;
+ }
+ cv.visitLdcInsn(cls.getName());
+ cv.visitMethodInsn
+ (Opcodes.INVOKESTATIC, classInternalName, forName,
+ Type.getMethodDescriptor
+ (Type.getType(Class.class),
+ new Type[] { Type.getType(String.class) }));
+ }
+
+ private void generateClassArray(MethodVisitor code, Class[] classes)
+ {
+ code.visitLdcInsn(new Integer(classes.length));
+ code.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Class.class));
+ for (int i = 0; i < classes.length; i++)
+ {
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn(new Integer(i));
+ generateClassConstant(code, classes[i]);
+ code.visitInsn(Opcodes.AASTORE);
+ }
+ }
+
+ private void fillOperationArray(MethodVisitor clinit)
+ {
+ // Operations array
+ clinit.visitLdcInsn(new Integer(remotemethods.length));
+ clinit.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Operation.class));
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+
+ StringBuilder desc = new StringBuilder();
+ desc.append(getPrettyName(m.getReturnType()) + " ");
+ desc.append(m.getName() + "(");
+
+ // signature
+ Class[] sig = m.getParameterTypes();
+ for (int j = 0; j < sig.length; j++)
+ {
+ desc.append(getPrettyName(sig[j]));
+ if (j + 1 < sig.length)
+ desc.append(", ");
+ }
+
+ // push operations array
+ clinit.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ // push array index
+ clinit.visitLdcInsn(new Integer(i));
+
+ // instantiate operation and leave a copy on the stack
+ clinit.visitTypeInsn(Opcodes.NEW, typeArg(Operation.class));
+ clinit.visitInsn(Opcodes.DUP);
+ clinit.visitLdcInsn(desc.toString());
+ clinit.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(Operation.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+
+ // store in operations array
+ clinit.visitInsn(Opcodes.AASTORE);
+ }
+ }
+
+ private void generateStaticMethodObjs(MethodVisitor clinit)
+ {
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+
+ /*
+ * $method_<i>m.getName()</i>_<i>i</i> =
+ * <i>m.getDeclaringClass()</i>.class.getMethod
+ * (m.getName(), m.getParameterType())
+ */
+ String methodVar = "$method_" + m.getName() + "_" + i;
+ generateClassConstant(clinit, m.getDeclaringClass());
+ clinit.visitLdcInsn(m.getName());
+ generateClassArray(clinit, m.getParameterTypes());
+ clinit.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(Class.class),
+ "getMethod",
+ Type.getMethodDescriptor
+ (Type.getType(Method.class),
+ new Type[] { Type.getType(String.class),
+ Type.getType(Class[].class) }));
+
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, methodVar,
+ Type.getDescriptor(Method.class));
+ }
+ }
+
+ private void generateStub()
+ throws IOException
+ {
+ stubname = fullclassname + "_Stub";
+ String stubclassname = classname + "_Stub";
+ File file = new File((destination == null ? "." : destination)
+ + File.separator
+ + stubname.replace('.', File.separatorChar)
+ + ".class");
+
+ if (verbose)
+ System.out.println("[Generating class " + stubname + "]");
+
+ final ClassWriter stub = new ClassWriter(true);
+ classInternalName = stubname.replace('.', '/');
+ final String superInternalName =
+ Type.getType(RemoteStub.class).getInternalName();
+
+ String[] remoteInternalNames =
+ internalNameArray((Class[]) mRemoteInterfaces.toArray(new Class[] {}));
+ stub.visit
+ (Opcodes.V1_2, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, classInternalName,
+ null, superInternalName, remoteInternalNames);
+
+ if (need12Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "serialVersionUID",
+ Type.LONG_TYPE.getDescriptor(), null, new Long(2L));
+ }
+
+ if (need11Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL,
+ "interfaceHash", Type.LONG_TYPE.getDescriptor(), null,
+ new Long(RMIHashes.getInterfaceHash(clazz)));
+
+ if (need12Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor(), null, null);
+ }
+
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL,
+ "operations", Type.getDescriptor(Operation[].class), null, null);
+ }
+
+ // Set of method references.
+ if (need12Stubs)
+ {
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+ String slotName = "$method_" + m.getName() + "_" + i;
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, slotName,
+ Type.getDescriptor(Method.class), null, null);
+ }
+ }
+
+ MethodVisitor clinit = stub.visitMethod
+ (Opcodes.ACC_STATIC, "<clinit>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+
+ if (need11Stubs)
+ {
+ fillOperationArray(clinit);
+ if (! need12Stubs)
+ clinit.visitInsn(Opcodes.RETURN);
+ }
+
+ if (need12Stubs)
+ {
+ // begin of try
+ Label begin = new Label();
+
+ // beginning of catch
+ Label handler = new Label();
+ clinit.visitLabel(begin);
+
+ // Initialize the methods references.
+ if (need11Stubs)
+ {
+ /*
+ * RemoteRef.class.getMethod("invoke", new Class[] {
+ * Remote.class, Method.class, Object[].class, long.class })
+ */
+ generateClassConstant(clinit, RemoteRef.class);
+ clinit.visitLdcInsn("invoke");
+ generateClassArray
+ (clinit, new Class[] { Remote.class, Method.class,
+ Object[].class, long.class });
+ clinit.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(Class.class),
+ "getMethod",
+ Type.getMethodDescriptor
+ (Type.getType(Method.class),
+ new Type[] { Type.getType(String.class),
+ Type.getType(Class[].class) }));
+
+ // useNewInvoke = true
+ clinit.visitInsn(Opcodes.ICONST_1);
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor());
+ }
+
+ generateStaticMethodObjs(clinit);
+
+ // jump past handler
+ clinit.visitInsn(Opcodes.RETURN);
+ clinit.visitLabel(handler);
+ if (need11Stubs)
+ {
+ // useNewInvoke = false
+ clinit.visitInsn(Opcodes.ICONST_0);
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor());
+ clinit.visitInsn(Opcodes.RETURN);
+ }
+ else
+ {
+ // throw NoSuchMethodError
+ clinit.visitTypeInsn(Opcodes.NEW, typeArg(NoSuchMethodError.class));
+ clinit.visitInsn(Opcodes.DUP);
+ clinit.visitLdcInsn("stub class initialization failed");
+ clinit.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(NoSuchMethodError.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class) }));
+ clinit.visitInsn(Opcodes.ATHROW);
+ }
+
+ clinit.visitTryCatchBlock
+ (begin, handler, handler,
+ Type.getInternalName(NoSuchMethodException.class));
+
+ }
+
+ clinit.visitMaxs(-1, -1);
+
+ generateClassForNamer(stub);
+
+ // Constructors
+ if (need11Stubs)
+ {
+ // no arg public constructor
+ MethodVisitor code = stub.visitMethod
+ (Opcodes.ACC_PUBLIC, "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}),
+ null, null);
+ code.visitVarInsn(Opcodes.ALOAD, 0);
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, superInternalName, "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ code.visitInsn(Opcodes.RETURN);
+
+ code.visitMaxs(-1, -1);
+ }
+
+ // public RemoteRef constructor
+ MethodVisitor constructor = stub.visitMethod
+ (Opcodes.ACC_PUBLIC, "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] {Type.getType(RemoteRef.class)}),
+ null, null);
+ constructor.visitVarInsn(Opcodes.ALOAD, 0);
+ constructor.visitVarInsn(Opcodes.ALOAD, 1);
+ constructor.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, superInternalName, "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] {Type.getType(RemoteRef.class)}));
+ constructor.visitInsn(Opcodes.RETURN);
+ constructor.visitMaxs(-1, -1);
+
+ // Method implementations
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+ Class[] sig = m.getParameterTypes();
+ Class returntype = m.getReturnType();
+ Class[] except = sortExceptions
+ ((Class[]) remotemethods[i].exceptions.toArray(new Class[0]));
+
+ MethodVisitor code = stub.visitMethod
+ (Opcodes.ACC_PUBLIC,
+ m.getName(),
+ Type.getMethodDescriptor(Type.getType(returntype), typeArray(sig)),
+ null,
+ internalNameArray(typeArray(except)));
+
+ final Variables var = new Variables();
+
+ // this and parameters are the declared vars
+ var.declare("this");
+ for (int j = 0; j < sig.length; j++)
+ var.declare(param(m, j), size(sig[j]));
+
+ Label methodTryBegin = new Label();
+ code.visitLabel(methodTryBegin);
+
+ if (need12Stubs)
+ {
+ Label oldInvoke = new Label();
+ if (need11Stubs)
+ {
+ // if not useNewInvoke jump to old invoke
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "useNewInvoke",
+ Type.getDescriptor(boolean.class));
+ code.visitJumpInsn(Opcodes.IFEQ, oldInvoke);
+ }
+
+ // this.ref
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD, Type.getInternalName(RemoteObject.class),
+ "ref", Type.getDescriptor(RemoteRef.class));
+
+ // "this" is first arg to invoke
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+
+ // method object is second arg to invoke
+ String methName = "$method_" + m.getName() + "_" + i;
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, methName,
+ Type.getDescriptor(Method.class));
+
+ // args to remote method are third arg to invoke
+ if (sig.length == 0)
+ code.visitInsn(Opcodes.ACONST_NULL);
+ else
+ {
+ // create arg Object[] (with boxed primitives) and push it
+ code.visitLdcInsn(new Integer(sig.length));
+ code.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Object.class));
+
+ var.allocate("argArray");
+ code.visitVarInsn(Opcodes.ASTORE, var.get("argArray"));
+
+ for (int j = 0; j < sig.length; j++)
+ {
+ int size = size(sig[j]);
+ int insn = loadOpcode(sig[j]);
+ Class box = sig[j].isPrimitive() ? box(sig[j]) : null;
+
+ code.visitVarInsn(Opcodes.ALOAD, var.get("argArray"));
+ code.visitLdcInsn(new Integer(j));
+
+ // put argument on stack
+ if (box != null)
+ {
+ code.visitTypeInsn(Opcodes.NEW, typeArg(box));
+ code.visitInsn(Opcodes.DUP);
+ code.visitVarInsn(insn, var.get(param(m, j)));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(box),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(sig[j]) }));
+ }
+ else
+ code.visitVarInsn(insn, var.get(param(m, j)));
+
+ code.visitInsn(Opcodes.AASTORE);
+ }
+
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("argArray"));
+ }
+
+ // push remote operation opcode
+ code.visitLdcInsn(new Long(remotemethods[i].hash));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "invoke",
+ Type.getMethodDescriptor
+ (Type.getType(Object.class),
+ new Type[] { Type.getType(Remote.class),
+ Type.getType(Method.class),
+ Type.getType(Object[].class),
+ Type.LONG_TYPE }));
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ int retcode = returnOpcode(returntype);
+ Class boxCls =
+ returntype.isPrimitive() ? box(returntype) : null;
+ code.visitTypeInsn
+ (Opcodes.CHECKCAST, typeArg(boxCls == null ? returntype : boxCls));
+ if (returntype.isPrimitive())
+ {
+ // unbox
+ code.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getType(boxCls).getInternalName(),
+ unboxMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.getType(returntype), new Type[] {}));
+ }
+
+ code.visitInsn(retcode);
+ }
+ else
+ code.visitInsn(Opcodes.RETURN);
+
+
+ if (need11Stubs)
+ code.visitLabel(oldInvoke);
+ }
+
+ if (need11Stubs)
+ {
+
+ // this.ref.newCall(this, operations, index, interfaceHash)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD,
+ Type.getInternalName(RemoteObject.class),
+ "ref",
+ Type.getDescriptor(RemoteRef.class));
+
+ // "this" is first arg to newCall
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+
+ // operations is second arg to newCall
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ // method index is third arg
+ code.visitLdcInsn(new Integer(i));
+
+ // interface hash is fourth arg
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "interfaceHash",
+ Type.LONG_TYPE.getDescriptor());
+
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "newCall",
+ Type.getMethodDescriptor
+ (Type.getType(RemoteCall.class),
+ new Type[] { Type.getType(RemoteObject.class),
+ Type.getType(Operation[].class),
+ Type.INT_TYPE,
+ Type.LONG_TYPE }));
+
+ // store call object on stack and leave copy on stack
+ var.allocate("call");
+ code.visitInsn(Opcodes.DUP);
+ code.visitVarInsn(Opcodes.ASTORE, var.get("call"));
+
+ Label beginArgumentTryBlock = new Label();
+ code.visitLabel(beginArgumentTryBlock);
+
+ // ObjectOutput out = call.getOutputStream();
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getOutputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectOutput.class), new Type[] {}));
+
+ for (int j = 0; j < sig.length; j++)
+ {
+ // dup the ObjectOutput
+ code.visitInsn(Opcodes.DUP);
+
+ // get j'th arg to remote method
+ code.visitVarInsn(loadOpcode(sig[j]), var.get(param(m, j)));
+
+ Class argCls =
+ sig[j].isPrimitive() ? sig[j] : Object.class;
+
+ // out.writeFoo
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectOutput.class),
+ writeMethod(sig[j]),
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(argCls) }));
+ }
+
+ // pop ObjectOutput
+ code.visitInsn(Opcodes.POP);
+
+ Label iohandler = new Label();
+ Label endArgumentTryBlock = new Label();
+ code.visitJumpInsn(Opcodes.GOTO, endArgumentTryBlock);
+ code.visitLabel(iohandler);
+
+ // throw new MarshalException(msg, ioexception);
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ code.visitTypeInsn(Opcodes.NEW, typeArg(MarshalException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn("error marshalling arguments");
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(MarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ code.visitLabel(endArgumentTryBlock);
+ code.visitTryCatchBlock
+ (beginArgumentTryBlock, iohandler, iohandler,
+ Type.getInternalName(IOException.class));
+
+ // this.ref.invoke(call)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD, Type.getInternalName(RemoteObject.class),
+ "ref", Type.getDescriptor(RemoteRef.class));
+ code.visitVarInsn(Opcodes.ALOAD, var.get("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "invoke",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(RemoteCall.class) }));
+
+ // handle return value
+ boolean needcastcheck = false;
+
+ Label beginReturnTryCatch = new Label();
+ code.visitLabel(beginReturnTryCatch);
+
+ int returncode = returnOpcode(returntype);
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ // call.getInputStream()
+ code.visitVarInsn(Opcodes.ALOAD, var.get("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getInputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectInput.class), new Type[] {}));
+
+ Class readCls =
+ returntype.isPrimitive() ? returntype : Object.class;
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectInput.class),
+ readMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.getType(readCls), new Type[] {}));
+
+ boolean castresult = false;
+
+ if (! returntype.isPrimitive())
+ {
+ if (! returntype.equals(Object.class))
+ castresult = true;
+ else
+ needcastcheck = true;
+ }
+
+ if (castresult)
+ code.visitTypeInsn(Opcodes.CHECKCAST, typeArg(returntype));
+
+ // leave result on stack for return
+ }
+
+ // this.ref.done(call)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD,
+ Type.getInternalName(RemoteObject.class),
+ "ref",
+ Type.getDescriptor(RemoteRef.class));
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "done",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(RemoteCall.class) }));
+
+ // return; or return result;
+ code.visitInsn(returncode);
+
+ // exception handler
+ Label handler = new Label();
+ code.visitLabel(handler);
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+
+ // throw new UnmarshalException(msg, e)
+ code.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn("error unmarshalling return");
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ Label endReturnTryCatch = new Label();
+
+ // catch IOException
+ code.visitTryCatchBlock
+ (beginReturnTryCatch, handler, handler,
+ Type.getInternalName(IOException.class));
+
+ if (needcastcheck)
+ {
+ // catch ClassNotFoundException
+ code.visitTryCatchBlock
+ (beginReturnTryCatch, handler, handler,
+ Type.getInternalName(ClassNotFoundException.class));
+ }
+ }
+
+ Label rethrowHandler = new Label();
+ code.visitLabel(rethrowHandler);
+ // rethrow declared exceptions
+ code.visitInsn(Opcodes.ATHROW);
+
+ boolean needgeneral = true;
+ for (int j = 0; j < except.length; j++)
+ {
+ if (except[j] == Exception.class)
+ needgeneral = false;
+ }
+
+ for (int j = 0; j < except.length; j++)
+ {
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, rethrowHandler,
+ Type.getInternalName(except[j]));
+ }
+
+ if (needgeneral)
+ {
+ // rethrow unchecked exceptions
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, rethrowHandler,
+ Type.getInternalName(RuntimeException.class));
+
+ Label generalHandler = new Label();
+ code.visitLabel(generalHandler);
+ String msg = "undeclared checked exception";
+
+ // throw new java.rmi.UnexpectedException(msg, e)
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ code.visitTypeInsn(Opcodes.NEW, typeArg(UnexpectedException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn(msg);
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnexpectedException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type [] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, generalHandler,
+ Type.getInternalName(Exception.class));
+ }
+
+ code.visitMaxs(-1, -1);
+ }
+
+ stub.visitEnd();
+ byte[] classData = stub.toByteArray();
+ if (!noWrite)
+ {
+ if (file.exists())
+ file.delete();
+ if (file.getParentFile() != null)
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(classData);
+ fos.flush();
+ fos.close();
+ }
+ }
+
+ private void generateSkel() throws IOException
+ {
+ skelname = fullclassname + "_Skel";
+ String skelclassname = classname + "_Skel";
+ File file = new File(destination == null ? "" : destination
+ + File.separator
+ + skelname.replace('.', File.separatorChar)
+ + ".class");
+ if (verbose)
+ System.out.println("[Generating class " + skelname + "]");
+
+ final ClassWriter skel = new ClassWriter(true);
+ classInternalName = skelname.replace('.', '/');
+ skel.visit
+ (Opcodes.V1_1, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL,
+ classInternalName, Type.getInternalName(Object.class), null,
+ new String[] { Type.getType(Skeleton.class).getInternalName() });
+
+ skel.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "interfaceHash",
+ Type.LONG_TYPE.getDescriptor(), null,
+ new Long(RMIHashes.getInterfaceHash(clazz)));
+
+ skel.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "operations",
+ Type.getDescriptor(Operation[].class), null, null);
+
+ MethodVisitor clinit = skel.visitMethod
+ (Opcodes.ACC_STATIC, "<clinit>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+
+ fillOperationArray(clinit);
+ clinit.visitInsn(Opcodes.RETURN);
+
+ clinit.visitMaxs(-1, -1);
+
+ // no arg public constructor
+ MethodVisitor init = skel.visitMethod
+ (Opcodes.ACC_PUBLIC, "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+ init.visitVarInsn(Opcodes.ALOAD, 0);
+ init.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ init.visitInsn(Opcodes.RETURN);
+ init.visitMaxs(-1, -1);
+
+ /*
+ * public Operation[] getOperations()
+ * returns a clone of the operations array
+ */
+ MethodVisitor getOp = skel.visitMethod
+ (Opcodes.ACC_PUBLIC, "getOperations",
+ Type.getMethodDescriptor
+ (Type.getType(Operation[].class), new Type[] {}),
+ null, null);
+ getOp.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+ getOp.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL, Type.getInternalName(Object.class),
+ "clone", Type.getMethodDescriptor(Type.getType(Object.class),
+ new Type[] {}));
+ getOp.visitTypeInsn(Opcodes.CHECKCAST, typeArg(Operation[].class));
+ getOp.visitInsn(Opcodes.ARETURN);
+ getOp.visitMaxs(-1, -1);
+
+ // public void dispatch(Remote, RemoteCall, int opnum, long hash)
+ MethodVisitor dispatch = skel.visitMethod
+ (Opcodes.ACC_PUBLIC,
+ "dispatch",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(Remote.class),
+ Type.getType(RemoteCall.class),
+ Type.INT_TYPE, Type.LONG_TYPE }), null,
+ new String[] { Type.getInternalName(Exception.class) });
+
+ Variables var = new Variables();
+ var.declare("this");
+ var.declare("remoteobj");
+ var.declare("remotecall");
+ var.declare("opnum");
+ var.declareWide("hash");
+
+ /*
+ * if opnum >= 0
+ * XXX it is unclear why there is handling of negative opnums
+ */
+ dispatch.visitVarInsn(Opcodes.ILOAD, var.get("opnum"));
+ Label nonNegativeOpnum = new Label();
+ Label opnumSet = new Label();
+ dispatch.visitJumpInsn(Opcodes.IFGE, nonNegativeOpnum);
+
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ // assign opnum if hash matches supplied hash
+ dispatch.visitVarInsn(Opcodes.LLOAD, var.get("hash"));
+ dispatch.visitLdcInsn(new Long(remotemethods[i].hash));
+ Label notIt = new Label();
+ dispatch.visitInsn(Opcodes.LCMP);
+ dispatch.visitJumpInsn(Opcodes.IFNE, notIt);
+
+ // opnum = <opnum>
+ dispatch.visitLdcInsn(new Integer(i));
+ dispatch.visitVarInsn(Opcodes.ISTORE, var.get("opnum"));
+ dispatch.visitJumpInsn(Opcodes.GOTO, opnumSet);
+ dispatch.visitLabel(notIt);
+ }
+
+ // throw new SkeletonMismatchException
+ Label mismatch = new Label();
+ dispatch.visitJumpInsn(Opcodes.GOTO, mismatch);
+
+ dispatch.visitLabel(nonNegativeOpnum);
+
+ // if opnum is already set, check that the hash matches the interface
+ dispatch.visitVarInsn(Opcodes.LLOAD, var.get("hash"));
+ dispatch.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName,
+ "interfaceHash", Type.LONG_TYPE.getDescriptor());
+ dispatch.visitInsn(Opcodes.LCMP);
+ dispatch.visitJumpInsn(Opcodes.IFEQ, opnumSet);
+
+ dispatch.visitLabel(mismatch);
+ dispatch.visitTypeInsn
+ (Opcodes.NEW, typeArg(SkeletonMismatchException.class));
+ dispatch.visitInsn(Opcodes.DUP);
+ dispatch.visitLdcInsn("interface hash mismatch");
+ dispatch.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(SkeletonMismatchException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ dispatch.visitInsn(Opcodes.ATHROW);
+
+ // opnum has been set
+ dispatch.visitLabel(opnumSet);
+
+ dispatch.visitVarInsn(Opcodes.ALOAD, var.get("remoteobj"));
+ dispatch.visitTypeInsn(Opcodes.CHECKCAST, typeArg(clazz));
+ dispatch.visitVarInsn(Opcodes.ASTORE, var.get("remoteobj"));
+
+ Label deflt = new Label();
+ Label[] methLabels = new Label[remotemethods.length];
+ for (int i = 0; i < methLabels.length; i++)
+ methLabels[i] = new Label();
+
+ // switch on opnum
+ dispatch.visitVarInsn(Opcodes.ILOAD, var.get("opnum"));
+ dispatch.visitTableSwitchInsn
+ (0, remotemethods.length - 1, deflt, methLabels);
+
+ // Method dispatch
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ dispatch.visitLabel(methLabels[i]);
+ Method m = remotemethods[i].meth;
+ generateMethodSkel(dispatch, m, var);
+ }
+
+ dispatch.visitLabel(deflt);
+ dispatch.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ dispatch.visitInsn(Opcodes.DUP);
+ dispatch.visitLdcInsn("invalid method number");
+ dispatch.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ dispatch.visitInsn(Opcodes.ATHROW);
+
+ dispatch.visitMaxs(-1, -1);
+
+ skel.visitEnd();
+ byte[] classData = skel.toByteArray();
+ if (!noWrite)
+ {
+ if (file.exists())
+ file.delete();
+ if (file.getParentFile() != null)
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(classData);
+ fos.flush();
+ fos.close();
+ }
+ }
+
+ private void generateMethodSkel(MethodVisitor cv, Method m, Variables var)
+ {
+ Class[] sig = m.getParameterTypes();
+
+ Label readArgs = new Label();
+ cv.visitLabel(readArgs);
+
+ boolean needcastcheck = false;
+
+ // ObjectInput in = call.getInputStream();
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class), "getInputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectInput.class), new Type[] {}));
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("objectinput"));
+
+ for (int i = 0; i < sig.length; i++)
+ {
+ // dup input stream
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("objectinput"));
+
+ Class readCls = sig[i].isPrimitive() ? sig[i] : Object.class;
+
+ // in.readFoo()
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectInput.class),
+ readMethod(sig[i]),
+ Type.getMethodDescriptor
+ (Type.getType(readCls), new Type [] {}));
+
+ if (! sig[i].isPrimitive() && ! sig[i].equals(Object.class))
+ {
+ needcastcheck = true;
+ cv.visitTypeInsn(Opcodes.CHECKCAST, typeArg(sig[i]));
+ }
+
+ // store arg in variable
+ cv.visitVarInsn
+ (storeOpcode(sig[i]), var.allocate(param(m, i), size(sig[i])));
+ }
+
+ var.deallocate("objectinput");
+
+ Label doCall = new Label();
+ Label closeInput = new Label();
+
+ cv.visitJumpInsn(Opcodes.JSR, closeInput);
+ cv.visitJumpInsn(Opcodes.GOTO, doCall);
+
+ // throw new UnmarshalException
+ Label handler = new Label();
+ cv.visitLabel(handler);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitLdcInsn("error unmarshalling arguments");
+ cv.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("toThrow"));
+ cv.visitJumpInsn(Opcodes.JSR, closeInput);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("toThrow"));
+ cv.visitInsn(Opcodes.ATHROW);
+
+ cv.visitTryCatchBlock
+ (readArgs, handler, handler, Type.getInternalName(IOException.class));
+ if (needcastcheck)
+ {
+ cv.visitTryCatchBlock
+ (readArgs, handler, handler,
+ Type.getInternalName(ClassCastException.class));
+ }
+
+ // finally block
+ cv.visitLabel(closeInput);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("retAddress"));
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "releaseInputStream",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ cv.visitVarInsn(Opcodes.RET, var.deallocate("retAddress"));
+ var.deallocate("toThrow");
+
+ // do the call using args stored as variables
+ cv.visitLabel(doCall);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remoteobj"));
+ for (int i = 0; i < sig.length; i++)
+ cv.visitVarInsn(loadOpcode(sig[i]), var.deallocate(param(m, i)));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL, Type.getInternalName(clazz), m.getName(),
+ Type.getMethodDescriptor(m));
+
+ Class returntype = m.getReturnType();
+ if (! returntype.equals(Void.TYPE))
+ {
+ cv.visitVarInsn
+ (storeOpcode(returntype), var.allocate("result", size(returntype)));
+ }
+
+ // write result to result stream
+ Label writeResult = new Label();
+ cv.visitLabel(writeResult);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitInsn(Opcodes.ICONST_1);
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getResultStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectOutput.class),
+ new Type[] { Type.BOOLEAN_TYPE }));
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ // out.writeFoo(result)
+ cv.visitVarInsn(loadOpcode(returntype), var.deallocate("result"));
+ Class writeCls = returntype.isPrimitive() ? returntype : Object.class;
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectOutput.class),
+ writeMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(writeCls) }));
+ }
+
+ cv.visitInsn(Opcodes.RETURN);
+
+ // throw new MarshalException
+ Label marshalHandler = new Label();
+ cv.visitLabel(marshalHandler);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(MarshalException.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitLdcInsn("error marshalling return");
+ cv.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(MarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ cv.visitInsn(Opcodes.ATHROW);
+ cv.visitTryCatchBlock
+ (writeResult, marshalHandler, marshalHandler,
+ Type.getInternalName(IOException.class));
+ }
+
+ private static String typeArg(Class cls)
+ {
+ if (cls.isArray())
+ return Type.getDescriptor(cls);
+
+ return Type.getInternalName(cls);
+ }
+
+ private static String readMethod(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not read void");
+
+ String method;
+ if (cls.equals(Boolean.TYPE))
+ method = "readBoolean";
+ else if (cls.equals(Byte.TYPE))
+ method = "readByte";
+ else if (cls.equals(Character.TYPE))
+ method = "readChar";
+ else if (cls.equals(Short.TYPE))
+ method = "readShort";
+ else if (cls.equals(Integer.TYPE))
+ method = "readInt";
+ else if (cls.equals(Long.TYPE))
+ method = "readLong";
+ else if (cls.equals(Float.TYPE))
+ method = "readFloat";
+ else if (cls.equals(Double.TYPE))
+ method = "readDouble";
+ else
+ method = "readObject";
+
+ return method;
+ }
+
+ private static String writeMethod(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not read void");
+
+ String method;
+ if (cls.equals(Boolean.TYPE))
+ method = "writeBoolean";
+ else if (cls.equals(Byte.TYPE))
+ method = "writeByte";
+ else if (cls.equals(Character.TYPE))
+ method = "writeChar";
+ else if (cls.equals(Short.TYPE))
+ method = "writeShort";
+ else if (cls.equals(Integer.TYPE))
+ method = "writeInt";
+ else if (cls.equals(Long.TYPE))
+ method = "writeLong";
+ else if (cls.equals(Float.TYPE))
+ method = "writeFloat";
+ else if (cls.equals(Double.TYPE))
+ method = "writeDouble";
+ else
+ method = "writeObject";
+
+ return method;
+ }
+
+ private static int returnOpcode(Class cls)
+ {
+ int returncode;
+ if (cls.equals(Boolean.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Byte.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Character.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Short.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Integer.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Long.TYPE))
+ returncode = Opcodes.LRETURN;
+ else if (cls.equals(Float.TYPE))
+ returncode = Opcodes.FRETURN;
+ else if (cls.equals(Double.TYPE))
+ returncode = Opcodes.DRETURN;
+ else if (cls.equals(Void.TYPE))
+ returncode = Opcodes.RETURN;
+ else
+ returncode = Opcodes.ARETURN;
+
+ return returncode;
+ }
+
+ private static int loadOpcode(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not load void");
+
+ int loadcode;
+ if (cls.equals(Boolean.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Byte.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Character.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Short.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Integer.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Long.TYPE))
+ loadcode = Opcodes.LLOAD;
+ else if (cls.equals(Float.TYPE))
+ loadcode = Opcodes.FLOAD;
+ else if (cls.equals(Double.TYPE))
+ loadcode = Opcodes.DLOAD;
+ else
+ loadcode = Opcodes.ALOAD;
+
+ return loadcode;
+ }
+
+ private static int storeOpcode(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not load void");
+
+ int storecode;
+ if (cls.equals(Boolean.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Byte.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Character.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Short.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Integer.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Long.TYPE))
+ storecode = Opcodes.LSTORE;
+ else if (cls.equals(Float.TYPE))
+ storecode = Opcodes.FSTORE;
+ else if (cls.equals(Double.TYPE))
+ storecode = Opcodes.DSTORE;
+ else
+ storecode = Opcodes.ASTORE;
+
+ return storecode;
+ }
+
+ private static String unboxMethod(Class primitive)
+ {
+ if (! primitive.isPrimitive())
+ throw new IllegalArgumentException("can not unbox nonprimitive");
+
+ String method;
+ if (primitive.equals(Boolean.TYPE))
+ method = "booleanValue";
+ else if (primitive.equals(Byte.TYPE))
+ method = "byteValue";
+ else if (primitive.equals(Character.TYPE))
+ method = "charValue";
+ else if (primitive.equals(Short.TYPE))
+ method = "shortValue";
+ else if (primitive.equals(Integer.TYPE))
+ method = "intValue";
+ else if (primitive.equals(Long.TYPE))
+ method = "longValue";
+ else if (primitive.equals(Float.TYPE))
+ method = "floatValue";
+ else if (primitive.equals(Double.TYPE))
+ method = "doubleValue";
+ else
+ throw new IllegalStateException("unknown primitive class " + primitive);
+
+ return method;
+ }
+
+ public static Class box(Class cls)
+ {
+ if (! cls.isPrimitive())
+ throw new IllegalArgumentException("can only box primitive");
+
+ Class box;
+ if (cls.equals(Boolean.TYPE))
+ box = Boolean.class;
+ else if (cls.equals(Byte.TYPE))
+ box = Byte.class;
+ else if (cls.equals(Character.TYPE))
+ box = Character.class;
+ else if (cls.equals(Short.TYPE))
+ box = Short.class;
+ else if (cls.equals(Integer.TYPE))
+ box = Integer.class;
+ else if (cls.equals(Long.TYPE))
+ box = Long.class;
+ else if (cls.equals(Float.TYPE))
+ box = Float.class;
+ else if (cls.equals(Double.TYPE))
+ box = Double.class;
+ else
+ throw new IllegalStateException("unknown primitive type " + cls);
+
+ return box;
+ }
+
+ private static int size(Class cls) {
+ if (cls.equals(Long.TYPE) || cls.equals(Double.TYPE))
+ return 2;
+ else
+ return 1;
+ }
+
+ /**
+ * Sort exceptions so the most general go last.
+ */
+ private Class[] sortExceptions(Class[] except)
+ {
+ for (int i = 0; i < except.length; i++)
+ {
+ for (int j = i + 1; j < except.length; j++)
+ {
+ if (except[i].isAssignableFrom(except[j]))
+ {
+ Class tmp = except[i];
+ except[i] = except[j];
+ except[j] = tmp;
+ }
+ }
+ }
+ return (except);
+ }
+
+ public void setup(boolean keep, boolean need11Stubs, boolean need12Stubs,
+ boolean iiop, boolean poa, boolean debug, boolean warnings,
+ boolean noWrite, boolean verbose, boolean force, String classpath,
+ String bootclasspath, String extdirs, String outputDirectory)
+ {
+ this.keep = keep;
+ this.need11Stubs = need11Stubs;
+ this.need12Stubs = need12Stubs;
+ this.verbose = verbose;
+ this.noWrite = noWrite;
+
+ // Set up classpath.
+ this.classpath = classpath;
+ StringTokenizer st =
+ new StringTokenizer(classpath, File.pathSeparator);
+ URL[] u = new URL[st.countTokens()];
+ for (int i = 0; i < u.length; i++)
+ {
+ String path = st.nextToken();
+ File f = new File(path);
+ try
+ {
+ u[i] = f.toURL();
+ }
+ catch (java.net.MalformedURLException mue)
+ {
+ logError("malformed classpath component " + path);
+ return;
+ }
+ }
+ loader = new URLClassLoader(u);
+
+ destination = outputDirectory;
+ }
+
+ private void findRemoteMethods()
+ throws RMICException
+ {
+ List rmeths = new ArrayList();
+ for (Class cur = clazz; cur != null; cur = cur.getSuperclass())
+ {
+ Class[] interfaces = cur.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ if (java.rmi.Remote.class.isAssignableFrom(interfaces[i]))
+ {
+ Class remoteInterface = interfaces[i];
+ if (verbose)
+ System.out.println
+ ("[implements " + remoteInterface.getName() + "]");
+
+ // check if the methods declare RemoteExceptions
+ Method[] meths = remoteInterface.getMethods();
+ for (int j = 0; j < meths.length; j++)
+ {
+ Method m = meths[j];
+ Class[] exs = m.getExceptionTypes();
+
+ boolean throwsRemote = false;
+ for (int k = 0; k < exs.length; k++)
+ {
+ if (exs[k].isAssignableFrom(RemoteException.class))
+ throwsRemote = true;
+ }
+
+ if (! throwsRemote)
+ {
+ throw new RMICException
+ ("Method " + m + " in interface " + remoteInterface
+ + " does not throw a RemoteException");
+ }
+
+ rmeths.add(m);
+ }
+
+ mRemoteInterfaces.add(remoteInterface);
+ }
+ }
+ }
+
+ // intersect exceptions for doubly inherited methods
+ boolean[] skip = new boolean[rmeths.size()];
+ for (int i = 0; i < skip.length; i++)
+ skip[i] = false;
+ List methrefs = new ArrayList();
+ for (int i = 0; i < rmeths.size(); i++)
+ {
+ if (skip[i]) continue;
+ Method current = (Method) rmeths.get(i);
+ MethodRef ref = new MethodRef(current);
+ for (int j = i+1; j < rmeths.size(); j++)
+ {
+ Method other = (Method) rmeths.get(j);
+ if (ref.isMatch(other))
+ {
+ ref.intersectExceptions(other);
+ skip[j] = true;
+ }
+ }
+ methrefs.add(ref);
+ }
+
+ // Convert into a MethodRef array and sort them
+ remotemethods = (MethodRef[])
+ methrefs.toArray(new MethodRef[methrefs.size()]);
+ Arrays.sort(remotemethods);
+ }
+
+ /**
+ * Prints an error to System.err and increases the error count.
+ */
+ private void logError(Exception theError)
+ {
+ logError(theError.getMessage());
+ if (verbose)
+ theError.printStackTrace(System.err);
+ }
+
+ /**
+ * Prints an error to System.err and increases the error count.
+ */
+ private void logError(String theError)
+ {
+ errorCount++;
+ System.err.println("error: " + theError);
+ }
+
+ private static String getPrettyName(Class cls)
+ {
+ StringBuilder str = new StringBuilder();
+ for (int count = 0;; count++)
+ {
+ if (! cls.isArray())
+ {
+ str.append(cls.getName());
+ for (; count > 0; count--)
+ str.append("[]");
+ return (str.toString());
+ }
+ cls = cls.getComponentType();
+ }
+ }
+
+ private static class MethodRef
+ implements Comparable
+ {
+ Method meth;
+ long hash;
+ List exceptions;
+ private String sig;
+
+ MethodRef(Method m) {
+ meth = m;
+ sig = Type.getMethodDescriptor(meth);
+ hash = RMIHashes.getMethodHash(m);
+ // add exceptions removing subclasses
+ exceptions = removeSubclasses(m.getExceptionTypes());
+ }
+
+ public int compareTo(Object obj) {
+ MethodRef that = (MethodRef) obj;
+ int name = this.meth.getName().compareTo(that.meth.getName());
+ if (name == 0) {
+ return this.sig.compareTo(that.sig);
+ }
+ return name;
+ }
+
+ public boolean isMatch(Method m)
+ {
+ if (!meth.getName().equals(m.getName()))
+ return false;
+
+ Class[] params1 = meth.getParameterTypes();
+ Class[] params2 = m.getParameterTypes();
+ if (params1.length != params2.length)
+ return false;
+
+ for (int i = 0; i < params1.length; i++)
+ if (!params1[i].equals(params2[i])) return false;
+
+ return true;
+ }
+
+ private static List removeSubclasses(Class[] classes)
+ {
+ List list = new ArrayList();
+ for (int i = 0; i < classes.length; i++)
+ {
+ Class candidate = classes[i];
+ boolean add = true;
+ for (int j = 0; j < classes.length; j++)
+ {
+ if (classes[j].equals(candidate))
+ continue;
+ else if (classes[j].isAssignableFrom(candidate))
+ add = false;
+ }
+ if (add) list.add(candidate);
+ }
+
+ return list;
+ }
+
+ public void intersectExceptions(Method m)
+ {
+ List incoming = removeSubclasses(m.getExceptionTypes());
+
+ List updated = new ArrayList();
+
+ for (int i = 0; i < exceptions.size(); i++)
+ {
+ Class outer = (Class) exceptions.get(i);
+ boolean addOuter = false;
+ for (int j = 0; j < incoming.size(); j++)
+ {
+ Class inner = (Class) incoming.get(j);
+
+ if (inner.equals(outer) || inner.isAssignableFrom(outer))
+ addOuter = true;
+ else if (outer.isAssignableFrom(inner))
+ updated.add(inner);
+ }
+
+ if (addOuter)
+ updated.add(outer);
+ }
+
+ exceptions = updated;
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/CompilationError.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/CompilationError.java
new file mode 100644
index 000000000..2bfea7cc4
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/CompilationError.java
@@ -0,0 +1,69 @@
+/* CompilationError.java -- Thrown on compilation error.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+/**
+ * This error is thrown when the target being compiled has illegal
+ * strutures.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class CompilationError extends Error
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Create error with explaining message and cause.
+ */
+ public CompilationError(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * Create error with explaining message
+ */
+ public CompilationError(String message)
+ {
+ super(message);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/Generator.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/Generator.java
new file mode 100644
index 000000000..ba659d2c5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/Generator.java
@@ -0,0 +1,145 @@
+/* Generator.java -- Generic code generator.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Contains basic methods, used in code generation.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class Generator
+{
+ /**
+ * Get resource with the given name, as string.
+ *
+ * @param name the resource name
+ * @return the resourse string (in subfolder /templates).
+ */
+ public String getResource(String name)
+ {
+ String resourcePath = "templates/" + name;
+ InputStream in = getClass().getResourceAsStream(resourcePath);
+
+ if (in == null)
+ throw new InternalError(getClass().getName() + ": no resource "
+ + resourcePath);
+
+ BufferedReader r = new BufferedReader(new InputStreamReader(in));
+ StringBuilder b = new StringBuilder();
+
+ String s;
+ try
+ {
+ while ((s = r.readLine()) != null)
+ {
+ b.append(s);
+ b.append('\n');
+ }
+ r.close();
+ }
+ catch (IOException e)
+ {
+ InternalError ierr = new InternalError("No expected resource " + name);
+ ierr.initCause(e);
+ throw ierr;
+ }
+
+ return b.toString();
+ }
+
+ /**
+ * Replace the variable references (starting from #) in the template string by
+ * the values, present in the given map. The strings, not present in the
+ * variable map, are ignored.
+ *
+ * @param template
+ * the template string
+ * @param variables
+ * the map of variables (name to value) to replace.
+ * @return the string with replaced values.
+ */
+ public String replaceAll(String template, Map variables)
+ {
+ BufferedReader r = new BufferedReader(new StringReader(template));
+ String s;
+ StringBuilder b = new StringBuilder(template.length());
+ try
+ {
+ Iterator iter;
+ Collection vars = variables.keySet();
+ while ((s = r.readLine()) != null)
+ {
+ // At least one variable must appear in the string to make
+ // the string scan sensible.
+ if (s.indexOf('#') >= 0)
+ {
+ iter = vars.iterator();
+ String variable;
+ while (iter.hasNext())
+ {
+ variable = (String) iter.next();
+ if (s.indexOf(variable) >= 0)
+ s = s.replaceAll(variable,
+ (String) variables.get(variable));
+ }
+ }
+ b.append(s);
+ b.append('\n');
+ }
+ r.close();
+ }
+ catch (IOException e)
+ {
+ // This should never happen.
+ InternalError ierr = new InternalError("");
+ ierr.initCause(e);
+ throw ierr;
+ }
+ return b.toString();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/GiopIo.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/GiopIo.java
new file mode 100644
index 000000000..c3b3bc0a4
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/GiopIo.java
@@ -0,0 +1,129 @@
+/* GiopIo.java -- Generates GIOP input/output statements.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+import java.rmi.Remote;
+
+import org.omg.CORBA.portable.ObjectImpl;
+
+/**
+ * Generates the code for reading and writing data over GIOP stream.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class GiopIo
+{
+ /**
+ * Get the statement for writing the variable of the given type to the GIOP ({@link org.omg.CORBA_2_3.portable.OutputStream) stream. The
+ * stream is always named "out".
+ *
+ * @param c
+ * the class of the object being written
+ * @param variable
+ * the variable, where the object value is stored
+ * @param r
+ * the parent generator, used to name the class
+ * @return the write statement.
+ */
+ public static String getWriteStatement(Class c, String variable, SourceGiopRmicCompiler r)
+ {
+ if (c.equals(boolean.class))
+ return "out.write_boolean(" + variable + ");";
+ if (c.equals(byte.class))
+ return "out.write_octet(" + variable + ");";
+ else if (c.equals(short.class))
+ return "out.write_int(" + variable + ");";
+ else if (c.equals(int.class))
+ return "out.write_long(" + variable + ");";
+ else if (c.equals(long.class))
+ return "out.write_long_long(" + variable + ");";
+ else if (c.equals(double.class))
+ return "out.write_double(" + variable + ");";
+ else if (c.equals(float.class))
+ return "out.write_float(" + variable + ");";
+ else if (c.equals(char.class))
+ return "out.write_char(" + variable + ");";
+ else if (Remote.class.isAssignableFrom(c))
+ return "Util.writeRemoteObject(out, " + variable + ");";
+ else if (ObjectImpl.class.isAssignableFrom(c))
+ return "out.write_Object(" + variable + ");";
+ else
+ return "out.write_value(" + variable + ", " + r.name(c) + ".class);";
+ }
+
+ /**
+ * Get the statement for reading the value of the given type from to the GIOP ({@link org.omg.CORBA_2_3.portable.InputStream) stream. The
+ * stream is always named "in".
+ *
+ * @param c
+ * the class of the object being written
+ * @param r
+ * the parent generator, used to name the class
+ * @return the right side of the read statement.
+ */
+ public static String getReadStatement(Class c, SourceGiopRmicCompiler r)
+ {
+ if (c.equals(boolean.class))
+ return "in.read_boolean();";
+ else if (c.equals(byte.class))
+ return "in.read_octet();";
+ else if (c.equals(short.class))
+ return "in.read_int();";
+ else if (c.equals(int.class))
+ return "in.read_long();";
+ else if (c.equals(long.class))
+ return "in.read_long_long();";
+ else if (c.equals(double.class))
+ return "in.read_double();";
+ else if (c.equals(float.class))
+ return "in.read_float();";
+ else if (c.equals(char.class))
+ return "in.read_char();";
+ else if (Remote.class.isAssignableFrom(c))
+ return "(" + r.name(c)
+ + ") PortableRemoteObject.narrow(in.read_Object()," + r.name(c)
+ + ".class);";
+ else if (ObjectImpl.class.isAssignableFrom(c))
+ return "in.read_Object();";
+ else
+ return "(" + r.name(c)
+ + ") in.read_value(" + r.name(c) + ".class);";
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/HashFinder.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/HashFinder.java
new file mode 100644
index 000000000..7b6fc9bb5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/HashFinder.java
@@ -0,0 +1,100 @@
+/* HashFinder.java -- finds the hash character.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+import java.util.HashSet;
+
+/**
+ * This class finds the hash character (the most different character in
+ * the passed array of strings). This character is used to accelerate the
+ * method invocation by name.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class HashFinder
+{
+ /**
+ * Find the hash char position in the given collection of strings.
+ *
+ * @param strings the string collection
+ *
+ * @return the optimal hash character position, always less then the
+ * length of the shortest string.
+ */
+ public int findHashCharPosition(String[] strings)
+ {
+ // Find the length of the shortest string:
+
+ int l = strings[0].length();
+ for (int i = 1; i < strings.length; i++)
+ {
+ if (strings[i].length() < l)
+ l = strings[i].length();
+ }
+
+ // Find the position with the smallest number of the matching characters:
+ HashSet[] charLists = new HashSet[l];
+
+ for (int i = 0; i < charLists.length; i++)
+ {
+ charLists[i] = new HashSet(strings.length);
+ }
+
+ for (int i = 0; i < strings.length; i++)
+ for (int p = 0; p < l; p++)
+ {
+ charLists[p].add(new Integer(strings[i].charAt(p)));
+ }
+
+ int m = 0;
+ int v = charLists[0].size();
+
+ for (int i = 1; i < charLists.length; i++)
+ {
+ // Replace on equality also, seeking the hash char closer to the end
+ // of line.
+ if (charLists[i].size()>=v)
+ {
+ m = i;
+ v = charLists[i].size();
+ }
+ }
+ return m;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java
new file mode 100644
index 000000000..868fc758e
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java
@@ -0,0 +1,293 @@
+/* Main.java -- RMI stub generator.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.util.ArrayList;
+
+/**
+ * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Main
+{
+ private boolean noWrite;
+ private boolean warnings = true;
+ private boolean verbose;
+ private boolean force;
+ private String classpath = ".";
+ private String outputDirectory = ".";
+ private boolean poa;
+ private boolean need11Stubs = false;
+ private boolean need12Stubs = true;
+ private boolean keep;
+ private boolean iiop;
+ /**
+ * Specifies whether or not JRMP mode was explicitly requested.
+ */
+ private boolean jrmp;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("rmic", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("nowarn", //$NON-NLS-1$
+ Messages.getString("Main.NoWarn")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ warnings = false;
+ }
+ });
+ parser.add(new Option("nowrite", //$NON-NLS-1$
+ Messages.getString("Main.NoWrite")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ noWrite = true;
+ }
+ });
+ parser.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ parser.add(new Option("d", //$NON-NLS-1$
+ Messages.getString("Main.DirOpt"), //$NON-NLS-1$
+ Messages.getString("Main.DirArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ outputDirectory = argument;
+ }
+ });
+ parser.add(new Option("classpath", //$NON-NLS-1$
+ Messages.getString("Main.ClasspathOpt"), //$NON-NLS-1$
+ Messages.getString("Main.ClasspathArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ classpath = argument;
+ }
+ });
+ parser.add(new Option("bootclasspath", //$NON-NLS-1$
+ Messages.getString("Main.BootclasspathOpt"), //$NON-NLS-1$
+ Messages.getString("Main.BootclasspathArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("extdirs", //$NON-NLS-1$
+ Messages.getString("Main.ExtdirsOpt"), //$NON-NLS-1$
+ Messages.getString("Main.ExtdirsArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("iiop", //$NON-NLS-1$
+ Messages.getString("Main.IIOP")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ iiop = true;
+ }
+ });
+ parser.add(new Option("always", //$NON-NLS-1$
+ Messages.getString("Main.Always")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ force = true;
+ }
+ });
+ parser.add(new Option("alwaysgenerate", //$NON-NLS-1$
+ Messages.getString("Main.AlwaysGenerate")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ force = true;
+ }
+ });
+ parser.add(new Option("nolocalstubs", //$NON-NLS-1$
+ Messages.getString("Main.NoLocalStubs")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("poa", //$NON-NLS-1$
+ Messages.getString("Main.POA")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ poa = true;
+ }
+ });
+ parser.add(new Option("keep", //$NON-NLS-1$
+ Messages.getString("Main.Keep")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ keep = true;
+ }
+ });
+ parser.add(new Option("keepgenerated", //$NON-NLS-1$
+ Messages.getString("Main.KeepGenerated")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ keep = true;
+ }
+ });
+ parser.add(new Option("v1.1", //$NON-NLS-1$
+ Messages.getString("Main.v11")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ need11Stubs = true;
+ need12Stubs = false;
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("v1.2", //$NON-NLS-1$
+ Messages.getString("Main.v12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("vcompat", //$NON-NLS-1$
+ Messages.getString("Main.vcompat")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ need11Stubs = true;
+ need12Stubs = true;
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("g", //$NON-NLS-1$
+ Messages.getString("Main.DebugInfo")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ String[] files = p.parse(args);
+
+ if (files.length == 0)
+ {
+ p.printHelp();
+ System.exit(1);
+ }
+
+ ArrayList backends = new ArrayList();
+
+ // FIXME: need an IDL RmicBackend
+ // FIXME: need a ClassGiopRmicCompiler RmicBackend
+ if (iiop)
+ {
+ backends.add(new SourceGiopRmicCompiler());
+
+ if (jrmp)
+ {
+ // Both IIOP and JRMP stubs were requested.
+ backends.add(new ClassRmicCompiler());
+ // FIXME: SourceRmicCompiler should support v1.1
+ if (keep)
+ backends.add(new SourceRmicCompiler());
+ }
+ }
+ else
+ {
+ backends.add(new ClassRmicCompiler());
+ if (keep)
+ backends.add(new SourceRmicCompiler());
+ }
+
+ for (int i = 0; i < backends.size(); i++)
+ {
+ RmicBackend b = (RmicBackend) backends.get(i);
+ b.setup(keep, need11Stubs, need12Stubs,
+ iiop, poa, false, warnings,
+ noWrite, verbose, force, classpath,
+ null, null, outputDirectory);
+ if (!b.run(files))
+ System.exit(1);
+ }
+ }
+
+ /**
+ * The RMI compiler entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmicprogram = new Main();
+ try
+ {
+ rmicprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/Messages.java
new file mode 100644
index 000000000..5e67dd163
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmic
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmic.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/MethodGenerator.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/MethodGenerator.java
new file mode 100644
index 000000000..27a4bd2e1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/MethodGenerator.java
@@ -0,0 +1,302 @@
+/* MethodGenerator.java -- Generates methods for GIOP rmic compiler.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+/**
+ * Keeps information about the single method and generates the code fragments,
+ * related to that method.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class MethodGenerator implements AbstractMethodGenerator
+{
+ /**
+ * The method being defined.
+ */
+ Method method;
+
+ /**
+ * The parent code generator.
+ */
+ SourceGiopRmicCompiler rmic;
+
+ /**
+ * The previous method in the list, null for the first element.
+ * Used to avoid repretetive inclusion of the same hash code label.
+ */
+ MethodGenerator previous = null;
+
+ /**
+ * The hash character position.
+ */
+ int hashCharPosition;
+
+ /**
+ * Create the new method generator for the given method.
+ *
+ * @param aMethod
+ * the related method.
+ * @param aRmic
+ * the Rmic generator instance, where more class - related
+ * information is defined.
+ */
+ public MethodGenerator(Method aMethod, SourceGiopRmicCompiler aRmic)
+ {
+ method = aMethod;
+ rmic = aRmic;
+ }
+
+ /**
+ * Get the method name.
+ *
+ * @return the name of the method.
+ */
+ public String getGiopMethodName()
+ {
+ String m = method.getName();
+ if (m.startsWith("get"))
+ return "_get_J" + m.substring("get".length());
+ else if (m.startsWith("set"))
+ return "_set_J" + m.substring("set".length());
+ else
+ return m;
+ }
+
+ /**
+ * Get the method parameter declaration.
+ *
+ * @return the string - method parameter declaration.
+ */
+ public String getArgumentList()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the method parameter list only (no type declarations). This is used to
+ * generate the method invocations statement.
+ *
+ * @return the string - method parameter list.
+ */
+ public String getArgumentNames()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the list of exceptions, thrown by this method.
+ *
+ * @return the list of exceptions.
+ */
+ public String getThrows()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Class[] args = method.getExceptionTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Generate this method for the Stub class.
+ *
+ * @return the method body for the stub class.
+ */
+ public String generateStubMethod()
+ {
+ String templateName;
+
+ Properties vars = new Properties(rmic.vars);
+ vars.put("#return_type", rmic.name(method.getReturnType()));
+ vars.put("#method_name", method.getName());
+ vars.put("#giop_method_name", getGiopMethodName());
+ vars.put("#argument_list", getArgumentList());
+ vars.put("#argument_names", getArgumentNames());
+
+ vars.put("#argument_write", getStubParaWriteStatement());
+
+ if (method.getReturnType().equals(void.class))
+ vars.put("#read_return", "return;");
+ else
+ vars.put("#read_return",
+ "return "
+ + GiopIo.getReadStatement(method.getReturnType(), rmic));
+ String thr = getThrows();
+ if (thr.length() > 0)
+ vars.put("#throws", "\n throws " + thr);
+ else
+ vars.put("#throws", "");
+
+ if (method.getReturnType().equals(void.class))
+ templateName = "StubMethodVoid.jav";
+ else
+ {
+ vars.put("#write_result",
+ GiopIo.getWriteStatement(method.getReturnType(), "result",
+ rmic));
+ templateName = "StubMethod.jav";
+ }
+
+ String template = rmic.getResource(templateName);
+ String generated = rmic.replaceAll(template, vars);
+ return generated;
+ }
+
+ /**
+ * Generate this method handling fragment for the Tie class.
+ *
+ * @return the fragment to handle this method for the Tie class.
+ */
+ public String generateTieMethod()
+ {
+ String templateName;
+
+ Properties vars = new Properties(rmic.vars);
+ vars.put("#return_type", rmic.name(method.getReturnType()));
+ vars.put("#method_name", method.getName());
+ vars.put("#giop_method_name", getGiopMethodName());
+ vars.put("#argument_list", getArgumentList());
+ vars.put("#argument_names", getArgumentNames());
+
+ vars.put("#argument_write", getStubParaWriteStatement());
+
+ if (previous == null || previous.getHashChar()!=getHashChar())
+ vars.put("#hashCodeLabel"," case '"+getHashChar()+"':");
+ else
+ vars.put("#hashCodeLabel"," // also '"+getHashChar()+"':");
+
+ if (method.getReturnType().equals(void.class))
+ templateName = "TieMethodVoid.jav";
+ else
+ {
+ vars.put("#write_result",
+ GiopIo.getWriteStatement(method.getReturnType(), "result",
+ rmic));
+ templateName = "TieMethod.jav";
+ }
+ vars.put("#read_and_define_args", getRda());
+
+ String template = rmic.getResource(templateName);
+ String generated = rmic.replaceAll(template, vars);
+ return generated;
+ }
+
+ /**
+ * Generate sentences for Reading and Defining Arguments.
+ *
+ * @return the sequence of sentences for reading and defining arguments.
+ */
+ public String getRda()
+ {
+ StringBuilder b = new StringBuilder();
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" ");
+ b.append(rmic.name(args[i]));
+ b.append(" ");
+ b.append("p"+i);
+ b.append(" = ");
+ b.append(GiopIo.getReadStatement(args[i], rmic));
+ if (i<args.length-1)
+ b.append("\n");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the write statement for writing parameters inside the stub.
+ *
+ * @return the write statement.
+ */
+ public String getStubParaWriteStatement()
+ {
+ StringBuilder b = new StringBuilder();
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" ");
+ b.append(GiopIo.getWriteStatement(args[i], "p" + i, rmic));
+ b.append("\n");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the hash char.
+ */
+ public char getHashChar()
+ {
+ return getGiopMethodName().charAt(hashCharPosition);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/RMICException.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/RMICException.java
new file mode 100644
index 000000000..ca9983d0a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/RMICException.java
@@ -0,0 +1,70 @@
+/* RMICException.java --
+ Copyright (c) 2003, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmic;
+
+/**
+ * Thrown by the underlying compiler used by RMIC when it fails to compile a
+ * file.
+ *
+ * @author Dalibor Topic (robilad@kaffe.org)
+ */
+public class RMICException
+ extends Exception
+{
+ /**
+ * Create an exception with a message. The cause remains uninitialized.
+ *
+ * @param message the message string
+ * @see #initCause(Throwable)
+ */
+ public RMICException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param message the message string
+ * @param cause the cause of this exception
+ */
+ public RMICException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
new file mode 100644
index 000000000..e02f086ef
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
@@ -0,0 +1,297 @@
+/* MethodGenerator.java -- Generates methods for rmi compiler.
+ Copyright (C) 2006 Free Software Foundation
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
+import gnu.java.rmi.server.RMIHashes;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+/**
+ * Keeps information about the single method and generates the code fragments,
+ * related to that method.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class RmiMethodGenerator
+ implements AbstractMethodGenerator
+{
+ /**
+ * The method being defined.
+ */
+ Method method;
+
+ /**
+ * The parent code generator.
+ */
+ SourceRmicCompiler rmic;
+
+ /**
+ * Create the new method generator for the given method.
+ *
+ * @param aMethod the related method.
+ * @param aRmic the Rmic generator instance, where more class - related
+ * information is defined.
+ */
+ public RmiMethodGenerator(Method aMethod, SourceRmicCompiler aRmic)
+ {
+ method = aMethod;
+ rmic = aRmic;
+ if (method.getParameterTypes().length == 0)
+ rmic.addZeroSizeObjecArray = true;
+ }
+
+ /**
+ * Get the method parameter declaration.
+ *
+ * @return the string - method parameter declaration.
+ */
+ public String getArgumentList()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the method parameter list only (no type declarations). This is used to
+ * generate the method invocations statement.
+ *
+ * @return the string - method parameter list.
+ */
+ public String getArgumentNames()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the list of exceptions, thrown by this method.
+ *
+ * @return the list of exceptions.
+ */
+ public String getThrows()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Class[] args = method.getExceptionTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Generate this method for the Stub class.
+ *
+ * @return the method body for the stub class.
+ */
+ public String generateStubMethod()
+ {
+ String templateName;
+
+ Properties vars = new Properties(rmic.vars);
+ vars.put("#return_type", rmic.name(method.getReturnType()));
+ vars.put("#method_name", method.getName());
+ vars.put("#method_hash", getMethodHashCode());
+ vars.put("#argument_list", getArgumentList());
+ vars.put("#object_arg_list", getArgListAsObjectArray());
+ vars.put("#declaring_class", rmic.name(method.getDeclaringClass()));
+ vars.put("#class_arg_list", getArgListAsClassArray());
+
+ String thr = getThrows();
+ if (thr.length() > 0)
+ vars.put("#throws", "\n throws " + thr);
+ else
+ vars.put("#throws", "");
+
+ if (method.getReturnType().equals(void.class))
+ templateName = "Stub_12MethodVoid.jav";
+ else
+ {
+ templateName = "Stub_12Method.jav";
+ vars.put("#return_statement", getReturnStatement());
+ }
+
+ String template = rmic.getResource(templateName);
+ String generated = rmic.replaceAll(template, vars);
+ return generated;
+ }
+
+ /**
+ * Generate sentences for Reading and Defining Arguments.
+ *
+ * @return the sequence of sentences for reading and defining arguments.
+ */
+ public String getStaticMethodDeclarations()
+ {
+ StringBuilder b = new StringBuilder();
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" ");
+ b.append(rmic.name(args[i]));
+ b.append(" ");
+ b.append("p" + i);
+ b.append(" = ");
+ if (i < args.length - 1)
+ b.append("\n");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the write statement for writing parameters inside the stub.
+ *
+ * @return the write statement.
+ */
+ public String getArgListAsObjectArray()
+ {
+ Class[] args = method.getParameterTypes();
+
+ if (args.length==0)
+ return "NO_ARGS";
+
+ StringBuilder b = new StringBuilder("new Object[] {");
+
+ for (int i = 0; i < args.length; i++)
+ {
+ if (!args[i].isPrimitive())
+ b.append("p"+i);
+ else
+ {
+ b.append("new "+rmic.name(WrapUnWrapper.getWrappingClass(args[i])));
+ b.append("(p"+i+")");
+ }
+ if (i<args.length-1)
+ b.append(", ");
+ }
+ b.append("}");
+ return b.toString();
+ }
+
+ /**
+ * Get the return statement, assuming that the returned object is placed into
+ * the variable "result".
+ */
+ public String getReturnStatement()
+ {
+ Class r = method.getReturnType();
+ if (r.equals(void.class))
+ return "";
+ else
+ {
+ if (r.isPrimitive())
+ {
+ String wcd = rmic.name(WrapUnWrapper.getWrappingClass(r));
+ return "return ((" + wcd + ") result)."
+ + WrapUnWrapper.getUnwrappingMethod(r) + ";";
+ }
+ else
+ return "return (" + rmic.name(r) + ") result;";
+ }
+ }
+
+ /**
+ * Get argument list as class array.
+ */
+ public String getArgListAsClassArray()
+ {
+ StringBuilder b = new StringBuilder();
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ b.append(".class");
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * RMI ties (previously named Skeletons) are no longer used since v 1.2. This
+ * method should never be called.
+ */
+ public String generateTieMethod()
+ {
+ throw new InternalError();
+ }
+
+ /**
+ * Get the method hash code.
+ */
+ public String getMethodHashCode()
+ {
+ return RMIHashes.getMethodHash(method)+"L";
+ }
+
+ /**
+ * Additional processing of the stub name (nothing to do for JRMP stubs).
+ */
+ public String convertStubName(String name)
+ {
+ return name;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/RmicBackend.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/RmicBackend.java
new file mode 100644
index 000000000..92f982d53
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/RmicBackend.java
@@ -0,0 +1,48 @@
+/* RmicBackend.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmic;
+public interface RmicBackend
+{
+ void setup(boolean keep, boolean need11Stubs, boolean need12Stubs,
+ boolean iiop, boolean poa, boolean debug, boolean warnings,
+ boolean noWrite, boolean verbose, boolean force, String classpath,
+ String bootclasspath, String extdirs, String outputDirectory);
+
+ boolean run(String[] inputFiles);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
new file mode 100644
index 000000000..dd35c2bd5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
@@ -0,0 +1,694 @@
+/* SourceGiopRmicCompiler -- Central GIOP-based RMI stub and tie compiler class.
+ Copyright (C) 2006, 2008 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+/**
+ * Provides the extended rmic functionality to generate the POA - based classes
+ * for GIOP (javax.rmi.CORBA package).
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class SourceGiopRmicCompiler
+ extends Generator implements Comparator, RmicBackend
+{
+ /** The package name. */
+ protected String packag;
+
+ /**
+ * The "basic" name (normally, the interface name, unless several Remote -
+ * derived interfaces are implemented.
+ */
+ protected String name;
+
+ /**
+ * The name (without package) of the class, passed as the parameter.
+ */
+ protected String implName;
+
+ /**
+ * The proposed name for the stub.
+ */
+ protected String stubName;
+
+ /**
+ * The Remote's, implemented by this class.
+ */
+ protected Collection implementedRemotes = new HashSet();
+
+ /**
+ * The extra classes that must be imported.
+ */
+ protected Collection extraImports = new HashSet();
+
+ /**
+ * The methods we must implement.
+ */
+ protected Collection methods = new HashSet();
+
+ /**
+ * The map of all code generator variables.
+ */
+ public Properties vars = new Properties();
+
+ /**
+ * If this flag is set (true by default), the compiler generates the Servant
+ * based classes. If set to false, the compiler generates the old style
+ * ObjectImpl based classes.
+ */
+ protected boolean poaMode = true;
+
+ /**
+ * If this flag is set (true by default), the compiler emits warnings.
+ */
+ protected boolean warnings = true;
+
+ /**
+ * If this flag is set (false by default), the compiler does not
+ * write output files.
+ */
+ protected boolean noWrite = false;
+
+ /**
+ * If this flag is set (false by default), the compiler keeps source
+ * output files. For SourceGiopRmicCompiler this overrides
+ * -nowrite, since -nowrite doesn't apply to sources kept with
+ * -keep.
+ */
+ protected boolean keep = false;
+
+ /**
+ * Verbose output
+ */
+ protected boolean verbose = false;
+
+ /**
+ * Force mode - do not check the exceptions
+ */
+ protected boolean force = false;
+
+ /**
+ * The output directory for generated files.
+ */
+ protected String outputDirectory;
+
+ /**
+ * The class loader to load the class being compiled.
+ */
+ ClassLoader classLoader;
+
+ /**
+ * Clear data, preparing for the next compilation.
+ */
+ public synchronized void reset()
+ {
+ packag = name = implName = stubName = null;
+ implementedRemotes.clear();
+ extraImports.clear();
+ methods.clear();
+ vars.clear();
+ }
+
+ /**
+ * Set the class path (handle the -classpath key)
+ *
+ * @param classPath the class path to set.
+ */
+ public void setClassPath(String classPath)
+ {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator,
+ true);
+ ArrayList urls = new ArrayList(tok.countTokens());
+ String s = null;
+ try
+ {
+ while (tok.hasMoreTokens())
+ {
+ s = tok.nextToken();
+ if (s.equals(File.pathSeparator))
+ urls.add(new File(".").toURL());
+ else
+ {
+ urls.add(new File(s).toURL());
+ if (tok.hasMoreTokens())
+ {
+ // Skip the separator.
+ tok.nextToken();
+ // If the classpath ended with a separator,
+ // append the current directory.
+ if (! tok.hasMoreTokens())
+ urls.add(new File(".").toURL());
+ }
+ }
+ }
+ }
+ catch (MalformedURLException ex)
+ {
+ System.err.println("Malformed path '" + s + "' in classpath '"
+ + classPath + "'");
+ System.exit(1);
+ }
+ URL[] u = new URL[urls.size()];
+ for (int i = 0; i < u.length; i++)
+ {
+ u[i] = (URL) urls.get(i);
+ }
+
+ classLoader = new URLClassLoader(u, classLoader);
+ }
+
+ /**
+ * Loads the class with the given name (uses class path, if applicable)
+ *
+ * @param name the name of the class.
+ */
+ public Class loadClass(String name)
+ {
+ ClassLoader loader = classLoader;
+ if (loader == null)
+ loader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ return loader.loadClass(name);
+ }
+ catch (ClassNotFoundException e)
+ {
+ System.err.println(name+" not found on "+loader);
+ System.exit(1);
+ // Unreacheable code.
+ return null;
+ }
+ }
+
+ /**
+ * Compile the given class (the instance of Remote), generating the stub and
+ * tie for it.
+ *
+ * @param remote
+ * the class to compile.
+ */
+ public synchronized void compile(Class remote)
+ {
+ reset();
+ String s;
+
+ // Get the package.
+ s = remote.getName();
+ int p = s.lastIndexOf('.');
+ if (p < 0)
+ {
+ // Root package.
+ packag = "";
+ implName = name = s;
+ }
+ else
+ {
+ packag = s.substring(0, p);
+ implName = name = s.substring(p + 1);
+ }
+
+ name = convertStubName(name);
+
+ stubName = name;
+
+ vars.put("#name", name);
+ vars.put("#package", packag);
+ vars.put("#implName", implName);
+
+ if (verbose)
+ System.out.println("Package " + packag + ", name " + name + " impl "
+ + implName);
+
+ // Get the implemented remotes.
+ Class[] interfaces = remote.getInterfaces();
+
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ if (Remote.class.isAssignableFrom(interfaces[i]))
+ {
+ if (! interfaces[i].equals(Remote.class))
+ {
+ implementedRemotes.add(interfaces[i]);
+ }
+ }
+ }
+
+ vars.put("#idList", getIdList(implementedRemotes));
+
+ // Collect and process methods.
+ Iterator iter = implementedRemotes.iterator();
+
+ while (iter.hasNext())
+ {
+ Class c = (Class) iter.next();
+ Method[] m = c.getMethods();
+
+ // Check if throws RemoteException.
+ for (int i = 0; i < m.length; i++)
+ {
+ Class[] exc = m[i].getExceptionTypes();
+ boolean remEx = false;
+
+ for (int j = 0; j < exc.length; j++)
+ {
+ if (exc[j].isAssignableFrom(RemoteException.class))
+ {
+ remEx = true;
+ break;
+ }
+ }
+ if (! remEx && !force)
+ throw new CompilationError(m[i].getName() + ", defined in "
+ + c.getName()
+ + ", does not throw "
+ + RemoteException.class.getName());
+ AbstractMethodGenerator mm = createMethodGenerator(m[i]);
+ methods.add(mm);
+ }
+ }
+ }
+
+ /**
+ * Create the method generator for the given method.
+ *
+ * @param m the method
+ *
+ * @return the created method generator
+ */
+ protected AbstractMethodGenerator createMethodGenerator(Method m)
+ {
+ return new MethodGenerator(m, this);
+ }
+
+ /**
+ * Get the name of the given class. The class is added to imports, if not
+ * already present and not from java.lang and not from the current package.
+ *
+ * @param nameIt
+ * the class to name
+ * @return the name of class as it should appear in java language
+ */
+ public synchronized String name(Class nameIt)
+ {
+ if (nameIt.isArray())
+ {
+ // Mesure dimensions:
+ int dimension = 0;
+ Class finalComponent = nameIt;
+ while (finalComponent.isArray())
+ {
+ finalComponent = finalComponent.getComponentType();
+ dimension++;
+ }
+
+ StringBuilder brackets = new StringBuilder();
+
+ for (int i = 0; i < dimension; i++)
+ {
+ brackets.append("[]");
+ }
+
+ return name(finalComponent) + " " + brackets;
+ }
+ else
+ {
+ String n = nameIt.getName();
+ if (! nameIt.isArray() && ! nameIt.isPrimitive())
+ if (! n.startsWith("java.lang")
+ && ! (packag != null && n.startsWith(packag)))
+ extraImports.add(n);
+
+ int p = n.lastIndexOf('.');
+ if (p < 0)
+ return n;
+ else
+ return n.substring(p + 1);
+ }
+ }
+
+ /**
+ * Get the RMI-style repository Id for the given class.
+ *
+ * @param c
+ * the interface, for that the repository Id must be created.
+ * @return the repository id
+ */
+ public String getId(Class c)
+ {
+ return "RMI:" + c.getName() + ":0000000000000000";
+ }
+
+ /**
+ * Get repository Id string array declaration.
+ *
+ * @param remotes
+ * the collection of interfaces
+ * @return the fully formatted string array.
+ */
+ public String getIdList(Collection remotes)
+ {
+ StringBuilder b = new StringBuilder();
+
+ // Keep the Ids sorted, ensuring, that the same order will be preserved
+ // between compilations.
+ TreeSet sortedIds = new TreeSet();
+
+ Iterator iter = remotes.iterator();
+ while (iter.hasNext())
+ {
+ sortedIds.add(getId((Class) iter.next()));
+ }
+
+ iter = sortedIds.iterator();
+ while (iter.hasNext())
+ {
+ b.append(" \"" + iter.next() + "\"");
+ if (iter.hasNext())
+ b.append(", \n");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Generate stub. Can only be called from {@link #compile}.
+ *
+ * @return the string, containing the text of the generated stub.
+ */
+ public String generateStub()
+ {
+ String template = getResource("Stub.jav");
+
+ // Generate methods.
+ StringBuilder b = new StringBuilder();
+ Iterator iter = methods.iterator();
+ while (iter.hasNext())
+ {
+ AbstractMethodGenerator m = (AbstractMethodGenerator) iter.next();
+ b.append(m.generateStubMethod());
+ }
+
+ vars.put("#stub_methods", b.toString());
+ vars.put("#imports", getImportStatements());
+ vars.put("#interfaces", getAllInterfaces());
+
+ String output = replaceAll(template, vars);
+ return output;
+ }
+
+ /**
+ * Get the list of all interfaces, implemented by the class, that are
+ * derived from Remote.
+ *
+ * @return the string - all interfaces.
+ */
+ public String getAllInterfaces()
+ {
+ StringBuilder b = new StringBuilder();
+ Iterator iter = implementedRemotes.iterator();
+
+ while (iter.hasNext())
+ {
+ b.append(name((Class) iter.next()));
+ if (iter.hasNext())
+ b.append(", ");
+ }
+
+ return b.toString();
+ }
+
+ /**
+ * Generate Tie. Can only be called from {@link #compile}.
+ *
+ * @return the string, containing the text of the generated Tie.
+ */
+ public String generateTie()
+ {
+ String template;
+ if (poaMode)
+ template = getResource("Tie.jav");
+ else
+ template = getResource("ImplTie.jav");
+
+ // Generate methods.
+ HashFinder hashFinder = new HashFinder();
+
+ // Find the hash character position:
+ Iterator iter = methods.iterator();
+ String[] names = new String[methods.size()];
+ int p = 0;
+
+ for (int i = 0; i < names.length; i++)
+ names[i] = ((MethodGenerator) iter.next()).getGiopMethodName();
+
+ int hashCharPosition = hashFinder.findHashCharPosition(names);
+
+ iter = methods.iterator();
+ while (iter.hasNext())
+ ((MethodGenerator) iter.next()).hashCharPosition = hashCharPosition;
+
+ vars.put("#hashCharPos", Integer.toString(hashCharPosition));
+
+ ArrayList sortedMethods = new ArrayList(methods);
+ Collections.sort(sortedMethods, this);
+
+ iter = sortedMethods.iterator();
+
+ StringBuilder b = new StringBuilder();
+
+ MethodGenerator prev = null;
+
+ while (iter.hasNext())
+ {
+ MethodGenerator m = (MethodGenerator) iter.next();
+ m.previous = prev;
+ m.hashCharPosition = hashCharPosition;
+ prev = m;
+ b.append(m.generateTieMethod());
+ }
+
+ vars.put("#tie_methods", b.toString());
+
+ vars.put("#imports", getImportStatements());
+
+ String output = replaceAll(template, vars);
+ return output;
+ }
+
+ public int compare(Object a, Object b)
+ {
+ MethodGenerator g1 = (MethodGenerator) a;
+ MethodGenerator g2 = (MethodGenerator) b;
+
+ return g1.getHashChar() - g2.getHashChar();
+ }
+
+ /**
+ * Import the extra classes, used as the method parameters and return values.
+ *
+ * @return the additional import block.
+ */
+ protected String getImportStatements()
+ {
+ TreeSet imp = new TreeSet();
+
+ Iterator it = extraImports.iterator();
+ while (it.hasNext())
+ {
+ String ic = it.next().toString();
+ imp.add("import " + ic + ";\n");
+ }
+
+ StringBuilder b = new StringBuilder();
+ it = imp.iterator();
+
+ while (it.hasNext())
+ {
+ b.append(it.next());
+ }
+ return b.toString();
+ }
+
+ /**
+ * If this flag is set (true by default), the compiler generates the Servant
+ * based classes. If set to false, the compiler generates the old style
+ * ObjectImpl based classes.
+ */
+ public void setPoaMode(boolean mode)
+ {
+ poaMode = mode;
+ }
+
+ /**
+ * Set the verbose output mode (false by default)
+ *
+ * @param isVerbose the verbose output mode
+ */
+ public void setVerbose(boolean isVerbose)
+ {
+ verbose = isVerbose;
+ }
+
+ /**
+ * If this flag is set (true by default), the compiler emits warnings.
+ */
+ public void setWarnings(boolean warn)
+ {
+ warnings = warn;
+ }
+
+ /**
+ * Set the error ignore mode.
+ */
+ public void setForce(boolean isforce)
+ {
+ force = isforce;
+ }
+
+ /**
+ * Get the package name.
+ */
+ public String getPackageName()
+ {
+ return packag;
+ }
+
+ /**
+ * Get the proposed stub name
+ */
+ public String getStubName()
+ {
+ return stubName;
+ }
+
+ /**
+ * Additional processing of the stub name.
+ */
+ public String convertStubName(String name)
+ {
+ // Drop the Impl suffix, if one exists.
+ if (name.endsWith("Impl"))
+ return name.substring(0, name.length() - "Impl".length());
+ else
+ return name;
+ }
+
+ /**
+ * Assumes that output directory is already created.
+ */
+ protected boolean outputTie(File fw, Class c)
+ {
+ try
+ {
+ String tie = generateTie();
+ String tieName = "_" + name(c) + "_Tie.java";
+
+ OutputStream out = new FileOutputStream(new File(fw, tieName));
+ out.write(tie.getBytes());
+ out.close();
+ }
+ catch (IOException ioex)
+ {
+ System.err.println("Output path not accessible");
+ ioex.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ public void setup(boolean keep, boolean need11Stubs, boolean need12Stubs,
+ boolean iiop, boolean poa, boolean debug, boolean warnings,
+ boolean noWrite, boolean verbose, boolean force, String classpath,
+ String bootclasspath, String extdirs, String outputDirectory)
+ {
+ setWarnings(warnings);
+ setVerbose(verbose);
+ setForce(force);
+ setClassPath(classpath);
+ setPoaMode(poa);
+ this.outputDirectory = outputDirectory;
+ this.noWrite = noWrite;
+ this.keep = keep;
+ }
+
+ public boolean run(String[] inputFiles)
+ {
+ for (int i = 0; i < inputFiles.length; i++)
+ {
+ reset();
+ Class c = loadClass(inputFiles[i]);
+
+ compile(c);
+ String packag = getPackageName().replace('.', '/');
+ File fw = new File(outputDirectory, packag);
+
+ // Generate stub.
+ String stub = generateStub();
+ String subName = getStubName() + "_Stub.java";
+
+ // -keep overrides -nowrite for sources.
+ if (!noWrite || keep)
+ {
+ try
+ {
+ fw.mkdirs();
+ OutputStream out = new FileOutputStream(new File(fw,
+ subName));
+ out.write(stub.getBytes());
+ out.close();
+
+ // Generate tie
+ if (!outputTie(fw, c))
+ return false;
+ }
+ catch (IOException ioex)
+ {
+ System.err.println("Output path not accessible");
+ ioex.printStackTrace();
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java
new file mode 100644
index 000000000..413d91ad2
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java
@@ -0,0 +1,189 @@
+/* SourceRmicCompiler.java -- RMI stub generator for java.rmi.*
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmic;
+
+import java.lang.reflect.Method;
+import java.io.File;
+import java.util.Iterator;
+
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
+
+/**
+ * RMI stub source code generator, required to support java.rmi.*
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class SourceRmicCompiler extends SourceGiopRmicCompiler
+{
+ /**
+ * If true, the zero size object array is declared in the stub to reduce
+ * garbage generation.
+ */
+ public boolean addZeroSizeObjecArray;
+
+ /**
+ * Generate a RMI stub.
+ *
+ * @return the string, containing the text of the generated stub.
+ */
+ public String generateStub()
+ {
+ String template = getResource("Stub_12.jav");
+
+ // Generate methods.
+ StringBuilder b = new StringBuilder();
+ Iterator iter = methods.iterator();
+ while (iter.hasNext())
+ {
+ RmiMethodGenerator m = (RmiMethodGenerator) iter.next();
+ b.append(m.generateStubMethod());
+ }
+
+ vars.put("#stub_methods", b.toString());
+ vars.put("#imports", getImportStatements());
+ vars.put("#interfaces", getAllInterfaces());
+ vars.put("#stub_method_declarations", getStubMethodDeclarations());
+ vars.put("#stub_method_initializations", getStubMethodInitializations());
+ if (addZeroSizeObjecArray)
+ {
+ vars.put("#zeroSizeObjecArray",
+ "private static final Object[] NO_ARGS = new Object[0];");
+ vars.put("#zeroSizeClassArray",
+ "final Class[] NO_ARGSc = new Class[0];");
+ }
+ else
+ {
+ vars.put("#zeroSizeObjecArray","");
+ vars.put("#zeroSizeClassArray","");
+ }
+
+ String output = replaceAll(template, vars);
+ return output;
+ }
+
+ /**
+ * Create a method generator, applicable for RMI stub methods.
+ */
+ protected AbstractMethodGenerator createMethodGenerator(Method m)
+ {
+ return new RmiMethodGenerator(m, this);
+ }
+
+ /**
+ * Get the stub method declarations.
+ */
+ public String getStubMethodDeclarations()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Iterator iter = methods.iterator();
+
+ while (iter.hasNext())
+ {
+ RmiMethodGenerator method = (RmiMethodGenerator) iter.next();
+ b.append(" ");
+ b.append("private static final Method met_");
+ b.append(method.method.getName());
+ b.append(';');
+ if (iter.hasNext())
+ b.append('\n');
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get stub method initializations. These must be done in a try-catch
+ * statement to catch {@link NoSuchMethodException}.
+ */
+ public String getStubMethodInitializations()
+ {
+ StringBuilder b = new StringBuilder();
+
+ Iterator iter = methods.iterator();
+
+ while (iter.hasNext())
+ {
+ RmiMethodGenerator method = (RmiMethodGenerator) iter.next();
+ b.append(" ");
+ b.append("met_");
+ b.append(method.method.getName());
+ b.append(" =\n ");
+ b.append(name(method.method.getDeclaringClass()));
+ b.append(".class.getMethod(");
+ b.append('"');
+ b.append(method.method.getName());
+ b.append("\", ");
+ if (method.method.getParameterTypes().length == 0)
+ b.append("NO_ARGSc);");
+ else
+ {
+ b.append("new Class[]\n {\n ");
+ b.append(method.getArgListAsClassArray());
+ b.append("\n }");
+ b.append(");");
+ }
+ b.append('\n');
+ }
+ return b.toString();
+ }
+
+ /**
+ * Prepare for the compilation of the next class.
+ */
+ public void reset()
+ {
+ addZeroSizeObjecArray = false;
+ super.reset();
+ }
+
+ /**
+ * Additional processing of the stub name (nothing to do for JRMP stubs).
+ */
+ public String convertStubName(String name)
+ {
+ return name;
+ }
+
+ /**
+ * Override to do nothing.
+ */
+ protected boolean outputTie(File fw, Class c)
+ {
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java
new file mode 100644
index 000000000..1fc6a8095
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java
@@ -0,0 +1,154 @@
+/* Variables.java --
+ Copyright (c) 2004, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmic;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+class Variables
+{
+ private final HashSet free = new HashSet();
+ private final HashMap names = new HashMap();
+ private final HashSet wides = new HashSet();
+ private final HashSet declared = new HashSet();
+ private boolean allocated = false;
+
+ public void declare(Object name)
+ {
+ declare(name, 1);
+ }
+
+ public void declareWide(Object name)
+ {
+ declare(name, 2);
+ }
+
+ public void declare(Object name, int size)
+ {
+ if (allocated)
+ throw new IllegalStateException("cannot declare after allocating");
+ if (size != 1 && size != 2)
+ throw new IllegalArgumentException("size must be 1 or 2");
+ if (names.containsKey(name))
+ throw new IllegalStateException("already allocated " + name);
+
+ allocateNew(name, size);
+ declared.add(name);
+ }
+
+ private int allocateNew(Object name, int size)
+ {
+ // total allocation size is first unallocated slot
+ int i = free.size() + names.size() + wides.size();
+ names.put(name, new Integer(i));
+ if (size == 2) wides.add(name);
+ return i;
+ }
+
+ public int allocate(Object name)
+ {
+ return allocate(name, 1);
+ }
+
+ public int allocateWide(Object name)
+ {
+ return allocate(name, 2);
+ }
+
+ public int allocate(Object name, int size)
+ {
+ allocated = true;
+ if (size != 1 && size != 2)
+ throw new IllegalArgumentException("size must be 1 or 2");
+ if (names.containsKey(name))
+ throw new IllegalStateException("already allocated " + name);
+
+ if (size == 2)
+ {
+ // look for consecutive free slots
+ for (Iterator it = free.iterator(); it.hasNext(); )
+ {
+ Integer i = (Integer) it.next();
+ Integer next = new Integer(i.intValue() + 1);
+ if (free.contains(next))
+ {
+ free.remove(i);
+ free.remove(next);
+ wides.add(name);
+ names.put(name, i);
+ return i.intValue();
+ }
+ }
+ }
+ else if (free.size() > 0)
+ {
+ Integer i = (Integer) free.iterator().next();
+ free.remove(i);
+ names.put(name, i);
+ return i.intValue();
+ }
+
+ return allocateNew(name, size);
+ }
+
+ public int deallocate(Object name)
+ {
+ if (! names.containsKey(name))
+ throw new IllegalArgumentException("no variable " + name);
+
+ if (declared.contains(name))
+ throw new IllegalStateException(name + " can't be deallocated");
+
+ Integer i = (Integer) names.get(name);
+ names.remove(name);
+ free.add(i);
+ if (wides.remove(name))
+ free.add(new Integer(i.intValue() + 1));
+ return i.intValue();
+ }
+
+ public int get(Object name)
+ {
+ if (! names.containsKey(name))
+ throw new IllegalArgumentException("no variable " + name);
+
+ return ((Integer) names.get(name)).intValue();
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java
new file mode 100644
index 000000000..cb412851b
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java
@@ -0,0 +1,99 @@
+/* WrapUnWrapper.java -- Wrapper and unwrapper for primitive types.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+
+public class WrapUnWrapper
+{
+ /**
+ * Get the wrapper class for the primitive type
+ *
+ * @param primitive the class of the primitive type
+ *
+ * @return the wrapper class
+ */
+ public static Class getWrappingClass(Class primitive)
+ {
+ if (primitive.equals(byte.class))
+ return Byte.class;
+ if (primitive.equals(int.class))
+ return Integer.class;
+ if (primitive.equals(long.class))
+ return Long.class;
+ if (primitive.equals(boolean.class))
+ return Boolean.class;
+ if (primitive.equals(double.class))
+ return Double.class;
+ if (primitive.equals(float.class))
+ return Float.class;
+ if (primitive.equals(char.class))
+ return Character.class;
+ else
+ return null;
+ }
+
+ /**
+ * Get the method, invocation of that would return the wrapped value.
+ *
+ * @param primitive the class of the primitive type.
+ *
+ * @return the wrapper method that unwraps the value to the primitive type.
+ */
+ public static String getUnwrappingMethod(Class primitive)
+ {
+ if (primitive.equals(byte.class))
+ return "byteValue()";
+ if (primitive.equals(int.class))
+ return "intValue()";
+ if (primitive.equals(long.class))
+ return "longValue()";
+ if (primitive.equals(boolean.class))
+ return "booleanValue()";
+ if (primitive.equals(double.class))
+ return "doubleValue()";
+ if (primitive.equals(float.class))
+ return "floatValue()";
+ if (primitive.equals(char.class))
+ return "charValue()";
+ else
+ return null;
+ }
+
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java b/libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java
new file mode 100644
index 000000000..fb2764873
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java
@@ -0,0 +1,243 @@
+/* ActivationSystemImpl.java -- implementation of the activation system.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmid;
+
+import gnu.classpath.tools.common.Persistent;
+import gnu.java.rmi.activation.ActivationSystemTransient;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationException;
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationInstantiator;
+import java.rmi.activation.ActivationMonitor;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.activation.Activator;
+import java.rmi.activation.UnknownGroupException;
+import java.rmi.activation.UnknownObjectException;
+
+/**
+ * Implements the rmid activation system.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class ActivationSystemImpl extends ActivationSystemTransient implements
+ ActivationSystem, Activator, ActivationMonitor, Serializable
+{
+ /**
+ * Use for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The singleton instance of this class.
+ */
+ public static ActivationSystemImpl singleton2;
+
+ /**
+ * Obtain the singleton instance of this class.
+ *
+ * @param folder the folder, where the activation system will keep its files.
+ * @param cold do the cold start if true, hot (usual) if false.
+ */
+ public static ActivationSystem getInstance(File folder, boolean cold)
+ {
+ if (singleton2 == null)
+ singleton2 = new ActivationSystemImpl(folder, cold);
+ return singleton2;
+ }
+
+ /**
+ * Creates the group with transient maps.
+ *
+ * @param folder
+ * the folder, where the activation system will keep its files.
+ * @param cold
+ * do the cold start if true, hot (usual) if false.
+ */
+ protected ActivationSystemImpl(File folder, boolean cold)
+ {
+ super(new PersistentBidiHashTable(), new PersistentBidiHashTable());
+ singleton2 = this;
+ ((PersistentBidiHashTable) groupDescs).init(
+ new File(folder, "asi_objects.data"), cold);
+ ((PersistentBidiHashTable) descriptions).init(
+ new File(folder, "asi_groups.data"), cold);
+ }
+
+ /** @inheritDoc */
+ public MarshalledObject activate(ActivationID id, boolean force)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ return super.activate(id, force);
+ }
+
+ /** @inheritDoc */
+ public ActivationMonitor activeGroup(ActivationGroupID id,
+ ActivationInstantiator group,
+ long incarnation)
+ throws UnknownGroupException, ActivationException, RemoteException
+ {
+ return super.activeGroup(id, group, incarnation);
+ }
+
+ /** @inheritDoc */
+ public void activeObject(ActivationID id, MarshalledObject obj)
+ throws UnknownObjectException, RemoteException
+ {
+ super.activeObject(id, obj);
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc getActivationDesc(ActivationID id)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ return super.getActivationDesc(id);
+ }
+
+ public ActivationGroupDesc getActivationGroupDesc(ActivationGroupID groupId)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ return super.getActivationGroupDesc(groupId);
+ }
+
+ /** @inheritDoc */
+ public void inactiveGroup(ActivationGroupID groupId, long incarnation)
+ throws UnknownGroupException, RemoteException
+ {
+ super.inactiveGroup(groupId, incarnation);
+ }
+
+ /** @inheritDoc */
+ public void inactiveObject(ActivationID id) throws UnknownObjectException,
+ RemoteException
+ {
+ super.inactiveObject(id);
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupID registerGroup(ActivationGroupDesc groupDesc)
+ throws ActivationException, RemoteException
+ {
+ return super.registerGroup(groupDesc);
+ }
+
+ /** @inheritDoc */
+ public ActivationID registerObject(ActivationDesc desc)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ return super.registerObject(desc);
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc setActivationDesc(ActivationID id, ActivationDesc desc)
+ throws ActivationException, UnknownObjectException,
+ UnknownGroupException, RemoteException
+ {
+ return super.setActivationDesc(id, desc);
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupDesc setActivationGroupDesc(
+ ActivationGroupID groupId, ActivationGroupDesc groupDesc)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ return super.setActivationGroupDesc(groupId, groupDesc);
+ }
+
+ /**
+ * This method saves the state of the activation system and then
+ * terminates in 10 seconds.
+ */
+ public void shutdown() throws RemoteException
+ {
+ super.shutdown();
+ System.out.println("Shutdown command received. Will terminate in 10 s");
+ Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
+ }
+
+ /** @inheritDoc */
+ public void unregisterGroup(ActivationGroupID groupId)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ super.unregisterGroup(groupId);
+ }
+
+ /** @inheritDoc */
+ public void unregisterObject(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ super.unregisterObject(id);
+ }
+
+ /**
+ * Read the object from the input stream.
+ *
+ * @param in the stream to read from
+ *
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream in) throws IOException,
+ ClassNotFoundException
+ {
+ // Read no fields.
+ }
+
+ /**
+ * Write the object to the output stream.
+ *
+ * @param out the stream to write int
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException,
+ ClassNotFoundException
+ {
+ // Write no fields.
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java b/libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java
new file mode 100644
index 000000000..446a87fb2
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java
@@ -0,0 +1,556 @@
+/* ActivationSystemImpl.java -- implementation of the activation system.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmid;
+
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationException;
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationInstantiator;
+import java.rmi.activation.ActivationMonitor;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.activation.Activator;
+import java.rmi.activation.UnknownGroupException;
+import java.rmi.activation.UnknownObjectException;
+
+import java.lang.reflect.Method;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.UnexpectedException;
+
+/**
+ * This class delegates its method calls to the remote RMI object, referenced
+ * by {@link RemoteRef}.
+ *
+ * It is normally generated with rmic.
+ */
+public final class ActivationSystemImpl_Stub
+ extends RemoteStub
+ implements ActivationMonitor, Activator, ActivationSystem
+{
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 2;
+
+ /**
+ * The explaining message for {@ling UnexpectedException}.
+ */
+ private static final String exception_message =
+ "undeclared checked exception";
+
+ /* All remote methods, invoked by this stub: */
+ private static final Method met_setActivationGroupDesc;
+ private static final Method met_inactiveGroup;
+ private static final Method met_unregisterObject;
+ private static final Method met_getActivationDesc;
+ private static final Method met_setActivationDesc;
+ private static final Method met_shutdown;
+ private static final Method met_activate;
+ private static final Method met_activeGroup;
+ private static final Method met_registerGroup;
+ private static final Method met_getActivationGroupDesc;
+ private static final Method met_activeObject;
+ private static final Method met_registerObject;
+ private static final Method met_inactiveObject;
+ private static final Method met_unregisterGroup;
+ private static final Object[] NO_ARGS = new Object[0];
+ static
+ {
+ final Class[] NO_ARGSc = new Class[0];
+ try
+ {
+ met_setActivationGroupDesc =
+ ActivationSystem.class.getMethod("setActivationGroupDesc", new Class[]
+ {
+ ActivationGroupID.class, ActivationGroupDesc.class
+ });
+ met_inactiveGroup =
+ ActivationMonitor.class.getMethod("inactiveGroup", new Class[]
+ {
+ ActivationGroupID.class, long.class
+ });
+ met_unregisterObject =
+ ActivationSystem.class.getMethod("unregisterObject", new Class[]
+ {
+ ActivationID.class
+ });
+ met_getActivationDesc =
+ ActivationSystem.class.getMethod("getActivationDesc", new Class[]
+ {
+ ActivationID.class
+ });
+ met_setActivationDesc =
+ ActivationSystem.class.getMethod("setActivationDesc", new Class[]
+ {
+ ActivationID.class, ActivationDesc.class
+ });
+ met_shutdown =
+ ActivationSystem.class.getMethod("shutdown", NO_ARGSc);
+ met_activate =
+ Activator.class.getMethod("activate", new Class[]
+ {
+ ActivationID.class, boolean.class
+ });
+ met_activeGroup =
+ ActivationSystem.class.getMethod("activeGroup", new Class[]
+ {
+ ActivationGroupID.class, ActivationInstantiator.class, long.class
+ });
+ met_registerGroup =
+ ActivationSystem.class.getMethod("registerGroup", new Class[]
+ {
+ ActivationGroupDesc.class
+ });
+ met_getActivationGroupDesc =
+ ActivationSystem.class.getMethod("getActivationGroupDesc", new Class[]
+ {
+ ActivationGroupID.class
+ });
+ met_activeObject =
+ ActivationMonitor.class.getMethod("activeObject", new Class[]
+ {
+ ActivationID.class, MarshalledObject.class
+ });
+ met_registerObject =
+ ActivationSystem.class.getMethod("registerObject", new Class[]
+ {
+ ActivationDesc.class
+ });
+ met_inactiveObject =
+ ActivationMonitor.class.getMethod("inactiveObject", new Class[]
+ {
+ ActivationID.class
+ });
+ met_unregisterGroup =
+ ActivationSystem.class.getMethod("unregisterGroup", new Class[]
+ {
+ ActivationGroupID.class
+ });
+
+ }
+ catch (NoSuchMethodException nex)
+ {
+ NoSuchMethodError err = new NoSuchMethodError(
+ "ActivationSystemImpl_Stub class initialization failed");
+ err.initCause(nex);
+ throw err;
+ }
+ }
+
+ /**
+ * Create the instance for _ActivationSystemImpl_Stub that forwards method calls to the
+ * remote object.
+ *
+ * @para the reference to the remote object.
+ */
+ public ActivationSystemImpl_Stub(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /* Methods */
+ /** @inheritDoc */
+ public ActivationGroupDesc setActivationGroupDesc(ActivationGroupID p0,
+ ActivationGroupDesc p1)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_setActivationGroupDesc,
+ new Object[] { p0, p1 },
+ 1213918527826541191L);
+ return (ActivationGroupDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void inactiveGroup(ActivationGroupID p0, long p1)
+ throws UnknownGroupException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_inactiveGroup, new Object[] { p0, new Long(p1) },
+ -399287892768650944L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void unregisterObject(ActivationID p0) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_unregisterObject, new Object[] { p0 },
+ -6843850585331411084L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc getActivationDesc(ActivationID p0)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_getActivationDesc,
+ new Object[] { p0 }, 4830055440982622087L);
+ return (ActivationDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc setActivationDesc(ActivationID p0, ActivationDesc p1)
+ throws ActivationException, UnknownObjectException,
+ UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_setActivationDesc,
+ new Object[] { p0, p1 },
+ 7128043237057180796L);
+ return (ActivationDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void shutdown() throws RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_shutdown, NO_ARGS, -7207851917985848402L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public MarshalledObject activate(ActivationID p0, boolean p1)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_activate,
+ new Object[] { p0, new Boolean(p1) },
+ -8767355154875805558L);
+ return (MarshalledObject) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationMonitor activeGroup(ActivationGroupID p0,
+ ActivationInstantiator p1, long p2)
+ throws UnknownGroupException, ActivationException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_activeGroup,
+ new Object[] { p0, p1, new Long(p2) },
+ -4575843150759415294L);
+ return (ActivationMonitor) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupID registerGroup(ActivationGroupDesc p0)
+ throws ActivationException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_registerGroup,
+ new Object[] { p0 }, 6921515268192657754L);
+ return (ActivationGroupID) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupDesc getActivationGroupDesc(ActivationGroupID p0)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_getActivationGroupDesc,
+ new Object[] { p0 }, -8701843806548736528L);
+ return (ActivationGroupDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void activeObject(ActivationID p0, MarshalledObject p1)
+ throws UnknownObjectException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_activeObject, new Object[] { p0, p1 },
+ 2543984342209939736L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationID registerObject(ActivationDesc p0)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_registerObject,
+ new Object[] { p0 }, -3006759798994351347L);
+ return (ActivationID) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void inactiveObject(ActivationID p0) throws UnknownObjectException,
+ RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_inactiveObject, new Object[] { p0 },
+ -4165404120701281807L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void unregisterGroup(ActivationGroupID p0) throws ActivationException,
+ UnknownGroupException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_unregisterGroup, new Object[] { p0 },
+ 3768097077835970701L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmid/Main.java b/libjava/classpath/tools/gnu/classpath/tools/rmid/Main.java
new file mode 100644
index 000000000..3cc2a12ad
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmid/Main.java
@@ -0,0 +1,258 @@
+/* Main.java -- the RMI activation daemon.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmid;
+
+import gnu.classpath.tools.rmid.ActivationSystemImpl;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.rmi.activation.ActivationSystemTransient;
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.rmi.Remote;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIServerSocketFactory;
+
+
+/**
+ * The persistent RMI activation daemon.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class Main
+{
+ /**
+ * The RMI server socket factory.
+ */
+ static RMIServerSocketFactory ACTIVATION_REGISTY_SOCKET_FACTORY = null;
+
+ /**
+ * The activation registry port.
+ */
+ static int ACTIVATION_REGISTRY_PORT = ActivationSystem.SYSTEM_PORT;
+
+ /**
+ * The activation system name.
+ */
+ static String ACTIVATION_SYSTEM_NAME = "java.rmi.activation.ActivationSystem";
+
+ // Parse parameters:
+ private boolean stop = false;
+ private String directory = ".";
+ private boolean cold = false;
+ private boolean persistent = false;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("rmiregistry", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+
+ OptionGroup controlGroup
+ = new OptionGroup(Messages.getString("Main.ControlGroup")); //$NON-NLS-1$
+ controlGroup.add(new Option("port", //$NON-NLS-1$
+ Messages.getString("Main.PortOption"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ ACTIVATION_REGISTRY_PORT = Integer.parseInt(portArgument);
+ }
+ });
+ controlGroup.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ cold = true;
+ }
+ });
+ controlGroup.add(new Option("stop", //$NON-NLS-1$
+ Messages.getString("Main.Stop")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ stop = true;
+ }
+ });
+ parser.add(controlGroup);
+
+ OptionGroup persistenceGroup
+ = new OptionGroup(Messages.getString("Main.PersistenceGroup")); //$NON-NLS-1$
+ persistenceGroup.add(new Option("persistent", //$NON-NLS-1$
+ Messages.getString("Main.Persistent")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ persistent = true;
+ }
+ });
+ persistenceGroup.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(persistenceGroup);
+
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebugGroup")); //$NON-NLS-1$
+ debuggingGroup.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString ("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ ActivationSystemTransient.debug = true;
+ }
+ });
+ parser.add(debuggingGroup);
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args);
+
+ try
+ {
+ if (!stop)
+ {
+ // Start the system.
+ File dataDirectory = new File(directory);
+ if (!dataDirectory.exists())
+ dataDirectory.mkdirs();
+ ActivationSystem system;
+
+ if (!persistent)
+ system = ActivationSystemTransient.getInstance();
+ else
+ system = ActivationSystemImpl.getInstance(dataDirectory, cold);
+
+ // We must export with the specific activation id that is only
+ // possible when going into the gnu.java.rmi.activation.
+ UnicastServerRef sref = new UnicastServerRef(
+ new ObjID(ObjID.ACTIVATOR_ID), ACTIVATION_REGISTRY_PORT,
+ ACTIVATION_REGISTY_SOCKET_FACTORY);
+ Remote systemStub = sref.exportObject(system);
+
+ // Start the naming system on the activation system port
+ // (if not already running).
+
+ Registry r;
+ try
+ {
+ // Expect the naming service running first.
+ // The local host may want to use the shared registry
+ r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
+ r.rebind(ACTIVATION_SYSTEM_NAME, systemStub);
+ }
+ catch (Exception ex)
+ {
+ // The naming service is not running. Start it.
+ r = LocateRegistry.createRegistry(ACTIVATION_REGISTRY_PORT);
+ r.rebind(ACTIVATION_SYSTEM_NAME, systemStub);
+ }
+ String host = InetAddress.getLocalHost().getCanonicalHostName();
+ System.out.println("The RMI daemon is listening on " + host +
+ " (port "
+ + ACTIVATION_REGISTRY_PORT + ")");
+
+ }
+ else
+ {
+ // Stop the activation system.
+ Registry r;
+ try
+ {
+ System.out.print("Stopping RMI daemon at "
+ + ACTIVATION_REGISTRY_PORT+" ... ");
+ // Expect the naming service running first.
+ // The local host may want to use the shared registry
+ r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
+ ActivationSystem asys =
+ (ActivationSystem) r.lookup(ACTIVATION_SYSTEM_NAME);
+ asys.shutdown();
+ System.out.println("OK.");
+ }
+ catch (Exception ex)
+ {
+ System.out.println("The RMI daemon seems not running at "
+ + ACTIVATION_REGISTRY_PORT);
+ if (ActivationSystemTransient.debug)
+ ex.printStackTrace();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ System.out.println("Failed to start the RMI daemon.");
+ if (ActivationSystemTransient.debug)
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * The activation system entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmidprogram = new Main();
+ try
+ {
+ rmidprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmid/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/rmid/Messages.java
new file mode 100644
index 000000000..4365c6de7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmid/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmid
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.rmid;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmid.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java b/libjava/classpath/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java
new file mode 100644
index 000000000..9d9849663
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java
@@ -0,0 +1,269 @@
+/* PersistentBidiHasthable.java -- Bidirectional persistent hash table.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmid;
+
+import gnu.classpath.tools.common.Persistent;
+import gnu.classpath.tools.rmid.ActivationSystemImpl;
+import gnu.java.rmi.activation.BidiTable;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TimerTask;
+
+/**
+ * The persistent bidirectional hash table, maps both a to b and b to a. The
+ * changes are written to dist after SAVE_AT_MOST_AFTER time from the latest
+ * database change or at most after ALWAYS_UPDATE, if the database is updated
+ * very frequently. To ensure that no information is lost, the shutdown method
+ * must be called before exit.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class PersistentBidiHashTable extends BidiTable implements
+ Persistent
+{
+ class WriteToDiskTask extends TimerTask
+ {
+ /**
+ * Save the database.
+ */
+ public void run()
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * Replaces instances of ActivationSystemImpl into the currently active
+ * instance of the ActivationSystemImpl
+ */
+ class AdaptedReader extends ObjectInputStream
+ {
+ AdaptedReader(InputStream in) throws IOException
+ {
+ super(in);
+ enableResolveObject(true);
+ }
+
+ protected Object resolveObject(Object obj) throws IOException
+ {
+ if (obj instanceof ActivationSystemImpl)
+ return ActivationSystemImpl.singleton2;
+ else
+ return obj;
+ }
+ }
+
+ /**
+ * The database file.
+ */
+ File database;
+
+ /**
+ * The currently sheduled write to disk task, null if none.
+ */
+ WriteToDiskTask sheduled = null;
+
+ /**
+ * The time, when the disk database was last updated.
+ */
+ long lastUpdated;
+
+ /**
+ * Create the unitialised instance that must be initalised when
+ * ActivationSystemImpl.singleton2 is assigned.
+ */
+ public PersistentBidiHashTable()
+ {
+ // Do not initalise the table fields - the initalise method must be
+ // called later.
+ super(0);
+ }
+
+ /**
+ * Create a new persistent table that stores its information into the given
+ * file. The ActivationSystemImpl.singleton2 must be assigned.
+ *
+ * @param file
+ * the file, where the table stores its information.
+ * @param coldStart
+ * if true, the existing file with this name will be erased and
+ * ignored. Otherwise, it will be assumed that the file contains the
+ * persistent table information.
+ */
+ public void init(File file, boolean coldStart)
+ {
+ try
+ {
+ database = file;
+ if (database.exists())
+ {
+ if (coldStart)
+ {
+ k2v = new Hashtable();
+ v2k = new Hashtable();
+ database.delete();
+ }
+ else
+ {
+ FileInputStream fi = new FileInputStream(file);
+ BufferedInputStream b = new BufferedInputStream(fi);
+ ObjectInputStream oin = new AdaptedReader(b);
+
+ k2v = (Map) oin.readObject();
+ oin.close();
+
+ v2k = new Hashtable(k2v.size());
+
+ // Reguild v2k from k2v:
+ Iterator en = k2v.keySet().iterator();
+ Object key;
+ while (en.hasNext())
+ {
+ key = en.next();
+ v2k.put(k2v.get(key), key);
+ }
+ }
+ }
+ else
+ {
+ k2v = new Hashtable();
+ v2k = new Hashtable();
+ }
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError("Unable to intialize with file "
+ + file);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+ /**
+ * Write the database content to the disk.
+ */
+ public synchronized void writeContent()
+ {
+ try
+ {
+ FileOutputStream fou = new FileOutputStream(database);
+ BufferedOutputStream b = new BufferedOutputStream(fou);
+ ObjectOutputStream oout = new ObjectOutputStream(b);
+ oout.writeObject(k2v);
+ oout.close();
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError(
+ "Failed to write database to disk: "
+ + database);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+ /**
+ * Mark the modified database as modified. The database will be written after
+ * several seconds, unless another modification occurs.
+ */
+ public void markDirty()
+ {
+ if (System.currentTimeMillis() - lastUpdated > ALWAYS_UPDATE)
+ {
+ // Force storing to disk under intensive operation.
+ writeContent();
+ lastUpdated = System.currentTimeMillis();
+ if (sheduled != null)
+ {
+ sheduled.cancel();
+ sheduled = null;
+ }
+ }
+ else
+ {
+ // Otherwise coalesce the disk database copy update events.
+ if (sheduled != null)
+ sheduled.cancel();
+ sheduled = new WriteToDiskTask();
+ timer.schedule(sheduled, SAVE_AT_MOST_AFTER);
+ }
+ }
+
+ /**
+ * Save the current database state to the disk before exit.
+ */
+ public void shutdown()
+ {
+ if (sheduled != null)
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public void put(Object key, Object value)
+ {
+ super.put(key, value);
+ markDirty();
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public void removeKey(Object key)
+ {
+ super.removeKey(key);
+ markDirty();
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Main.java b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Main.java
new file mode 100644
index 000000000..f22e81b6e
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Main.java
@@ -0,0 +1,232 @@
+/* Main.java -- RMI registry starter.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmiregistry;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.classpath.tools.rmiregistry.RegistryImpl;
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.io.File;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIServerSocketFactory;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * The optionally persistent RMI registry implementation.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class Main
+{
+ /**
+ * The stop command.
+ */
+ public static String STOP = "gnu.classpath.tools.rmi.registry.command.STOP";
+
+ /**
+ * If true, the registry prints registration events to console.
+ */
+ public static boolean verbose = false;
+
+ /**
+ * Parsed parameters.
+ */
+ private String directory = ".";
+ private boolean cold = false;
+ private boolean persistent = false;
+ private boolean stop = false;
+ private int port = Registry.REGISTRY_PORT;
+ private RMIServerSocketFactory ssf = null;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("rmiregistry", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ OptionGroup controlGroup
+ = new OptionGroup(Messages.getString("Main.ControlGroup")); //$NON-NLS-1$
+ controlGroup.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ cold = true;
+ }
+ });
+ controlGroup.add(new Option("stop", //$NON-NLS-1$
+ Messages.getString("Main.Stop")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ stop = true;
+ }
+ });
+ parser.add(controlGroup);
+
+ OptionGroup persistenceGroup
+ = new OptionGroup(Messages.getString("Main.PersistenceGroup")); //$NON-NLS-1$
+ persistenceGroup.add(new Option("persistent", //$NON-NLS-1$
+ Messages.getString("Main.Persistent")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ persistent = true;
+ }
+ });
+ persistenceGroup.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(persistenceGroup);
+
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebugGroup")); //$NON-NLS-1$
+ debuggingGroup.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString ("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ parser.add(debuggingGroup);
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args, new FileArgumentCallback()
+ {
+ public void notifyFile(String portArgument)
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ if (!stop)
+ {
+ Map table;
+ if (!persistent)
+ table = new Hashtable();
+ else
+ {
+ // Start the system.
+ File dataDirectory = new File(directory);
+ if (!dataDirectory.exists())
+ dataDirectory.mkdirs();
+ table = PersistentHashTable.createInstance(
+ new File(dataDirectory, "rmiregistry.data"), cold);
+ }
+
+ RegistryImpl system = new RegistryImpl(table);
+
+ // We must export with the specific activation id that is only
+ // possible when going into the gnu.java.rmi
+ try
+ {
+ UnicastServerRef sref = new UnicastServerRef(
+ new ObjID(ObjID.REGISTRY_ID), port, ssf);
+
+ sref.exportObject(system);
+ System.out.println("The RMI naming service is listening at " + port);
+ }
+ catch (Exception ex)
+ {
+ System.out.println("Failed to start RMI naming service at " + port);
+ }
+ }
+ else
+ {
+ // Stop the naming service.
+ try
+ {
+ Registry r = LocateRegistry.getRegistry(port);
+ // Search for this specific line will command to stop the registry.
+
+ // Our service returns null, but any other service will thrown
+ // NotBoundException.
+ r.unbind(STOP);
+ }
+ catch (RemoteException e)
+ {
+ System.out.println("Failed to stop RMI naming service at " + port);
+ }
+ catch (NotBoundException e)
+ {
+ System.out.println("The naming service at port " + port + " is not a "
+ + Main.class.getName());
+ }
+ }
+ }
+
+ /**
+ * The RMI registry implementation entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmiregistryprogram = new Main();
+ try
+ {
+ rmiregistryprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Messages.java
new file mode 100644
index 000000000..05bfcf62d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmiregistry
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.rmiregistry;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmiregistry.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java
new file mode 100644
index 000000000..3202a8405
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java
@@ -0,0 +1,262 @@
+/* PersistentHasthable.java -- Persistent hash table.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmiregistry;
+
+import gnu.classpath.tools.common.Persistent;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.TimerTask;
+
+/**
+ * The persistent hash table. The changes are written to dist after
+ * SAVE_AT_MOST_AFTER time from the latest database change or at most after
+ * ALWAYS_UPDATE, if the database is updated very frequently. To ensure that no
+ * information is lost, the shutdown method must be called before exit.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class PersistentHashTable
+ extends Hashtable
+ implements Serializable, Persistent
+{
+
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 1;
+
+ class WriteToDiskTask extends TimerTask
+ {
+ /**
+ * Save the database.
+ */
+ public void run()
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * The database file.
+ */
+ File database;
+
+ /**
+ * The currently sheduled write to disk task, null if none.
+ */
+ WriteToDiskTask sheduled = null;
+
+ /**
+ * The time, when the disk database was last updated.
+ */
+ long lastUpdated;
+
+ /**
+ * Setting to false prevents the automated disk update.
+ * The initial value is true to prevent writing while reading and is set
+ * to false in createInstance.
+ */
+ transient boolean ready;
+
+ /**
+ * Use static method to obtain the instance.
+ */
+ private PersistentHashTable(File file)
+ {
+ if (file == null)
+ throw new NullPointerException("Null file provided");
+ database = file;
+ }
+
+ /**
+ * Create a new persistent table that stores its information into the given
+ * file.
+ *
+ * @param file
+ * the file, where the table stores its information.
+ * @param coldStart
+ * if true, the existing file with this name will be erased and
+ * ignored. Otherwise, it will be assumed that the file contains the
+ * persistent table information.
+ */
+ public static Map createInstance(File file, boolean coldStart)
+ {
+ try
+ {
+ PersistentHashTable k2v;
+ System.out.println ("Here1");
+ if (file.exists())
+ {
+ System.out.println ("Here2");
+ if (coldStart)
+ {
+ System.out.println ("Here2.5");
+ file.delete();
+ k2v = new PersistentHashTable(file);
+ }
+ else
+ {
+ System.out.println ("Here3");
+ FileInputStream fi = new FileInputStream(file);
+ System.out.println ("Here3.1");
+ BufferedInputStream b = new BufferedInputStream(fi);
+ System.out.println ("Here3.2");
+ ObjectInputStream oin = new ObjectInputStream(b);
+ System.out.println ("Here3.3");
+
+ System.out.println ("Here4");
+ k2v = (PersistentHashTable) oin.readObject();
+ oin.close();
+ System.out.println ("Here5");
+ }
+ }
+ else
+ {
+ System.out.println ("Here6");
+ k2v = new PersistentHashTable(file);
+ System.out.println ("Here7");
+ }
+
+ System.out.println ("Here8");
+ k2v.ready = true;
+ return k2v;
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError("Unable to intialize with file "
+ + file);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+
+ /**
+ * Write the database content to the disk.
+ */
+ public synchronized void writeContent()
+ {
+ try
+ {
+ FileOutputStream fou = new FileOutputStream(database);
+ BufferedOutputStream b = new BufferedOutputStream(fou);
+ ObjectOutputStream oout = new ObjectOutputStream(b);
+ oout.writeObject(this);
+ oout.close();
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError(
+ "Failed to write database to disk: "+ database);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+ /**
+ * Mark the modified database as modified. The database will be written after
+ * several seconds, unless another modification occurs.
+ */
+ public void markDirty()
+ {
+ if (System.currentTimeMillis() - lastUpdated > ALWAYS_UPDATE)
+ {
+ // Force storing to disk under intensive operation.
+ writeContent();
+ lastUpdated = System.currentTimeMillis();
+ if (sheduled != null)
+ {
+ sheduled.cancel();
+ sheduled = null;
+ }
+ }
+ else
+ {
+ // Otherwise coalesce the disk database copy update events.
+ if (sheduled != null)
+ sheduled.cancel();
+ sheduled = new WriteToDiskTask();
+ timer.schedule(sheduled, SAVE_AT_MOST_AFTER);
+ }
+ }
+
+ /**
+ * Save the current database state to the disk before exit.
+ */
+ public void shutdown()
+ {
+ if (sheduled != null)
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public Object put(Object key, Object value)
+ {
+ super.put(key, value);
+ if (ready)
+ markDirty();
+ return value;
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public Object remove(Object key)
+ {
+ Object removed = super.remove(key);
+ if (ready)
+ markDirty();
+ return removed;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java
new file mode 100644
index 000000000..80d0fe0c1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java
@@ -0,0 +1,138 @@
+/* RegistryImpl.java -- the RMI registry implementation
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2005, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmiregistry;
+
+import gnu.classpath.tools.common.Persistent;
+
+import java.rmi.AccessException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * The optionally persistent registry implementation.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class RegistryImpl implements Registry
+{
+ /**
+ * The binding table.
+ */
+ Map bindings;
+
+ /**
+ * Create the registry implementation that uses the given bidirectinal
+ * table to keep the data.
+ */
+ public RegistryImpl(Map aTable)
+ {
+ bindings = aTable;
+ }
+
+ /** @inheritDoc */
+ public Remote lookup(String name) throws RemoteException, NotBoundException,
+ AccessException
+ {
+ Object obj = bindings.get(name);
+ if (obj == null)
+ throw new NotBoundException(name);
+ return ((Remote) obj);
+ }
+
+ /** @inheritDoc */
+ public void bind(String name, Remote obj) throws RemoteException,
+ AlreadyBoundException, AccessException
+ {
+ if (Main.verbose)
+ System.out.println("Bind "+name);
+ if (bindings.containsKey(name))
+ throw new AlreadyBoundException(name);
+ bindings.put(name, obj);
+ }
+
+ /** @inheritDoc */
+ public void unbind(String name) throws RemoteException, NotBoundException,
+ AccessException
+ {
+ if (name.equals(Main.STOP))
+ {
+ if (bindings instanceof Persistent)
+ ((Persistent) bindings).writeContent();
+ // Terminate in 10 seconds.
+ System.out.println("Shutdown command received. Will terminate in 10 s");
+ Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
+ }
+ else
+ {
+ if (Main.verbose)
+ System.out.println("Unbind "+name);
+
+ if (!bindings.containsKey(name))
+ throw new NotBoundException(name);
+ else
+ bindings.remove(name);
+ }
+ }
+
+ /** @inheritDoc */
+ public void rebind(String name, Remote obj) throws RemoteException,
+ AccessException
+ {
+ if (Main.verbose)
+ System.out.println("Rebind "+name);
+ bindings.put(name, obj);
+ }
+
+ /** @inheritDoc */
+ public String[] list() throws RemoteException, AccessException
+ {
+ // Create a separated array to prevent race conditions.
+ ArrayList keys = new ArrayList(bindings.keySet());
+ int n = keys.size();
+ String[] rt = new String[n];
+ for (int i = 0; i < n; i++)
+ rt[i] = (String) keys.get(i);
+ return rt;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java
new file mode 100644
index 000000000..fa717892a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java
@@ -0,0 +1,278 @@
+/* RegistryImpl_Skel.java
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmiregistry;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.rmi.MarshalException;
+import java.rmi.Remote;
+import java.rmi.UnmarshalException;
+import java.rmi.server.Operation;
+import java.rmi.server.RemoteCall;
+import java.rmi.server.SkeletonMismatchException;
+
+/**
+ * This skeleton supports unlikely cases when the naming service is
+ * contacted from other interoperable java implementation that still uses
+ * the old style skeleton-dependent invocations.
+ */
+public final class RegistryImpl_Skel
+ implements java.rmi.server.Skeleton
+{
+ private static final long interfaceHash = 4905912898345647071L;
+
+ /**
+ * Repeated multiple times.
+ */
+ static final String EUM = "error unmarshalling arguments for Registry";
+
+ /**
+ * Repeated multiple times.
+ */
+ static final String EMR = "error marshalling return from Registry";
+
+ private static final Operation[] operations =
+ {
+ new Operation("void bind(java.lang.String, Remote"),
+ new Operation("java.lang.String[] list("),
+ new Operation("Remote lookup(java.lang.String"),
+ new Operation("void rebind(java.lang.String, Remote"),
+ new Operation("void unbind(java.lang.String")
+ };
+
+ public Operation[] getOperations()
+ {
+ return ((Operation[]) operations.clone());
+ }
+
+ public void dispatch(Remote obj, RemoteCall call,
+ int opnum, long hash) throws java.lang.Exception
+ {
+ if (opnum < 0)
+ {
+ if (hash == 7583982177005850366L)
+ opnum = 0;
+ else if (hash == 2571371476350237748L)
+ opnum = 1;
+ else if (hash == -7538657168040752697L)
+ opnum = 2;
+ else if (hash == -8381844669958460146L)
+ opnum = 3;
+ else if (hash == 7305022919901907578L)
+ opnum = 4;
+ else
+ throw new SkeletonMismatchException("interface hash mismatch");
+ }
+ else if (hash != interfaceHash)
+ throw new SkeletonMismatchException("interface hash mismatch");
+
+ RegistryImpl server = (RegistryImpl) obj;
+ switch (opnum)
+ {
+ case 0:
+ {
+ java.lang.String $param_0;
+ Remote $param_1;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+ $param_1 = (Remote) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ server.bind($param_0, $param_1);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 1:
+ {
+ try
+ {
+ ObjectInput in = call.getInputStream();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ java.lang.String[] $result = server.list();
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ out.writeObject($result);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 2:
+ {
+ java.lang.String $param_0;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ Remote $result = server.lookup($param_0);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ out.writeObject($result);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 3:
+ {
+ java.lang.String $param_0;
+ Remote $param_1;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+ $param_1 = (Remote) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ server.rebind($param_0, $param_1);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 4:
+ {
+ java.lang.String $param_0;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ server.unbind($param_0);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ default:
+ throw new UnmarshalException("invalid method number");
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java
new file mode 100644
index 000000000..dfb277fbd
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java
@@ -0,0 +1,263 @@
+/* RegistryImpl_Stub.java -- Registry stub.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmiregistry;
+
+import java.rmi.AccessException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+
+import java.lang.reflect.Method;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.UnexpectedException;
+
+/**
+ * This class delegates its method calls to the remote RMI object, referenced
+ * by {@link RemoteRef}.
+ *
+ * It is normally generated with rmic.
+ */
+public final class RegistryImpl_Stub
+ extends RemoteStub
+ implements Registry
+{
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 3;
+
+ /**
+ * The explaining message for {@ling UnexpectedException}.
+ */
+ private static final String exception_message =
+ "undeclared checked exception";
+
+ /* All remote methods, invoked by this stub: */
+ private static final Method met_list;
+ private static final Method met_rebind;
+ private static final Method met_unbind;
+ private static final Method met_lookup;
+ private static final Method met_bind;
+ private static final Object[] NO_ARGS = new Object[0];
+ static
+ {
+ final Class[] NO_ARGSc = new Class[0];
+ try
+ {
+ met_list =
+ Registry.class.getMethod("list", NO_ARGSc);
+ met_rebind =
+ Registry.class.getMethod("rebind", new Class[]
+ {
+ String.class, Remote.class
+ });
+ met_unbind =
+ Registry.class.getMethod("unbind", new Class[]
+ {
+ String.class
+ });
+ met_lookup =
+ Registry.class.getMethod("lookup", new Class[]
+ {
+ String.class
+ });
+ met_bind =
+ Registry.class.getMethod("bind", new Class[]
+ {
+ String.class, Remote.class
+ });
+
+ }
+ catch (NoSuchMethodException nex)
+ {
+ NoSuchMethodError err = new NoSuchMethodError(
+ "RegistryImpl_Stub class initialization failed");
+ err.initCause(nex);
+ throw err;
+ }
+ }
+
+ /**
+ * Create the instance for _RegistryImpl_Stub that forwards method calls to the
+ * remote object.
+ *
+ * @para the reference to the remote object.
+ */
+ public RegistryImpl_Stub(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /* Methods */
+ /** @inheritDoc */
+ public String [] list()
+ throws RemoteException, AccessException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_list,
+ NO_ARGS,
+ 2571371476350237748L);
+ return (String []) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void rebind(String p0, Remote p1)
+ throws RemoteException, AccessException
+ {
+ try
+ {
+ ref.invoke(this, met_rebind,
+ new Object[] {p0, p1},
+ -8381844669958460146L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void unbind(String p0)
+ throws RemoteException, NotBoundException, AccessException
+ {
+ try
+ {
+ ref.invoke(this, met_unbind,
+ new Object[] {p0},
+ 7305022919901907578L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public Remote lookup(String p0)
+ throws RemoteException, NotBoundException, AccessException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_lookup,
+ new Object[] {p0},
+ -7538657168040752697L);
+ return (Remote) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void bind(String p0, Remote p1)
+ throws RemoteException, AlreadyBoundException, AccessException
+ {
+ try
+ {
+ ref.invoke(this, met_bind,
+ new Object[] {p0, p1},
+ 7583982177005850366L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java
new file mode 100644
index 000000000..a6ab67add
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java
@@ -0,0 +1,68 @@
+/* Messages.java -- translations for serialver tool
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.serialver;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.serialver.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ // TODO Auto-generated method stub
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java b/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java
new file mode 100644
index 000000000..5fd7419b2
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java
@@ -0,0 +1,179 @@
+/* gnu.classpath.tools.SerialVer
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.serialver;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.ObjectStreamClass;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+/**
+ * This class is an implementation of the `serialver' program. Any number of
+ * class names can be passed as arguments, and the serial version unique
+ * identitfier for each class will be printed in a manner suitable for cuting
+ * and pasting into a Java source file.
+ */
+public class SerialVer
+{
+ // List of classes to load.
+ ArrayList<String> classes = new ArrayList<String>();
+ // The class path to use.
+ String classpath;
+
+ // FIXME: taken from ClassLoader, should share it.
+ private static void addFileURL(ArrayList<URL> list, String file)
+ {
+ try
+ {
+ list.add(new File(file).toURL());
+ }
+ catch(java.net.MalformedURLException x)
+ {
+ }
+ }
+
+ private ClassLoader getClassLoader()
+ {
+ // FIXME: this code is taken from ClassLoader.
+ // We should share it somewhere.
+ URL[] urls;
+ if (classpath == null)
+ urls = new URL[0];
+ else
+ {
+ StringTokenizer tok = new StringTokenizer(classpath,
+ File.pathSeparator, true);
+ ArrayList<URL> list = new ArrayList<URL>();
+ while (tok.hasMoreTokens())
+ {
+ String s = tok.nextToken();
+ if (s.equals(File.pathSeparator))
+ addFileURL(list, "."); //$NON-NLS-1$
+ else
+ {
+ addFileURL(list, s);
+ if (tok.hasMoreTokens())
+ {
+ // Skip the separator.
+ tok.nextToken();
+ // If the classpath ended with a separator,
+ // append the current directory.
+ if (!tok.hasMoreTokens())
+ addFileURL(list, "."); //$NON-NLS-1$
+ }
+ }
+ }
+ urls = new URL[list.size()];
+ urls = (URL[]) list.toArray(urls);
+ }
+ return new URLClassLoader(urls);
+ }
+
+ private void printMessage(String format, String klass)
+ {
+ System.err.println(MessageFormat.format(format, new Object[] { klass }));
+ }
+
+ public void run(String[] args)
+ {
+ Parser p = new ClasspathToolParser("serialver", true) //$NON-NLS-1$
+ {
+ protected void validate() throws OptionException
+ {
+ if (classes.isEmpty())
+ throw new OptionException(Messages.getString("SerialVer.NoClassesSpecd")); //$NON-NLS-1$
+ }
+ };
+ p.setHeader(Messages.getString("SerialVer.HelpHeader")); //$NON-NLS-1$
+
+ p.add(new Option(Messages.getString("SerialVer.5"), Messages.getString("SerialVer.ClasspathHelp"), "PATH") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ if (classpath != null)
+ throw new OptionException(Messages.getString("SerialVer.DupClasspath")); //$NON-NLS-1$
+ classpath = argument;
+ }
+ });
+
+ p.parse(args, new FileArgumentCallback()
+ {
+ public void notifyFile(String fileArgument) throws OptionException
+ {
+ classes.add(fileArgument);
+ }
+ });
+
+ ClassLoader loader = getClassLoader();
+ Iterator it = classes.iterator();
+ while (it.hasNext())
+ {
+ String name = (String) it.next();
+ try
+ {
+ Class clazz = loader.loadClass(name);
+ ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
+ if (osc != null)
+ System.out.println(clazz.getName() + ": " //$NON-NLS-1$
+ + "static final long serialVersionUID = " //$NON-NLS-1$
+ + osc.getSerialVersionUID() + "L;"); //$NON-NLS-1$
+ else
+ printMessage(Messages.getString("SerialVer.ClassNotSerial"), name); //$NON-NLS-1$
+ }
+ catch (ClassNotFoundException e)
+ {
+ printMessage(Messages.getString("SerialVer.ClassNotFound"), name); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ new SerialVer().run(args);
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/AuthorTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/AuthorTaglet.java
new file mode 100644
index 000000000..1a1f32b7d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/AuthorTaglet.java
@@ -0,0 +1,293 @@
+/* gnu.classpath.tools.taglets.AuthorTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * The default Taglet which handles Author information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class AuthorTaglet implements Taglet {
+
+ /**
+ * Enum class which denotes whether and how to replace email
+ * addresses in author tags.
+ */
+ public static class EmailReplacement {
+ private EmailReplacement() {}
+
+ /**
+ * Specifies that email addresses should not be replaced.
+ */
+ public static final EmailReplacement NO_REPLACEMENT = new EmailReplacement();
+
+ /**
+ * Specifies that author tag text matching "Real Name
+ * (user@domain.tld)" is converted to "&lt;a
+ * href="mailto:user@domain.tld"&gt;Real Name&lt;/a&gt;.
+ */
+ public static final EmailReplacement MAILTO_NAME = new EmailReplacement();
+
+ /**
+ * Specifies that author tag text matching "Real Name
+ * (user@domain.tld)" is converted to "Real Name (&lt;a
+ * href="mailto:user@domain.tld"&gt;user@domain.tld&lt;/a&gt;).
+ */
+ public static final EmailReplacement NAME_MAILTO_ADDRESS = new EmailReplacement();
+
+ /**
+ * Specifies that author tag text matching "Real Name
+ * (user@domain.tld)" is converted to "Real Name (user AT
+ * domain DOT tld)", where the "AT" and "DOT" replacement are
+ * specified by AuthorTaglet.emailAtReplacement and
+ * AuthorTaglet.emailDotReplacement.
+ */
+ public static final EmailReplacement NAME_MANGLED_ADDRESS = new EmailReplacement();
+ }
+
+ private static EmailReplacement emailReplacementType = EmailReplacement.NO_REPLACEMENT;
+ private static String atReplacement = " <b>at</b> ";
+ private static String dotReplacement = " <b>dot</b> ";
+
+ private static final String NAME = "author";
+ private static final String SINGLE_HEADER = "Author:";
+ private static final String MULTI_HEADER = "Authors:";
+
+ private static boolean enabled = true;
+
+ /**
+ * Matches <code>.</code> (dot).
+ */
+ private static final Pattern dotPattern = Pattern.compile("[.]");
+
+ /**
+ * Matches <code>@</code> (at sign).
+ */
+ private static final Pattern atPattern = Pattern.compile("[@]");
+
+ /**
+ * Matches <code>Real Name (user@domain.tld)</code>.
+ */
+ private static final Pattern authorEmailPattern
+ = Pattern.compile("^"
+ + "\\s*" // optional whitespace
+ + "(" // group #1 start (real name)
+ + "(?:[^\t\r\n ]|\\()+" // first name
+ + "(?:\\s+(?:[^\t\r\n ]|\\()+)*" // additional names
+ + ")" // group #1 end
+ + "\\s*" // optional whitespace
+ + "[(<]" // opening paren
+ + "\\s*" // optional whitespace
+ + "(" // group #2 start (email address)
+ + "(" // group #3 start (email user)
+ + "[A-z0-9_\\-\\.]+" // username
+ + ")" // group #3 end
+ + "[@]" // at sign
+ + "[A-z0-9_\\-]+(?:[.][A-z0-9_\\-]+)+[A-z]" // domain
+ + ")" // group #2 end
+ + "\\s*" // optional whitespace
+ + "(?:\\)|>)" // closing paren
+ + "$");
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ AuthorTaglet authorTaglet = new AuthorTaglet();
+ tagletMap.put(authorTaglet.getName(), authorTaglet);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+ StringBuffer result = new StringBuffer();
+ result.append("<dl class=\"tag list\">");
+ result.append("<dt class=\"tag section header\"><b>");
+ if (tags.length == 1) {
+ result.append(SINGLE_HEADER);
+ }
+ else {
+ result.append(MULTI_HEADER);
+ }
+ result.append("</b></dt>");
+ for (int i = 0; i < tags.length; i++) {
+ result.append("<dd class=\"tag item\">");
+ result.append(replaceEmail(tags[i].text()));
+ result.append("</dd>");
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Reformat the tag text according to {@link #emailReplacementType}.
+ */
+ private String replaceEmail(String text) {
+
+ if (EmailReplacement.NO_REPLACEMENT == emailReplacementType) {
+ return text;
+ }
+ else {
+ Matcher matcher = authorEmailPattern.matcher(text);
+ if (matcher.matches()) {
+ String realName = matcher.group(1);
+ String emailAddress = matcher.group(2);
+ if (EmailReplacement.MAILTO_NAME == emailReplacementType) {
+ return "<a href=\"mailto:" + emailAddress + "\">" + realName + "</a>";
+ }
+ else if (EmailReplacement.NAME_MAILTO_ADDRESS == emailReplacementType) {
+ return realName + " (<a href=\"mailto:" + emailAddress + "\">" + emailAddress + "</a>)";
+ }
+ else if (EmailReplacement.NAME_MANGLED_ADDRESS == emailReplacementType) {
+ Matcher dotMatcher = dotPattern.matcher(emailAddress);
+ Matcher atMatcher = atPattern.matcher(dotMatcher.replaceAll(dotReplacement));
+ String mangledAddress = atMatcher.replaceAll(atReplacement);
+ return realName + " (" + mangledAddress + ")";
+ }
+ else {
+ // this shouldn't happen
+ return text;
+ }
+ }
+ else {
+ return text;
+ }
+ }
+ }
+
+ /**
+ * Set the email replacement type.
+ */
+ public static void setEmailReplacementType(EmailReplacement emailReplacementType)
+ {
+ if (null == emailReplacementType) {
+ throw new NullPointerException();
+ }
+ AuthorTaglet.emailReplacementType = emailReplacementType;
+ }
+
+ /**
+ * Set the HTML text by which the <code>@</code> (at sign) in email
+ * addresses should be replaced if the email replacement type is
+ * <code>NAME_MANGLED_ADDRESS</code>.
+ */
+ public static void setAtReplacement(String atReplacement)
+ {
+ AuthorTaglet.atReplacement = atReplacement;
+ }
+
+ /**
+ * Set the HTML text by which the <code>.</code> (dot) in email
+ * addresses should be replaced if the email replacement type is
+ * <code>NAME_MANGLED_ADDRESS</code>.
+ */
+ public static void setDotReplacement(String dotReplacement)
+ {
+ AuthorTaglet.dotReplacement = dotReplacement;
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ AuthorTaglet.enabled = enabled;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/CodeTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/CodeTaglet.java
new file mode 100644
index 000000000..adc34f391
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/CodeTaglet.java
@@ -0,0 +1,101 @@
+/* gnu.classpath.tools.taglets.CodeTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Doc;
+import com.sun.javadoc.Tag;
+import com.sun.javadoc.FieldDoc;
+import com.sun.javadoc.MemberDoc;
+import com.sun.javadoc.SeeTag;
+
+/**
+ * The default Taglet which shows its contents enclosed in a
+ * <code>code</code> tag.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class CodeTaglet
+ implements Taglet
+{
+ private static final String NAME = "code";
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return true;
+ }
+
+ public String toString(Tag tag) {
+ return "<code>" + tag.text() + "</code>";
+ }
+
+ public String toString(Tag[] tag) {
+ return null;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java
new file mode 100644
index 000000000..60e3e40a8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java
@@ -0,0 +1,123 @@
+/* gnu.classpath.tools.taglets.CopyrightTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * A simple Taglet which handles Copyright information.
+ */
+public class CopyrightTaglet implements Taglet {
+
+ private static final String NAME = "copyright";
+ private static final String HEADER = "Copyright:";
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ CopyrightTaglet copyrightTaglet = new CopyrightTaglet();
+ tagletMap.put(copyrightTaglet.getName(), copyrightTaglet);
+ }
+
+ public String toString(Tag tag) {
+ return toString(new Tag[] { tag });
+ }
+
+ public String toString(Tag[] tags) {
+ if (tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+ StringBuffer result = new StringBuffer();
+ result.append("<dl>");
+ for (int i = 0; i < tags.length; i++) {
+ if (tags[i].text().length() > 0) {
+ result.append("<dt><i>Copyright &#169; " + tags[i].text() + "</i></dt>");
+ }
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java
new file mode 100644
index 000000000..d292c7f3a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java
@@ -0,0 +1,132 @@
+/* gnu.classpath.tools.taglets.DeprecatedTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * The default Taglet which handles deprecated information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class DeprecatedTaglet implements Taglet {
+
+ private static final String NAME = "deprecated";
+ private static final String HEADER = "Deprecated:";
+
+ private static boolean enabled = true;
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ DeprecatedTaglet deprecatedTaglet = new DeprecatedTaglet();
+ tagletMap.put(deprecatedTaglet.getName(), deprecatedTaglet);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+
+ StringBuffer result = new StringBuffer();
+ result.append("<div class=\"classdoc-tag-section-header\">");
+ result.append(HEADER);
+ result.append("</div>");
+ result.append("<dl class=\"classdoc-list\">");
+ for (int i = 0; i < tags.length; i++) {
+ result.append("<dt>");
+ result.append(tags[i].text());
+ result.append("</dt>");
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ DeprecatedTaglet.enabled = enabled;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/GenericTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/GenericTaglet.java
new file mode 100644
index 000000000..31ff28922
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/GenericTaglet.java
@@ -0,0 +1,157 @@
+/* gnu.classpath.tools.taglets.GenericTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * A taglet which can be configured at runtime.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class GenericTaglet implements Taglet {
+
+ private String name = "since";
+ private String header = "Since:";
+
+ private boolean scopeOverview;
+ private boolean scopePackage;
+ private boolean scopeType;
+ private boolean scopeConstructor;
+ private boolean scopeMethod;
+ private boolean scopeField;
+
+ private boolean enabled = true;
+
+ public GenericTaglet(String name,
+ String header,
+ boolean scopeOverview,
+ boolean scopePackage,
+ boolean scopeType,
+ boolean scopeConstructor,
+ boolean scopeMethod,
+ boolean scopeField)
+ {
+ this.name = name;
+ this.header = header;
+ this.scopeOverview = scopeOverview;
+ this.scopePackage = scopePackage;
+ this.scopeType = scopeType;
+ this.scopeConstructor = scopeConstructor;
+ this.scopeMethod = scopeMethod;
+ this.scopeField = scopeField;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean inField() {
+ return scopeField;
+ }
+
+ public boolean inConstructor() {
+ return scopeConstructor;
+ }
+
+ public boolean inMethod() {
+ return scopeMethod;
+ }
+
+ public boolean inOverview() {
+ return scopeOverview;
+ }
+
+ public boolean inPackage() {
+ return scopePackage;
+ }
+
+ public boolean inType() {
+ return scopeType;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public void register(Map tagletMap) {
+ tagletMap.put(getName(), this);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+
+ StringBuffer result = new StringBuffer();
+ result.append("<div class=\"classdoc-tag-section-header\">");
+ result.append(header);
+ result.append("</div>");
+ result.append("<dl class=\"classdoc-list\">");
+ for (int i = 0; i < tags.length; i++) {
+ result.append("<dt>");
+ result.append(tags[i].text());
+ result.append("</dt>");
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public void setTagletEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/GnuExtendedTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/GnuExtendedTaglet.java
new file mode 100644
index 000000000..e78019067
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/GnuExtendedTaglet.java
@@ -0,0 +1,48 @@
+/* gnu.classpath.tools.taglets.GnuExtendedTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import com.sun.javadoc.Tag;
+import com.sun.tools.doclets.Taglet;
+
+public interface GnuExtendedTaglet
+ extends Taglet
+{
+ public String toString(Tag tag, TagletContext context);
+ public String toString(Tag[] tags, TagletContext context);
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/SinceTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/SinceTaglet.java
new file mode 100644
index 000000000..c3737522d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/SinceTaglet.java
@@ -0,0 +1,161 @@
+/* gnu.classpath.tools.taglets.SinceTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+import gnu.classpath.tools.doclets.InlineTagRenderer;
+
+/**
+ * The default Taglet which handles since information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class SinceTaglet implements GnuExtendedTaglet {
+
+ private static final String NAME = "since";
+ private static final String HEADER = "Since:";
+
+ private static boolean enabled = true;
+
+ private InlineTagRenderer inlineTagRenderer;
+
+ public SinceTaglet(InlineTagRenderer inlineTagRenderer)
+ {
+ this.inlineTagRenderer = inlineTagRenderer;
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public String toString(Tag tag) {
+ // should raise assertion
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ // should raise assertion
+ return toString(tags, null);
+ }
+
+ public String toString(Tag tag, TagletContext context)
+ {
+ return null;
+ }
+
+ public String toString(Tag[] tags, TagletContext context)
+ {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+ StringBuffer result = new StringBuffer();
+ result.append("<dl class=\"tag list\">");
+ result.append("<dt class=\"tag section header\"><b>");
+ result.append(HEADER);
+ result.append("</b></dt>");
+ for (int i = 0; i < tags.length; ++i) {
+ if (tags[i].text().length() > 0) {
+ result.append("<dd>");
+ result.append(inlineTagRenderer.renderInlineTags(tags[i].inlineTags(), context));
+ result.append("</dd>");
+ }
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ SinceTaglet.enabled = enabled;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/TagletContext.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/TagletContext.java
new file mode 100644
index 000000000..82d8aea26
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/TagletContext.java
@@ -0,0 +1,60 @@
+/* TagletContext.java -
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import com.sun.javadoc.Doc;
+
+public class TagletContext
+{
+ protected Doc doc;
+
+ public TagletContext(Doc doc)
+ {
+ this.doc = doc;
+ }
+
+ public Doc getDoc()
+ {
+ return this.doc;
+ }
+
+ public String toString()
+ {
+ return "TagletContext{doc=" + doc + "}";
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/ValueTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/ValueTaglet.java
new file mode 100644
index 000000000..1b07ada8c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/ValueTaglet.java
@@ -0,0 +1,130 @@
+/* gnu.classpath.tools.taglets.ValueTaglet
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Doc;
+import com.sun.javadoc.Tag;
+import com.sun.javadoc.FieldDoc;
+import com.sun.javadoc.MemberDoc;
+import com.sun.javadoc.SeeTag;
+
+/**
+ * The default Taglet which shows final static field values.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class ValueTaglet
+ implements GnuExtendedTaglet
+{
+ private static final String NAME = "value";
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return true;
+ }
+
+ public static void register(Map tagletMap) {
+ ValueTaglet valueTaglet = new ValueTaglet();
+ tagletMap.put(valueTaglet.getName(), valueTaglet);
+ }
+
+ public String toString(Tag tag) {
+ return null;
+ }
+
+ public String toString(Tag tag, TagletContext context) {
+ if (0 == tag.inlineTags().length) {
+ if (context.getDoc().isField()) {
+ FieldDoc fieldDoc = (FieldDoc)context.getDoc();
+ if (fieldDoc.isStatic() && fieldDoc.isFinal()) {
+ return fieldDoc.constantValueExpression();
+ }
+ }
+ }
+ else {
+ MemberDoc referencedMember = ((SeeTag)tag).referencedMember();
+ if (null != referencedMember && referencedMember.isField()) {
+ FieldDoc fieldDoc = (FieldDoc)referencedMember;
+ if (fieldDoc.isStatic() && fieldDoc.isFinal()) {
+ return fieldDoc.constantValueExpression();
+ }
+ }
+ }
+ return "";
+ }
+
+ public String toString(Tag[] tags) {
+ return null;
+ }
+
+ public String toString(Tag[] tags, TagletContext context) {
+ return null;
+ }
+
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/taglets/VersionTaglet.java b/libjava/classpath/tools/gnu/classpath/tools/taglets/VersionTaglet.java
new file mode 100644
index 000000000..fed926e06
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/taglets/VersionTaglet.java
@@ -0,0 +1,153 @@
+/* gnu.classpath.tools.taglets.VersionTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * The default Taglet which handles version information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class VersionTaglet implements Taglet {
+
+ private static final String NAME = "version";
+ private static final String HEADER = "Version:";
+
+ private static boolean enabled = true;
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ VersionTaglet versionTaglet = new VersionTaglet();
+ tagletMap.put(versionTaglet.getName(), versionTaglet);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+
+ StringBuffer result = new StringBuffer();
+ result.append("<dl class=\"tag list\">");
+ result.append("</dl>");
+ result.append("<dt class=\"tag section header\"><b>");
+ result.append(HEADER);
+ result.append("</b></dt><dd>");
+ boolean firstEntry = true;
+ for (int i = 0; i < tags.length; i++) {
+ if (tags[i].text().length() > 0) {
+ if (!firstEntry) {
+ result.append(", ");
+ }
+ else {
+ firstEntry = false;
+ }
+ result.append(tags[i].text());
+ }
+ }
+ result.append("</dd>");
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ VersionTaglet.enabled = enabled;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/tnameserv/Main.java b/libjava/classpath/tools/gnu/classpath/tools/tnameserv/Main.java
new file mode 100644
index 000000000..b163fd539
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/tnameserv/Main.java
@@ -0,0 +1,115 @@
+/* Main.java -- Transient GIOP naming service.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.tnameserv;
+
+import gnu.CORBA.NamingService.NamingServiceTransient;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+/**
+ * The implementation of the transient naming service. The naming service
+ * is a kind of the network server that registers local and remote objects
+ * by name, and later can provide the object reference in response to the
+ * given name.
+ *
+ * GNU Classpath currently works with this naming service and is also
+ * interoperable with the Sun Microsystems naming services from releases 1.3 and
+ * 1.4, both transient <i>tnameserv</i> and persistent <i>orbd</i>.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Main
+{
+ private int port = -1;
+ private String iorf;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("tnameserv", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("ORBInitialPort", //$NON-NLS-1$
+ Messages.getString("Main.ORBInitialPort"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ parser.add(new Option("ior", //$NON-NLS-1$
+ Messages.getString("Main.IOR"), //$NON-NLS-1$
+ Messages.getString("Main.IORFile")) //$NON-NLS-1$
+ {
+ public void parsed(String fileArgument) throws OptionException
+ {
+ iorf = fileArgument;
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args);
+ NamingServiceTransient.start(port, iorf);
+ }
+
+ /**
+ * The naming service entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main tnameservprogram = new Main();
+ try
+ {
+ tnameservprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/tnameserv/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/tnameserv/Messages.java
new file mode 100644
index 000000000..505397302
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/tnameserv/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for tnameserv
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.tnameserv;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.tnameserv.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/gorbd.in b/libjava/classpath/tools/gorbd.in
new file mode 100644
index 000000000..dbe33d3a0
--- /dev/null
+++ b/libjava/classpath/tools/gorbd.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath orbd tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.orbd.Main "$@"
diff --git a/libjava/classpath/tools/grmic.in b/libjava/classpath/tools/grmic.in
new file mode 100644
index 000000000..299b4b50b
--- /dev/null
+++ b/libjava/classpath/tools/grmic.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmic tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.rmic.Main "$@"
diff --git a/libjava/classpath/tools/grmid.in b/libjava/classpath/tools/grmid.in
new file mode 100644
index 000000000..73e5789ee
--- /dev/null
+++ b/libjava/classpath/tools/grmid.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmid tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.rmid.Main "$@"
diff --git a/libjava/classpath/tools/grmiregistry.in b/libjava/classpath/tools/grmiregistry.in
new file mode 100644
index 000000000..e3bbb7386
--- /dev/null
+++ b/libjava/classpath/tools/grmiregistry.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmiregistry tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.rmiregistry.Main "$@"
diff --git a/libjava/classpath/tools/gserialver.in b/libjava/classpath/tools/gserialver.in
new file mode 100644
index 000000000..24acdeb81
--- /dev/null
+++ b/libjava/classpath/tools/gserialver.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath serialver tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.serialver.SerialVer "$@"
diff --git a/libjava/classpath/tools/gtnameserv.in b/libjava/classpath/tools/gtnameserv.in
new file mode 100644
index 000000000..119062d09
--- /dev/null
+++ b/libjava/classpath/tools/gtnameserv.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath tnameserv tool.
+##
+
+prefix=@prefix@
+datarootdir=@datarootdir@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.tnameserv.Main "$@"
diff --git a/libjava/classpath/tools/jarsigner.in b/libjava/classpath/tools/jarsigner.in
new file mode 100644
index 000000000..537b7faf0
--- /dev/null
+++ b/libjava/classpath/tools/jarsigner.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath jarsigner tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jarsigner.Main $@
diff --git a/libjava/classpath/tools/keytool.in b/libjava/classpath/tools/keytool.in
new file mode 100644
index 000000000..613baf7fd
--- /dev/null
+++ b/libjava/classpath/tools/keytool.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is 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 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath keytool tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.keytool.Main $@
diff --git a/libjava/classpath/tools/resource/com/sun/tools/javac/messages.properties b/libjava/classpath/tools/resource/com/sun/tools/javac/messages.properties
new file mode 100644
index 000000000..995e871d9
--- /dev/null
+++ b/libjava/classpath/tools/resource/com/sun/tools/javac/messages.properties
@@ -0,0 +1,42 @@
+# messages.properties -- English language messages
+# Copyright (C) 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.FailedToRead:failed to read ecj.jar (reconfigure with --with-ecj-jar): {0}
+Main.MalformedURL:malformed URL for ecj.jar: {0}
+Main.FailedToLoad:failed to load {0} from ecj.jar: {1}
+Main.FailedConstructor:failed to find ecj constructor
+Main.FailedCompile:failed to find ecj compile method
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/appletviewer/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/appletviewer/messages.properties
new file mode 100644
index 000000000..c826afa21
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/appletviewer/messages.properties
@@ -0,0 +1,102 @@
+# messages.properties -- English language messages
+# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.ErrorApplet=An error occurred while loading this applet.
+Main.Usage=Usage: appletviewer [OPTION] -code CODE | URL...
+Main.AppletTagOptions=Applet tag options
+Main.CodeDescription=specify the code attribute
+Main.CodeArgument=CODE
+Main.CodebaseDescription=specify the codebase attribute
+Main.CodebaseArgument=CODEBASE
+Main.ArchiveDescription=specify the archive attribute
+Main.ArchiveArgument=ARCHIVE
+Main.WidthDescription=specify the width attribute
+Main.WidthArgument=WIDTH
+Main.HeightDescription=specify the height attribute
+Main.HeightArgument=HEIGHT
+Main.ParamDescription=specify the parameter arguments
+Main.ParamArgument=NAME,VALUE
+Main.PluginOption=Plugin option
+Main.PluginDescription=enable plugin mode
+Main.PluginArgument=INPUT,OUTPUT
+Main.DebuggingOption=Debugging option
+Main.VerboseDescription=enable verbose mode
+Main.CompatibilityOptions=Compatibility options
+Main.DebugDescription=enable debugging mode (not implemented)
+Main.EncodingDescription=specify the HTML character encoding
+Main.EncodingArgument=CHARSET
+Main.SecurityWarning=WARNING: CURRENTLY GAPPLETVIEWER RUNS WITH NO\
+ SECURITY MANAGER.\n\
+THIS MEANS THAT APPLETS YOU LOAD CAN DO ANYTHING A JAVA APPLICATION\n\
+THAT YOU DOWNLOAD AND RUN CAN DO. BE *VERY* CAREFUL WHICH APPLETS YOU RUN.\n\
+DO NOT USE GAPPLETVIEWER ON YOUR SYSTEM IF YOUR SYSTEM STORES IMPORTANT\
+ DATA.\n\
+THIS DATA CAN BE DESTROYED OR STOLEN IF YOU LOAD A MALICIOUS APPLET.
+Main.ContinuationPrompt=[press 'c' or 'C' to continue or anything else to quit]
+Main.NoInputFiles=appletviewer: no input files
+Main.RawArguments=Raw arguments:
+
+PluginAppletViewer.AppletViewerWrote=PIPE: applet viewer wrote:
+PluginAppletViewer.AppletViewerRead=PIPE: applet viewer read:
+PluginAppletViewer.AppletViewerExiting=appletviewer: exiting plugin applet\
+ viewer
+
+StandaloneAppletContext.ShowDocumentError=showDocument is not implemented in\
+ standalone mode
+
+StandaloneAppletViewer.ParsedAppletTags=Parsed applet tags:
+StandaloneAppletViewer.Tag=tag
+StandaloneAppletViewer.CodeOptionError=appletviewer: option '--code' requires\
+ a class filename
+
+StandaloneAppletWindow.MenuTitle=Applet
+StandaloneAppletWindow.MenuReload=Reload
+StandaloneAppletWindow.MenuRestart=Restart
+StandaloneAppletWindow.MenuStart=Start
+StandaloneAppletWindow.MenuStop=Stop
+StandaloneAppletWindow.MenuClone=Clone ...
+StandaloneAppletWindow.MenuQuit=Quit
+StandaloneAppletWindow.MenuClose=Close
+StandaloneAppletWindow.MenuTag=Tag ...
+StandaloneAppletWindow.MenuInfo=Info ...
+StandaloneAppletWindow.MenuEdit=Edit
+StandaloneAppletWindow.MenuEncoding=Character Encoding
+StandaloneAppletWindow.MenuPrint=Print ...
+StandaloneAppletWindow.MenuProperties=Properties ...
+StandaloneAppletWindow.MenuCancel=Cancel
+StandaloneAppletWindow.MenuSave=Save ...
+StandaloneAppletWindow.WindowTitle=GNU Classpath Applet Viewer:
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/common/Messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/common/Messages.properties
new file mode 100644
index 000000000..17e79c453
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/common/Messages.properties
@@ -0,0 +1,40 @@
+# MessagesBundle.properties -- English language messages
+# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+ClasspathToolParser.JArgument=pass argument to the Java runtime
+ClasspathToolParser.JName=OPTION
+ClasspathToolParser.VersionFormat={0} (GNU Classpath) {1}\n\nCopyright 2008 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/getopt/Messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/getopt/Messages.properties
new file mode 100644
index 000000000..a747ab4b4
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/getopt/Messages.properties
@@ -0,0 +1,46 @@
+# MessagesBundle.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Parser.StdOptions=Standard options
+Parser.PrintHelp=print this help, then exit
+Parser.PrintVersion=print version number, then exit
+Parser.ArgReqd=option ''{0}'' requires an argument
+Parser.Unrecognized=unrecognized option ''{0}''
+Parser.NoArg=option ''{0}'' doesn''t allow an argument
+Parser.UnrecDash=unrecognized option ''-{0}''
+Parser.TryHelpShort=Try ''{0} -help'' for more information
+Parser.TryHelpLong=Try ''{0} --help'' for more information
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/gjdoc_common.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/gjdoc_common.xsl
new file mode 100644
index 000000000..2b5aec105
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/gjdoc_common.xsl
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- gjdoc_common.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Common templates for HTML generation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:param name="gjdoc.outputfile.info" select="''"/>
+ <xsl:param name="gjdoc.refdocs1" select="''"/>
+ <xsl:param name="gjdoc.pathtoroot" select="''"/>
+ <xsl:param name="gjdoc.xmldoclet.version" select="''"/>
+ <xsl:param name="gjdoc.allowimages" select="0"/>
+ <xsl:param name="gjdoc.option.nonavbar" select="''"/>
+ <xsl:param name="gjdoc.option.noindex" select="''"/>
+ <xsl:param name="gjdoc.option.notree" select="''"/>
+ <xsl:param name="gjdoc.option.nohelp" select="''"/>
+ <xsl:param name="gjdoc.option.nocomment" select="''"/>
+ <xsl:param name="gjdoc.option.splitindex" select="''"/>
+ <xsl:param name="gjdoc.option.linksource" select="''"/>
+ <xsl:param name="gjdoc.option.windowtitle" select="''"/>
+ <xsl:param name="gjdoc.option.helpfile" select="''"/>
+ <xsl:param name="gjdoc.option.stylesheetfile" select="''"/>
+ <xsl:param name="gjdoc.option.header" select="''"/>
+ <xsl:param name="gjdoc.option.footer" select="''"/>
+ <xsl:param name="gjdoc.option.bottom" select="''"/>
+ <xsl:param name="gjdoc.option.doctitle" select="''"/>
+ <xsl:param name="gjdoc.option.nodeprecatedlist" select="''"/>
+ <xsl:param name="gjdoc.option.uses" select="''"/>
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/about.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/about.xsl
new file mode 100644
index 000000000..fa78cb309
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/about.xsl
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- about.xsl
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the class descriptor files for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="html"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <xsl:call-template name="include_common"/>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="'Help'"/>
+ </xsl:call-template>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded()">
+
+ <div class="pagebody">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_about" select="0"/>
+ <xsl:with-param name="p_curr_about" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <h1 class="classdoc-title">About this API documentation</h1>
+
+ <div class="footer">
+ <xsl:text>Generated on</xsl:text><xsl:value-of select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:created"/><xsl:text> by </xsl:text><a href="http://www.gnu.org/software/cp-tools" target="cptoolsinfo"><xsl:text>GNU Classpath Tools</xsl:text></a><xsl:text> (Gjdoc XmlDoclet </xsl:text><xsl:value-of select="$gjdoc.xmldoclet.version"/><xsl:text>).</xsl:text>
+ </div>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_about" select="0"/>
+ <xsl:with-param name="p_curr_about" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allclasses.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allclasses.xsl
new file mode 100644
index 000000000..8739d197f
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allclasses.xsl
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- allclasses.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the allclasses.html file for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <title>
+ <xsl:value-of select="concat(/gjdoc:rootdoc/gjdoc:title, ' - All Classes')"/>
+ </title>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body onload="secondaryPageLoaded('classes');" class="menu allclasses">
+ <h3 class="menu-title">All Classes</h3>
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@name">
+ <xsl:sort select="." order="ascending"/>
+ <xsl:variable name="v_url" select="concat(translate(../gjdoc:containingPackage/@name,'.','/'), '/', ../@name, '.html')"/>
+ <a href="{$v_url}" target="content" class="menu allclasses">
+ <xsl:value-of select="."/>
+ </a>
+ <br/>
+ </xsl:for-each>
+ </body>
+ </html>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allpackages.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allpackages.xsl
new file mode 100644
index 000000000..d4449ef5e
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allpackages.xsl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- allpackages.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the allpackages.html file for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <title>
+ <xsl:if test="document('index.xml',/)/gjdoc:rootdoc/gjdoc:title">
+ <xsl:value-of select="document('index.xml',/)/gjdoc:rootdoc/gjdoc:title"/>
+ <xsl:text> - </xsl:text>
+ </xsl:if>
+ <xsl:text>Packages</xsl:text>
+ <xsl:value-of select="@name"/>
+ </title>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="menu allpackages">
+ <h3 class="menu-title">
+ <a href="index_noframes.html" target="content">
+ <xsl:choose>
+ <xsl:when test="document('index.xml',/)/gjdoc:rootdoc/gjdoc:title">
+ <xsl:value-of select="document('index.xml',/)/gjdoc:rootdoc/gjdoc:title"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>Packages</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </a>
+ </h3>
+ <a href="allclasses.html" target="classes" class="menu allpackages">All Classes</a><br/><br/>
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:specifiedpackage/@name">
+ <xsl:sort select="." order="ascending"/>
+ <a href="{concat(translate(., '.','/'), '/classes.html')}" target="classes" class="menu allpackages">
+ <xsl:value-of select="."/>
+ </a>
+ <br/>
+ </xsl:for-each>
+ </body>
+ </html>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex.xsl
new file mode 100644
index 000000000..5aa915cd8
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex.xsl
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- alphaindex.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the alphaindex.html file for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="'Alphabetical Index'"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="0"/>
+ <xsl:with-param name="p_curr_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <div class="pagebody">
+ <h1 class="classdoc-title">
+ Alphabetical Index
+ </h1>
+
+ <div class="index-categories">
+ <xsl:for-each select="document('alphaindex.xml',/)/gjdoc:alphaindex/gjdoc:category">
+ <xsl:choose>
+ <xsl:when test="@letter=$gjdoc.outputfile.info">
+ <span class="index-category-current"><xsl:value-of select="@letter"/></span>
+ </xsl:when>
+ <xsl:otherwise>
+ <a href="{concat('#category_', @letter)}" class="index-category-link"><xsl:value-of select="@letter"/></a>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </div>
+
+ <xsl:for-each select="document('alphaindex.xml',/)/gjdoc:alphaindex/gjdoc:category">
+ <a name="{concat('category_', @letter)}" class="classdoc"><h3 class="ignore"> </h3></a>
+ <h2><xsl:value-of select="@letter"/></h2>
+ <xsl:call-template name="output_alphaindex_category"/>
+ </xsl:for-each>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="0"/>
+ <xsl:with-param name="p_curr_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+ </div>
+ </body>
+ </html>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex_chunked.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex_chunked.xsl
new file mode 100644
index 000000000..e1847385b
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex_chunked.xsl
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- alphaindex.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the alphaindex.html file for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="concat('Alphabetical Index: ', $gjdoc.outputfile.info)"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)">
+ <div class="pagebody">
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="0"/>
+ <xsl:with-param name="p_curr_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <h1 class="classdoc-title">
+ Alphabetical Index
+ <xsl:if test="$gjdoc.outputfile.info">
+ -
+ <xsl:value-of select="$gjdoc.outputfile.info"/>
+ </xsl:if>
+ </h1>
+
+ <div class="index-categories">
+ <xsl:for-each select="document('alphaindex.xml',/)/gjdoc:alphaindex/gjdoc:category">
+ <xsl:choose>
+ <xsl:when test="@letter=$gjdoc.outputfile.info">
+ <span class="index-category-current"><xsl:value-of select="@letter"/></span>
+ </xsl:when>
+ <xsl:otherwise>
+ <a href="{concat('alphaindex_', @letter, '.html') class="index-category-link"}"><xsl:value-of select="@letter"/></a>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </div>
+
+ <xsl:if test="$gjdoc.outputfile.info">
+ <xsl:for-each select="document('alphaindex.xml',/)/gjdoc:alphaindex/gjdoc:category[@letter=$gjdoc.outputfile.info]">
+ <h2><xsl:value-of select="@letter"/></h2>
+ <xsl:call-template name="output_alphaindex_category"/>
+ </xsl:for-each>
+
+ </xsl:if>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="0"/>
+ <xsl:with-param name="p_curr_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+ </div>
+ </body>
+ </html>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-source.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-source.xsl
new file mode 100644
index 000000000..a6405e40c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-source.xsl
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- classdoc-source.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Outputs an HTML file showing the source code for the class
+ designated by $gjdoc.outputfile.info.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="html"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <xsl:for-each select="document(concat($gjdoc.outputfile.info, '.xml'),/gjdoc:rootdoc)/gjdoc:classdoc/gjdoc:source">
+ <html>
+ <head>
+ <xsl:call-template name="include_common"/>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="concat(ancestor::gjdoc:classdoc/@name, '.java')"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <xsl:copy-of select="."/>
+ </body>
+ </html>
+ </xsl:for-each>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-uses.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-uses.xsl
new file mode 100644
index 000000000..17f9b3f7f
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-uses.xsl
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- classdoc-uses.xsl
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Outputs an HTML file showing the source code for the class
+ designated by $gjdoc.outputfile.info.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="html"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="gjdoc:referencing-package">
+ <h2 class="classdoc-header">
+ Uses in package
+ <xsl:value-of select="@name"/>
+ </h2>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="gjdoc:user">
+ <dt>
+ <xsl:choose>
+ <xsl:when test="@field">
+ <a href="{concat($gjdoc.pathtoroot, translate(ancestor::gjdoc:referencing-package/@name, '.', '/'), '/', @class, '.html#', @field)}">
+ <xsl:value-of select="concat(@class, '.', @field)"/>
+ </a>
+ </xsl:when>
+ <xsl:when test="@method">
+ <a href="{concat($gjdoc.pathtoroot, translate(ancestor::gjdoc:referencing-package/@name, '.', '/'), '/', @class, '.html#', @method, @signature)}">
+ <xsl:value-of select="concat(@class, '.', @method, @flatSignature)"/>
+ </a>
+ </xsl:when>
+ <xsl:when test="@class">
+ <a href="{concat($gjdoc.pathtoroot, translate(ancestor::gjdoc:referencing-package/@name, '.', '/'), '/', @class, '.html')}">
+ <xsl:value-of select="@class"/>
+ </a>
+ </xsl:when>
+ </xsl:choose>
+ </dt>
+ </xsl:template>
+
+ <xsl:template match="gjdoc:usage-type">
+
+ <h3 class="classdoc-header">
+ <xsl:variable name="v_qualifiedtypename"
+ select="ancestor::gjdoc:classdoc/@qualifiedtypename"/>
+ <xsl:variable name="v_packagename"
+ select="../@name"/>
+ <xsl:choose>
+ <xsl:when test="@id='class-derived-from'">
+ <xsl:text>Classes in </xsl:text><xsl:value-of select="$v_packagename"/><xsl:text> derived from </xsl:text><xsl:value-of select="$v_qualifiedtypename"/>
+ </xsl:when>
+ <xsl:when test="@id='field-of-type'">
+ <xsl:text>Fields in </xsl:text><xsl:value-of select="$v_packagename"/><xsl:text> of type </xsl:text><xsl:value-of select="$v_qualifiedtypename"/>
+ </xsl:when>
+ <xsl:when test="@id='method-with-return-type'">
+ <xsl:text>Methods in </xsl:text><xsl:value-of select="$v_packagename"/><xsl:text> returning </xsl:text><xsl:value-of select="$v_qualifiedtypename"/>
+ </xsl:when>
+ <xsl:when test="@id='method-with-parameter-type'">
+ <xsl:text>Methods in </xsl:text><xsl:value-of select="$v_packagename"/><xsl:text> accepting parameters of type </xsl:text><xsl:value-of select="$v_qualifiedtypename"/>
+ </xsl:when>
+ <xsl:when test="@id='method-with-thrown-type'">
+ <xsl:text>Methods in </xsl:text><xsl:value-of select="$v_packagename"/><xsl:text> throwing </xsl:text><xsl:value-of select="$v_qualifiedtypename"/>
+ </xsl:when>
+ <xsl:when test="@id='constructor-with-parameter-type'">
+ <xsl:text>Constructors in </xsl:text><xsl:value-of select="$v_packagename"/><xsl:text> accepting parameters of type </xsl:text><xsl:value-of select="$v_qualifiedtypename"/>
+ </xsl:when>
+ <xsl:when test="@id='constructor-with-thrown-type'">
+ <xsl:text>Constructors in </xsl:text><xsl:value-of select="$v_packagename"/><xsl:text> throwing </xsl:text><xsl:value-of select="$v_qualifiedtypename"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>Unknown ID </xsl:text><xsl:value-of select="@id"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </h3>
+ <dl>
+ <xsl:apply-templates/>
+ </dl>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <xsl:call-template name="include_common"/>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="concat(ancestor::gjdoc:classdoc/@name, ' Class Usage')"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <div class="pagebody">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="1"/>
+ <xsl:with-param name="p_show_package_tree" select="1"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ <xsl:with-param name="p_show_source" select="concat($gjdoc.pathtoroot, 'src-html/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_show_class" select="concat($gjdoc.pathtoroot, translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_curr_uses" select="1"/>
+ </xsl:call-template>
+
+ <xsl:for-each select="document(concat($gjdoc.outputfile.info, '.xml'),/gjdoc:rootdoc)/gjdoc:classdoc/gjdoc:references">
+
+ <h1 class="classdoc-header">
+ Uses of class
+ <xsl:value-of select="ancestor::gjdoc:classdoc/@qualifiedtypename"/>
+ <xsl:apply-templates/>
+ </h1>
+ </xsl:for-each>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="1"/>
+ <xsl:with-param name="p_show_package_tree" select="1"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ <xsl:with-param name="p_show_source" select="concat($gjdoc.pathtoroot, 'src-html/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_show_class" select="concat($gjdoc.pathtoroot, translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_curr_uses" select="1"/>
+ </xsl:call-template>
+
+ </div>
+ </body>
+ </html>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc.xsl
new file mode 100644
index 000000000..e54e5fb12
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc.xsl
@@ -0,0 +1,1070 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- classdoc.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the class descriptor files for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="html"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="gjdoc:tag[attribute::kind='@see'][attribute::name='@link']">
+ <xsl:call-template name="output_link_tag"/>
+ </xsl:template>
+
+ <xsl:template mode="pre" match="*">
+ <xsl:choose>
+ <xsl:when test="'pre'=local-name(.)">
+ <xsl:apply-templates mode="pre"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template mode="pre" match="text()[position()=last()]">
+ <xsl:call-template name="strip_trailing_ws">
+ <xsl:with-param name="p_content" select="."/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template name="strip_trailing_ws">
+ <xsl:param name="p_content"/>
+
+ <xsl:if test="normalize-space($p_content)!=''">
+ <xsl:choose>
+ <xsl:when test="normalize-space(substring($p_content, string-length($p_content), 1))=''">
+ <xsl:call-template name="strip_trailing_ws">
+ <xsl:with-param name="p_content">
+ <xsl:value-of select="substring($p_content, 1, string-length($p_content)-1)"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$p_content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="*">
+ <xsl:element name="{name()}">
+ <xsl:for-each select="attribute::*">
+ <xsl:attribute name="{name()}">
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ </xsl:for-each>
+ <xsl:choose>
+ <xsl:when test="name()='pre'">
+ <xsl:apply-templates select="." mode="pre"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="/">
+
+ <xsl:for-each select="document(concat($gjdoc.outputfile.info, '.xml'),/gjdoc:rootdoc)/gjdoc:classdoc">
+ <xsl:call-template name="create_classdoc"/>
+ </xsl:for-each>
+
+ </xsl:template>
+
+ <!-- For every classdoc node found in the source XML, create a corresponding -->
+ <!-- class rootdoc HTML file. -->
+
+ <xsl:template name="create_classdoc">
+
+ <xsl:variable name="v_sub_xml_filename">
+ <xsl:value-of select="concat(@qualifiedtypename,'.xml')"/>
+ </xsl:variable>
+
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="@name"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)">
+
+ <div class="pagebody">
+
+ <xsl:call-template name="classdoc_header"/>
+ <xsl:call-template name="classdoc_all_field_summary">
+ <xsl:with-param name="v_sub_xml_filename">
+ <xsl:value-of select="$v_sub_xml_filename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:call-template name="classdoc_all_constructor_summary">
+ <xsl:with-param name="v_sub_xml_filename">
+ <xsl:value-of select="$v_sub_xml_filename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:call-template name="classdoc_all_method_summary">
+ <xsl:with-param name="v_sub_xml_filename">
+ <xsl:value-of select="$v_sub_xml_filename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:if test="gjdoc:fielddoc">
+ <h1 class="classdoc-header">Field Details</h1>
+
+ <xsl:for-each select="gjdoc:fielddoc">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="classdoc_field_details"/>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:constructordoc">
+ <h1 class="classdoc-header">Constructor Details</h1>
+
+ <xsl:for-each select="gjdoc:constructordoc">
+ <xsl:sort select="gjdoc:signature/@full" order="ascending"/>
+ <xsl:call-template name="classdoc_method_details"/>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:methoddoc">
+ <h1 class="classdoc-header">Method Details</h1>
+
+ <xsl:for-each select="gjdoc:methoddoc">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:sort select="gjdoc:signature/@full" order="ascending"/>
+ <xsl:call-template name="classdoc_method_details"/>
+ </xsl:for-each>
+ </xsl:if>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="1"/>
+ <xsl:with-param name="p_show_package_tree" select="1"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ <xsl:with-param name="p_show_source" select="concat($gjdoc.pathtoroot, 'src-html/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_show_use" select="concat($gjdoc.pathtoroot, 'class-use/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_curr_class" select="1"/>
+ </xsl:call-template>
+
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+ <!-- Output header for Class documentation -->
+
+ <xsl:template name="classdoc_header">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="1"/>
+ <xsl:with-param name="p_show_package_tree" select="1"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ <xsl:with-param name="p_show_source" select="concat($gjdoc.pathtoroot, 'src-html/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_show_use" select="concat($gjdoc.pathtoroot, 'class-use/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ <xsl:with-param name="p_curr_class" select="1"/>
+ </xsl:call-template>
+
+ <div class="classdoc-head">
+
+ <div class="classdoc-head-packagename classdoc-subtitle">
+ <xsl:value-of select="gjdoc:containingPackage/@name"/>
+ </div>
+
+ <h1 class="classdoc-head-classname classdoc-title">
+ <xsl:choose>
+ <xsl:when test="gjdoc:isInterface">
+ <xsl:text>Interface </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>Class </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of select="@name"/>
+ </h1>
+
+ </div>
+
+ <xsl:if test="gjdoc:isClass">
+ <xsl:call-template name="classdoc_heritage_tree"/>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:containingClass">
+ <xsl:variable name="v_qualifiedtypename" select="attribute::qualifiedtypename"/>
+ <b>Enclosing Class:</b><br/>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_name" select="gjdoc:containingClass/@typename"/>
+ <xsl:with-param name="p_qualifiedname" select="gjdoc:containingClass/@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:implements">
+ <p/>
+ <b>
+ <xsl:choose>
+ <xsl:when test="gjdoc:isInterface">
+ <xsl:text>All Superinterfaces:</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>All Implemented Interfaces:</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </b>
+ <br/>
+ <xsl:for-each select="gjdoc:implements|gjdoc:superimplements">
+ <xsl:sort select="@qualifiedtypename" order="ascending"/>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_name" select="@typename"/>
+ <xsl:with-param name="p_qualifiedname" select="@qualifiedtypename"/>
+ </xsl:call-template>
+ <xsl:if test="position() != last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:if>
+ <p/>
+
+ <xsl:if test="gjdoc:isInterface">
+ <xsl:variable name="v_qualifiedtypename" select="attribute::qualifiedtypename"/>
+ <xsl:variable name="v_implementors" select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[child::gjdoc:isInterface]/gjdoc:implements[attribute::qualifiedtypename=$v_qualifiedtypename]"/>
+ <xsl:if test="$v_implementors">
+ <b>All Known Direct Subinterfaces:</b><br/>
+ <xsl:for-each select="$v_implementors">
+ <xsl:sort select="../@qualifiedtypename" order="ascending"/>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_name" select="../@name"/>
+ <xsl:with-param name="p_qualifiedname" select="../@qualifiedtypename"/>
+ </xsl:call-template>
+ <xsl:if test="position() != last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:if>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:isInterface">
+ <xsl:variable name="v_qualifiedtypename" select="attribute::qualifiedtypename"/>
+ <xsl:variable name="v_implementors" select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[child::gjdoc:isClass]/gjdoc:implements[attribute::qualifiedtypename=$v_qualifiedtypename]"/>
+ <xsl:if test="$v_implementors">
+ <b>Known Implementing Classes:</b><br/>
+ <xsl:for-each select="$v_implementors">
+ <xsl:sort select="../@qualifiedtypename" order="ascending"/>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_name" select="../@name"/>
+ <xsl:with-param name="p_qualifiedname" select="../@qualifiedtypename"/>
+ </xsl:call-template>
+ <xsl:if test="position() != last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:if>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:isClass">
+ <xsl:variable name="v_qualifiedtypename" select="attribute::qualifiedtypename"/>
+ <xsl:variable name="v_implementors" select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[not(child::gjdoc:isInterface)]/gjdoc:superclass[attribute::qualifiedtypename=$v_qualifiedtypename]"/>
+ <xsl:if test="$v_implementors">
+ <b>Known Direct Subclasses:</b><br/>
+ <xsl:for-each select="$v_implementors">
+ <xsl:sort select="../@qualifiedtypename" order="ascending"/>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_name" select="../@name"/>
+ <xsl:with-param name="p_qualifiedname" select="../@qualifiedtypename"/>
+ </xsl:call-template>
+ <xsl:if test="position() != last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:if>
+ </xsl:if>
+
+ <hr/>
+
+ <div class="classdoc-prototype">
+
+ <!-- 'public final class Byte' -->
+
+ <xsl:value-of select="gjdoc:access/@scope"/><xsl:text> </xsl:text>
+ <xsl:if test="gjdoc:isStatic"><xsl:text>static </xsl:text></xsl:if>
+ <xsl:if test="gjdoc:isFinal"><xsl:text>final </xsl:text></xsl:if>
+ <xsl:choose>
+ <xsl:when test="gjdoc:isInterface">
+ <xsl:text>interface </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="gjdoc:isAbstract"><xsl:text>abstract </xsl:text></xsl:if>
+ <xsl:text>class </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="link_to_class_source"/><br/>
+
+ <!-- 'extends Number' -->
+
+ <xsl:if test="gjdoc:isClass and @qualifiedtypename!='java.lang.Object'">
+ <xsl:text>extends </xsl:text>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_qualifiedname">
+ <xsl:value-of select="gjdoc:superclass/@qualifiedtypename"/>
+ </xsl:with-param>
+ <xsl:with-param name="p_name">
+ <xsl:value-of select="gjdoc:superclass/@typename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <br/>
+ </xsl:if>
+
+ <!-- 'implements Comparable' -->
+
+ <xsl:if test="gjdoc:implements">
+ <xsl:text>implements </xsl:text>
+ </xsl:if>
+ <xsl:for-each select="gjdoc:implements">
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_qualifiedname">
+ <xsl:value-of select="@qualifiedtypename"/>
+ </xsl:with-param>
+ <xsl:with-param name="p_name">
+ <xsl:value-of select="@typename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="position() != last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+
+ </div>
+
+ <!-- Documentation -->
+
+ <p/>
+
+ <xsl:if test="gjdoc:inlineTags">
+ <div class="classdoc-class-comment-body">
+ <xsl:for-each select="gjdoc:inlineTags/node()">
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ </div>
+ </xsl:if>
+
+ <xsl:call-template name="output_see_tags"/>
+ <xsl:call-template name="output_taglet_tags"/>
+
+ </xsl:template>
+
+ <xsl:template name="output_taglet_tags">
+
+ <xsl:for-each select="gjdoc:tags/gjdoc:tag">
+ <xsl:choose>
+ <xsl:when test="@name='@deprecated'">
+ <div class="classdoc-tag-section-header">
+ <xsl:value-of select="'Deprecated:'"/>
+ </div>
+ <dl class="classdoc-list">
+ <xsl:for-each select="gjdoc:inlineTags">
+ <xsl:apply-templates/>
+ </xsl:for-each>
+ </dl>
+ </xsl:when>
+ <xsl:when test="@taglet-generated">
+ <xsl:copy-of select="./*"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:for-each>
+
+ </xsl:template>
+
+ <!-- Output summary of all fields in this class -->
+
+ <xsl:template name="classdoc_all_field_summary">
+
+ <xsl:if test=".//gjdoc:fielddoc">
+
+ <table border="1" cellspacing="0" class="classdoc-table">
+ <tr><td class="section-header" colspan="2"><div class="section-header">Field Summary</div></td></tr>
+ <xsl:for-each select="gjdoc:fielddoc">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="classdoc_field_summary_tr"/>
+ </xsl:for-each>
+ </table>
+
+ <xsl:for-each select="gjdoc:superclass">
+ <xsl:call-template name="output_superclass_fields"/>
+ </xsl:for-each>
+ </xsl:if>
+
+ </xsl:template>
+
+ <!-- Output summary of all methods in this class -->
+
+ <xsl:template name="classdoc_all_method_summary">
+
+ <xsl:if test=".//gjdoc:methoddoc">
+ <table border="1" cellspacing="0" class="classdoc-table">
+ <tr><td class="section-header" colspan="2"><div class="section-header">Method Summary</div></td></tr>
+ <xsl:for-each select="gjdoc:methoddoc">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="classdoc_method_summary_tr"/>
+ </xsl:for-each>
+ </table>
+
+ <xsl:for-each select="gjdoc:superclass">
+ <xsl:call-template name="output_superclass_methods"/>
+ </xsl:for-each>
+ </xsl:if>
+
+ </xsl:template>
+
+ <!-- Output summary of all constructors in this class -->
+
+ <xsl:template name="classdoc_all_constructor_summary">
+
+ <xsl:if test=".//gjdoc:constructordoc">
+ <!--
+ <h1 class="classdoc-header">Constructor Summary</h1>
+-->
+
+ <table class="classdoc-table">
+ <tr><td class="section-header" colspan="2"><div class="section-header">Constructor Summary</div></td></tr>
+ <xsl:for-each select="gjdoc:constructordoc">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="classdoc_method_summary_tr"/>
+ </xsl:for-each>
+ </table>
+ </xsl:if>
+
+ </xsl:template>
+
+ <!-- Output summary of a single field -->
+
+ <xsl:template name="classdoc_field_summary_tr">
+
+ <tr valign="top">
+
+ <!-- Left table cell: Modifiers and Return Type -->
+
+ <td valign="top" class="member-summary field modifiers">
+ <code class="member-summary field modifiers">
+ <xsl:call-template name="output_modifiers_summary"/>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_name">
+ <xsl:value-of select="gjdoc:type/@typename"/>
+ </xsl:with-param>
+ <xsl:with-param name="p_qualifiedname">
+ <xsl:value-of select="gjdoc:type/@qualifiedtypename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:value-of select="gjdoc:type/@dimension"/>
+ </code>
+ </td>
+
+ <!-- Right table cell: name and short description -->
+
+ <td class="member-summary field name">
+ <!-- Method signature -->
+
+ <!-- Link to field definition -->
+
+ <code class="member-summary field name">
+ <a href="{concat('#',@name)}" class="field name"><xsl:value-of select="@name"/></a>
+ </code>
+
+ <!-- Brief description of field -->
+
+ <blockquote class="member-summary field comment">
+ <xsl:for-each select="gjdoc:firstSentenceTags/node()">
+ <xsl:value-of select="." disable-output-escaping="yes"/>
+ </xsl:for-each>
+ </blockquote>
+ </td>
+
+ </tr>
+
+ </xsl:template>
+
+ <xsl:template name="output_modifiers">
+ <xsl:if test="gjdoc:isNative">
+ <xsl:text>native </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isStatic">
+ <xsl:text>static </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isFinal">
+ <xsl:text>final </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isAbstract">
+ <xsl:text>abstract </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isTransient">
+ <xsl:text>transient </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isVolatile">
+ <xsl:text>volatile </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isSynchronized">
+ <xsl:text>synchronized </xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="output_modifiers_summary">
+ <xsl:if test="gjdoc:isStatic">
+ <xsl:text>static </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isAbstract">
+ <xsl:text>abstract </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isTransient">
+ <xsl:text>transient </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isVolatile">
+ <xsl:text>volatile </xsl:text>
+ </xsl:if>
+ <xsl:if test="gjdoc:isSynchronized">
+ <xsl:text>synchronized </xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- Output summary of a single method or constructor -->
+
+ <xsl:template name="classdoc_method_summary_tr">
+
+ <tr valign="top">
+
+ <!-- Left table cell: Modifiers and Return Type -->
+
+ <xsl:if test="gjdoc:isMethod">
+ <td valign="top" class="member-summary method modifiers">
+ <code class="member-summary method modifiers">
+ <xsl:call-template name="output_modifiers_summary"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_qualifiedname" select="gjdoc:returns/@qualifiedtypename"/>
+ <xsl:with-param name="p_name" select="gjdoc:returns/@typename"/>
+ </xsl:call-template>
+ <xsl:value-of select="gjdoc:returns/@dimension"/>
+ </code>
+ </td>
+ </xsl:if>
+
+ <!-- Right table cell: signature and short description -->
+
+ <td align="left" valign="top" class="member-summary method name">
+
+ <!-- Method signature -->
+
+ <code class="member-summary method signature">
+
+ <!-- Link to method definition -->
+
+ <a href="{concat('#',@name,gjdoc:signature/@full)}" class="member-summary method name"><xsl:value-of select="@name"/></a>
+
+ <!-- Parameter List -->
+
+ <xsl:text>(</xsl:text>
+ <xsl:call-template name="list_parameters"/>
+ <xsl:text>)</xsl:text>
+ </code>
+
+ <!-- Brief description of Method -->
+
+ <blockquote class="member-summary method comment">
+ <xsl:choose>
+ <xsl:when test="gjdoc:tags/gjdoc:tag[@kind='@deprecated']">
+ <i>
+ <b>Deprecated. </b>
+ <xsl:for-each select="gjdoc:tags/gjdoc:tag[@kind='@deprecated']/gjdoc:firstSentenceTags">
+ <xsl:apply-templates/>
+ </xsl:for-each>
+ </i>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="gjdoc:firstSentenceTags/node()">
+ <xsl:value-of disable-output-escaping="yes" select="."/>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </blockquote>
+ </td>
+ </tr>
+
+ </xsl:template>
+
+ <!-- Output a list of all parameters of the current methoddoc -->
+ <xsl:template name="list_parameters">
+ <xsl:for-each select="gjdoc:parameter">
+ <span class="parameter">
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_qualifiedname">
+ <xsl:value-of select="@qualifiedtypename"/>
+ </xsl:with-param>
+ <xsl:with-param name="p_name">
+ <xsl:value-of select="@typename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:value-of select="@dimension"/>
+ <xsl:text disable-output-escaping="no">&#160;</xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:if test="position() != last()">
+ <xsl:text>,</xsl:text>
+ </xsl:if>
+ </span>
+ <xsl:if test="position() != last()">
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="list_parameter_details">
+ <dl class="classdoc-list">
+ <xsl:for-each select="gjdoc:parameter">
+ <dt>
+ <span class="prototype-name">
+ <xsl:value-of select="@name"/>
+ </span>
+ <xsl:variable name="param_position" select="position()"/>
+
+ <xsl:if test="../gjdoc:tags/gjdoc:tag[attribute::kind='@param' and position()=$param_position]">
+ <xsl:text> - </xsl:text>
+ <xsl:for-each select="../gjdoc:tags/gjdoc:tag[attribute::kind='@param' and position()=$param_position]/gjdoc:inlineTags/node()">
+ <xsl:copy-of select="."/>
+ </xsl:for-each>
+ </xsl:if>
+ </dt>
+ </xsl:for-each>
+ </dl>
+ </xsl:template>
+
+ <xsl:template name="output_see_tags">
+ <xsl:if test="gjdoc:tags/gjdoc:tag[attribute::kind='@see']">
+ <div class="classdoc-tag-section-header"><b>See Also:</b></div>
+
+ <dl class="classdoc-list">
+ <xsl:for-each select="gjdoc:tags/gjdoc:tag[attribute::kind='@see']">
+ <!--
+ <xsl:variable name="v_see" select="normalize-space(.)"/>
+ -->
+ <dt>
+ <code>
+ <xsl:call-template name="output_link_tag"/>
+ </code>
+ </dt>
+ </xsl:for-each>
+ </dl>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- Output details of all fields in this class -->
+
+ <xsl:template name="classdoc_field_details">
+
+ <a name="{@name}" class="classdoc"> </a>
+ <div class="before-details"> </div>
+
+ <h3><xsl:value-of select="@name"/></h3>
+
+ <p class="prototype"><code>
+ <xsl:value-of select="gjdoc:access/@scope"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="output_modifiers"/>
+ <xsl:value-of select="gjdoc:type/@typename"/>
+ <xsl:value-of select="gjdoc:type/@dimension"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="link_to_member_source"/>
+ </code></p>
+
+ <p/>
+
+ <!-- Full comment text -->
+
+ <xsl:if test="gjdoc:inlineTags">
+ <div class="classdoc-comment-body">
+ <xsl:for-each select="gjdoc:inlineTags/node()">
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ </div>
+ </xsl:if>
+
+ <p/>
+
+ <xsl:call-template name="output_taglet_tags"/>
+
+ <!-- See Also -->
+
+ <xsl:call-template name="output_see_tags"/>
+
+ <xsl:if test="position()!=last()">
+ <hr/>
+ </xsl:if>
+
+ </xsl:template>
+
+
+ <!-- Output details of all methods in this class -->
+
+ <xsl:template name="classdoc_method_details">
+
+ <a name="{concat(@name,gjdoc:signature/@full)}" class="classdoc"> </a>
+ <div class="before-details"> </div>
+
+ <h3><xsl:value-of select="@name"/></h3>
+
+ <p class="prototype"><code>
+ <xsl:value-of select="gjdoc:access/@scope"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="output_modifiers"/>
+ <xsl:value-of select="gjdoc:returns/@typename"/><xsl:value-of select="gjdoc:returns/@dimension"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="link_to_member_source"/>
+ <xsl:text>(</xsl:text>
+ <xsl:call-template name="list_parameters"/>
+ <xsl:text>)</xsl:text>
+ </code></p>
+
+ <!-- Full comment text -->
+
+ <xsl:if test="gjdoc:inlineTags">
+ <div class="classdoc-comment-body">
+ <xsl:for-each select="gjdoc:inlineTags/node()">
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ </div>
+ </xsl:if>
+
+ <p/>
+
+ <xsl:call-template name="output_taglet_tags"/>
+
+ <xsl:if test="gjdoc:parameter">
+ <div class="classdoc-tag-section-header"><b>Parameters:</b></div>
+ <xsl:call-template name="list_parameter_details"/>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:tags/gjdoc:tag[attribute::kind='@return']">
+ <div class="classdoc-tag-section-header"><b>Returns:</b></div>
+ <dl class="classdoc-list">
+ <dt>
+ <xsl:for-each select="gjdoc:tags/gjdoc:tag[attribute::kind='@return']">
+ <xsl:value-of select="." disable-output-escaping="yes"/>
+ </xsl:for-each>
+ </dt>
+ </dl>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:tags/gjdoc:tag[attribute::kind='@throws']">
+ <div class="classdoc-tag-section-header"><b>Throws:</b></div>
+ <dl class="classdoc-list">
+ <xsl:for-each select="gjdoc:tags/gjdoc:tag[attribute::kind='@throws']">
+ <dt>
+ <code>
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_qualifiedname">
+ <xsl:value-of select="gjdoc:exception/@qualifiedtypename"/>
+ </xsl:with-param>
+ <xsl:with-param name="p_name">
+ <xsl:value-of select="gjdoc:exception/@typename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </code>
+ <xsl:text> - </xsl:text>
+ <xsl:for-each select="gjdoc:inlineTags/node()">
+ <xsl:copy-of select="."/>
+ </xsl:for-each>
+ </dt>
+ </xsl:for-each>
+ </dl>
+ </xsl:if>
+
+ <xsl:call-template name="output_see_tags"/>
+
+ <xsl:if test="position()!=last()">
+ <hr/>
+ </xsl:if>
+
+ </xsl:template>
+
+ <!-- Recursively create the tree showing the heritage of the -->
+ <!-- given class -->
+
+ <xsl:template name="create_tree">
+ <xsl:param name="p_superclass"/>
+ <xsl:param name="p_indent"/>
+ <xsl:param name="p_final" select="0"/>
+
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[attribute::qualifiedtypename=$p_superclass]">
+
+ <xsl:if test="gjdoc:superclass">
+ <xsl:call-template name="create_tree">
+ <xsl:with-param name="p_indent" select="$p_indent+-1"/>
+ <xsl:with-param name="p_superclass" select="gjdoc:superclass/@qualifiedtypename"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="tree_indentation_text_empty">
+ <xsl:with-param name="p_indent" select="$p_indent"/>
+ </xsl:call-template>
+ <xsl:text>|
+</xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+
+ <xsl:if test="$p_indent>0">
+ <xsl:call-template name="tree_indentation">
+ <xsl:with-param name="p_indent" select="$p_indent"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$p_final=1">
+ <xsl:value-of select="$p_superclass"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="link_to_class_full">
+ <xsl:with-param name="p_qualifiedname">
+ <xsl:value-of select="$p_superclass"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>
+</xsl:text>
+ </xsl:template>
+
+ <!-- Recursively create the tree showing the heritage of the -->
+ <!-- given class, use bitmaps -->
+
+ <xsl:template name="create_tree_gfx">
+ <xsl:param name="p_superclass"/>
+ <xsl:param name="p_indent"/>
+ <xsl:param name="p_final" select="0"/>
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:classdoc[attribute::qualifiedtypename=$p_superclass]/gjdoc:superclass">
+ <xsl:call-template name="create_tree">
+ <xsl:with-param name="p_indent" select="$p_indent+-1"/>
+ <xsl:with-param name="p_superclass" select="/gjdoc:rootdoc/gjdoc:classdoc[attribute::qualifiedtypename=$p_superclass]/gjdoc:superclass/@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:if>
+ <tr><td>
+ <table cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <xsl:variable name="imagename">
+ <xsl:choose>
+ <xsl:when test="$p_final=1">
+ <xsl:text>images/tree-final-node.png</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>images/tree-node.png</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <td>
+ <xsl:if test="$p_indent>0">
+ <xsl:call-template name="tree_indentation">
+ <xsl:with-param name="p_indent"><xsl:value-of select="$p_indent"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <img width="10" height="21" class="classdoc-tree-image" src="{$imagename}"/>
+ </td>
+
+ <xsl:choose>
+ <xsl:when test="$p_final=1">
+ <td class="classdoc-tree-label"><xsl:value-of select="$p_superclass"/></td>
+ </xsl:when>
+ <xsl:otherwise>
+ <td class="classdoc-tree-label">
+ <xsl:call-template name="link_to_class_full">
+ <xsl:with-param name="p_qualifiedname">
+ <xsl:value-of select="$p_superclass"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </td>
+ </xsl:otherwise>
+ </xsl:choose>
+ </tr></table>
+ </td></tr>
+ </xsl:template>
+
+ <!-- Recursively output one character for each superclass found for the given -->
+ <!-- class. The length of the resulting string tells how many levels of -->
+ <!-- indentation are required for creating the heritage tree. -->
+
+ <xsl:template name="output_base_markers">
+ <xsl:param name="p_superclass"/>
+
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[attribute::qualifiedtypename=$p_superclass]">
+ <xsl:if test="gjdoc:superclass">
+ <xsl:call-template name="output_base_markers">
+ <xsl:with-param name="p_superclass" select="gjdoc:superclass/@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>
+
+ <xsl:text>*</xsl:text>
+ </xsl:template>
+
+ <!-- Heritage Tree -->
+
+ <xsl:template name="classdoc_heritage_tree">
+
+ <xsl:variable name="p_qualifiedtypename" select="@qualifiedtypename"/>
+
+ <xsl:for-each select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[@qualifiedtypename=$p_qualifiedtypename]">
+
+ <xsl:variable name="superclass_markers">
+ <xsl:call-template name="output_base_markers">
+ <xsl:with-param name="p_superclass" select="gjdoc:superclass/@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$gjdoc.allowimages=1">
+ <table border="0" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px; line-height:1px">
+ <xsl:call-template name="create_tree_gfx">
+ <xsl:with-param name="p_indent" select="string-length($superclass_markers)"/>
+ <xsl:with-param name="p_superclass" select="$p_qualifiedtypename"/>
+ <xsl:with-param name="p_final" select="1"/>
+ </xsl:call-template>
+ </table>
+ </xsl:when>
+ <xsl:otherwise>
+ <pre class="inheritance-tree">
+ <xsl:call-template name="create_tree">
+ <xsl:with-param name="p_indent" select="string-length($superclass_markers)"/>
+ <xsl:with-param name="p_superclass" select="$p_qualifiedtypename"/>
+ <xsl:with-param name="p_final" select="1"/>
+ </xsl:call-template>
+ </pre>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="tree_indentation_text_empty">
+ <xsl:param name="p_indent"/>
+ <xsl:choose>
+ <xsl:when test="$p_indent&gt;1">
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="tree_indentation_text_empty">
+ <xsl:with-param name="p_indent"><xsl:value-of select="$p_indent+-1"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- Recursively insert indentation for heritage tree. -->
+ <!-- This one uses images for nice, visual indentation. -->
+ <!-- p_indent selects level of indentation. -->
+
+ <xsl:template name="tree_indentation">
+ <xsl:param name="p_indent"/>
+ <xsl:choose>
+ <xsl:when test="$p_indent&gt;1">
+ <xsl:choose>
+ <xsl:when test="$gjdoc.allowimages=1">
+ <img width="26" height="21" border="0" src="images/tree-empty.png" class="classdoc-tree-image"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text> </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="tree_indentation">
+ <xsl:with-param name="p_indent"><xsl:value-of select="$p_indent+-1"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$gjdoc.allowimages=1">
+ <img width="26" height="21" border="0" src="images/tree-branch.png" class="classdoc-tree-image"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>+--</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="output_superclass_methods">
+ <xsl:if test="gjdoc:methoddoc">
+ <table class="classdoc-table">
+ <tr>
+ <td class="sub-section-header">
+ <div class="sub-section-header">Methods inherited from class <xsl:value-of select="@qualifiedtypename"/></div>
+ </td>
+ </tr>
+ <tr>
+ <td class="member-summary super method">
+ <xsl:for-each select="gjdoc:methoddoc">
+ <code class="member-summary super method"><a href="{concat($gjdoc.pathtoroot, translate(../gjdoc:containingPackage/@name, '.', '/'), '/', ../@typename, '.html#', @name, gjdoc:signature/@full)}" class="member-summary super method"><xsl:value-of select="@name"/></a><xsl:if test="position() != last()">, </xsl:if></code>
+ </xsl:for-each>
+ </td>
+ </tr>
+ </table>
+ </xsl:if>
+ </xsl:template>
+
+
+ <xsl:template name="output_superclass_fields">
+ <xsl:if test="gjdoc:fielddoc">
+ <table class="classdoc-table">
+ <tr>
+ <td class="sub-section-header">
+ <div class="sub-section-header">Fields inherited from class <xsl:value-of select="@qualifiedtypename"/></div>
+ </td>
+ </tr>
+ <tr>
+ <td class="member-summary super field">
+ <xsl:for-each select="gjdoc:fielddoc">
+ <code class="member-summary super field"><a href="{concat($gjdoc.pathtoroot, translate(../gjdoc:containingPackage/@name, '.', '/'), '/', ../@typename, '.html#', @name)}" class="member-summary super field"><xsl:value-of select="@name"/></a><xsl:if test="position() != last()">, </xsl:if></code>
+ </xsl:for-each>
+ </td>
+ </tr>
+ </table>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/deprecated.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/deprecated.xsl
new file mode 100644
index 000000000..4fc9dfdfd
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/deprecated.xsl
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- deprecated.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the deprecation information page for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="gjdoc:tag[attribute::kind='@see'][attribute::name='@link']">
+ <xsl:call-template name="output_link_tag">
+ <xsl:with-param name="p_contexturl"
+ select="concat(translate(ancestor::gjdoc:classdoc/gjdoc:containingPackage/@name, '.', '/'), '/', ancestor::gjdoc:classdoc/@name,'.html')"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="'Deprecated List'"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_show_deprecated" select="0"/>
+ <xsl:with-param name="p_curr_deprecated" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <div class="pagebody">
+
+ <h1 class="classdoc-title">Deprecated API</h1>
+
+ <xsl:choose>
+ <xsl:when test="gjdoc:rootdoc/gjdoc:hasDeprecatedInterfaces or gjdoc:rootdoc/gjdoc:hasDeprecatedClasses or gjdoc:rootdoc/gjdoc:hasDeprecatedExceptions or gjdoc:rootdoc/gjdoc:hasDeprecatedErrors or gjdoc:rootdoc/gjdoc:rootdoc/gjdoc:hasDeprecatedMethods or gjdoc:rootdoc/gjdoc:hasDeprecatedFields">
+ <div class="classdoc-tag-section-header">Contents:</div>
+ <dl class="classdoc-list">
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedInterfaces">
+ <dt><a href="#interfaces">Deprecated Interfaces</a></dt>
+ </xsl:if>
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedClasses">
+ <dt><a href="#classes">Deprecated Classes</a></dt>
+ </xsl:if>
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedExceptions">
+ <dt><a href="#exceptions">Deprecated Exceptions</a></dt>
+ </xsl:if>
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedErrors">
+ <dt><a href="#errors">Deprecated Errors</a></dt>
+ </xsl:if>
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedFields">
+ <dt><a href="#fields">Deprecated Fields</a></dt>
+ </xsl:if>
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedMethods">
+ <dt><a href="#methods">Deprecated Methods</a></dt>
+ </xsl:if>
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedConstructors">
+ <dt><a href="#constructors">Deprecated Constructors</a></dt>
+ </xsl:if>
+ </dl>
+ </xsl:when>
+ <xsl:otherwise>
+ <p>No parts of this API are deprecated.</p>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedInterfaces">
+ <a name="interfaces"/>
+ <h1 class="classdoc-header">Deprecated Interfaces</h1>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@qualifiedtypename">
+ <xsl:variable name="v_currentclass" select="."/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(.,'.xml')"/>
+ <xsl:for-each select="document($v_sub_xml_filename,/gjdoc:rootdoc)//gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/@qualifiedtypename/..">
+ <xsl:if test="gjdoc:isInterface">
+ <xsl:call-template name="output-deprecated-class"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedClasses">
+ <a name="classes"/>
+ <h1 class="classdoc-header">Deprecated Classes</h1>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@qualifiedtypename">
+ <xsl:variable name="v_currentclass" select="."/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(.,'.xml')"/>
+ <xsl:for-each select="document($v_sub_xml_filename,/gjdoc:rootdoc)//gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/@qualifiedtypename/..">
+ <xsl:if test="gjdoc:isOrdinaryClass">
+ <xsl:call-template name="output-deprecated-class"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedExceptions">
+ <a name="exceptions"/>
+ <h1 class="classdoc-header">Deprecated Exceptions</h1>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@qualifiedtypename">
+ <xsl:variable name="v_currentclass" select="."/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(.,'.xml')"/>
+ <xsl:for-each select="document($v_sub_xml_filename,/gjdoc:rootdoc)//gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/.">
+ <xsl:if test="gjdoc:isException">
+ <xsl:call-template name="output-deprecated-class"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedErrors">
+ <a name="errors"/>
+ <h1 class="classdoc-header">Deprecated Errors</h1>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@qualifiedtypename">
+ <xsl:variable name="v_currentclass" select="."/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(.,'.xml')"/>
+ <xsl:for-each select="document($v_sub_xml_filename,/gjdoc:rootdoc)//gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/.">
+ <xsl:if test="gjdoc:isError">
+ <xsl:call-template name="output-deprecated-class"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedFields">
+ <a name="fields"/>
+ <h1 class="classdoc-header">Deprecated Fields</h1>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@qualifiedtypename">
+ <xsl:variable name="v_currentclass" select="."/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(.,'.xml')"/>
+ <xsl:for-each select="document($v_sub_xml_filename,/gjdoc:rootdoc)//gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/gjdoc:fielddoc/@name">
+ <xsl:call-template name="output-deprecated-member"/>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedMethods">
+ <a name="methods"/>
+ <h1 class="classdoc-header">Deprecated Methods</h1>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@qualifiedtypename">
+ <xsl:variable name="v_currentclass" select="."/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(.,'.xml')"/>
+ <xsl:for-each select="document($v_sub_xml_filename,/gjdoc:rootdoc)//gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/gjdoc:methoddoc/@name">
+ <xsl:call-template name="output-deprecated-member"/>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="gjdoc:rootdoc/gjdoc:hasDeprecatedConstructors">
+ <a name="constructors"/>
+ <h1 class="classdoc-header">Deprecated Constructors</h1>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc/@qualifiedtypename">
+ <xsl:variable name="v_currentclass" select="."/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(.,'.xml')"/>
+ <xsl:for-each select="document($v_sub_xml_filename,/gjdoc:rootdoc)//gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/gjdoc:constructordoc/@name">
+ <xsl:call-template name="output-deprecated-member"/>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:if>
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_show_deprecated" select="0"/>
+ <xsl:with-param name="p_curr_deprecated" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="output-deprecated-member">
+
+ <xsl:if test="../gjdoc:tags/gjdoc:tag[@kind='@deprecated']">
+ <dl>
+ <dt>
+ <a href="{concat($gjdoc.pathtoroot, translate(ancestor::gjdoc:classdoc/gjdoc:containingPackage/@name, '.', '/'), '/', ancestor::gjdoc:classdoc/@name, '.html#', ., ../gjdoc:signature/@full)}">
+ <xsl:value-of select="concat(ancestor::gjdoc:classdoc/@qualifiedtypename, '.', ., ../gjdoc:signature/@flat)"/>
+ </a>
+ </dt>
+ <dd>
+ <xsl:for-each select="../gjdoc:tags/gjdoc:tag[@kind='@deprecated']/gjdoc:firstSentenceTags/node()">
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ </dd>
+ </dl>
+ </xsl:if>
+
+ </xsl:template>
+
+ <xsl:template name="output-deprecated-class">
+ <xsl:if test="gjdoc:tags/gjdoc:tag[@kind='@deprecated']">
+ <dl>
+ <dt>
+ <a href="{concat($gjdoc.pathtoroot, translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')}"><xsl:value-of select="@qualifiedtypename"/></a>
+ </dt>
+ <dd>
+ <xsl:for-each select="gjdoc:tags/gjdoc:tag[@kind='@deprecated']/gjdoc:firstSentenceTags/node()">
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ </dd>
+ </dl>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/descriptor.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/descriptor.xsl
new file mode 100644
index 000000000..5cdb3325d
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/descriptor.xsl
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- descriptor.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the index.html file for HTML documentation. This is only
+ a simple frameset.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <gjdoc:descriptor>
+ <gjdoc:about>
+ This file was generated by Gjdoc <xsl:value-of select="$gjdoc.xmldoclet.version"/>
+ on <xsl:value-of select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:created"/>.
+
+ <xsl:copy-of select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:bottomnote"/>
+ </gjdoc:about>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:packagedoc">
+ <gjdoc:package name="{@name}"/>
+ </xsl:for-each>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc">
+ <gjdoc:class name="{@name}" qualifiedtypename="{@qualifiedtypename}"/>
+ </xsl:for-each>
+ </gjdoc:descriptor>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/doctranslet.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/doctranslet.xsl
new file mode 100644
index 000000000..7008f73a3
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/doctranslet.xsl
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- outputfiles.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Returns a list of files generated by this stylesheet complex.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.gnu.org/software/cp-tools/gjdocxslfiles">
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <doctranslet>
+
+ <name>GNU Gjdoc HTML DocTranslet</name>
+
+ <version>0.6.1</version>
+
+ <outputtype>
+ <name>HTML</name>
+ </outputtype>
+
+ <outputfile>
+ <name><xsl:text>index.html</xsl:text></name>
+ <type><xsl:text>index</xsl:text></type>
+ <sheet><xsl:text>index.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Index file</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>index_noframes.html</xsl:text></name>
+ <type><xsl:text>index_noframes</xsl:text></type>
+ <sheet><xsl:text>index_noframes.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Index file (No Frames)</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>descriptor.xml</xsl:text></name>
+ <type><xsl:text>descriptor</xsl:text></type>
+ <sheet><xsl:text>descriptor.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Descriptor file</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>allclasses.html</xsl:text></name>
+ <type><xsl:text>allclasses</xsl:text></type>
+ <sheet><xsl:text>allclasses.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML All Classes file</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>allpackages.html</xsl:text></name>
+ <type><xsl:text>allpackages</xsl:text></type>
+ <sheet><xsl:text>allpackages.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML All Packages file</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>fulltree.html</xsl:text></name>
+ <type><xsl:text>fulltree</xsl:text></type>
+ <sheet><xsl:text>fulltree.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Tree file</xsl:text></comment>
+ </outputfile>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:packagedoc">
+ <outputfile>
+ <name><xsl:value-of select="concat(translate(@name,'.','/'),'/package-summary.html')"/></name>
+ <type><xsl:text>package</xsl:text></type>
+ <info><xsl:value-of select="@name"/></info>
+ <sheet><xsl:text>packagedoc.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Documentation for package </xsl:text><xsl:value-of select="@name"/></comment>
+ </outputfile>
+ </xsl:for-each>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc">
+ <outputfile>
+ <name><xsl:value-of select="concat(translate(gjdoc:containingPackage/@name,'.','/'),'/',@name,'.html')"/></name>
+ <type><xsl:text>class</xsl:text></type>
+ <info><xsl:value-of select="@qualifiedtypename"/></info>
+ <sheet><xsl:text>classdoc.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Documentation for </xsl:text><xsl:value-of select="@qualifiedtypename"/></comment>
+ </outputfile>
+ </xsl:for-each>
+
+ </doctranslet>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/fulltree.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/fulltree.xsl
new file mode 100644
index 000000000..3d60bbba2
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/fulltree.xsl
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- fulltree.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the fulltree.html file for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template name="output_tree_recursive">
+ <xsl:param name="p_level" select="0"/>
+
+ <xsl:value-of select="gjdoc:containingPackage/@name"/><xsl:text>.</xsl:text><a class="tree-class-link" href="{concat($gjdoc.pathtoroot,translate(gjdoc:containingPackage/@name,'.','/'),'/',@name,'.html')}"><xsl:value-of select="@name"/></a>
+ <xsl:if test="gjdoc:implements">
+ <xsl:text> (implements </xsl:text>
+ <xsl:for-each select="gjdoc:implements">
+ <xsl:sort select="@qualifiedtypename" order="ascending"/>
+ <xsl:choose>
+ <xsl:when test="string-length($gjdoc.outputfile.info)=0">
+ <xsl:call-template name="link_to_class_full">
+ <xsl:with-param name="p_name" select="@typename"/>
+ <xsl:with-param name="p_qualifiedname" select="@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="gjdoc:containingPackage/@name=$gjdoc.outputfile.info">
+ <xsl:call-template name="link_to_class">
+ <xsl:with-param name="p_name" select="@typename"/>
+ <xsl:with-param name="p_qualifiedname" select="@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="link_to_class_full">
+ <xsl:with-param name="p_name" select="@typename"/>
+ <xsl:with-param name="p_qualifiedname" select="@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="position() != last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+
+ <xsl:variable name="v_qualifiedname">
+ <xsl:value-of select="@qualifiedtypename"/>
+ </xsl:variable>
+ <xsl:variable name="v_result">
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:superclass/@qualifiedtypename=$v_qualifiedname]">
+ <xsl:sort select="@qualifiedtypename" order="ascending"/>
+ <xsl:variable name="v_is_used">
+ <xsl:choose>
+ <xsl:when test="string-length($gjdoc.outputfile.info)=0">
+ <xsl:value-of select="true()"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:containingPackage/@name=$gjdoc.outputfile.info">
+ <xsl:value-of select="true()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="is_class_parent_of_package_class">
+ <xsl:with-param name="p_package" select="$gjdoc.outputfile.info"/>
+ <xsl:with-param name="p_qualifiedtypename" select="@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:if test="string-length($v_is_used)>0">
+ <li class="tree">
+ <xsl:call-template name="output_tree_recursive">
+ <xsl:with-param name="p_level"><xsl:value-of select="$p_level+1"/></xsl:with-param>
+ </xsl:call-template>
+ </li>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:if test="string-length($v_result)>0">
+ <ul><xsl:copy-of select="$v_result"/></ul>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="is_class_parent_of_package_class">
+ <xsl:param name="p_package"/>
+ <xsl:param name="p_qualifiedtypename"/>
+
+ <xsl:choose>
+
+ <xsl:when test="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:superclass/@qualifiedtypename=$p_qualifiedtypename and gjdoc:containingPackage/@name=$p_package]">
+ <xsl:value-of select="true()"/>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:superclass/@qualifiedtypename=$p_qualifiedtypename]">
+ <xsl:call-template name="is_class_parent_of_package_class">
+ <xsl:with-param name="p_package" select="$p_package"/>
+ <xsl:with-param name="p_qualifiedtypename" select="@qualifiedtypename"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="/">
+
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="'Full Tree'"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)">
+ <div class="pagebody">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="string-length($gjdoc.outputfile.info)&gt;0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_curr_package_tree" select="string-length($gjdoc.outputfile.info)&gt;0"/>
+ <xsl:with-param name="p_show_full_tree" select="string-length($gjdoc.outputfile.info)&gt;0"/>
+ <xsl:with-param name="p_curr_full_tree" select="string-length($gjdoc.outputfile.info)&lt;=0"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <h1 class="classdoc-title">
+ <xsl:choose>
+ <xsl:when test="string-length($gjdoc.outputfile.info)=0">
+ Full Class Tree
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:title">
+ <xsl:text> for </xsl:text>
+ <xsl:value-of select="/gjdoc:rootdoc/gjdoc:title"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ Class Hierarchy for Package <xsl:value-of select="$gjdoc.outputfile.info"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </h1>
+
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[@qualifiedtypename='java.lang.Object']">
+ <ul class="tree">
+ <li class="tree">
+ <xsl:call-template name="output_tree_recursive"/>
+ </li>
+ </ul>
+ </xsl:for-each>
+
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="string-length($gjdoc.outputfile.info)&lt;=0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_curr_package_tree" select="string-length($gjdoc.outputfile.info)&gt;0"/>
+ <xsl:with-param name="p_show_full_tree" select="string-length($gjdoc.outputfile.info)&gt;0"/>
+ <xsl:with-param name="p_curr_full_tree" select="string-length($gjdoc.outputfile.info)&lt;=0"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+ </div>
+ </body>
+ </html>
+
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/gjdoc.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/gjdoc.xsl
new file mode 100644
index 000000000..74558abf4
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/gjdoc.xsl
@@ -0,0 +1,240 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- outputfiles.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Returns a list of files generated by this stylesheet complex.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.gnu.org/software/cp-tools/gjdocxslfiles">
+
+ <xsl:include href="../gjdoc_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <gjdocoutput>
+
+ <comment><xsl:text>GNU Gjdoc HTML Documentation</xsl:text></comment>
+
+ <outputfile>
+ <name><xsl:text>index.html</xsl:text></name>
+ <sheet><xsl:text>index.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Index file</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>index_noframes.html</xsl:text></name>
+ <sheet><xsl:text>index_noframes.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Index file (No Frames)</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>descriptor.xml</xsl:text></name>
+ <sheet><xsl:text>descriptor.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Descriptor file</xsl:text></comment>
+ </outputfile>
+
+ <outputfile>
+ <name><xsl:text>allclasses.html</xsl:text></name>
+ <sheet><xsl:text>allclasses.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML All Classes file</xsl:text></comment>
+ </outputfile>
+
+ <xsl:if test="count(gjdoc:rootdoc/gjdoc:packagedoc) > 1">
+ <outputfile>
+ <name><xsl:text>allpackages.html</xsl:text></name>
+ <sheet><xsl:text>allpackages.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML All Packages file</xsl:text></comment>
+ </outputfile>
+ </xsl:if>
+
+ <xsl:if test="not($gjdoc.option.notree)">
+ <outputfile>
+ <name><xsl:text>fulltree.html</xsl:text></name>
+ <sheet><xsl:text>fulltree.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Tree file</xsl:text></comment>
+ </outputfile>
+ </xsl:if>
+
+ <xsl:if test="not($gjdoc.option.noindex)">
+ <xsl:choose>
+ <xsl:when test="$gjdoc.option.splitindex">
+
+ <outputfile>
+ <name><xsl:text>alphaindex.html</xsl:text></name>
+ <info/>
+ <sheet><xsl:text>alphaindex_chunked.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Alphabetical Index (Overview)</xsl:text></comment>
+ </outputfile>
+
+ <xsl:for-each select="document('alphaindex.xml',/)/gjdoc:alphaindex/gjdoc:category">
+ <outputfile>
+ <name><xsl:value-of select="concat('alphaindex_', @letter, '.html')"/></name>
+ <info><xsl:value-of select="@letter"/></info>
+ <sheet><xsl:text>alphaindex_chunked.xsl</xsl:text></sheet>
+ <comment><xsl:value-of select="concat('HTML Alphabetical Index (Letter ', @letter, ')')"/></comment>
+ </outputfile>
+ </xsl:for-each>
+
+ </xsl:when>
+ <xsl:otherwise>
+ <outputfile>
+ <name><xsl:text>alphaindex.html</xsl:text></name>
+ <sheet><xsl:text>alphaindex.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Alphabetical Index</xsl:text></comment>
+ </outputfile>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:packagedoc">
+ <outputfile>
+ <name><xsl:value-of select="concat(translate(@name,'.','/'),'/package-summary.html')"/></name>
+ <info><xsl:value-of select="@name"/></info>
+ <sheet><xsl:text>packagedoc.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Documentation for package </xsl:text><xsl:value-of select="@name"/></comment>
+ </outputfile>
+ <outputfile>
+ <name><xsl:value-of select="concat(translate(@name,'.','/'),'/classes.html')"/></name>
+ <info><xsl:value-of select="@name"/></info>
+ <sheet><xsl:text>packageclasses.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Class list for package </xsl:text><xsl:value-of select="@name"/></comment>
+ </outputfile>
+
+ <xsl:if test="not($gjdoc.option.notree)">
+ <outputfile>
+ <name><xsl:value-of select="concat(translate(@name,'.','/'),'/package-tree.html')"/></name>
+ <info><xsl:value-of select="@name"/></info>
+ <sheet><xsl:text>fulltree.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Hierarchy for package </xsl:text><xsl:value-of select="@name"/></comment>
+ </outputfile>
+ </xsl:if>
+ </xsl:for-each>
+
+ <xsl:for-each select="gjdoc:rootdoc/gjdoc:classdoc">
+ <xsl:sort select="@qualifiedtypename" order="ascending"/>
+ <outputfile>
+ <name><xsl:value-of select="concat(translate(gjdoc:containingPackage/@name,'.','/'),'/',@name,'.html')"/></name>
+ <info><xsl:value-of select="@qualifiedtypename"/></info>
+ <sheet><xsl:text>classdoc.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Documentation for </xsl:text><xsl:value-of select="@qualifiedtypename"/></comment>
+ </outputfile>
+
+ <xsl:if test="$gjdoc.option.linksource">
+ <outputfile>
+ <name><xsl:text>src-html/</xsl:text><xsl:value-of select="concat(translate(gjdoc:containingPackage/@name,'.','/'),'/',@name,'.html')"/></name>
+ <info><xsl:value-of select="@qualifiedtypename"/></info>
+ <sheet><xsl:text>classdoc-source.xsl</xsl:text></sheet>
+ <comment><xsl:text>HTML Source for </xsl:text><xsl:value-of select="@qualifiedtypename"/></comment>
+ </outputfile>
+ </xsl:if>
+
+ <xsl:if test="$gjdoc.option.uses">
+ <outputfile>
+ <name><xsl:text>class-use/</xsl:text><xsl:value-of select="concat(translate(gjdoc:containingPackage/@name,'.','/'),'/',@name,'.html')"/></name>
+ <info><xsl:value-of select="@qualifiedtypename"/></info>
+ <sheet><xsl:text>classdoc-uses.xsl</xsl:text></sheet>
+ <comment><xsl:text>usage information for </xsl:text><xsl:value-of select="@qualifiedtypename"/></comment>
+ </outputfile>
+ </xsl:if>
+
+ </xsl:for-each>
+
+ <xsl:choose>
+ <xsl:when test="$gjdoc.option.stylesheetfile">
+ <outputfile>
+ <name><xsl:text>user.css</xsl:text></name>
+ <source><xsl:value-of select="$gjdoc.option.stylesheetfile"/></source>
+ <comment><xsl:text>user-supplied CSS stylesheet</xsl:text></comment>
+ </outputfile>
+ </xsl:when>
+ <xsl:otherwise>
+ <outputfile>
+ <name><xsl:text>gjdochtml.css</xsl:text></name>
+ <source><xsl:text>res/gjdochtml.css</xsl:text></source>
+ <comment><xsl:text>CSS base stylesheet</xsl:text></comment>
+ </outputfile>
+ <outputfile>
+ <name><xsl:text>gjdochtml-clean.css</xsl:text></name>
+ <source><xsl:text>res/gjdochtml-clean.css</xsl:text></source>
+ <comment><xsl:text>CSS stylesheet 'Clean'</xsl:text></comment>
+ </outputfile>
+ <outputfile>
+ <name><xsl:text>gjdochtml-sclara.css</xsl:text></name>
+ <source><xsl:text>res/gjdochtml-sclara.css</xsl:text></source>
+ <comment><xsl:text>CSS stylesheet 'Santa Clara'</xsl:text></comment>
+ </outputfile>
+ <outputfile>
+ <name><xsl:text>gjdochtml-fixed.css</xsl:text></name>
+ <source><xsl:text>res/gjdochtml-fixed.css</xsl:text></source>
+ <comment><xsl:text>CSS stylesheet 'Fixed'</xsl:text></comment>
+ </outputfile>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <outputfile>
+ <name><xsl:text>gjdoc.js</xsl:text></name>
+ <source><xsl:text>res/gjdoc.js</xsl:text></source>
+ <comment><xsl:text>JavaScript helper file</xsl:text></comment>
+ </outputfile>
+
+ <xsl:if test="not($gjdoc.option.nohelp)">
+ <outputfile>
+ <name><xsl:text>help.html</xsl:text></name>
+ <sheet><xsl:text>help.xsl</xsl:text></sheet>
+ <comment><xsl:text>help file</xsl:text></comment>
+ </outputfile>
+ </xsl:if>
+
+ <outputfile>
+ <name><xsl:text>about.html</xsl:text></name>
+ <sheet><xsl:text>about.xsl</xsl:text></sheet>
+ <comment><xsl:text>about file</xsl:text></comment>
+ </outputfile>
+
+ <xsl:if test="not($gjdoc.option.nodeprecatedlist)">
+ <outputfile>
+ <name><xsl:text>deprecated.html</xsl:text></name>
+ <sheet><xsl:text>deprecated.xsl</xsl:text></sheet>
+ <comment><xsl:text>deprecated list</xsl:text></comment>
+ </outputfile>
+ </xsl:if>
+
+ <outputfile>
+ <name><xsl:text>serialized.html</xsl:text></name>
+ <sheet><xsl:text>serialized.xsl</xsl:text></sheet>
+ <comment><xsl:text>serialization information</xsl:text></comment>
+ </outputfile>
+
+ </gjdocoutput>
+ </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/help.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/help.xsl
new file mode 100644
index 000000000..45af6a644
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/help.xsl
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- help.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the class descriptor files for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="html"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="'Help'"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)">
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="0"/>
+ <xsl:with-param name="p_curr_help" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <div class="pagebody">
+
+ <xsl:choose>
+ <xsl:when test="$gjdoc.option.helpfile">
+ <xsl:copy-of select="document($gjdoc.option.helpfile)//body"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="document('res/default_help_en.html')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="0"/>
+ <xsl:with-param name="p_curr_help" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/html_common.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/html_common.xsl
new file mode 100644
index 000000000..4e648d272
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/html_common.xsl
@@ -0,0 +1,584 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- html_common.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Common templates for HTML generation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="../gjdoc_common.xsl"/>
+
+ <!-- HTML head directives to be included in all generated HTML files. -->
+
+ <xsl:template name="include_common">
+ <script src="{concat($gjdoc.pathtoroot, 'gjdoc.js')}" type="text/javascript"><xsl:comment>this comment required for konqueror 3.2.2</xsl:comment>
+ </script>
+ <xsl:choose>
+ <xsl:when test="$gjdoc.option.stylesheetfile">
+ <link rel="stylesheet" type="text/css"
+ href="{concat($gjdoc.pathtoroot, 'user.css')}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <link rel="stylesheet" type="text/css"
+ href="{concat($gjdoc.pathtoroot, 'gjdochtml.css')}" title="GNU Clean"/>
+ <link rel="stylesheet" type="text/css"
+ href="{concat($gjdoc.pathtoroot, 'gjdochtml-clean.css')}" title="GNU Clean"/>
+ <link rel="alternate stylesheet" type="text/css"
+ href="{concat($gjdoc.pathtoroot, 'gjdochtml.css')}" title="Santa Clara"/>
+ <link rel="alternate stylesheet" type="text/css"
+ href="{concat($gjdoc.pathtoroot, 'gjdochtml-sclara.css')}" title="Santa Clara"/>
+ <link rel="alternate stylesheet" type="text/css"
+ href="{concat($gjdoc.pathtoroot, 'gjdochtml.css')}" title="Fixed Fruit"/>
+ <link rel="alternate stylesheet" type="text/css"
+ href="{concat($gjdoc.pathtoroot, 'gjdochtml-fixed.css')}" title="Fixed Fruit"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="output_copyright_footer">
+ <xsl:copy-of select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:bottomnote"/>
+ <hr class="footer"/>
+ <div class="footer">
+ <xsl:text>Generated on</xsl:text><xsl:value-of select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:created"/><xsl:text> by </xsl:text><a href="http://www.gnu.org/software/cp-tools" target="cptoolsinfo"><xsl:text>GNU Classpath Tools</xsl:text></a><xsl:text> (Gjdoc XmlDoclet </xsl:text><xsl:value-of select="$gjdoc.xmldoclet.version"/><xsl:text>).</xsl:text>
+ </div>
+ </xsl:template>
+
+ <!-- If the given class is also included, create a link to it. -->
+ <!-- Otherwise output the qualified name in plain text. -->
+
+ <xsl:template name="link_to_class_full">
+ <xsl:param name="p_qualifiedname" select="@qualifiedtypename"/>
+ <xsl:variable name="p_classdoc" select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[attribute::qualifiedtypename=$p_qualifiedname]"/>
+ <xsl:choose>
+ <xsl:when test="$p_classdoc">
+ <a href="{concat($gjdoc.pathtoroot, translate($p_classdoc/gjdoc:containingPackage/@name, '.', '/'), '/', $p_classdoc/@name, '.html')}">
+ <xsl:value-of select="$p_qualifiedname"/>
+ </a>
+ </xsl:when>
+ <xsl:when test="$gjdoc.refdocs1 and document(concat($gjdoc.refdocs1, '/descriptor.xml'), /)//gjdoc:class[attribute::qualifiedtypename=$p_qualifiedname]">
+ <a href="{concat($gjdoc.refdocs1, '/', $p_qualifiedname, '.html')}">
+ <xsl:value-of select="$p_qualifiedname"/>
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$p_qualifiedname"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- If the given class is also included, create a link to it. -->
+ <!-- Otherwise output the qualified name in plain text. -->
+
+ <xsl:template name="link_to_class">
+ <xsl:param name="p_qualifiedname" select="@qualifiedtypename"/>
+ <xsl:param name="p_name" select="@name"/>
+ <xsl:variable name="p_classdoc" select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[attribute::qualifiedtypename=$p_qualifiedname]"/>
+ <xsl:choose>
+ <xsl:when test="$p_classdoc">
+ <a href="{concat($gjdoc.pathtoroot, translate($p_classdoc/gjdoc:containingPackage/@name, '.', '/'), '/', $p_classdoc/@name, '.html')}"><xsl:value-of select="$p_name"/></a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$p_qualifiedname"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="output_alphaindex_category">
+ <dl>
+ <xsl:for-each select="gjdoc:entry">
+ <dt>
+ <xsl:element name="a">
+ <xsl:attribute name="href">
+ <xsl:choose>
+ <xsl:when test="gjdoc:isPackage">
+ <xsl:value-of select="concat(translate(@name, '.', '/'), '/package-summary.html')"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isClass and gjdoc:containingClass">
+ <xsl:value-of select="concat(translate(gjdoc:containingPackage/@name, '.', '/'), '/', gjdoc:containingClass/@name, '.', @name, '.html')"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isClass">
+ <xsl:value-of select="concat(translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isMethod">
+ <xsl:value-of select="concat(translate(gjdoc:containingPackage/@name, '.', '/'), '/', gjdoc:containingClass/@name, '.html#', gjdoc:method/@name, gjdoc:signature/@full)"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isField">
+ <xsl:value-of select="concat(translate(gjdoc:containingPackage/@name, '.', '/'), '/', gjdoc:containingClass/@name, '.html#', @name)"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </xsl:element>
+ -
+ <xsl:choose>
+ <xsl:when test="gjdoc:isPackage">
+ Package
+ </xsl:when>
+ <xsl:when test="gjdoc:isOrdinaryClass and gjdoc:containingClass">
+ Nested class in class
+ <xsl:value-of select="gjdoc:containingClass/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isException and gjdoc:containingClass">
+ Nested exception in class
+ <xsl:value-of select="gjdoc:containingClass/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isError and gjdoc:containingClass">
+ Nested error in class
+ <xsl:value-of select="gjdoc:containingClass/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isInterface and gjdoc:containingClass">
+ Nested interface in class
+ <xsl:value-of select="gjdoc:containingClass/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isOrdinaryClass">
+ Class in package
+ <xsl:value-of select="gjdoc:containingPackage/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isException">
+ Exception in package
+ <xsl:value-of select="gjdoc:containingPackage/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isError">
+ Error in package
+ <xsl:value-of select="gjdoc:containingPackage/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isInterface">
+ Interface in package
+ <xsl:value-of select="gjdoc:containingPackage/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isMethod">
+ Method in class
+ <xsl:value-of select="gjdoc:containingClass/@name"/>
+ </xsl:when>
+ <xsl:when test="gjdoc:isField">
+ Field in class
+ <xsl:value-of select="gjdoc:containingClass/@name"/>
+ </xsl:when>
+ </xsl:choose>
+ </dt>
+ <dd>
+ <xsl:for-each select="gjdoc:firstSentenceTags/node()">
+ <xsl:copy-of select="."/>
+ </xsl:for-each>
+ </dd>
+ </xsl:for-each>
+ </dl>
+
+ </xsl:template>
+
+ <xsl:template name="output_navlink">
+ <xsl:param name="p_href"/>
+ <xsl:param name="p_label"/>
+ <xsl:param name="p_target" select="'_self'"/>
+ <xsl:param name="p_enabled"/>
+ <xsl:param name="p_current"/>
+ <xsl:param name="p_onclick"/>
+ <xsl:param name="p_last" select="0"/>
+ <xsl:param name="p_css_class"/>
+ <xsl:param name="p_title"/>
+
+ <xsl:choose>
+ <xsl:when test="$p_enabled">
+ <span class="navi-button link"><a href="{$p_href}" target="{$p_target}" class="navi-button" title="{$p_title}" onClick="{$p_onclick}"><span class="{concat('navi-link ', $p_css_class)}"><xsl:value-of select="$p_label" disable-output-escaping="yes"/></span></a></span>
+ </xsl:when>
+ <xsl:when test="$p_current">
+ <span class="navi-button current"><xsl:value-of select="$p_label" disable-output-escaping="yes"/></span>
+ </xsl:when>
+ <xsl:otherwise>
+ <span class="navi-button unavailable"><xsl:value-of select="$p_label" disable-output-escaping="yes"/></span>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="not($p_last)"><span class="navsep"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></span></xsl:if>
+ </xsl:template>
+
+ <xsl:template name="output_navbar">
+ <xsl:param name="p_show_frames" select="1"/>
+ <xsl:param name="p_curr_frames"/>
+
+ <xsl:param name="p_show_noframes" select="1"/>
+ <xsl:param name="p_curr_noframes"/>
+
+ <xsl:param name="p_show_package" select="1"/>
+ <xsl:param name="p_curr_package"/>
+
+ <xsl:param name="p_show_package_tree" select="1"/>
+ <xsl:param name="p_curr_package_tree"/>
+
+ <xsl:param name="p_show_full_tree" select="1"/>
+ <xsl:param name="p_curr_full_tree"/>
+
+ <xsl:param name="p_show_index" select="1"/>
+ <xsl:param name="p_curr_index"/>
+
+ <xsl:param name="p_show_help" select="1"/>
+ <xsl:param name="p_curr_help"/>
+
+ <xsl:param name="p_show_about" select="1"/>
+ <xsl:param name="p_curr_about"/>
+
+ <xsl:param name="p_show_source" select="1"/>
+ <xsl:param name="p_curr_source"/>
+
+ <xsl:param name="p_show_class"/>
+ <xsl:param name="p_curr_class"/>
+
+ <xsl:param name="p_show_use"/>
+ <xsl:param name="p_curr_use"/>
+
+ <xsl:param name="p_show_deprecated" select="1"/>
+ <xsl:param name="p_curr_deprecated"/>
+
+ <xsl:param name="p_top"/>
+
+ <xsl:variable name="v_navbar_class">
+ <xsl:choose>
+ <xsl:when test="$p_top">
+ <xsl:value-of select="'navbar top'"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="'navbar bottom'"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="not($gjdoc.option.nonavbar)">
+ <div class="{$v_navbar_class}">
+ <table border="1" cellspacing="0" class="{$v_navbar_class}">
+ <tr class="{$v_navbar_class}">
+ <td class="{$v_navbar_class}">
+ <div class="navbar-first-row">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'index_noframes.html')"/>
+ <xsl:with-param name="p_label" select="'Overview'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_noframes"/>
+ <xsl:with-param name="p_current" select="$p_curr_noframes"/>
+ </xsl:call-template>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="'package-summary.html'"/>
+ <xsl:with-param name="p_label" select="'Package'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_package"/>
+ <xsl:with-param name="p_current" select="$p_curr_package"/>
+ </xsl:call-template>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="$p_show_class"/>
+ <xsl:with-param name="p_label" select="'Class'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_class"/>
+ <xsl:with-param name="p_current" select="$p_curr_class"/>
+ </xsl:call-template>
+ <xsl:if test="$gjdoc.option.linksource">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="$p_show_source"/>
+ <xsl:with-param name="p_label" select="'Source'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_source"/>
+ <xsl:with-param name="p_current" select="$p_curr_source"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$gjdoc.option.uses">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="$p_show_use"/>
+ <xsl:with-param name="p_label" select="'Use'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_use"/>
+ <xsl:with-param name="p_current" select="$p_curr_use"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="'package-tree.html'"/>
+ <xsl:with-param name="p_label" select="'Tree'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_package_tree"/>
+ <xsl:with-param name="p_current" select="$p_curr_package_tree"/>
+ </xsl:call-template>
+ <xsl:if test="not($gjdoc.option.noindex)">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'alphaindex.html')"/>
+ <xsl:with-param name="p_label" select="'Index'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_index"/>
+ <xsl:with-param name="p_current" select="$p_curr_index"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not($gjdoc.option.notree)">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'fulltree.html')"/>
+ <xsl:with-param name="p_label" select="'Full&amp;nbsp;Tree'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_full_tree"/>
+ <xsl:with-param name="p_current" select="$p_curr_full_tree"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not($gjdoc.option.nodeprecatedlist)">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'deprecated.html')"/>
+ <xsl:with-param name="p_label" select="'Deprecated'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_deprecated"/>
+ <xsl:with-param name="p_current" select="$p_curr_deprecated"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not($gjdoc.option.nohelp)">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'help.html')"/>
+ <xsl:with-param name="p_label" select="'Help'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_help"/>
+ <xsl:with-param name="p_current" select="$p_curr_help"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'about.html')"/>
+ <xsl:with-param name="p_label" select="'About'"/>
+ <xsl:with-param name="p_enabled" select="$p_show_about"/>
+ <xsl:with-param name="p_current" select="$p_curr_about"/>
+ <xsl:with-param name="p_last" select="1"/>
+ </xsl:call-template>
+ </div>
+ <div class="navbar-second-row">
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'index.html')"/>
+ <xsl:with-param name="p_label" select="'Frames'"/>
+ <xsl:with-param name="p_enabled" select="1"/>
+ <xsl:with-param name="p_target" select="'_top'"/>
+ </xsl:call-template>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_href" select="concat($gjdoc.pathtoroot, 'index_noframes.html')"/>
+ <xsl:with-param name="p_label" select="'No&amp;nbsp;Frames'"/>
+ <xsl:with-param name="p_enabled" select="1"/>
+ <xsl:with-param name="p_target" select="'_top'"/>
+ <xsl:with-param name="p_last" select="0"/>
+ </xsl:call-template>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_onclick" select="'return setStyleSheet(&quot;GNU Clean&quot;);'"/>
+ <xsl:with-param name="p_title" select="'GNU Clean Style'"/>
+ <xsl:with-param name="p_label" select="'GNU Clean'"/>
+ <xsl:with-param name="p_enabled" select="1"/>
+ <xsl:with-param name="p_last" select="0"/>
+ </xsl:call-template>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_onclick" select="'return setStyleSheet(&quot;Santa Clara&quot;);'"/>
+ <xsl:with-param name="p_title" select="'Santa Clara Style'"/>
+ <xsl:with-param name="p_label" select="'Santa Clara'"/>
+ <xsl:with-param name="p_enabled" select="1"/>
+ <xsl:with-param name="p_last" select="0"/>
+ </xsl:call-template>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_onclick" select="'return setStyleSheet(&quot;Fixed Fruit&quot;);'"/>
+ <xsl:with-param name="p_title" select="'Fixed Fruit Style'"/>
+ <xsl:with-param name="p_label" select="'Fixed Fruit'"/>
+ <xsl:with-param name="p_enabled" select="1"/>
+ <xsl:with-param name="p_last" select="0"/>
+ </xsl:call-template>
+ <xsl:call-template name="output_navlink">
+ <xsl:with-param name="p_onclick" select="'return setStyleSheet(&quot;Vanilla&quot;);'"/>
+ <xsl:with-param name="p_title" select="'Vanilla Style'"/>
+ <xsl:with-param name="p_label" select="'Vanilla'"/>
+ <xsl:with-param name="p_enabled" select="1"/>
+ <xsl:with-param name="p_last" select="0"/>
+ </xsl:call-template>
+
+ </div>
+ </td>
+ <xsl:choose>
+ <xsl:when test="$p_top">
+ <xsl:if test="$gjdoc.option.header">
+ <td class="{$v_navbar_class} navbar-header">
+ <xsl:value-of select="$gjdoc.option.header"/>
+ </td>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="$gjdoc.option.footer">
+ <td class="{$v_navbar_class} navbar-footer">
+ <xsl:value-of select="$gjdoc.option.footer"/>
+ </td>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </tr>
+ </table>
+
+ </div>
+ <xsl:if test="not($p_top) and $gjdoc.option.bottom">
+ <hr/>
+ <xsl:value-of select="$gjdoc.option.bottom"/>
+ </xsl:if>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="link_to_class_source">
+ <xsl:choose>
+ <xsl:when test="$gjdoc.option.linksource">
+ <a href="{concat($gjdoc.pathtoroot, 'src-html/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', @name, '.html')}"><b><xsl:value-of select="@name"/></b></a>
+ </xsl:when>
+ <xsl:otherwise>
+ <b><xsl:value-of select="@name"/></b>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="link_to_member_source">
+ <xsl:choose>
+ <xsl:when test="$gjdoc.option.linksource">
+ <a href="{concat($gjdoc.pathtoroot, 'src-html/', translate(gjdoc:containingPackage/@name, '.', '/'), '/', gjdoc:containingClass/@typename, '.html#line.', gjdoc:position/@line)}"><b><xsl:value-of select="@name"/></b></a>
+ </xsl:when>
+ <xsl:otherwise>
+ <b><xsl:value-of select="@name"/></b>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="output_title">
+ <xsl:param name="p_pagetitle"/>
+ <xsl:variable name="v_title">
+ <xsl:value-of select="$p_pagetitle"/>
+ <xsl:if test="$gjdoc.option.windowtitle">
+ <xsl:text> (</xsl:text>
+ <xsl:value-of select="$gjdoc.option.windowtitle"/>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+ </xsl:variable>
+ <title>
+ <xsl:value-of select="$v_title"/>
+ </title>
+ </xsl:template>
+
+ <xsl:template name="get_qualified_type">
+ <xsl:param name="p_typename"/>
+ <xsl:variable name="v_plaintype">
+ <xsl:choose>
+ <xsl:when test="contains($p_typename,'[')">
+ <xsl:value-of select="normalize-space(substring-before($p_typename, '['))"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$p_typename"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="v_containingpackage">
+ <xsl:value-of select="ancestor-or-self::gjdoc:classdoc/gjdoc:containingPackage/attribute::name"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[attribute::name=$v_plaintype]/gjdoc:containingPackage[attribute::name=$v_containingpackage]">
+ <xsl:value-of select="$v_containingpackage"/>
+ <xsl:text>.</xsl:text>
+ </xsl:when>
+ <xsl:when test="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[attribute::name=$v_plaintype]/gjdoc:containingPackage[attribute::name='java.lang']">
+ <xsl:text>java.lang.</xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:value-of select="$p_typename"/>
+ </xsl:template>
+
+
+ <xsl:template name="output_link_tag">
+ <xsl:param name="p_contexturl"/>
+ <xsl:variable name="v_see">
+ <xsl:choose>
+ <xsl:when test="contains(., '(')">
+ <xsl:value-of select="normalize-space(substring-before(., '('))"/>
+ <xsl:text>(</xsl:text>
+ <xsl:call-template name="resolve_parameter_list">
+ <xsl:with-param name="p_anchor">
+ <xsl:value-of select="normalize-space(substring-before(substring-after(., '('), ')'))"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="v_class">
+ <xsl:choose>
+ <xsl:when test="contains(., '#')">
+ <xsl:value-of select="normalize-space(substring-before(., '#'))"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="normalize-space(.)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="v_anchor" select="normalize-space(substring-after(., '#'))"/>
+ <xsl:variable name="v_seeanchor">
+ <xsl:if test="contains($v_see, '#')">
+ <xsl:value-of select="concat('#', normalize-space(substring-after($v_see, '#')))"/>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="v_classname" select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[attribute::name=$v_class]/attribute::qualifiedtypename"/>
+ <xsl:variable name="v_classnamefq" select="document('index.xml', /)/gjdoc:rootdoc/gjdoc:classdoc[attribute::qualifiedtypename=$v_class]/attribute::qualifiedtypename"/>
+ <xsl:choose>
+ <xsl:when test="starts-with(., '#')">
+ <xsl:choose>
+ <xsl:when test="$p_contexturl">
+ <a href="{concat($p_contexturl, translate($v_see,' ',''))}"><xsl:value-of select="$v_anchor"/></a>
+ </xsl:when>
+ <xsl:otherwise>
+ <a href="{translate($v_see,' ','')}"><xsl:value-of select="$v_anchor"/></a>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$v_classname">
+ <a href="{translate(concat($gjdoc.pathtoroot, translate($v_classname, '.', '/'), '.html', $v_seeanchor),' ','')}"><xsl:value-of select="translate($v_see,'#','.')"/></a>
+ </xsl:when>
+ <xsl:when test="$v_classnamefq">
+ <a href="{translate(concat($gjdoc.pathtoroot, translate($v_classnamefq, '.', '/'), '.html', $v_seeanchor),' ','')}"><xsl:value-of select="translate($v_see,'#','.')"/></a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="translate(., '#', '.')" disable-output-escaping="yes"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="resolve_parameter_list">
+ <xsl:param name="p_anchor"/>
+ <xsl:variable name="v_parameter">
+ <xsl:value-of select="normalize-space(substring-before($p_anchor, ','))"/>
+ </xsl:variable>
+ <xsl:variable name="v_remainder">
+ <xsl:value-of select="normalize-space(substring-after($p_anchor, ','))"/>
+ </xsl:variable>
+ <xsl:call-template name="get_qualified_type">
+ <xsl:with-param name="p_typename">
+ <xsl:choose>
+ <xsl:when test="string-length($v_remainder)>0">
+ <xsl:value-of select="$v_parameter"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$p_anchor"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:if test="string-length($v_remainder)>0">
+ <xsl:text>,</xsl:text>
+ <xsl:call-template name="resolve_parameter_list">
+ <xsl:with-param name="p_anchor">
+ <xsl:value-of select="$v_remainder"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index.xsl
new file mode 100644
index 000000000..da4ff6260
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index.xsl
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- index.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the index.html file for HTML documentation. This is only
+ a simple frameset.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="html"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <frameset cols="20%,80%">
+ <xsl:choose>
+ <xsl:when test="count(/gjdoc:rootdoc/gjdoc:packagedoc) > 1">
+ <frameset rows="25%,75%">
+ <frame src="allpackages.html" name="packages"/>
+ <frame src="allclasses.html" name="classes"/>
+ </frameset>
+ <frame src="index_noframes.html" name="content"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <frame src="allclasses.html" name="classes"/>
+ <frame src="{concat(translate(/gjdoc:rootdoc/gjdoc:packagedoc[position()=1]/@name, '.', '/'), '/package-summary.html')}" name="content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </frameset>
+ </html>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index_noframes.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index_noframes.xsl
new file mode 100644
index 000000000..ab4510231
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index_noframes.xsl
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- index_noframes.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the index.html file for HTML documentation. This is only
+ a simple frameset.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template name="output_packagedoc_tr">
+ <tr>
+ <td class="package-link">
+ <a href="{concat(translate(@name,'.','/'), '/package-summary.html')}" class="package-link">
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td class="package-summary-description">
+ <xsl:apply-templates select="./gjdoc:firstSentenceTags/node()"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="'Overview'"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(document.title)">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="0"/>
+ <xsl:with-param name="p_curr_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <div class="pagebody">
+
+ <xsl:if test="$gjdoc.option.doctitle">
+ <h1 class="overview-doctitle"><xsl:value-of select="$gjdoc.option.doctitle"/></h1>
+ </xsl:if>
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:firstSentenceTags">
+ <div class="overview-description-top">
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:firstSentenceTags/node()">
+ <xsl:copy-of select="."/>
+ </xsl:for-each>
+ </div>
+ <div class="classdoc-tag-section-header">See Also:</div>
+ <dl class="classdoc-list">
+ <dt><a href="#description">Description</a></dt>
+ </dl>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="/gjdoc:rootdoc/gjdoc:packagegroup">
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:packagegroup">
+ <h1 class="classdoc-title"><xsl:value-of select="@name"/></h1>
+ <table border="1" cellspacing="0" class="classdoc-table">
+ <xsl:for-each select="gjdoc:package">
+ <xsl:variable name="v_name" select="@name"/>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:packagedoc[@name=$v_name]">
+ <xsl:call-template name="output_packagedoc_tr"/>
+ </xsl:for-each>
+ </xsl:for-each>
+ </table>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <h1 class="classdoc-title">All Packages</h1>
+ <table border="1" cellspacing="0" class="classdoc-table">
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:packagedoc">
+ <xsl:call-template name="output_packagedoc_tr"/>
+ </xsl:for-each>
+ </table>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:inlineTags">
+ <a name="description"/>
+ <div class="overview-description-full">
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:inlineTags/node()">
+ <xsl:copy-of select="."/>
+ </xsl:for-each>
+ </div>
+ </xsl:if>
+ </div>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_frames" select="1"/>
+ <xsl:with-param name="p_show_noframes" select="0"/>
+ <xsl:with-param name="p_curr_noframes" select="1"/>
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_show_package_tree" select="0"/>
+ <xsl:with-param name="p_show_full_tree" select="1"/>
+ <xsl:with-param name="p_show_index" select="1"/>
+ <xsl:with-param name="p_show_help" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+
+ </body>
+ </html>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packageclasses.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packageclasses.xsl
new file mode 100644
index 000000000..430b94447
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packageclasses.xsl
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- packageclasses.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the package descriptor files for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template name="add_link_to_class">
+ <a href="{concat(@name, '.html')}" target="content" class="menu packageclasses">
+ <xsl:choose>
+ <xsl:when test="gjdoc:isInterface">
+ <i><xsl:value-of select="@name"/></i>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@name"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </a><br/>
+ </xsl:template>
+
+ <xsl:template match="/">
+
+ <html>
+ <head>
+ <title>
+ <xsl:value-of select="concat(/gjdoc:rootdoc/gjdoc:title, ' - ', 'Classes in ', $gjdoc.outputfile.info)"/>
+ </title>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body onload="secondaryPageLoaded('classes');" class="menu packageclasses">
+ <h3 class="menu-title"><a href="package-summary.html" target="content"><xsl:value-of select="$gjdoc.outputfile.info"/></a></h3>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info and not(child::gjdoc:isError or child::gjdoc:isException)]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="add_link_to_class"/>
+ </xsl:for-each>
+
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info and child::gjdoc:isException]">
+ <h3><xsl:value-of select="$gjdoc.outputfile.info"/> Exceptions</h3>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info and child::gjdoc:isException]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="add_link_to_class"/>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info and child::gjdoc:isError]">
+ <h3><xsl:value-of select="$gjdoc.outputfile.info"/> Errors</h3>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info and child::gjdoc:isError]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="add_link_to_class"/>
+ </xsl:for-each>
+ </xsl:if>
+ </body>
+ </html>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packagedoc.xsl b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packagedoc.xsl
new file mode 100644
index 000000000..afe6fb77f
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packagedoc.xsl
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- packagedoc.xsl
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<!-- Creates the package descriptor files for HTML documentation.
+ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml"
+ xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+ <xsl:include href="html_common.xsl"/>
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="no"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+
+ <html>
+ <head>
+ <xsl:call-template name="output_title">
+ <xsl:with-param name="p_pagetitle" select="$gjdoc.outputfile.info"/>
+ </xsl:call-template>
+ <xsl:call-template name="include_common"/>
+ </head>
+ <body class="classdoc" onload="if(parent.contentPageLoaded)parent.contentPageLoaded(getTitle())">
+
+ <!-- Top Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_curr_package" select="1"/>
+ <xsl:with-param name="p_show_package_tree" select="1"/>
+ <xsl:with-param name="p_top" select="1"/>
+ </xsl:call-template>
+
+ <div class="pagebody">
+
+ <h1 class="classdoc-title">Package <xsl:value-of select="$gjdoc.outputfile.info"/></h1>
+
+ <div class="classdoc-package-comment-body">
+ <xsl:apply-templates select="/gjdoc:rootdoc/gjdoc:packagedoc[@name=$gjdoc.outputfile.info]/gjdoc:firstSentenceTags/node()"/>
+ </div>
+
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isInterface]">
+ <table border="1" cellspacing="0" width="100%" class="classdoc-table">
+ <tr><td colspan="2" class="section-header"><div class="section-header">Interface Summary</div></td></tr>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isInterface]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="output-classes-summary"/>
+ </xsl:for-each>
+ </table>
+ </xsl:if>
+
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isOrdinaryClass]">
+ <table border="1" cellspacing="0" width="100%" class="classdoc-table">
+ <tr><td colspan="2" class="section-header"><div class="section-header">Class Summary</div></td></tr>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isOrdinaryClass]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="output-classes-summary"/>
+ </xsl:for-each>
+ </table>
+ </xsl:if>
+
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isException]">
+ <table border="1" cellspacing="0" width="100%" class="classdoc-table">
+ <tr><td colspan="2" class="section-header"><div class="section-header">Exception Summary</div></td></tr>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isException]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="output-classes-summary"/>
+ </xsl:for-each>
+ </table>
+ </xsl:if>
+
+ <xsl:if test="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isError]">
+ <table border="1" cellspacing="0" width="100%" class="classdoc-table">
+ <tr><td colspan="2" class="section-header"><div class="section-header">Error Summary</div></td></tr>
+ <xsl:for-each select="/gjdoc:rootdoc/gjdoc:classdoc[gjdoc:containingPackage/@name=$gjdoc.outputfile.info][gjdoc:isError]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:call-template name="output-classes-summary"/>
+ </xsl:for-each>
+ </table>
+ </xsl:if>
+
+ <a name="description"><p> </p></a>
+ <h1 class="classdoc-sub-title package-description">Package <xsl:value-of select="$gjdoc.outputfile.info"/> Description</h1>
+
+ <div class="classdoc-package-comment-body">
+ <xsl:apply-templates select="/gjdoc:rootdoc/gjdoc:packagedoc[@name=$gjdoc.outputfile.info]/gjdoc:inlineTags/node()"/>
+ </div>
+
+ </div>
+
+ <!-- Bottom Navigation Bar -->
+ <xsl:call-template name="output_navbar">
+ <xsl:with-param name="p_show_package" select="0"/>
+ <xsl:with-param name="p_curr_package" select="1"/>
+ <xsl:with-param name="p_show_package_tree" select="1"/>
+ <xsl:with-param name="p_top" select="0"/>
+ </xsl:call-template>
+ </body>
+ </html>
+
+ </xsl:template>
+
+ <xsl:template name="output-classes-summary">
+ <xsl:variable name="v_currentclass" select="@qualifiedtypename"/>
+ <xsl:variable name="v_sub_xml_filename" select="concat(@qualifiedtypename,'.xml')"/>
+ <tr>
+ <td class="class-link">
+ <a href="{concat(@name, '.html')}" class="package-link">
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td class="class-summary-description">
+ <xsl:variable name="v_docstring" select="document($v_sub_xml_filename,/gjdoc:rootdoc)/gjdoc:classdoc[@qualifiedtypename=$v_currentclass]/gjdoc:firstSentenceTags/node()"/>
+ <xsl:choose>
+ <xsl:when test="$v_docstring">
+ <xsl:for-each select="$v_docstring">
+ <xsl:value-of select="." disable-output-escaping="yes"/>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <i>No description available.</i>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ </tr>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/default_help_en.html b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/default_help_en.html
new file mode 100644
index 000000000..b59a63c4f
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/default_help_en.html
@@ -0,0 +1,7 @@
+ <body>
+ <h1 class="classdoc-title">Using the API Documentation</h1>
+
+ <p>
+ Write me.
+ </p>
+ </body>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdoc.js b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdoc.js
new file mode 100644
index 000000000..125f8f687
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdoc.js
@@ -0,0 +1,108 @@
+/* gjdoc.js
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/**
+ * Sets a new stylesheet for a single frame.
+ */
+function setStyleSheetForFrame(title, frame_name)
+{
+ var i, num, a, main;
+ f = eval("top.frames." + frame_name);
+ for(i=0; (a = f.document.getElementsByTagName("link")[i]); i++) {
+ if(a.getAttribute("rel").indexOf("style") != -1
+ && a.getAttribute("title")) {
+ a.disabled = true;
+ a.disabled = (a.getAttribute("title") != title);
+ }
+ }
+}
+
+/**
+ * Sets a new stylesheet for a single document.
+ */
+function setStyleSheetForDocument(title)
+{
+ var i, num, a, main;
+ for(i=0; (a = top.document.getElementsByTagName("link")[i]); i++) {
+ if(a.getAttribute("rel").indexOf("style") != -1
+ && a.getAttribute("title")) {
+ a.disabled = true;
+ a.disabled = (a.getAttribute("title") != title);
+ }
+ }
+}
+
+/**
+ * Sets a new stylesheets for all frames.
+ */
+function setStyleSheet(title)
+{
+ var i, num, a, main;
+ num = top.frames.length;
+ if (num > 0) {
+ for (i=0; i<num; i++) {
+ setStyleSheetForFrame(title, top.frames[i].name);
+ }
+ }
+ else {
+ setStyleSheetForDocument(title);
+ }
+ top.selectedSheet = title;
+ return false;
+}
+
+/**
+ * Returns the title of the set of stylesheets that is active in the
+ * given frame.
+ */
+function getActiveStylesheetTitle(frame)
+{
+ for(i=0; (a = frame.document.getElementsByTagName("link")[i]); i++) {
+ if(a.getAttribute("rel").indexOf("style") != -1
+ && a.getAttribute("title")) {
+ if (!a.disabled) {
+ return a.getAttribute("title");
+ }
+ }
+ }
+ return "";
+}
+
+/**
+ * Invoked when a page in the main content frame has been loaded.
+ */
+function contentPageLoaded(title)
+{
+ top.document.title = title;
+ if (top.frames.length > 0)
+ setStyleSheet(getActiveStylesheetTitle(top.frames.packages), "content");
+ else if (top.selectedSheet) {
+ setStyleSheet(top.selectedSheet, "content");
+ }
+}
+
+/**
+ * Invoked when a page in one of the two frames on the left hand has
+ * been loaded.
+ */
+function secondaryPageLoaded(frame_name)
+{
+ setStyleSheet(getActiveStylesheetTitle(top.frames.packages), frame_name);
+}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-clean.css b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-clean.css
new file mode 100644
index 000000000..0913e7d3e
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-clean.css
@@ -0,0 +1,382 @@
+/* gjdochtml-clean.css
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+body.classdoc {
+ background: white;
+ font-size: 100%;
+ margin: 0.5em 1em 0.5em 1em;
+}
+
+hr {
+ border-style: solid none none none;
+ border-width: thin;
+ height: 1px;
+ color: black;
+}
+
+hr.footer {
+ margin-top: 2em;
+}
+
+table,tr,td {
+ border: solid 1px #aaaaaa !important;
+ border-collapse: collapse !important;
+}
+
+table.classdoc-table {
+ border-width: 1px;
+ border-collapse: collapse;
+}
+
+table.classdoc-table tr {
+ border-width: 1px;
+ border-collapse: collapse;
+}
+
+table.classdoc-table td {
+ border: solid 1px #aaaaaa;
+ border-collapse: collapse;
+}
+
+.header {
+
+ border-style: solid;
+ padding: 0.2em;
+ margin: 0.3em;
+}
+
+ul {
+ padding-top: 0em;
+ margin-top: 0em;
+}
+
+td {
+ padding: 0.3em;
+ vertical-align: top;
+}
+
+td.with-border {
+ border-color: #aaaaaa;
+ border-style: solid;
+ border-top: 0px;
+}
+
+td.no-border-r {
+ border-color: #aaaaaa;
+ border-style: solid;
+ border-right: 0px;
+ border-top: 0px;
+}
+
+td.no-border-b {
+ border-color: #aaaaaa;
+ border-style: solid;
+ border-bottom: 0px;
+}
+
+td.no-border-rb {
+ border-color: #aaaaaa;
+ border-style: solid;
+ border-right: 0px;
+ border-bottom: 0px;
+}
+
+.classdoc-head {
+ border: 1px;
+ border-style: solid;
+ padding: 0.3em 0.7em 0.5em 0.7em;
+ margin: 0.0em;
+}
+
+.classdoc-head-packagename {
+ font-size: 110%;
+ padding: 0.0em;
+ margin: 0.0em;
+}
+
+.classdoc-head-classname {
+ font-size: 180%;
+ padding: 0.0em;
+ margin: 0.0em;
+}
+
+h1.classdoc-header {
+ border-width: 1px;
+ border-style: solid;
+ font-size: 140%;
+ padding: 0.2em 0.5em 0.3em 0.5em;
+ margin-top: 0.0em;
+}
+
+h2.classdoc-header {
+ border-width: 1px;
+ border-style: solid;
+ font-size: 140%;
+ padding: 0.2em 0.5em 0.3em 0.5em;
+ margin-top: 0.0em;
+}
+
+h1.classdoc-header,
+h2.classdoc-header,
+.classdoc-head,
+.classdoc-subheader,
+.section-header,
+.sub-section-header {
+ background: #80B9FF;
+ font-weight: bolder;
+}
+
+table.navbar {
+ background: #BFDCFF;
+}
+
+div[class="navbar top"] {
+ margin-bottom: 1em;
+}
+
+span[class="navi-button current"] {
+ color: white;
+ background: #0055BA;
+}
+
+span[class="navi-button unavailable"] {
+ color: #888888;
+}
+
+h3.classdoc-header {
+ font-size: 110%;
+}
+
+.classdoc-subheader {
+ border-width: 1px;
+ border-style: solid;
+ font-size: 120%;
+ padding: 1.0em;
+}
+
+.classdoc-prototype {
+}
+
+.classdoc-summary-comment {
+ margin-top: 1.0em;
+ margin-bottom: 1.0em;
+ font-size: 100%;
+}
+
+.classdoc-tree-label {
+ font-size: 80%;
+ line-height: 2.0em;
+ padding: 0%;
+ vertical-align: top;
+ height: 2.0em;
+ margin: 0%;
+ padding-left: 1.0em;
+}
+
+.classdoc-comment-body {
+ font-size: 100%;
+}
+
+blockquote.classdoc-summary-comment {
+ margin: 0.4em 0.0em 0.2em 2.0em;
+ padding: 0em;
+}
+
+div.classdoc-comment-body {
+ margin: 0.4em 0.0em 0.2em 2.0em;
+ padding: 0em;
+}
+
+div.classdoc-package-comment-body {
+ margin: 0.4em 0.0em 1.5em 0.0em;
+ padding: 0em;
+}
+
+div.classdoc-class-comment-body {
+ margin: 0.8em 0.0em 1.0em 0.0em;
+ padding: 0.0em;
+}
+
+ul.classdoc-list {
+ margin-top: 0.2em;
+ margin-left: 1.6em;
+}
+
+div.classdoc-tag-section-header {
+ margin-top: 0.5em;
+ font-weight: bold;
+}
+
+ol.classdoc-list {
+ margin-top: 0.2em;
+ margin-left: 1.6em;
+ list-style-type: circle;
+}
+
+dl.classdoc-list {
+ margin-top: 0.2em;
+ margin-left: 1.6em;
+}
+
+.navi-button {
+ padding: 0.0em;
+ margin: 0.0em;
+ padding-left: 0.2em;
+ padding-right: 0.2em;
+}
+
+.header {
+ width: 100%;
+ padding: 0.0em 0.7em 0.5em 0.0em;
+ margin: 0.0em 0.0em 0.9em 0.0em;
+ border: black 1px;
+ border-style: none none solid none;
+}
+
+.navbar-first-row {
+ width: 100%;
+ padding: 0.0em 0.7em 0.0em 0.0em;
+ margin: 0.0em 0.0em 0.4em 0.0em;
+ font-size: 80%;
+}
+
+.navbar-second-row {
+ width: 100%;
+ padding: 0.0em 0.7em 0.0em 0.0em;
+ margin: 0.0em 0.0em 0.0em 0.0em;
+ font-size: 70%;
+}
+
+.prototype {
+ text-indent:-2em;
+ font-family:monospace;
+ padding: 0em 0em 0em 2em;
+ margin: 0em;
+}
+
+.prototype-type {
+ font-family:monospace;
+ padding: 0em;
+ margin: 0em;
+}
+
+.prototype-name {
+ font-family:monospace;
+}
+
+span.parameter {
+ padding: 0em;
+ margin: 0em;
+ white-space: nowrap;
+}
+
+div.footer {
+ margin-bottom: 6cm;
+ font-style: italic;
+ font-size: 0.8em;
+}
+
+pre {
+ margin-left: 1.6em;
+}
+
+pre.inheritance-tree {
+ margin-left: 0.0em;
+}
+
+a.tree-class-link {
+ font-weight: bold;
+}
+
+span.index-category-current {
+ padding: 0.4em;
+ border: 1px black solid;
+}
+
+a.index-category-link {
+ padding: 0.4em;
+}
+
+a.menu {
+ font-size: 90%;
+}
+
+table.navbar {
+ width: 100%;
+ margin: 0px;
+ border: solid 1px #888888;
+ padding: 0px;
+}
+
+tr.navbar, td.navbar {
+ padding: 0.3em;
+ margin: 0px;
+}
+
+
+h1.overview-doctitle {
+ font-size: 170%;
+ text-align: center;
+ padding-bottom: 0.5em;
+}
+
+div.overview-description-top,
+div.overview-description-full {
+ margin-top: 1.5em;
+}
+
+table {
+ margin-top: 0em;
+ margin-bottom: 1em;
+ border-collapse: collapse;
+}
+
+span.navsep {
+}
+
+a[href] {
+ color: #0055BA;
+}
+
+a:visited {
+ color: #003B82;
+}
+
+a:active {
+ color: #80B9FF;
+}
+
+blockquote.member-summary {
+ text-indent: 2em;
+ margin: 0em;
+ margin-top: 0.2em;
+}
+
+table {
+ width: 100%;
+}
+
+td[class="member-summary method modifiers"] {
+ text-align: right;
+}
+
+td[class="member-summary field modifiers"] {
+ text-align: right;
+}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-fixed.css b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-fixed.css
new file mode 100644
index 000000000..0c96c009a
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-fixed.css
@@ -0,0 +1,286 @@
+/* gjdochtml-fixed.css
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+table {
+ border: none !important;
+ border-top: none !important;
+ border-left: none !important;
+ border-right: none !important;
+ border-bottom: none !important;
+}
+
+td {
+ border: none !important;
+ border-top: none !important;
+ border-left: none !important;
+ border-right: none !important;
+ border-bottom: none !important;
+}
+
+body.classdoc {
+ font-size: 100%;
+ margin: 0em;
+ padding: 0em;
+}
+
+table.navbar {
+ margin: 0em;
+ position: fixed;
+ z-index: 20;
+ left: 0em;
+ top: 0em;
+ width: 100%;
+ background: #0066B3;
+ color: white;
+ padding: 0.3em;
+ border-bottom: 3px solid black !important;
+ height: 5.3em;
+}
+
+table[class="navbar bottom"] {
+ visibility: hidden;
+}
+
+a.navi-button {
+ color: #FFB200;
+}
+
+.navbar-first-row {
+ font-size: 80%;
+ padding-bottom: 0.3em;
+}
+
+.navbar-second-row {
+ font-size: 70%;
+ text-align: right;
+ padding-right: 4.5em;
+}
+
+
+div.pagebody {
+ margin-top: 7em;
+ padding-left: 1em;
+ padding-right: 1em;
+ padding-bottom: 5em;
+ z-index: -100;
+}
+
+span.navsep:before {
+ padding-left: 0.25em;
+ content: "|";
+}
+
+span[class="navi-button current"] {
+ background: #003D6B;
+ color: white;
+}
+
+span[class="navi-button unavailable"] {
+ color: white;
+}
+
+.navi-button {
+ padding-left: 0.1em;
+ padding-right: 0.1em;
+
+}
+
+
+.classdoc-table-xxx {
+ border-color: #aaaaaa;
+ border-style: solid;
+ border-collapse: collapse;
+}
+
+.classdoc-table {
+ border: 0px;
+ border-collapse: collapse;
+}
+
+td {
+ vertical-align: top;
+ padding: 0.2em;
+}
+
+table {
+ margin-top: 1em;
+}
+
+span.index-category-current {
+ padding: 0.4em;
+ border: 1px black solid;
+}
+
+a.index-category-link {
+ width: 5em;
+ min-width: 5em;
+ padding: 0.3em;
+ margin-right: 0.4em;
+ color: #FFB200;
+ border: 1px #FFB200 solid;
+ text-decoration: none;
+}
+
+a[href] {
+ color: #991F00;
+}
+
+.classdoc-subtitle {
+ position: fixed;
+ left: 0.0em;
+ top: 2.7em;
+ font-size: 80%;
+ font-weight: bold;
+ color: #FFD980;
+ z-index: 30;
+ padding-left: 1.0em;
+ padding-top: 0.0em;
+ margin-top: 0.0em;
+}
+
+h1.classdoc-title {
+ position: fixed;
+ left: 0.0em;
+ top: 2.4em;
+ font-size: 130%;
+ z-index: 30;
+ color: #FFD980;
+ padding-left: 0.5em;
+ padding-top: 0.0em;
+ margin-top: 0.0em;
+}
+
+div.index-categories {
+ position: fixed;
+ left: 28em;
+ top: 5.8em;
+ font-size: 60%;
+ padding-top: 0.0em;
+ margin-top: 0.0em;
+}
+
+.before-details {
+}
+
+h3.menu-title {
+ width: 100%;
+ position: fixed;
+ left: 0em;
+ top: 0em;
+ margin-top: 0em;
+ background: #0066B3;
+ color: #FFD980;
+ padding: 0.3em;
+ padding-left: 0.8em;
+ border-bottom: 3px solid black;
+ font-size: 100%;
+}
+
+h3.menu-title > a {
+ color: #FFB200;
+}
+
+body.menu {
+ padding-top: 2em;
+}
+
+a.menu {
+ font-size: 85%;
+}
+
+a.classdoc {
+ position: relative;
+ top: -6em;
+}
+
+
+div.section-header, h1.classdoc-header {
+ background: #FFD980;
+ margin-bottom: 0px;
+ font-size: 130%;
+ font-weight: bolder;
+ padding-left: 2px;
+ margin-top: 1em;
+ padding-top: 4px;
+ padding-bottom: 4px;
+ position: relative;
+ left: -200px;
+ padding-left: 202px;
+ padding-right: 20px;
+ border: 1px solid black;
+ width: 60%;
+}
+
+div.sub-section-header {
+ background: #FFD980;
+ margin-bottom: 0px;
+ font-size: 110%;
+ font-weight: normal;
+ padding-left: 2px;
+ margin-top: 1em;
+ padding-top: 4px;
+ padding-bottom: 4px;
+ position: relative;
+ left: -200px;
+ padding-left: 202px;
+ padding-right: 20px;
+ border: 1px solid black;
+ width: 60%;
+}
+
+table {
+ width: 100%;
+}
+
+dl.classdoc-list {
+ margin-top: 0px;
+ margin-bottom: 0px;
+ margin-left: 2.5em;
+}
+
+blockquote.member-summary {
+ margin: 0px;
+ font-style: oblique;
+ font-size: 90%;
+ margin-top: 0.1em;
+ margin-bottom: 0.2em;
+ margin-left: 1em;
+}
+
+td[class="member-summary method modifiers"] {
+ text-align: right;
+}
+
+div.classdoc-tag-section-header {
+ margin-top: 0.5em;
+ font-weight: bold;
+}
+
+div.navbar-style-selector {
+ position: fixed;
+ right: 1em;
+ top: 2.9em;
+ z-index: 50;
+ padding-right: 0.6em;
+ vertical-align: top;
+}
+
+/* triad @ 225 deg */
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-sclara.css b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-sclara.css
new file mode 100644
index 000000000..5c7f119d9
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-sclara.css
@@ -0,0 +1,266 @@
+/* gjdochtml-sclara.css
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+div.section-header,
+h1.classdoc-header {
+ background: #ccccff;
+ border: black ridge 2px;
+ border-collapse: collapse;
+ vertical-align: inherit;
+ text-align: inherit;
+ margin-bottom: 0px;
+ font-size: 155%;
+ font-weight: bold;
+ padding-left: 2px;
+ margin-top: 1em;
+ padding-top: 2px;
+ padding-bottom: 2px;
+}
+
+td.section-header {
+ background: #ccccff;
+ margin-bottom: 0px;
+ font-size: 155%;
+ font-weight: bold;
+ padding-left: 2px;
+ margin-top: 1em;
+ padding-top: 2px;
+ padding-bottom: 2px;
+}
+
+td.sub-section-header {
+ background: #eeeeff;
+ margin-bottom: 0px;
+ font-size: 110%;
+ font-weight: normal;
+ padding-left: 2px;
+ margin-top: 1em;
+ padding-top: 2px;
+ padding-bottom: 2px;
+}
+
+table.classdoc-table {
+ margin-top: 1.5em;
+}
+
+div.navbar-first-row {
+ background: #eeeeff;
+ padding-top: 4px;
+ padding-bottom: 4px;
+ padding-left: 4px;
+ padding-right: 4px;
+ font-size: 100%;
+ color: black;
+ font-family: Arial, sans-serif;
+ font-weight: normal;
+}
+
+div.navbar-second-row {
+ padding-top: 0px;
+ padding-bottom: 9px;
+}
+
+div.navbar-second-row a[href] {
+ text-decoration: underline;
+ font-family: Arial, sans-serif;
+ font-weight: normal;
+ font-size: 60%;
+ text-transform: uppercase;
+ padding-top: 0px;
+ margin-top: 0px;
+ background: white;
+ margin-left: 8px;
+}
+
+div.navbar-second-row span {
+ padding: 0px;
+ margin: 0px;
+}
+
+span.navi-button {
+ padding-left: 0.4em;
+ padding-right: 0.4em;
+}
+
+div.navbar-first-row span[class="navi-button current"] {
+ background: #00008B;
+ color: white;
+ font-weight: bold;
+}
+
+div.navbar-first-row span[class="navi-button unavailable"] {
+ font-weight: normal;
+}
+
+div.navbar-first-row a[href] {
+ padding-bottom: 0px;
+ font-weight: lighter;
+ text-decoration: none;
+ border-bottom: 1px solid blue;
+ position: relative;
+ top: -1px;
+}
+
+div.navbar-first-row a:visited {
+ color: black;
+ font-weight: lighter;
+ text-decoration: none;
+ border-bottom: 1px solid black;
+}
+
+div.navbar-first-row span.navi-link {
+ padding: 0px;
+ margin: 0px;
+ color: black;
+ font-weight: bold;
+ position: relative;
+ top: 1px;
+}
+
+span.navsep {
+ padding-left: 0.15em;
+}
+
+a.menu {
+ font-family: Arial, Sans-Serif;
+ font-size: 90%;
+}
+
+table.navbar[class="navbar top"] {
+ padding-bottom: 4px;
+ border-bottom: inset 1px black;
+}
+
+table {
+ width: 100%;
+ margin: 0px;
+ border: none;
+ padding: 0px;
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+tr.navbar {
+ margin: 0px;
+ padding: 0px;
+ border: none;
+}
+
+td.navbar {
+ margin: 0px;
+ padding: 0px;
+ border: none;
+}
+
+a.package-link,
+a.class-link {
+ font-weight: bold;
+}
+
+table,tr,td {
+}
+
+table.classdoc-table {
+}
+
+table.classdoc-table tr {
+}
+
+table.classdoc-table td {
+ border: ridge 2px black;
+ border-collapse: separate;
+}
+
+td {
+ padding: 2px;
+}
+
+h1.classdoc-title,
+h1.classdoc-sub-title {
+ font-size: 150%;
+ font-weight: bold;
+}
+
+div.pagebody {
+ padding-bottom: 1em;
+}
+
+h3.menu-title {
+ font-family: Arial, Sans-Serif;
+ font-weight: normal;
+ font-size: 105%;
+}
+
+p.member-summary {
+ margin: 0px;
+ padding: 0px;
+ font-family: Monospace;
+}
+
+p.modifiers {
+ font-size: 80%;
+}
+
+a.name {
+ font-weight: bold;
+}
+
+blockquote.member-summary {
+ text-indent: 3em;
+ margin: 0px;
+}
+
+td.member-summary {
+ vertical-align: top;
+}
+
+.classdoc-head-packagename {
+ font-weight: bold;
+ padding-top: 2em;
+ padding-bottom: 0em;
+ margin: 0em;
+}
+
+.classdoc-head-classname {
+ padding-top: 0em;
+ margin-top: 0em;
+}
+
+td.super {
+ font-family: Monospace;
+}
+
+.classdoc-tag-section-header {
+ font-weight: bold;
+}
+
+dl.classdoc-list {
+ margin-top: 0px;
+ margin-bottom: 0px;
+ margin-left: 2.5em;
+}
+
+div.section-header,
+div.sub-section-header {
+ border: none;
+ padding: 0px;
+ margin: 0px;
+ font-size: inherit;
+}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml.css b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml.css
new file mode 100644
index 000000000..5944c6cdb
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml.css
@@ -0,0 +1,29 @@
+/* gjdochtml.css
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+body {
+ background: white;
+ font-size: 100%;
+}
+
+ol.tree,
+li.tree {
+ list-style-type: disc;
+}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/dbcentx.mod b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/dbcentx.mod
new file mode 100644
index 000000000..144d38dea
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/dbcentx.mod
@@ -0,0 +1,204 @@
+<!-- ...................................................................... -->
+<!-- DocBook XML character entities module V4.1.2 ........................... -->
+<!-- File dbcentx.mod ..................................................... -->
+
+<!-- Copyright 1992-2000 HaL Computer Systems, Inc.,
+ O'Reilly & Associates, Inc., ArborText, Inc., Fujitsu Software
+ Corporation, Norman Walsh, and the Organization for the Advancement
+ of Structured Information Standards (OASIS).
+
+ $Id: dbcentx.mod,v 1.1 2008/05/27 19:26:05 jsumali Exp $
+
+ Permission to use, copy, modify and distribute the DocBook XML DTD
+ and its accompanying documentation for any purpose and without fee
+ is hereby granted in perpetuity, provided that the above copyright
+ notice and this paragraph appear in all copies. The copyright
+ holders make no representation about the suitability of the DTD for
+ any purpose. It is provided "as is" without expressed or implied
+ warranty.
+
+ If you modify the DocBook XML DTD in any way, except for declaring and
+ referencing additional sets of general entities and declaring
+ additional notations, label your DTD as a variant of DocBook. See
+ the maintenance documentation for more information.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+-->
+
+<!-- ...................................................................... -->
+
+<!-- This module contains the entity declarations for the standard ISO
+ entity sets used by DocBook.
+
+ In DTD driver files referring to this module, please use an entity
+ declaration that uses the public identifier shown below:
+
+ <!ENTITY % dbcent PUBLIC
+ "-//OASIS//ENTITIES DocBook XML Character Entities V4.1.2//EN"
+ "dbcentx.mod">
+ %dbcent;
+
+ See the documentation for detailed information on the parameter
+ entity and module scheme used in DocBook, customizing DocBook and
+ planning for interchange, and changes made since the last release
+ of DocBook.
+-->
+
+<!-- ...................................................................... -->
+
+<!ENTITY % ISOamsa.module "INCLUDE">
+<![%ISOamsa.module;[
+<!ENTITY % ISOamsa PUBLIC
+"ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN//XML"
+"ent/iso-amsa.ent">
+%ISOamsa;
+<!--end of ISOamsa.module-->]]>
+
+<!ENTITY % ISOamsb.module "INCLUDE">
+<![%ISOamsb.module;[
+<!ENTITY % ISOamsb PUBLIC
+"ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN//XML"
+"ent/iso-amsb.ent">
+%ISOamsb;
+<!--end of ISOamsb.module-->]]>
+
+<!ENTITY % ISOamsc.module "INCLUDE">
+<![%ISOamsc.module;[
+<!ENTITY % ISOamsc PUBLIC
+"ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN//XML"
+"ent/iso-amsc.ent">
+%ISOamsc;
+<!--end of ISOamsc.module-->]]>
+
+<!ENTITY % ISOamsn.module "INCLUDE">
+<![%ISOamsn.module;[
+<!ENTITY % ISOamsn PUBLIC
+"ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN//XML"
+"ent/iso-amsn.ent">
+%ISOamsn;
+<!--end of ISOamsn.module-->]]>
+
+<!ENTITY % ISOamso.module "INCLUDE">
+<![%ISOamso.module;[
+<!ENTITY % ISOamso PUBLIC
+"ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN//XML"
+"ent/iso-amso.ent">
+%ISOamso;
+<!--end of ISOamso.module-->]]>
+
+<!ENTITY % ISOamsr.module "INCLUDE">
+<![%ISOamsr.module;[
+<!ENTITY % ISOamsr PUBLIC
+"ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN//XML"
+"ent/iso-amsr.ent">
+%ISOamsr;
+<!--end of ISOamsr.module-->]]>
+
+<!ENTITY % ISObox.module "INCLUDE">
+<![%ISObox.module;[
+<!ENTITY % ISObox PUBLIC
+"ISO 8879:1986//ENTITIES Box and Line Drawing//EN//XML"
+"ent/iso-box.ent">
+%ISObox;
+<!--end of ISObox.module-->]]>
+
+<!ENTITY % ISOcyr1.module "INCLUDE">
+<![%ISOcyr1.module;[
+<!ENTITY % ISOcyr1 PUBLIC
+"ISO 8879:1986//ENTITIES Russian Cyrillic//EN//XML"
+"ent/iso-cyr1.ent">
+%ISOcyr1;
+<!--end of ISOcyr1.module-->]]>
+
+<!ENTITY % ISOcyr2.module "INCLUDE">
+<![%ISOcyr2.module;[
+<!ENTITY % ISOcyr2 PUBLIC
+"ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN//XML"
+"ent/iso-cyr2.ent">
+%ISOcyr2;
+<!--end of ISOcyr2.module-->]]>
+
+<!ENTITY % ISOdia.module "INCLUDE">
+<![%ISOdia.module;[
+<!ENTITY % ISOdia PUBLIC
+"ISO 8879:1986//ENTITIES Diacritical Marks//EN//XML"
+"ent/iso-dia.ent">
+%ISOdia;
+<!--end of ISOdia.module-->]]>
+
+<!ENTITY % ISOgrk1.module "INCLUDE">
+<![%ISOgrk1.module;[
+<!ENTITY % ISOgrk1 PUBLIC
+"ISO 8879:1986//ENTITIES Greek Letters//EN//XML"
+"ent/iso-grk1.ent">
+%ISOgrk1;
+<!--end of ISOgrk1.module-->]]>
+
+<!ENTITY % ISOgrk2.module "INCLUDE">
+<![%ISOgrk2.module;[
+<!ENTITY % ISOgrk2 PUBLIC
+"ISO 8879:1986//ENTITIES Monotoniko Greek//EN//XML"
+"ent/iso-grk2.ent">
+%ISOgrk2;
+<!--end of ISOgrk2.module-->]]>
+
+<!ENTITY % ISOgrk3.module "INCLUDE">
+<![%ISOgrk3.module;[
+<!ENTITY % ISOgrk3 PUBLIC
+"ISO 8879:1986//ENTITIES Greek Symbols//EN//XML"
+"ent/iso-grk3.ent">
+%ISOgrk3;
+<!--end of ISOgrk3.module-->]]>
+
+<!ENTITY % ISOgrk4.module "INCLUDE">
+<![%ISOgrk4.module;[
+<!ENTITY % ISOgrk4 PUBLIC
+"ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN//XML"
+"ent/iso-grk4.ent">
+%ISOgrk4;
+<!--end of ISOgrk4.module-->]]>
+
+<!ENTITY % ISOlat1.module "INCLUDE">
+<![%ISOlat1.module;[
+<!ENTITY % ISOlat1 PUBLIC
+"ISO 8879:1986//ENTITIES Added Latin 1//EN//XML"
+"ent/iso-lat1.ent">
+%ISOlat1;
+<!--end of ISOlat1.module-->]]>
+
+<!ENTITY % ISOlat2.module "INCLUDE">
+<![%ISOlat2.module;[
+<!ENTITY % ISOlat2 PUBLIC
+"ISO 8879:1986//ENTITIES Added Latin 2//EN//XML"
+"ent/iso-lat2.ent">
+%ISOlat2;
+<!--end of ISOlat2.module-->]]>
+
+<!ENTITY % ISOnum.module "INCLUDE">
+<![%ISOnum.module;[
+<!ENTITY % ISOnum PUBLIC
+"ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML"
+"ent/iso-num.ent">
+%ISOnum;
+<!--end of ISOnum.module-->]]>
+
+<!ENTITY % ISOpub.module "INCLUDE">
+<![%ISOpub.module;[
+<!ENTITY % ISOpub PUBLIC
+"ISO 8879:1986//ENTITIES Publishing//EN//XML"
+"ent/iso-pub.ent">
+%ISOpub;
+<!--end of ISOpub.module-->]]>
+
+<!ENTITY % ISOtech.module "INCLUDE">
+<![%ISOtech.module;[
+<!ENTITY % ISOtech PUBLIC
+"ISO 8879:1986//ENTITIES General Technical//EN//XML"
+"ent/iso-tech.ent">
+%ISOtech;
+<!--end of ISOtech.module-->]]>
+
+<!-- End of DocBook XML character entity sets module V4.1.2 ................. -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsa.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsa.ent
new file mode 100644
index 000000000..c03b1c91e
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsa.ent
@@ -0,0 +1,98 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Math Symbols: Arrow Relations Entities V0.3 ................ -->
+<!-- File iso-amsa.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-amsa.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-amsa.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN//XML
+-->
+
+<!ENTITY cularr "&#x21B6;"> <!-- ANTICLOCKWISE TOP SEMICIRCLE ARROW -->
+<!ENTITY curarr "&#x21B7;"> <!-- CLOCKWISE TOP SEMICIRCLE ARROW -->
+<!ENTITY dArr "&#x21D3;"> <!-- DOWNWARDS DOUBLE ARROW -->
+<!ENTITY darr2 "&#x21CA;"> <!-- DOWNWARDS PAIRED ARROWS -->
+<!ENTITY dharl "&#x21C3;"> <!-- DOWNWARDS HARPOON WITH BARB LEFTWARDS -->
+<!ENTITY dharr "&#x21C2;"> <!-- DOWNWARDS HARPOON WITH BARB RIGHTWARDS -->
+<!ENTITY lAarr "&#x21DA;"> <!-- LEFTWARDS TRIPLE ARROW -->
+<!ENTITY Larr "&#x219E;"> <!-- LEFTWARDS TWO HEADED ARROW -->
+<!ENTITY larr2 "&#x21C7;"> <!-- LEFTWARDS PAIRED ARROWS -->
+<!ENTITY larrhk "&#x21A9;"> <!-- LEFTWARDS ARROW WITH HOOK -->
+<!ENTITY larrlp "&#x21AB;"> <!-- LEFTWARDS ARROW WITH LOOP -->
+<!ENTITY larrtl "&#x21A2;"> <!-- LEFTWARDS ARROW WITH TAIL -->
+<!ENTITY lhard "&#x21BD;"> <!-- LEFTWARDS HARPOON WITH BARB DOWNWARDS -->
+<!ENTITY lharu "&#x21BC;"> <!-- LEFTWARDS HARPOON WITH BARB UPWARDS -->
+<!ENTITY hArr "&#x21D4;"> <!-- -->
+<!ENTITY harr "&#x2194;"> <!-- LEFT RIGHT ARROW -->
+<!ENTITY lrarr2 "&#x21C6;"> <!-- LEFTWARDS ARROW OVER RIGHTWARDS ARROW -->
+<!ENTITY rlarr2 "&#x21C4;"> <!-- RIGHTWARDS ARROW OVER LEFTWARDS ARROW -->
+<!ENTITY harrw "&#x21AD;"> <!-- LEFT RIGHT WAVE ARROW -->
+<!ENTITY rlhar2 "&#x21CC;"> <!-- RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON -->
+<!ENTITY lrhar2 "&#x21CB;"> <!-- LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON -->
+<!ENTITY lsh "&#x21B0;"> <!-- UPWARDS ARROW WITH TIP LEFTWARDS -->
+<!ENTITY map "&#x21A6;"> <!-- RIGHTWARDS ARROW FROM BAR -->
+<!ENTITY mumap "&#x22B8;"> <!-- MULTIMAP -->
+<!ENTITY nearr "&#x2197;"> <!-- NORTH EAST ARROW -->
+<!ENTITY nlArr "&#x21CD;"> <!-- LEFTWARDS DOUBLE ARROW WITH STROKE -->
+<!ENTITY nlarr "&#x219A;"> <!-- LEFTWARDS ARROW WITH STROKE -->
+<!ENTITY nhArr "&#x21CE;"> <!-- LEFT RIGHT DOUBLE ARROW WITH STROKE -->
+<!ENTITY nharr "&#x21AE;"> <!-- LEFT RIGHT ARROW WITH STROKE -->
+<!ENTITY nrarr "&#x219B;"> <!-- RIGHTWARDS ARROW WITH STROKE -->
+<!ENTITY nrArr "&#x21CF;"> <!-- RIGHTWARDS DOUBLE ARROW WITH STROKE -->
+<!ENTITY nwarr "&#x2196;"> <!-- NORTH WEST ARROW -->
+<!ENTITY olarr "&#x21BA;"> <!-- ANTICLOCKWISE OPEN CIRCLE ARROW -->
+<!ENTITY orarr "&#x21BB;"> <!-- CLOCKWISE OPEN CIRCLE ARROW -->
+<!ENTITY rAarr "&#x21DB;"> <!-- RIGHTWARDS TRIPLE ARROW -->
+<!ENTITY Rarr "&#x21A0;"> <!-- RIGHTWARDS TWO HEADED ARROW -->
+<!ENTITY rarr2 "&#x21C9;"> <!-- RIGHTWARDS PAIRED ARROWS -->
+<!ENTITY rarrhk "&#x21AA;"> <!-- RIGHTWARDS ARROW WITH HOOK -->
+<!ENTITY rarrlp "&#x21AC;"> <!-- RIGHTWARDS ARROW WITH LOOP -->
+<!ENTITY rarrtl "&#x21A3;"> <!-- RIGHTWARDS ARROW WITH TAIL -->
+<!ENTITY rarrw "&#x219D;"> <!-- RIGHTWARDS SQUIGGLE ARROW -->
+<!ENTITY rhard "&#x21C1;"> <!-- RIGHTWARDS HARPOON WITH BARB DOWNWARDS -->
+<!ENTITY rharu "&#x21C0;"> <!-- RIGHTWARDS HARPOON WITH BARB UPWARDS -->
+<!ENTITY rsh "&#x21B1;"> <!-- UPWARDS ARROW WITH TIP RIGHTWARDS -->
+<!ENTITY drarr "&#x2198;"> <!-- SOUTH EAST ARROW -->
+<!ENTITY dlarr "&#x2199;"> <!-- SOUTH WEST ARROW -->
+<!ENTITY uArr "&#x21D1;"> <!-- UPWARDS DOUBLE ARROW -->
+<!ENTITY uarr2 "&#x21C8;"> <!-- UPWARDS PAIRED ARROWS -->
+<!ENTITY vArr "&#x21D5;"> <!-- UP DOWN DOUBLE ARROW -->
+<!ENTITY varr "&#x2195;"> <!-- UP DOWN ARROW -->
+<!ENTITY uharl "&#x21BF;"> <!-- UPWARDS HARPOON WITH BARB LEFTWARDS -->
+<!ENTITY uharr "&#x21BE;"> <!-- UPWARDS HARPOON WITH BARB RIGHTWARDS -->
+<!ENTITY xlArr "&#x21D0;"> <!-- LEFTWARDS DOUBLE ARROW -->
+<!ENTITY xhArr "&#x2194;"> <!-- LEFT RIGHT ARROW -->
+<!ENTITY xharr "&#x2194;"> <!-- LEFT RIGHT ARROW -->
+<!ENTITY xrArr "&#x21D2;"> <!-- RIGHTWARDS DOUBLE ARROW -->
+
+<!-- End of Added Math Symbols: Arrow Relations Entities V0.3 ............. -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsb.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsb.ent
new file mode 100644
index 000000000..945d7eef4
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsb.ent
@@ -0,0 +1,84 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Math Symbols: Binary Operators Entities V0.3 ............... -->
+<!-- File iso-amsb.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-amsb.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-amsb.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN//XML
+-->
+
+<!ENTITY amalg "&#x2210;"> <!-- N-ARY COPRODUCT -->
+<!ENTITY Barwed "&#x2306;"> <!-- PERSPECTIVE -->
+<!ENTITY barwed "&#x22BC;"> <!-- NAND -->
+<!ENTITY Cap "&#x22D2;"> <!-- DOUBLE INTERSECTION -->
+<!ENTITY Cup "&#x22D3;"> <!-- DOUBLE UNION -->
+<!ENTITY cuvee "&#x22CE;"> <!-- CURLY LOGICAL OR -->
+<!ENTITY cuwed "&#x22CF;"> <!-- CURLY LOGICAL AND -->
+<!ENTITY diam "&#x22C4;"> <!-- DIAMOND OPERATOR -->
+<!ENTITY divonx "&#x22C7;"> <!-- DIVISION TIMES -->
+<!ENTITY intcal "&#x22BA;"> <!-- INTERCALATE -->
+<!ENTITY lthree "&#x22CB;"> <!-- LEFT SEMIDIRECT PRODUCT -->
+<!ENTITY ltimes "&#x22C9;"> <!-- LEFT NORMAL FACTOR SEMIDIRECT PRODUCT -->
+<!ENTITY minusb "&#x229F;"> <!-- SQUARED MINUS -->
+<!ENTITY oast "&#x229B;"> <!-- CIRCLED ASTERISK OPERATOR -->
+<!ENTITY ocir "&#x229A;"> <!-- CIRCLED RING OPERATOR -->
+<!ENTITY odash "&#x229D;"> <!-- CIRCLED DASH -->
+<!ENTITY odot "&#x2299;"> <!-- CIRCLED DOT OPERATOR -->
+<!ENTITY ominus "&#x2296;"> <!-- CIRCLED MINUS -->
+<!ENTITY oplus "&#x2295;"> <!-- CIRCLED PLUS -->
+<!ENTITY osol "&#x2298;"> <!-- CIRCLED DIVISION SLASH -->
+<!ENTITY otimes "&#x2297;"> <!-- CIRCLED TIMES -->
+<!ENTITY plusb "&#x229E;"> <!-- SQUARED PLUS -->
+<!ENTITY plusdo "&#x2214;"> <!-- DOT PLUS -->
+<!ENTITY rthree "&#x22CC;"> <!-- RIGHT SEMIDIRECT PRODUCT -->
+<!ENTITY rtimes "&#x22CA;"> <!-- RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT -->
+<!ENTITY sdot "&#x22C5;"> <!-- DOT OPERATOR -->
+<!ENTITY sdotb "&#x22A1;"> <!-- SQUARED DOT OPERATOR -->
+<!ENTITY setmn "&#x2216;"> <!-- SET MINUS -->
+<!ENTITY sqcap "&#x2293;"> <!-- SQUARE CAP -->
+<!ENTITY sqcup "&#x2294;"> <!-- SQUARE CUP -->
+<!ENTITY ssetmn "&#x2216;"> <!-- SET MINUS -->
+<!ENTITY sstarf "&#x22C6;"> <!-- STAR OPERATOR -->
+<!ENTITY timesb "&#x22A0;"> <!-- SQUARED TIMES -->
+<!ENTITY top "&#x22A4;"> <!-- DOWN TACK -->
+<!ENTITY uplus "&#x228E;"> <!-- MULTISET UNION -->
+<!ENTITY wreath "&#x2240;"> <!-- WREATH PRODUCT -->
+<!ENTITY xcirc "&#x25CB;"> <!-- WHITE CIRCLE -->
+<!ENTITY xdtri "&#x25BD;"> <!-- WHITE DOWN-POINTING TRIANGLE -->
+<!ENTITY xutri "&#x25B3;"> <!-- WHITE UP-POINTING TRIANGLE -->
+<!ENTITY coprod "&#x2210;"> <!-- N-ARY COPRODUCT -->
+<!ENTITY prod "&#x220F;"> <!-- N-ARY PRODUCT -->
+<!ENTITY sum "&#x2211;"> <!-- N-ARY SUMMATION -->
+
+<!-- End of Added Math Symbols: Binary Operators Entities V0.3 ............ -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsc.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsc.ent
new file mode 100644
index 000000000..604ac480c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsc.ent
@@ -0,0 +1,52 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Math Symbols: Delimiters Entities V0.3 ..................... -->
+<!-- File iso-amsc.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-amsc.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-amsc.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN//XML
+-->
+
+<!ENTITY rceil "&#x2309;"> <!-- RIGHT CEILING -->
+<!ENTITY rfloor "&#x230B;"> <!-- RIGHT FLOOR -->
+<!ENTITY rpargt "&#xE291;"> <!-- -->
+<!ENTITY urcorn "&#x231D;"> <!-- TOP RIGHT CORNER -->
+<!ENTITY drcorn "&#x231F;"> <!-- BOTTOM RIGHT CORNER -->
+<!ENTITY lceil "&#x2308;"> <!-- LEFT CEILING -->
+<!ENTITY lfloor "&#x230A;"> <!-- LEFT FLOOR -->
+<!-- lpargt Unknown unicode character -->
+<!ENTITY ulcorn "&#x231C;"> <!-- TOP LEFT CORNER -->
+<!ENTITY dlcorn "&#x231E;"> <!-- BOTTOM LEFT CORNER -->
+
+<!-- End of Added Math Symbols: Delimiters Entities V0.3 .................. -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsn.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsn.ent
new file mode 100644
index 000000000..fbc1e94e1
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsn.ent
@@ -0,0 +1,101 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Math Symbols: Negated Relations Entities V0.3 .............. -->
+<!-- File iso-amsn.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-amsn.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-amsn.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN//XML
+-->
+
+<!ENTITY gnap "&#xE411;"> <!-- -->
+<!ENTITY gne "&#x2269;"> <!-- -->
+<!ENTITY gnE "&#x2269;"> <!-- -->
+<!ENTITY gnsim "&#x22E7;"> <!-- GREATER-THAN BUT NOT EQUIVALENT TO -->
+<!ENTITY gvnE "&#x2269;"> <!-- GREATER-THAN BUT NOT EQUAL TO -->
+<!ENTITY lnap "&#xE2A2;"> <!-- -->
+<!ENTITY lnE "&#x2268;"> <!-- -->
+<!ENTITY lne "&#x2268;"> <!-- -->
+<!ENTITY lnsim "&#x22E6;"> <!-- -->
+<!ENTITY lvnE "&#x2268;"> <!-- LESS-THAN BUT NOT EQUAL TO -->
+<!ENTITY nap "&#x2249;"> <!-- NOT ALMOST EQUAL TO -->
+<!ENTITY ncong "&#x2247;"> <!-- NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO -->
+<!ENTITY nequiv "&#x2262;"> <!-- NOT IDENTICAL TO -->
+<!ENTITY ngE "&#x2271;"> <!-- -->
+<!ENTITY nge "&#x2271;"> <!-- NEITHER GREATER-THAN NOR EQUAL TO -->
+<!ENTITY nges "&#x2271;"> <!-- -->
+<!ENTITY ngt "&#x226F;"> <!-- NOT GREATER-THAN -->
+<!ENTITY nle "&#x2270;"> <!-- NEITHER LESS-THAN NOR EQUAL TO -->
+<!ENTITY nlE "&#x2270;"> <!-- -->
+<!ENTITY nles "&#x2270;"> <!-- -->
+<!ENTITY nlt "&#x226E;"> <!-- NOT LESS-THAN -->
+<!ENTITY nltri "&#x22EA;"> <!-- NOT NORMAL SUBGROUP OF -->
+<!ENTITY nltrie "&#x22EC;"> <!-- NOT NORMAL SUBGROUP OF OR EQUAL TO -->
+<!ENTITY nmid "&#x2224;"> <!-- DOES NOT DIVIDE -->
+<!ENTITY npar "&#x2226;"> <!-- NOT PARALLEL TO -->
+<!ENTITY npr "&#x2280;"> <!-- DOES NOT PRECEDE -->
+<!ENTITY npre "&#x22E0;"> <!-- DOES NOT PRECEDE OR EQUAL -->
+<!ENTITY nrtri "&#x22EB;"> <!-- DOES NOT CONTAIN AS NORMAL SUBGROUP -->
+<!ENTITY nrtrie "&#x22ED;"> <!-- DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL -->
+<!ENTITY nsc "&#x2281;"> <!-- DOES NOT SUCCEED -->
+<!ENTITY nsce "&#x22E1;"> <!-- DOES NOT SUCCEED OR EQUAL -->
+<!ENTITY nsim "&#x2241;"> <!-- -->
+<!ENTITY nsime "&#x2244;"> <!-- -->
+<!ENTITY nsmid "&#xE2AA;"> <!-- -->
+<!ENTITY nspar "&#x2226;"> <!-- NOT PARALLEL TO -->
+<!ENTITY nsub "&#x2284;"> <!-- NOT A SUBSET OF -->
+<!ENTITY nsube "&#x2288;"> <!-- -->
+<!ENTITY nsubE "&#x2288;"> <!-- -->
+<!ENTITY nsup "&#x2285;"> <!-- NOT A SUPERSET OF -->
+<!ENTITY nsupE "&#x2289;"> <!-- -->
+<!ENTITY nsupe "&#x2289;"> <!-- -->
+<!ENTITY nvdash "&#x22AC;"> <!-- DOES NOT PROVE -->
+<!ENTITY nvDash "&#x22AD;"> <!-- NOT TRUE -->
+<!ENTITY nVDash "&#x22AF;"> <!-- NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE -->
+<!ENTITY nVdash "&#x22AE;"> <!-- DOES NOT FORCE -->
+<!ENTITY prnap "&#x22E8;"> <!-- -->
+<!ENTITY prnE "&#xE2B3;"> <!-- -->
+<!ENTITY prnsim "&#x22E8;"> <!-- -->
+<!ENTITY scnap "&#x22E9;"> <!-- -->
+<!ENTITY scnE "&#xE2B5;"> <!-- -->
+<!ENTITY scnsim "&#x22E9;"> <!-- -->
+<!ENTITY subne "&#x228A;"> <!-- -->
+<!ENTITY subnE "&#x228A;"> <!-- SUBSET OF WITH NOT EQUAL TO -->
+<!ENTITY supne "&#x228B;"> <!-- -->
+<!ENTITY supnE "&#x228B;"> <!-- -->
+<!ENTITY vsubnE "&#xE2B8;"> <!-- -->
+<!ENTITY vsubne "&#x228A;"> <!-- SUBSET OF WITH NOT EQUAL TO -->
+<!ENTITY vsupne "&#x228B;"> <!-- SUPERSET OF WITH NOT EQUAL TO -->
+<!ENTITY vsupnE "&#x228B;"> <!-- SUPERSET OF WITH NOT EQUAL TO -->
+
+<!-- End of ISO Added Math Symbols: Negated Relations Entities V0.3 ....... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amso.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amso.ent
new file mode 100644
index 000000000..6dc68108f
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amso.ent
@@ -0,0 +1,68 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Math Symbols: Ordinary Entities V0.3 ....................... -->
+<!-- File iso-amso.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-amso.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-amso.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN//XML
+-->
+
+<!-- iso-amso.ent (initially distributed with DocBook XML DTD V4.1.1beta1) -->
+
+<!-- Derived from the corresponding ISO 8879 standard entity set
+ and the Unicode character mappings provided by Sebastian Rahtz
+ With additional derivations from
+ ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT -->
+
+<!ENTITY ang "&#x2220;"> <!-- ANGLE -->
+<!ENTITY angmsd "&#x2221;"> <!-- MEASURED ANGLE -->
+<!ENTITY beth "&#x2136;"> <!-- BET SYMBOL -->
+<!ENTITY bprime "&#x2035;"> <!-- REVERSED PRIME -->
+<!ENTITY comp "&#x2201;"> <!-- COMPLEMENT -->
+<!ENTITY daleth "&#x2138;"> <!-- DALET SYMBOL -->
+<!ENTITY ell "&#x2113;"> <!-- SCRIPT SMALL L -->
+<!ENTITY empty "&#x2205;"> <!-- -->
+<!ENTITY gimel "&#x2137;"> <!-- GIMEL SYMBOL -->
+<!ENTITY image "&#x2111;"> <!-- BLACK-LETTER CAPITAL I -->
+<!ENTITY inodot "&#x0131;"> <!-- LATIN SMALL LETTER DOTLESS I -->
+<!-- jnodot Unknown unicode character -->
+<!ENTITY nexist "&#x2204;"> <!-- THERE DOES NOT EXIST -->
+<!ENTITY oS "&#x24C8;"> <!-- CIRCLED LATIN CAPITAL LETTER S -->
+<!ENTITY planck "&#x210F;"> <!-- PLANCK CONSTANT OVER TWO PI -->
+<!ENTITY real "&#x211C;"> <!-- BLACK-LETTER CAPITAL R -->
+<!ENTITY sbsol "&#xFE68;"> <!-- SMALL REVERSE SOLIDUS -->
+<!ENTITY vprime "&#x2032;"> <!-- PRIME -->
+<!ENTITY weierp "&#x2118;"> <!-- SCRIPT CAPITAL P -->
+
+<!-- End of ISO Added Math Symbols: Ordinary Entities V0.3 ................ -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsr.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsr.ent
new file mode 100644
index 000000000..9c370b3ad
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsr.ent
@@ -0,0 +1,126 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Math Symbols: Relations Entities V0.3 ...................... -->
+<!-- File iso-amsr.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-amsr.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-amsr.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN//XML
+-->
+
+<!ENTITY ape "&#x224A;"> <!-- -->
+<!ENTITY asymp "&#x224D;"> <!-- EQUIVALENT TO -->
+<!ENTITY bcong "&#x224C;"> <!-- ALL EQUAL TO -->
+<!ENTITY bepsi "&#x220D;"> <!-- SMALL CONTAINS AS MEMBER -->
+<!ENTITY bowtie "&#x22C8;"> <!-- -->
+<!ENTITY bsim "&#x223D;"> <!-- -->
+<!ENTITY bsime "&#x22CD;"> <!-- -->
+<!ENTITY bump "&#x224E;"> <!-- -->
+<!ENTITY bumpe "&#x224F;"> <!-- -->
+<!ENTITY cire "&#x2257;"> <!-- -->
+<!ENTITY colone "&#x2254;"> <!-- -->
+<!ENTITY cuepr "&#x22DE;"> <!-- -->
+<!ENTITY cuesc "&#x22DF;"> <!-- -->
+<!ENTITY cupre "&#x227C;"> <!-- -->
+<!ENTITY dashv "&#x22A3;"> <!-- -->
+<!ENTITY ecir "&#x2256;"> <!-- -->
+<!ENTITY ecolon "&#x2255;"> <!-- -->
+<!ENTITY eDot "&#x2251;"> <!-- -->
+<!ENTITY esdot "&#x2250;"> <!-- -->
+<!ENTITY efDot "&#x2252;"> <!-- -->
+<!ENTITY egs "&#x22DD;"> <!-- -->
+<!ENTITY els "&#x22DC;"> <!-- -->
+<!ENTITY erDot "&#x2253;"> <!-- -->
+<!ENTITY fork "&#x22D4;"> <!-- -->
+<!ENTITY frown "&#x2322;"> <!-- -->
+<!ENTITY gap "&#x2273;"> <!-- GREATER-THAN OR EQUIVALENT TO -->
+<!ENTITY gsdot "&#x22D7;"> <!-- -->
+<!ENTITY gE "&#x2267;"> <!-- -->
+<!ENTITY gel "&#x22DB;"> <!-- -->
+<!ENTITY gEl "&#x22DB;"> <!-- -->
+<!ENTITY ges "&#x2265;"> <!-- GREATER-THAN OR EQUAL TO -->
+<!ENTITY Gg "&#x22D9;"> <!-- VERY MUCH GREATER-THAN -->
+<!ENTITY gl "&#x2277;"> <!-- -->
+<!ENTITY gsim "&#x2273;"> <!-- GREATER-THAN OR EQUIVALENT TO -->
+<!ENTITY Gt "&#x226B;"> <!-- MUCH GREATER-THAN -->
+<!ENTITY lap "&#x2272;"> <!-- LESS-THAN OR EQUIVALENT TO -->
+<!ENTITY ldot "&#x22D6;"> <!-- -->
+<!ENTITY lE "&#x2266;"> <!-- -->
+<!ENTITY lEg "&#x22DA;"> <!-- -->
+<!ENTITY leg "&#x22DA;"> <!-- -->
+<!ENTITY les "&#x2264;"> <!-- LESS-THAN OR EQUAL TO -->
+<!ENTITY lg "&#x2276;"> <!-- LESS-THAN OR GREATER-THAN -->
+<!ENTITY Ll "&#x22D8;"> <!-- -->
+<!ENTITY lsim "&#x2272;"> <!-- LESS-THAN OR EQUIVALENT TO -->
+<!ENTITY Lt "&#x226A;"> <!-- MUCH LESS-THAN -->
+<!ENTITY ltrie "&#x22B4;"> <!-- -->
+<!ENTITY mid "&#x2223;"> <!-- -->
+<!ENTITY models "&#x22A7;"> <!-- MODELS -->
+<!ENTITY pr "&#x227A;"> <!-- -->
+<!ENTITY prap "&#x227E;"> <!-- -->
+<!ENTITY pre "&#x227C;"> <!-- -->
+<!ENTITY prsim "&#x227E;"> <!-- -->
+<!ENTITY rtrie "&#x22B5;"> <!-- -->
+<!ENTITY samalg "&#x2210;"> <!-- -->
+<!ENTITY sc "&#x227B;"> <!-- -->
+<!ENTITY scap "&#x227F;"> <!-- -->
+<!ENTITY sccue "&#x227D;"> <!-- -->
+<!ENTITY sce "&#x227D;"> <!-- -->
+<!ENTITY scsim "&#x227F;"> <!-- -->
+<!ENTITY sfrown "&#x2322;"> <!-- FROWN -->
+<!ENTITY smid "&#xE301;"> <!-- -->
+<!ENTITY smile "&#x2323;"> <!-- -->
+<!ENTITY spar "&#x2225;"> <!-- PARALLEL TO -->
+<!ENTITY sqsub "&#x228F;"> <!-- -->
+<!ENTITY sqsube "&#x2291;"> <!-- -->
+<!ENTITY sqsup "&#x2290;"> <!-- -->
+<!ENTITY sqsupe "&#x2292;"> <!-- -->
+<!ENTITY ssmile "&#x2323;"> <!-- SMILE -->
+<!ENTITY Sub "&#x22D0;"> <!-- -->
+<!ENTITY subE "&#x2286;"> <!-- -->
+<!ENTITY Sup "&#x22D1;"> <!-- -->
+<!ENTITY supE "&#x2287;"> <!-- -->
+<!ENTITY thkap "&#x2248;"> <!-- ALMOST EQUAL TO -->
+<!ENTITY thksim "&#x223C;"> <!-- TILDE OPERATOR -->
+<!ENTITY trie "&#x225C;"> <!-- -->
+<!ENTITY twixt "&#x226C;"> <!-- BETWEEN -->
+<!ENTITY vdash "&#x22A2;"> <!-- -->
+<!ENTITY Vdash "&#x22A9;"> <!-- -->
+<!ENTITY vDash "&#x22A8;"> <!-- -->
+<!ENTITY veebar "&#x22BB;"> <!-- -->
+<!ENTITY vltri "&#x22B2;"> <!-- -->
+<!ENTITY vprop "&#x221D;"> <!-- -->
+<!ENTITY vrtri "&#x22B3;"> <!-- -->
+<!ENTITY Vvdash "&#x22AA;"> <!-- -->
+
+<!-- End of ISO Added Math Symbols: Relations Entities V0.3 ............... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-box.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-box.ent
new file mode 100644
index 000000000..904916c90
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-box.ent
@@ -0,0 +1,82 @@
+<!-- ...................................................................... -->
+<!-- ISO Box and Line Drawing Entities V0.3 ............................... -->
+<!-- File iso-box.ent ..................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-box.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-box.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Box and Line Drawing//EN//XML
+-->
+
+<!ENTITY boxh "&#x2500;"> <!-- BOX DRAWINGS LIGHT HORIZONTAL -->
+<!ENTITY boxv "&#x2502;"> <!-- BOX DRAWINGS LIGHT VERTICAL -->
+<!ENTITY boxur "&#x2514;"> <!-- BOX DRAWINGS LIGHT UP AND RIGHT -->
+<!ENTITY boxul "&#x2518;"> <!-- BOX DRAWINGS LIGHT UP AND LEFT -->
+<!ENTITY boxdl "&#x2510;"> <!-- BOX DRAWINGS LIGHT DOWN AND LEFT -->
+<!ENTITY boxdr "&#x250C;"> <!-- BOX DRAWINGS LIGHT DOWN AND RIGHT -->
+<!ENTITY boxvr "&#x251C;"> <!-- BOX DRAWINGS LIGHT VERTICAL AND RIGHT -->
+<!ENTITY boxhu "&#x2534;"> <!-- BOX DRAWINGS LIGHT UP AND HORIZONTAL -->
+<!ENTITY boxvl "&#x2524;"> <!-- BOX DRAWINGS LIGHT VERTICAL AND LEFT -->
+<!ENTITY boxhd "&#x252C;"> <!-- BOX DRAWINGS LIGHT DOWN AND HORIZONTAL -->
+<!ENTITY boxvh "&#x253C;"> <!-- BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL -->
+<!ENTITY boxvR "&#x255E;"> <!-- BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE -->
+<!ENTITY boxhU "&#x2567;"> <!-- BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE -->
+<!ENTITY boxvL "&#x2561;"> <!-- BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE -->
+<!ENTITY boxhD "&#x2564;"> <!-- BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE -->
+<!ENTITY boxvH "&#x256A;"> <!-- BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE -->
+<!ENTITY boxH "&#x2550;"> <!-- BOX DRAWINGS DOUBLE HORIZONTAL -->
+<!ENTITY boxV "&#x2551;"> <!-- BOX DRAWINGS DOUBLE VERTICAL -->
+<!ENTITY boxUR "&#x2558;"> <!-- BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE -->
+<!ENTITY boxUL "&#x255B;"> <!-- BOX DRAWINGS UP SINGLE AND LEFT DOUBLE -->
+<!ENTITY boxDL "&#x2555;"> <!-- BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE -->
+<!ENTITY boxDR "&#x2552;"> <!-- BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE -->
+<!ENTITY boxVR "&#x255F;"> <!-- BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE -->
+<!ENTITY boxHU "&#x2568;"> <!-- BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE -->
+<!ENTITY boxVL "&#x2562;"> <!-- BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE -->
+<!ENTITY boxHD "&#x2565;"> <!-- BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE -->
+<!ENTITY boxVH "&#x256B;"> <!-- BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE -->
+<!ENTITY boxVr "&#x2560;"> <!-- BOX DRAWINGS DOUBLE VERTICAL AND RIGHT -->
+<!ENTITY boxHu "&#x2569;"> <!-- BOX DRAWINGS DOUBLE UP AND HORIZONTAL -->
+<!ENTITY boxVl "&#x2563;"> <!-- BOX DRAWINGS DOUBLE VERTICAL AND LEFT -->
+<!ENTITY boxHd "&#x2566;"> <!-- BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL -->
+<!ENTITY boxVh "&#x256C;"> <!-- BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL -->
+<!ENTITY boxuR "&#x2559;"> <!-- BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE -->
+<!ENTITY boxUl "&#x255C;"> <!-- BOX DRAWINGS UP DOUBLE AND LEFT SINGLE -->
+<!ENTITY boxdL "&#x2556;"> <!-- BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE -->
+<!ENTITY boxDr "&#x2553;"> <!-- BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE -->
+<!ENTITY boxUr "&#x255A;"> <!-- BOX DRAWINGS DOUBLE UP AND RIGHT -->
+<!ENTITY boxuL "&#x255D;"> <!-- BOX DRAWINGS DOUBLE UP AND LEFT -->
+<!ENTITY boxDl "&#x2557;"> <!-- BOX DRAWINGS DOUBLE DOWN AND LEFT -->
+<!ENTITY boxdR "&#x2554;"> <!-- BOX DRAWINGS DOUBLE DOWN AND RIGHT -->
+
+<!-- End of ISO Box and Line Drawing Entities V0.3 ........................ -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr1.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr1.ent
new file mode 100644
index 000000000..6507c79cb
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr1.ent
@@ -0,0 +1,109 @@
+<!-- ...................................................................... -->
+<!-- ISO Russian Cyrillic Entities V0.3 ................................... -->
+<!-- File iso-cyr1.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-cyr1.ent,v 1.1 2008/05/27 19:26:06 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-cyr1.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Russian Cyrillic//EN//XML
+-->
+
+<!ENTITY acy "&#x0430;"> <!-- CYRILLIC SMALL LETTER A -->
+<!ENTITY Acy "&#x0410;"> <!-- CYRILLIC CAPITAL LETTER A -->
+<!ENTITY bcy "&#x0431;"> <!-- CYRILLIC SMALL LETTER BE -->
+<!ENTITY Bcy "&#x0411;"> <!-- CYRILLIC CAPITAL LETTER BE -->
+<!ENTITY vcy "&#x0432;"> <!-- CYRILLIC SMALL LETTER VE -->
+<!ENTITY Vcy "&#x0412;"> <!-- CYRILLIC CAPITAL LETTER VE -->
+<!ENTITY gcy "&#x0433;"> <!-- CYRILLIC SMALL LETTER GHE -->
+<!ENTITY Gcy "&#x0413;"> <!-- CYRILLIC CAPITAL LETTER GHE -->
+<!ENTITY dcy "&#x0434;"> <!-- CYRILLIC SMALL LETTER DE -->
+<!ENTITY Dcy "&#x0414;"> <!-- CYRILLIC CAPITAL LETTER DE -->
+<!ENTITY iecy "&#x0435;"> <!-- CYRILLIC SMALL LETTER IE -->
+<!ENTITY IEcy "&#x0415;"> <!-- CYRILLIC CAPITAL LETTER IE -->
+<!ENTITY iocy "&#x0451;"> <!-- CYRILLIC SMALL LETTER IO -->
+<!ENTITY IOcy "&#x0401;"> <!-- CYRILLIC CAPITAL LETTER IO -->
+<!ENTITY zhcy "&#x0436;"> <!-- CYRILLIC SMALL LETTER ZHE -->
+<!ENTITY ZHcy "&#x0416;"> <!-- CYRILLIC CAPITAL LETTER ZHE -->
+<!ENTITY zcy "&#x0437;"> <!-- CYRILLIC SMALL LETTER ZE -->
+<!ENTITY Zcy "&#x0417;"> <!-- CYRILLIC CAPITAL LETTER ZE -->
+<!ENTITY icy "&#x0438;"> <!-- CYRILLIC SMALL LETTER I -->
+<!ENTITY Icy "&#x0418;"> <!-- CYRILLIC CAPITAL LETTER I -->
+<!ENTITY jcy "&#x0439;"> <!-- CYRILLIC SMALL LETTER SHORT I -->
+<!ENTITY Jcy "&#x0419;"> <!-- CYRILLIC CAPITAL LETTER SHORT I -->
+<!ENTITY kcy "&#x043A;"> <!-- CYRILLIC SMALL LETTER KA -->
+<!ENTITY Kcy "&#x041A;"> <!-- CYRILLIC CAPITAL LETTER KA -->
+<!ENTITY lcy "&#x043B;"> <!-- CYRILLIC SMALL LETTER EL -->
+<!ENTITY Lcy "&#x041B;"> <!-- CYRILLIC CAPITAL LETTER EL -->
+<!ENTITY mcy "&#x043C;"> <!-- CYRILLIC SMALL LETTER EM -->
+<!ENTITY Mcy "&#x041C;"> <!-- CYRILLIC CAPITAL LETTER EM -->
+<!ENTITY ncy "&#x043D;"> <!-- CYRILLIC SMALL LETTER EN -->
+<!ENTITY Ncy "&#x041D;"> <!-- CYRILLIC CAPITAL LETTER EN -->
+<!ENTITY ocy "&#x043E;"> <!-- CYRILLIC SMALL LETTER O -->
+<!ENTITY Ocy "&#x041E;"> <!-- CYRILLIC CAPITAL LETTER O -->
+<!ENTITY pcy "&#x043F;"> <!-- CYRILLIC SMALL LETTER PE -->
+<!ENTITY Pcy "&#x041F;"> <!-- CYRILLIC CAPITAL LETTER PE -->
+<!ENTITY rcy "&#x0440;"> <!-- CYRILLIC SMALL LETTER ER -->
+<!ENTITY Rcy "&#x0420;"> <!-- CYRILLIC CAPITAL LETTER ER -->
+<!ENTITY scy "&#x0441;"> <!-- CYRILLIC SMALL LETTER ES -->
+<!ENTITY Scy "&#x0421;"> <!-- CYRILLIC CAPITAL LETTER ES -->
+<!ENTITY tcy "&#x0442;"> <!-- CYRILLIC SMALL LETTER TE -->
+<!ENTITY Tcy "&#x0422;"> <!-- CYRILLIC CAPITAL LETTER TE -->
+<!ENTITY ucy "&#x0443;"> <!-- CYRILLIC SMALL LETTER U -->
+<!ENTITY Ucy "&#x0423;"> <!-- CYRILLIC CAPITAL LETTER U -->
+<!ENTITY fcy "&#x0444;"> <!-- CYRILLIC SMALL LETTER EF -->
+<!ENTITY Fcy "&#x0424;"> <!-- CYRILLIC CAPITAL LETTER EF -->
+<!ENTITY khcy "&#x0445;"> <!-- CYRILLIC SMALL LETTER HA -->
+<!ENTITY KHcy "&#x0425;"> <!-- CYRILLIC CAPITAL LETTER HA -->
+<!ENTITY tscy "&#x0446;"> <!-- CYRILLIC SMALL LETTER TSE -->
+<!ENTITY TScy "&#x0426;"> <!-- CYRILLIC CAPITAL LETTER TSE -->
+<!ENTITY chcy "&#x0447;"> <!-- CYRILLIC SMALL LETTER CHE -->
+<!ENTITY CHcy "&#x0427;"> <!-- CYRILLIC CAPITAL LETTER CHE -->
+<!ENTITY shcy "&#x0448;"> <!-- CYRILLIC SMALL LETTER SHA -->
+<!ENTITY SHcy "&#x0428;"> <!-- CYRILLIC CAPITAL LETTER SHA -->
+<!ENTITY shchcy "&#x0449;"> <!-- CYRILLIC SMALL LETTER SHCHA -->
+<!ENTITY SHCHcy "&#x0429;"> <!-- CYRILLIC CAPITAL LETTER SHCHA -->
+<!ENTITY hardcy "&#x044A;"> <!-- CYRILLIC SMALL LETTER HARD SIGN -->
+<!ENTITY HARDcy "&#x042A;"> <!-- CYRILLIC CAPITAL LETTER HARD SIGN -->
+<!ENTITY ycy "&#x044B;"> <!-- CYRILLIC SMALL LETTER YERU -->
+<!ENTITY Ycy "&#x042B;"> <!-- CYRILLIC CAPITAL LETTER YERU -->
+<!ENTITY softcy "&#x044C;"> <!-- CYRILLIC SMALL LETTER SOFT SIGN -->
+<!ENTITY SOFTcy "&#x042C;"> <!-- CYRILLIC CAPITAL LETTER SOFT SIGN -->
+<!ENTITY ecy "&#x044D;"> <!-- CYRILLIC SMALL LETTER E -->
+<!ENTITY Ecy "&#x042D;"> <!-- CYRILLIC CAPITAL LETTER E -->
+<!ENTITY yucy "&#x044E;"> <!-- CYRILLIC SMALL LETTER YU -->
+<!ENTITY YUcy "&#x042E;"> <!-- CYRILLIC CAPITAL LETTER YU -->
+<!ENTITY yacy "&#x044F;"> <!-- CYRILLIC SMALL LETTER YA -->
+<!ENTITY YAcy "&#x042F;"> <!-- CYRILLIC CAPITAL LETTER YA -->
+<!ENTITY numero "&#x2116;"> <!-- NUMERO SIGN -->
+
+<!-- End of ISO Russian Cyrillic Entities V0.3 ............................ -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr2.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr2.ent
new file mode 100644
index 000000000..50f534749
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr2.ent
@@ -0,0 +1,68 @@
+<!-- ...................................................................... -->
+<!-- ISO Non-Russian Cyrillic Entities V0.3 ............................... -->
+<!-- File iso-cyr2.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-cyr2.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-cyr2.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN//XML
+-->
+
+<!ENTITY djcy "&#x0452;"> <!-- CYRILLIC SMALL LETTER DJE -->
+<!ENTITY DJcy "&#x0402;"> <!-- CYRILLIC CAPITAL LETTER DJE -->
+<!ENTITY gjcy "&#x0453;"> <!-- CYRILLIC SMALL LETTER GJE -->
+<!ENTITY GJcy "&#x0403;"> <!-- CYRILLIC CAPITAL LETTER GJE -->
+<!ENTITY jukcy "&#x0454;"> <!-- CYRILLIC SMALL LETTER UKRAINIAN IE -->
+<!ENTITY Jukcy "&#x0404;"> <!-- CYRILLIC CAPITAL LETTER UKRAINIAN IE -->
+<!ENTITY dscy "&#x0455;"> <!-- CYRILLIC SMALL LETTER DZE -->
+<!ENTITY DScy "&#x0405;"> <!-- CYRILLIC CAPITAL LETTER DZE -->
+<!ENTITY iukcy "&#x0456;"> <!-- CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I -->
+<!ENTITY Iukcy "&#x0406;"> <!-- CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I -->
+<!ENTITY yicy "&#x0457;"> <!-- CYRILLIC SMALL LETTER YI -->
+<!ENTITY YIcy "&#x0407;"> <!-- CYRILLIC CAPITAL LETTER YI -->
+<!ENTITY jsercy "&#x0458;"> <!-- CYRILLIC SMALL LETTER JE -->
+<!ENTITY Jsercy "&#x0408;"> <!-- CYRILLIC CAPITAL LETTER JE -->
+<!ENTITY ljcy "&#x0459;"> <!-- CYRILLIC SMALL LETTER LJE -->
+<!ENTITY LJcy "&#x0409;"> <!-- CYRILLIC CAPITAL LETTER LJE -->
+<!ENTITY njcy "&#x045A;"> <!-- CYRILLIC SMALL LETTER NJE -->
+<!ENTITY NJcy "&#x040A;"> <!-- CYRILLIC CAPITAL LETTER NJE -->
+<!ENTITY tshcy "&#x045B;"> <!-- CYRILLIC SMALL LETTER TSHE -->
+<!ENTITY TSHcy "&#x040B;"> <!-- CYRILLIC CAPITAL LETTER TSHE -->
+<!ENTITY kjcy "&#x045C;"> <!-- CYRILLIC SMALL LETTER KJE -->
+<!ENTITY KJcy "&#x040C;"> <!-- CYRILLIC CAPITAL LETTER KJE -->
+<!ENTITY ubrcy "&#x045E;"> <!-- CYRILLIC SMALL LETTER SHORT U -->
+<!ENTITY Ubrcy "&#x040E;"> <!-- CYRILLIC CAPITAL LETTER SHORT U -->
+<!ENTITY dzcy "&#x045F;"> <!-- CYRILLIC SMALL LETTER DZHE -->
+<!ENTITY DZcy "&#x040F;"> <!-- CYRILLIC CAPITAL LETTER DZHE -->
+
+<!-- End of ISO Non-Russian Cyrillic Entities V0.3 ........................ -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-dia.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-dia.ent
new file mode 100644
index 000000000..278e5d9e0
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-dia.ent
@@ -0,0 +1,56 @@
+<!-- ...................................................................... -->
+<!-- ISO Diacritical Marks Entities V0.3 .................................. -->
+<!-- File iso-dia.ent ..................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-dia.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-dia.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Diacritical Marks//EN//XML
+-->
+
+<!ENTITY acute "&#x00B4;"> <!-- ACUTE ACCENT -->
+<!ENTITY breve "&#x02D8;"> <!-- BREVE -->
+<!ENTITY caron "&#x02C7;"> <!-- CARON -->
+<!ENTITY cedil "&#x00B8;"> <!-- CEDILLA -->
+<!ENTITY circ "&#x005E;"> <!-- RING OPERATOR -->
+<!ENTITY dblac "&#x02DD;"> <!-- DOUBLE ACUTE ACCENT -->
+<!ENTITY die "&#x00A8;"> <!-- -->
+<!ENTITY dot "&#x02D9;"> <!-- DOT ABOVE -->
+<!ENTITY grave "&#x0060;"> <!-- GRAVE ACCENT -->
+<!ENTITY macr "&#x00AF;"> <!-- MACRON -->
+<!ENTITY ogon "&#x02DB;"> <!-- OGONEK -->
+<!ENTITY ring "&#x02DA;"> <!-- RING ABOVE -->
+<!ENTITY tilde "&#x02DC;"> <!-- TILDE -->
+<!ENTITY uml "&#x00A8;"> <!-- -->
+
+<!-- End of ISO Diacritical Marks Entities V0.3 ........................... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk1.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk1.ent
new file mode 100644
index 000000000..848f203d0
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk1.ent
@@ -0,0 +1,91 @@
+<!-- ...................................................................... -->
+<!-- ISO Greek Letters Entities V0.3 ...................................... -->
+<!-- File iso-grk1.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-grk1.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-grk1.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Greek Letters//EN//XML
+-->
+
+<!ENTITY agr "&#x03B1;"> <!-- -->
+<!ENTITY Agr "&#x0391;"> <!-- GREEK CAPITAL LETTER ALPHA -->
+<!ENTITY bgr "&#x03B2;"> <!-- GREEK SMALL LETTER BETA -->
+<!ENTITY Bgr "&#x0392;"> <!-- GREEK CAPITAL LETTER BETA -->
+<!ENTITY ggr "&#x03B3;"> <!-- GREEK SMALL LETTER GAMMA -->
+<!ENTITY Ggr "&#x0393;"> <!-- GREEK CAPITAL LETTER GAMMA -->
+<!ENTITY dgr "&#x03B4;"> <!-- GREEK SMALL LETTER DELTA -->
+<!ENTITY Dgr "&#x0394;"> <!-- GREEK CAPITAL LETTER DELTA -->
+<!ENTITY egr "&#x03B5;"> <!-- -->
+<!ENTITY Egr "&#x0395;"> <!-- GREEK CAPITAL LETTER EPSILON -->
+<!ENTITY zgr "&#x03B6;"> <!-- GREEK SMALL LETTER ZETA -->
+<!ENTITY Zgr "&#x0396;"> <!-- GREEK CAPITAL LETTER ZETA -->
+<!ENTITY eegr "&#x03B7;"> <!-- GREEK SMALL LETTER ETA -->
+<!ENTITY EEgr "&#x0397;"> <!-- GREEK CAPITAL LETTER ETA -->
+<!ENTITY thgr "&#x03B8;"> <!-- -->
+<!ENTITY THgr "&#x0398;"> <!-- GREEK CAPITAL LETTER THETA -->
+<!ENTITY igr "&#x03B9;"> <!-- GREEK SMALL LETTER IOTA -->
+<!ENTITY Igr "&#x0399;"> <!-- GREEK CAPITAL LETTER IOTA -->
+<!ENTITY kgr "&#x03BA;"> <!-- GREEK SMALL LETTER KAPPA -->
+<!ENTITY Kgr "&#x039A;"> <!-- GREEK CAPITAL LETTER KAPPA -->
+<!ENTITY lgr "&#x03BB;"> <!-- GREEK SMALL LETTER LAMDA -->
+<!ENTITY Lgr "&#x039B;"> <!-- GREEK CAPITAL LETTER LAMDA -->
+<!ENTITY mgr "&#x03BC;"> <!-- GREEK SMALL LETTER MU -->
+<!ENTITY Mgr "&#x039C;"> <!-- GREEK CAPITAL LETTER MU -->
+<!ENTITY ngr "&#x03BD;"> <!-- GREEK SMALL LETTER NU -->
+<!ENTITY Ngr "&#x039D;"> <!-- GREEK CAPITAL LETTER NU -->
+<!ENTITY xgr "&#x03BE;"> <!-- GREEK SMALL LETTER XI -->
+<!ENTITY Xgr "&#x039E;"> <!-- GREEK CAPITAL LETTER XI -->
+<!ENTITY ogr "&#x03BF;"> <!-- GREEK SMALL LETTER OMICRON -->
+<!ENTITY Ogr "&#x039F;"> <!-- GREEK CAPITAL LETTER OMICRON -->
+<!ENTITY pgr "&#x03C0;"> <!-- GREEK SMALL LETTER PI -->
+<!ENTITY Pgr "&#x03A0;"> <!-- GREEK CAPITAL LETTER PI -->
+<!ENTITY rgr "&#x03C1;"> <!-- GREEK SMALL LETTER RHO -->
+<!ENTITY Rgr "&#x03A1;"> <!-- GREEK CAPITAL LETTER RHO -->
+<!ENTITY sgr "&#x03C3;"> <!-- GREEK SMALL LETTER SIGMA -->
+<!ENTITY Sgr "&#x03A3;"> <!-- GREEK CAPITAL LETTER SIGMA -->
+<!ENTITY sfgr "&#x03C2;"> <!-- -->
+<!ENTITY tgr "&#x03C4;"> <!-- GREEK SMALL LETTER TAU -->
+<!ENTITY Tgr "&#x03A4;"> <!-- GREEK CAPITAL LETTER TAU -->
+<!ENTITY ugr "&#x03C5;"> <!-- GREEK SMALL LETTER UPSILON -->
+<!ENTITY Ugr "&#x03A5;"> <!-- -->
+<!ENTITY phgr "&#x03C6;"> <!-- GREEK SMALL LETTER PHI -->
+<!ENTITY PHgr "&#x03A6;"> <!-- GREEK CAPITAL LETTER PHI -->
+<!ENTITY khgr "&#x03C7;"> <!-- GREEK SMALL LETTER CHI -->
+<!ENTITY KHgr "&#x03A7;"> <!-- GREEK CAPITAL LETTER CHI -->
+<!ENTITY psgr "&#x03C8;"> <!-- GREEK SMALL LETTER PSI -->
+<!ENTITY PSgr "&#x03A8;"> <!-- GREEK CAPITAL LETTER PSI -->
+<!ENTITY ohgr "&#x03C9;"> <!-- GREEK SMALL LETTER OMEGA -->
+<!ENTITY OHgr "&#x03A9;"> <!-- GREEK CAPITAL LETTER OMEGA -->
+
+<!-- End of ISO Greek Letters V0.3 ........................................ -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk2.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk2.ent
new file mode 100644
index 000000000..a75f5b04a
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk2.ent
@@ -0,0 +1,62 @@
+<!-- ...................................................................... -->
+<!-- ISO Monotoniko Greek Entities V0.3 ................................... -->
+<!-- File iso-grk2.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-grk2.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-grk2.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Monotoniko Greek//EN//XML
+-->
+
+<!ENTITY aacgr "&#x03AC;"> <!-- GREEK SMALL LETTER ALPHA WITH TONOS -->
+<!ENTITY Aacgr "&#x0386;"> <!-- GREEK CAPITAL LETTER ALPHA WITH TONOS -->
+<!ENTITY eacgr "&#x03AD;"> <!-- GREEK SMALL LETTER EPSILON WITH TONOS -->
+<!ENTITY Eacgr "&#x0388;"> <!-- GREEK CAPITAL LETTER EPSILON WITH TONOS -->
+<!ENTITY eeacgr "&#x03AE;"> <!-- GREEK SMALL LETTER ETA WITH TONOS -->
+<!ENTITY EEacgr "&#x0389;"> <!-- GREEK CAPITAL LETTER ETA WITH TONOS -->
+<!ENTITY idigr "&#x03CA;"> <!-- GREEK SMALL LETTER IOTA WITH DIALYTIKA -->
+<!ENTITY Idigr "&#x03AA;"> <!-- GREEK CAPITAL LETTER IOTA WITH DIALYTIKA -->
+<!ENTITY iacgr "&#x03AF;"> <!-- GREEK SMALL LETTER IOTA WITH TONOS -->
+<!ENTITY Iacgr "&#x038A;"> <!-- GREEK CAPITAL LETTER IOTA WITH TONOS -->
+<!ENTITY idiagr "&#x0390;"> <!-- GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS -->
+<!ENTITY oacgr "&#x03CC;"> <!-- GREEK SMALL LETTER OMICRON WITH TONOS -->
+<!ENTITY Oacgr "&#x038C;"> <!-- GREEK CAPITAL LETTER OMICRON WITH TONOS -->
+<!ENTITY udigr "&#x03CB;"> <!-- GREEK SMALL LETTER UPSILON WITH DIALYTIKA -->
+<!ENTITY Udigr "&#x03AB;"> <!-- GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA -->
+<!ENTITY uacgr "&#x03CD;"> <!-- GREEK SMALL LETTER UPSILON WITH TONOS -->
+<!ENTITY Uacgr "&#x038E;"> <!-- GREEK CAPITAL LETTER UPSILON WITH TONOS -->
+<!ENTITY udiagr "&#x03B0;"> <!-- GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS -->
+<!ENTITY ohacgr "&#x03CE;"> <!-- GREEK SMALL LETTER OMEGA WITH TONOS -->
+<!ENTITY OHacgr "&#x038F;"> <!-- GREEK CAPITAL LETTER OMEGA WITH TONOS -->
+
+<!-- End of ISO Monotoniko Greek Entities V0.3 ............................ -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk3.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk3.ent
new file mode 100644
index 000000000..070ef252c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk3.ent
@@ -0,0 +1,85 @@
+<!-- ...................................................................... -->
+<!-- ISO Greek Symbols Entities V0.3 ...................................... -->
+<!-- File iso-grk3.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-grk3.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-grk3.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Greek Symbols//EN//XML
+-->
+
+<!ENTITY alpha "&#x03B1;"> <!-- -->
+<!ENTITY beta "&#x03B2;"> <!-- GREEK SMALL LETTER BETA -->
+<!ENTITY gamma "&#x03B3;"> <!-- GREEK SMALL LETTER GAMMA -->
+<!ENTITY Gamma "&#x0393;"> <!-- GREEK CAPITAL LETTER GAMMA -->
+<!ENTITY gammad "&#x03DC;"> <!-- GREEK LETTER DIGAMMA -->
+<!ENTITY delta "&#x03B4;"> <!-- GREEK SMALL LETTER DELTA -->
+<!ENTITY Delta "&#x0394;"> <!-- GREEK CAPITAL LETTER DELTA -->
+<!ENTITY epsi "&#x220A;"> <!-- -->
+<!ENTITY epsiv "&#x03B5;"> <!-- -->
+<!ENTITY epsis "&#x220A;"> <!-- -->
+<!ENTITY zeta "&#x03B6;"> <!-- GREEK SMALL LETTER ZETA -->
+<!ENTITY eta "&#x03B7;"> <!-- GREEK SMALL LETTER ETA -->
+<!ENTITY thetas "&#x03B8;"> <!-- -->
+<!ENTITY Theta "&#x0398;"> <!-- GREEK CAPITAL LETTER THETA -->
+<!ENTITY thetav "&#x03D1;"> <!-- -->
+<!ENTITY iota "&#x03B9;"> <!-- GREEK SMALL LETTER IOTA -->
+<!ENTITY kappa "&#x03BA;"> <!-- GREEK SMALL LETTER KAPPA -->
+<!ENTITY kappav "&#x03F0;"> <!-- GREEK KAPPA SYMBOL -->
+<!ENTITY lambda "&#x03BB;"> <!-- GREEK SMALL LETTER LAMDA -->
+<!ENTITY Lambda "&#x039B;"> <!-- GREEK CAPITAL LETTER LAMDA -->
+<!ENTITY mu "&#x03BC;"> <!-- GREEK SMALL LETTER MU -->
+<!ENTITY nu "&#x03BD;"> <!-- GREEK SMALL LETTER NU -->
+<!ENTITY xi "&#x03BE;"> <!-- GREEK SMALL LETTER XI -->
+<!ENTITY Xi "&#x039E;"> <!-- GREEK CAPITAL LETTER XI -->
+<!ENTITY pi "&#x03C0;"> <!-- GREEK SMALL LETTER PI -->
+<!ENTITY piv "&#x03D6;"> <!-- GREEK PI SYMBOL -->
+<!ENTITY Pi "&#x03A0;"> <!-- GREEK CAPITAL LETTER PI -->
+<!ENTITY rho "&#x03C1;"> <!-- GREEK SMALL LETTER RHO -->
+<!ENTITY rhov "&#x03F1;"> <!-- GREEK RHO SYMBOL -->
+<!ENTITY sigma "&#x03C3;"> <!-- GREEK SMALL LETTER SIGMA -->
+<!ENTITY Sigma "&#x03A3;"> <!-- GREEK CAPITAL LETTER SIGMA -->
+<!ENTITY sigmav "&#x03C2;"> <!-- -->
+<!ENTITY tau "&#x03C4;"> <!-- GREEK SMALL LETTER TAU -->
+<!ENTITY upsi "&#x03C5;"> <!-- GREEK SMALL LETTER UPSILON -->
+<!ENTITY Upsi "&#x03D2;"> <!-- -->
+<!ENTITY phis "&#x03C6;"> <!-- GREEK SMALL LETTER PHI -->
+<!ENTITY Phi "&#x03A6;"> <!-- GREEK CAPITAL LETTER PHI -->
+<!ENTITY phiv "&#x03D5;"> <!-- GREEK PHI SYMBOL -->
+<!ENTITY chi "&#x03C7;"> <!-- GREEK SMALL LETTER CHI -->
+<!ENTITY psi "&#x03C8;"> <!-- GREEK SMALL LETTER PSI -->
+<!ENTITY Psi "&#x03A8;"> <!-- GREEK CAPITAL LETTER PSI -->
+<!ENTITY omega "&#x03C9;"> <!-- GREEK SMALL LETTER OMEGA -->
+<!ENTITY Omega "&#x03A9;"> <!-- GREEK CAPITAL LETTER OMEGA -->
+
+<!-- End of ISO Greek Symbols Entities V0.3 ............................... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk4.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk4.ent
new file mode 100644
index 000000000..18c96eb49
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk4.ent
@@ -0,0 +1,85 @@
+<!-- ...................................................................... -->
+<!-- ISO Alternative Greek Symbols Entities V0.3 .......................... -->
+<!-- File iso-grk4.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-grk4.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-grk4.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN//XML
+-->
+
+<!ENTITY b.alpha "&#x03B1;"> <!-- -->
+<!ENTITY b.beta "&#x03B2;"> <!-- GREEK SMALL LETTER BETA -->
+<!ENTITY b.gamma "&#x03B3;"> <!-- GREEK SMALL LETTER GAMMA -->
+<!ENTITY b.Gamma "&#x0393;"> <!-- GREEK CAPITAL LETTER GAMMA -->
+<!ENTITY b.gammad "&#x03DC;"> <!-- GREEK LETTER DIGAMMA -->
+<!ENTITY b.delta "&#x03B4;"> <!-- GREEK SMALL LETTER DELTA -->
+<!ENTITY b.Delta "&#x0394;"> <!-- GREEK CAPITAL LETTER DELTA -->
+<!ENTITY b.epsi "&#x03B5;"> <!-- -->
+<!ENTITY b.epsiv "&#x03B5;"> <!-- -->
+<!ENTITY b.epsis "&#x03B5;"> <!-- -->
+<!ENTITY b.zeta "&#x03B6;"> <!-- GREEK SMALL LETTER ZETA -->
+<!ENTITY b.eta "&#x03B7;"> <!-- GREEK SMALL LETTER ETA -->
+<!ENTITY b.thetas "&#x03B8;"> <!-- -->
+<!ENTITY b.Theta "&#x0398;"> <!-- GREEK CAPITAL LETTER THETA -->
+<!ENTITY b.thetav "&#x03D1;"> <!-- -->
+<!ENTITY b.iota "&#x03B9;"> <!-- GREEK SMALL LETTER IOTA -->
+<!ENTITY b.kappa "&#x03BA;"> <!-- GREEK SMALL LETTER KAPPA -->
+<!ENTITY b.kappav "&#x03F0;"> <!-- GREEK KAPPA SYMBOL -->
+<!ENTITY b.lambda "&#x03BB;"> <!-- GREEK SMALL LETTER LAMDA -->
+<!ENTITY b.Lambda "&#x039B;"> <!-- GREEK CAPITAL LETTER LAMDA -->
+<!ENTITY b.mu "&#x03BC;"> <!-- GREEK SMALL LETTER MU -->
+<!ENTITY b.nu "&#x03BD;"> <!-- GREEK SMALL LETTER NU -->
+<!ENTITY b.xi "&#x03BE;"> <!-- GREEK SMALL LETTER XI -->
+<!ENTITY b.Xi "&#x039E;"> <!-- GREEK CAPITAL LETTER XI -->
+<!ENTITY b.pi "&#x03C0;"> <!-- GREEK SMALL LETTER PI -->
+<!ENTITY b.Pi "&#x03A0;"> <!-- GREEK CAPITAL LETTER PI -->
+<!ENTITY b.piv "&#x03D6;"> <!-- GREEK PI SYMBOL -->
+<!ENTITY b.rho "&#x03C1;"> <!-- GREEK SMALL LETTER RHO -->
+<!ENTITY b.rhov "&#x03F1;"> <!-- GREEK RHO SYMBOL -->
+<!ENTITY b.sigma "&#x03C3;"> <!-- GREEK SMALL LETTER SIGMA -->
+<!ENTITY b.Sigma "&#x03A3;"> <!-- GREEK CAPITAL LETTER SIGMA -->
+<!ENTITY b.sigmav "&#x03C2;"> <!-- -->
+<!ENTITY b.tau "&#x03C4;"> <!-- GREEK SMALL LETTER TAU -->
+<!ENTITY b.upsi "&#x03C5;"> <!-- GREEK SMALL LETTER UPSILON -->
+<!ENTITY b.Upsi "&#x03D2;"> <!-- -->
+<!ENTITY b.phis "&#x03C6;"> <!-- GREEK SMALL LETTER PHI -->
+<!ENTITY b.Phi "&#x03A6;"> <!-- GREEK CAPITAL LETTER PHI -->
+<!ENTITY b.phiv "&#x03D5;"> <!-- GREEK PHI SYMBOL -->
+<!ENTITY b.chi "&#x03C7;"> <!-- GREEK SMALL LETTER CHI -->
+<!ENTITY b.psi "&#x03C8;"> <!-- GREEK SMALL LETTER PSI -->
+<!ENTITY b.Psi "&#x03A8;"> <!-- GREEK CAPITAL LETTER PSI -->
+<!ENTITY b.omega "&#x03C9;"> <!-- GREEK SMALL LETTER OMEGA -->
+<!ENTITY b.Omega "&#x03A9;"> <!-- GREEK CAPITAL LETTER OMEGA -->
+
+<!-- End of ISO Alternative Greek Symbols Entities V0.3 ................... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat1.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat1.ent
new file mode 100644
index 000000000..9c2c24932
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat1.ent
@@ -0,0 +1,104 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Latin 1 Entities V0.3 ...................................... -->
+<!-- File iso-lat1.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-lat1.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-lat1.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Latin 1//EN//XML
+-->
+
+<!ENTITY aacute "&#x00E1;"> <!-- LATIN SMALL LETTER A WITH ACUTE -->
+<!ENTITY Aacute "&#x00C1;"> <!-- LATIN CAPITAL LETTER A WITH ACUTE -->
+<!ENTITY acirc "&#x00E2;"> <!-- LATIN SMALL LETTER A WITH CIRCUMFLEX -->
+<!ENTITY Acirc "&#x00C2;"> <!-- LATIN CAPITAL LETTER A WITH CIRCUMFLEX -->
+<!ENTITY agrave "&#x00E0;"> <!-- LATIN SMALL LETTER A WITH GRAVE -->
+<!ENTITY Agrave "&#x00C0;"> <!-- LATIN CAPITAL LETTER A WITH GRAVE -->
+<!ENTITY aring "&#x00E5;"> <!-- LATIN SMALL LETTER A WITH RING ABOVE -->
+<!ENTITY Aring "&#x00C5;"> <!-- LATIN CAPITAL LETTER A WITH RING ABOVE -->
+<!ENTITY atilde "&#x00E3;"> <!-- LATIN SMALL LETTER A WITH TILDE -->
+<!ENTITY Atilde "&#x00C3;"> <!-- LATIN CAPITAL LETTER A WITH TILDE -->
+<!ENTITY auml "&#x00E4;"> <!-- LATIN SMALL LETTER A WITH DIAERESIS -->
+<!ENTITY Auml "&#x00C4;"> <!-- LATIN CAPITAL LETTER A WITH DIAERESIS -->
+<!ENTITY aelig "&#x00E6;"> <!-- LATIN SMALL LETTER AE -->
+<!ENTITY AElig "&#x00C6;"> <!-- LATIN CAPITAL LETTER AE -->
+<!ENTITY ccedil "&#x00E7;"> <!-- LATIN SMALL LETTER C WITH CEDILLA -->
+<!ENTITY Ccedil "&#x00C7;"> <!-- LATIN CAPITAL LETTER C WITH CEDILLA -->
+<!ENTITY eth "&#x00F0;"> <!-- LATIN SMALL LETTER ETH -->
+<!ENTITY ETH "&#x00D0;"> <!-- LATIN CAPITAL LETTER ETH -->
+<!ENTITY eacute "&#x00E9;"> <!-- LATIN SMALL LETTER E WITH ACUTE -->
+<!ENTITY Eacute "&#x00C9;"> <!-- LATIN CAPITAL LETTER E WITH ACUTE -->
+<!ENTITY ecirc "&#x00EA;"> <!-- LATIN SMALL LETTER E WITH CIRCUMFLEX -->
+<!ENTITY Ecirc "&#x00CA;"> <!-- LATIN CAPITAL LETTER E WITH CIRCUMFLEX -->
+<!ENTITY egrave "&#x00E8;"> <!-- LATIN SMALL LETTER E WITH GRAVE -->
+<!ENTITY Egrave "&#x00C8;"> <!-- LATIN CAPITAL LETTER E WITH GRAVE -->
+<!ENTITY euml "&#x00EB;"> <!-- LATIN SMALL LETTER E WITH DIAERESIS -->
+<!ENTITY Euml "&#x00CB;"> <!-- LATIN CAPITAL LETTER E WITH DIAERESIS -->
+<!ENTITY iacute "&#x00ED;"> <!-- LATIN SMALL LETTER I WITH ACUTE -->
+<!ENTITY Iacute "&#x00CD;"> <!-- LATIN CAPITAL LETTER I WITH ACUTE -->
+<!ENTITY icirc "&#x00EE;"> <!-- LATIN SMALL LETTER I WITH CIRCUMFLEX -->
+<!ENTITY Icirc "&#x00CE;"> <!-- LATIN CAPITAL LETTER I WITH CIRCUMFLEX -->
+<!ENTITY igrave "&#x00EC;"> <!-- LATIN SMALL LETTER I WITH GRAVE -->
+<!ENTITY Igrave "&#x00CC;"> <!-- LATIN CAPITAL LETTER I WITH GRAVE -->
+<!ENTITY iuml "&#x00EF;"> <!-- LATIN SMALL LETTER I WITH DIAERESIS -->
+<!ENTITY Iuml "&#x00CF;"> <!-- LATIN CAPITAL LETTER I WITH DIAERESIS -->
+<!ENTITY ntilde "&#x00F1;"> <!-- LATIN SMALL LETTER N WITH TILDE -->
+<!ENTITY Ntilde "&#x00D1;"> <!-- LATIN CAPITAL LETTER N WITH TILDE -->
+<!ENTITY oacute "&#x00F3;"> <!-- LATIN SMALL LETTER O WITH ACUTE -->
+<!ENTITY Oacute "&#x00D3;"> <!-- LATIN CAPITAL LETTER O WITH ACUTE -->
+<!ENTITY ocirc "&#x00F4;"> <!-- LATIN SMALL LETTER O WITH CIRCUMFLEX -->
+<!ENTITY Ocirc "&#x00D4;"> <!-- LATIN CAPITAL LETTER O WITH CIRCUMFLEX -->
+<!ENTITY ograve "&#x00F2;"> <!-- LATIN SMALL LETTER O WITH GRAVE -->
+<!ENTITY Ograve "&#x00D2;"> <!-- LATIN CAPITAL LETTER O WITH GRAVE -->
+<!ENTITY oslash "&#x00F8;"> <!-- LATIN SMALL LETTER O WITH STROKE -->
+<!ENTITY Oslash "&#x00D8;"> <!-- LATIN CAPITAL LETTER O WITH STROKE -->
+<!ENTITY otilde "&#x00F5;"> <!-- LATIN SMALL LETTER O WITH TILDE -->
+<!ENTITY Otilde "&#x00D5;"> <!-- LATIN CAPITAL LETTER O WITH TILDE -->
+<!ENTITY ouml "&#x00F6;"> <!-- LATIN SMALL LETTER O WITH DIAERESIS -->
+<!ENTITY Ouml "&#x00D6;"> <!-- LATIN CAPITAL LETTER O WITH DIAERESIS -->
+<!ENTITY szlig "&#x00DF;"> <!-- LATIN SMALL LETTER SHARP S -->
+<!ENTITY thorn "&#x00FE;"> <!-- LATIN SMALL LETTER THORN -->
+<!ENTITY THORN "&#x00DE;"> <!-- LATIN CAPITAL LETTER THORN -->
+<!ENTITY uacute "&#x00FA;"> <!-- LATIN SMALL LETTER U WITH ACUTE -->
+<!ENTITY Uacute "&#x00DA;"> <!-- LATIN CAPITAL LETTER U WITH ACUTE -->
+<!ENTITY ucirc "&#x00FB;"> <!-- LATIN SMALL LETTER U WITH CIRCUMFLEX -->
+<!ENTITY Ucirc "&#x00DB;"> <!-- LATIN CAPITAL LETTER U WITH CIRCUMFLEX -->
+<!ENTITY ugrave "&#x00F9;"> <!-- LATIN SMALL LETTER U WITH GRAVE -->
+<!ENTITY Ugrave "&#x00D9;"> <!-- LATIN CAPITAL LETTER U WITH GRAVE -->
+<!ENTITY uuml "&#x00FC;"> <!-- LATIN SMALL LETTER U WITH DIAERESIS -->
+<!ENTITY Uuml "&#x00DC;"> <!-- LATIN CAPITAL LETTER U WITH DIAERESIS -->
+<!ENTITY yacute "&#x00FD;"> <!-- LATIN SMALL LETTER Y WITH ACUTE -->
+<!ENTITY Yacute "&#x00DD;"> <!-- LATIN CAPITAL LETTER Y WITH ACUTE -->
+<!ENTITY yuml "&#x00FF;"> <!-- LATIN SMALL LETTER Y WITH DIAERESIS -->
+
+<!-- End of ISO Added Latin 1 Entities V0.3 ............................... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat2.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat2.ent
new file mode 100644
index 000000000..2f146967c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat2.ent
@@ -0,0 +1,163 @@
+<!-- ...................................................................... -->
+<!-- ISO Added Latin 2 Entities V0.3 ...................................... -->
+<!-- File iso-lat2.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-lat2.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-lat2.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Added Latin 2//EN//XML
+-->
+
+<!ENTITY abreve "&#x0103;"> <!-- LATIN SMALL LETTER A WITH BREVE -->
+<!ENTITY Abreve "&#x0102;"> <!-- LATIN CAPITAL LETTER A WITH BREVE -->
+<!ENTITY amacr "&#x0101;"> <!-- LATIN SMALL LETTER A WITH MACRON -->
+<!ENTITY Amacr "&#x0100;"> <!-- LATIN CAPITAL LETTER A WITH MACRON -->
+<!ENTITY aogon "&#x0105;"> <!-- LATIN SMALL LETTER A WITH OGONEK -->
+<!ENTITY Aogon "&#x0104;"> <!-- LATIN CAPITAL LETTER A WITH OGONEK -->
+<!ENTITY cacute "&#x0107;"> <!-- LATIN SMALL LETTER C WITH ACUTE -->
+<!ENTITY Cacute "&#x0106;"> <!-- LATIN CAPITAL LETTER C WITH ACUTE -->
+<!ENTITY ccaron "&#x010D;"> <!-- LATIN SMALL LETTER C WITH CARON -->
+<!ENTITY Ccaron "&#x010C;"> <!-- LATIN CAPITAL LETTER C WITH CARON -->
+<!ENTITY ccirc "&#x0109;"> <!-- LATIN SMALL LETTER C WITH CIRCUMFLEX -->
+<!ENTITY Ccirc "&#x0108;"> <!-- LATIN CAPITAL LETTER C WITH CIRCUMFLEX -->
+<!ENTITY cdot "&#x010B;"> <!-- LATIN SMALL LETTER C WITH DOT ABOVE -->
+<!ENTITY Cdot "&#x010A;"> <!-- LATIN CAPITAL LETTER C WITH DOT ABOVE -->
+<!ENTITY dcaron "&#x010F;"> <!-- LATIN SMALL LETTER D WITH CARON -->
+<!ENTITY Dcaron "&#x010E;"> <!-- LATIN CAPITAL LETTER D WITH CARON -->
+<!ENTITY dstrok "&#x0111;"> <!-- LATIN SMALL LETTER D WITH STROKE -->
+<!ENTITY Dstrok "&#x0110;"> <!-- LATIN CAPITAL LETTER D WITH STROKE -->
+<!ENTITY ecaron "&#x011B;"> <!-- LATIN SMALL LETTER E WITH CARON -->
+<!ENTITY Ecaron "&#x011A;"> <!-- LATIN CAPITAL LETTER E WITH CARON -->
+<!ENTITY edot "&#x0117;"> <!-- LATIN SMALL LETTER E WITH DOT ABOVE -->
+<!ENTITY Edot "&#x0116;"> <!-- LATIN CAPITAL LETTER E WITH DOT ABOVE -->
+<!ENTITY emacr "&#x0113;"> <!-- LATIN SMALL LETTER E WITH MACRON -->
+<!ENTITY Emacr "&#x0112;"> <!-- LATIN CAPITAL LETTER E WITH MACRON -->
+<!ENTITY eogon "&#x0119;"> <!-- LATIN SMALL LETTER E WITH OGONEK -->
+<!ENTITY Eogon "&#x0118;"> <!-- LATIN CAPITAL LETTER E WITH OGONEK -->
+<!ENTITY gacute "&#x01F5;"> <!-- LATIN SMALL LETTER G WITH ACUTE -->
+<!ENTITY gbreve "&#x011F;"> <!-- LATIN SMALL LETTER G WITH BREVE -->
+<!ENTITY Gbreve "&#x011E;"> <!-- LATIN CAPITAL LETTER G WITH BREVE -->
+<!ENTITY Gcedil "&#x0122;"> <!-- LATIN CAPITAL LETTER G WITH CEDILLA -->
+<!ENTITY gcirc "&#x011D;"> <!-- LATIN SMALL LETTER G WITH CIRCUMFLEX -->
+<!ENTITY Gcirc "&#x011C;"> <!-- LATIN CAPITAL LETTER G WITH CIRCUMFLEX -->
+<!ENTITY gdot "&#x0121;"> <!-- LATIN SMALL LETTER G WITH DOT ABOVE -->
+<!ENTITY Gdot "&#x0120;"> <!-- LATIN CAPITAL LETTER G WITH DOT ABOVE -->
+<!ENTITY hcirc "&#x0125;"> <!-- LATIN SMALL LETTER H WITH CIRCUMFLEX -->
+<!ENTITY Hcirc "&#x0124;"> <!-- LATIN CAPITAL LETTER H WITH CIRCUMFLEX -->
+<!ENTITY hstrok "&#x0127;"> <!-- LATIN SMALL LETTER H WITH STROKE -->
+<!ENTITY Hstrok "&#x0126;"> <!-- LATIN CAPITAL LETTER H WITH STROKE -->
+<!ENTITY Idot "&#x0130;"> <!-- LATIN CAPITAL LETTER I WITH DOT ABOVE -->
+<!ENTITY Imacr "&#x012A;"> <!-- LATIN CAPITAL LETTER I WITH MACRON -->
+<!ENTITY imacr "&#x012B;"> <!-- LATIN SMALL LETTER I WITH MACRON -->
+<!ENTITY ijlig "&#x0133;"> <!-- LATIN SMALL LIGATURE IJ -->
+<!ENTITY IJlig "&#x0132;"> <!-- LATIN CAPITAL LIGATURE IJ -->
+<!ENTITY inodot "&#x0131;"> <!-- LATIN SMALL LETTER DOTLESS I -->
+<!ENTITY iogon "&#x012F;"> <!-- LATIN SMALL LETTER I WITH OGONEK -->
+<!ENTITY Iogon "&#x012E;"> <!-- LATIN CAPITAL LETTER I WITH OGONEK -->
+<!ENTITY itilde "&#x0129;"> <!-- LATIN SMALL LETTER I WITH TILDE -->
+<!ENTITY Itilde "&#x0128;"> <!-- LATIN CAPITAL LETTER I WITH TILDE -->
+<!ENTITY jcirc "&#x0135;"> <!-- LATIN SMALL LETTER J WITH CIRCUMFLEX -->
+<!ENTITY Jcirc "&#x0134;"> <!-- LATIN CAPITAL LETTER J WITH CIRCUMFLEX -->
+<!ENTITY kcedil "&#x0137;"> <!-- LATIN SMALL LETTER K WITH CEDILLA -->
+<!ENTITY Kcedil "&#x0136;"> <!-- LATIN CAPITAL LETTER K WITH CEDILLA -->
+<!ENTITY kgreen "&#x0138;"> <!-- LATIN SMALL LETTER KRA -->
+<!ENTITY lacute "&#x013A;"> <!-- LATIN SMALL LETTER L WITH ACUTE -->
+<!ENTITY Lacute "&#x0139;"> <!-- LATIN CAPITAL LETTER L WITH ACUTE -->
+<!ENTITY lcaron "&#x013E;"> <!-- LATIN SMALL LETTER L WITH CARON -->
+<!ENTITY Lcaron "&#x013D;"> <!-- LATIN CAPITAL LETTER L WITH CARON -->
+<!ENTITY lcedil "&#x013C;"> <!-- LATIN SMALL LETTER L WITH CEDILLA -->
+<!ENTITY Lcedil "&#x013B;"> <!-- LATIN CAPITAL LETTER L WITH CEDILLA -->
+<!ENTITY lmidot "&#x0140;"> <!-- LATIN SMALL LETTER L WITH MIDDLE DOT -->
+<!ENTITY Lmidot "&#x013F;"> <!-- LATIN CAPITAL LETTER L WITH MIDDLE DOT -->
+<!ENTITY lstrok "&#x0142;"> <!-- LATIN SMALL LETTER L WITH STROKE -->
+<!ENTITY Lstrok "&#x0141;"> <!-- LATIN CAPITAL LETTER L WITH STROKE -->
+<!ENTITY nacute "&#x0144;"> <!-- LATIN SMALL LETTER N WITH ACUTE -->
+<!ENTITY Nacute "&#x0143;"> <!-- LATIN CAPITAL LETTER N WITH ACUTE -->
+<!ENTITY eng "&#x014B;"> <!-- LATIN SMALL LETTER ENG -->
+<!ENTITY ENG "&#x014A;"> <!-- LATIN CAPITAL LETTER ENG -->
+<!ENTITY napos "&#x0149;"> <!-- LATIN SMALL LETTER N PRECEDED BY APOSTROPHE -->
+<!ENTITY ncaron "&#x0148;"> <!-- LATIN SMALL LETTER N WITH CARON -->
+<!ENTITY Ncaron "&#x0147;"> <!-- LATIN CAPITAL LETTER N WITH CARON -->
+<!ENTITY ncedil "&#x0146;"> <!-- LATIN SMALL LETTER N WITH CEDILLA -->
+<!ENTITY Ncedil "&#x0145;"> <!-- LATIN CAPITAL LETTER N WITH CEDILLA -->
+<!ENTITY odblac "&#x0151;"> <!-- LATIN SMALL LETTER O WITH DOUBLE ACUTE -->
+<!ENTITY Odblac "&#x0150;"> <!-- LATIN CAPITAL LETTER O WITH DOUBLE ACUTE -->
+<!ENTITY Omacr "&#x014C;"> <!-- LATIN CAPITAL LETTER O WITH MACRON -->
+<!ENTITY omacr "&#x014D;"> <!-- LATIN SMALL LETTER O WITH MACRON -->
+<!ENTITY oelig "&#x0153;"> <!-- LATIN SMALL LIGATURE OE -->
+<!ENTITY OElig "&#x0152;"> <!-- LATIN CAPITAL LIGATURE OE -->
+<!ENTITY racute "&#x0155;"> <!-- LATIN SMALL LETTER R WITH ACUTE -->
+<!ENTITY Racute "&#x0154;"> <!-- LATIN CAPITAL LETTER R WITH ACUTE -->
+<!ENTITY rcaron "&#x0159;"> <!-- LATIN SMALL LETTER R WITH CARON -->
+<!ENTITY Rcaron "&#x0158;"> <!-- LATIN CAPITAL LETTER R WITH CARON -->
+<!ENTITY rcedil "&#x0157;"> <!-- LATIN SMALL LETTER R WITH CEDILLA -->
+<!ENTITY Rcedil "&#x0156;"> <!-- LATIN CAPITAL LETTER R WITH CEDILLA -->
+<!ENTITY sacute "&#x015B;"> <!-- LATIN SMALL LETTER S WITH ACUTE -->
+<!ENTITY Sacute "&#x015A;"> <!-- LATIN CAPITAL LETTER S WITH ACUTE -->
+<!ENTITY scaron "&#x0161;"> <!-- LATIN SMALL LETTER S WITH CARON -->
+<!ENTITY Scaron "&#x0160;"> <!-- LATIN CAPITAL LETTER S WITH CARON -->
+<!ENTITY scedil "&#x015F;"> <!-- LATIN SMALL LETTER S WITH CEDILLA -->
+<!ENTITY Scedil "&#x015E;"> <!-- LATIN CAPITAL LETTER S WITH CEDILLA -->
+<!ENTITY scirc "&#x015D;"> <!-- LATIN SMALL LETTER S WITH CIRCUMFLEX -->
+<!ENTITY Scirc "&#x015C;"> <!-- LATIN CAPITAL LETTER S WITH CIRCUMFLEX -->
+<!ENTITY tcaron "&#x0165;"> <!-- LATIN SMALL LETTER T WITH CARON -->
+<!ENTITY Tcaron "&#x0164;"> <!-- LATIN CAPITAL LETTER T WITH CARON -->
+<!ENTITY tcedil "&#x0163;"> <!-- LATIN SMALL LETTER T WITH CEDILLA -->
+<!ENTITY Tcedil "&#x0162;"> <!-- LATIN CAPITAL LETTER T WITH CEDILLA -->
+<!ENTITY tstrok "&#x0167;"> <!-- LATIN SMALL LETTER T WITH STROKE -->
+<!ENTITY Tstrok "&#x0166;"> <!-- LATIN CAPITAL LETTER T WITH STROKE -->
+<!ENTITY ubreve "&#x016D;"> <!-- LATIN SMALL LETTER U WITH BREVE -->
+<!ENTITY Ubreve "&#x016C;"> <!-- LATIN CAPITAL LETTER U WITH BREVE -->
+<!ENTITY udblac "&#x0171;"> <!-- LATIN SMALL LETTER U WITH DOUBLE ACUTE -->
+<!ENTITY Udblac "&#x0170;"> <!-- LATIN CAPITAL LETTER U WITH DOUBLE ACUTE -->
+<!ENTITY umacr "&#x016B;"> <!-- LATIN SMALL LETTER U WITH MACRON -->
+<!ENTITY Umacr "&#x016A;"> <!-- LATIN CAPITAL LETTER U WITH MACRON -->
+<!ENTITY uogon "&#x0173;"> <!-- LATIN SMALL LETTER U WITH OGONEK -->
+<!ENTITY Uogon "&#x0172;"> <!-- LATIN CAPITAL LETTER U WITH OGONEK -->
+<!ENTITY uring "&#x016F;"> <!-- LATIN SMALL LETTER U WITH RING ABOVE -->
+<!ENTITY Uring "&#x016E;"> <!-- LATIN CAPITAL LETTER U WITH RING ABOVE -->
+<!ENTITY utilde "&#x0169;"> <!-- LATIN SMALL LETTER U WITH TILDE -->
+<!ENTITY Utilde "&#x0168;"> <!-- LATIN CAPITAL LETTER U WITH TILDE -->
+<!ENTITY wcirc "&#x0175;"> <!-- LATIN SMALL LETTER W WITH CIRCUMFLEX -->
+<!ENTITY Wcirc "&#x0174;"> <!-- LATIN CAPITAL LETTER W WITH CIRCUMFLEX -->
+<!ENTITY ycirc "&#x0177;"> <!-- LATIN SMALL LETTER Y WITH CIRCUMFLEX -->
+<!ENTITY Ycirc "&#x0176;"> <!-- LATIN CAPITAL LETTER Y WITH CIRCUMFLEX -->
+<!ENTITY Yuml "&#x0178;"> <!-- LATIN CAPITAL LETTER Y WITH DIAERESIS -->
+<!ENTITY zacute "&#x017A;"> <!-- LATIN SMALL LETTER Z WITH ACUTE -->
+<!ENTITY Zacute "&#x0179;"> <!-- LATIN CAPITAL LETTER Z WITH ACUTE -->
+<!ENTITY zcaron "&#x017E;"> <!-- LATIN SMALL LETTER Z WITH CARON -->
+<!ENTITY Zcaron "&#x017D;"> <!-- LATIN CAPITAL LETTER Z WITH CARON -->
+<!ENTITY zdot "&#x017C;"> <!-- LATIN SMALL LETTER Z WITH DOT ABOVE -->
+<!ENTITY Zdot "&#x017B;"> <!-- LATIN CAPITAL LETTER Z WITH DOT ABOVE -->
+
+<!-- End of ISO Added Latin 2 Entities V0.3 ............................... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-num.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-num.ent
new file mode 100644
index 000000000..b3c434e30
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-num.ent
@@ -0,0 +1,118 @@
+<!-- ...................................................................... -->
+<!-- ISO Numeric and Special Graphic Entities V0.3 ........................ -->
+<!-- File iso-num.ent ..................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-num.ent,v 1.1 2008/05/27 19:26:07 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-num.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML
+-->
+
+<!ENTITY half "&#x00BD;"> <!-- VULGAR FRACTION ONE HALF -->
+<!ENTITY frac12 "&#x00BD;"> <!-- VULGAR FRACTION ONE HALF -->
+<!ENTITY frac14 "&#x00BC;"> <!-- VULGAR FRACTION ONE QUARTER -->
+<!ENTITY frac34 "&#x00BE;"> <!-- VULGAR FRACTION THREE QUARTERS -->
+<!ENTITY frac18 "&#x215B;"> <!-- -->
+<!ENTITY frac38 "&#x215C;"> <!-- -->
+<!ENTITY frac58 "&#x215D;"> <!-- -->
+<!ENTITY frac78 "&#x215E;"> <!-- -->
+<!ENTITY sup1 "&#x00B9;"> <!-- SUPERSCRIPT ONE -->
+<!ENTITY sup2 "&#x00B2;"> <!-- SUPERSCRIPT TWO -->
+<!ENTITY sup3 "&#x00B3;"> <!-- SUPERSCRIPT THREE -->
+<!ENTITY plus "&#x002B;"> <!-- PLUS SIGN -->
+<!ENTITY plusmn "&#x00B1;"> <!-- PLUS-MINUS SIGN -->
+<!ENTITY lt "&#38;#60;"> <!-- LESS-THAN SIGN -->
+<!ENTITY equals "&#x003D;"> <!-- EQUALS SIGN -->
+<!ENTITY gt "&#x003E;"> <!-- GREATER-THAN SIGN -->
+<!ENTITY divide "&#x00F7;"> <!-- DIVISION SIGN -->
+<!ENTITY times "&#x00D7;"> <!-- MULTIPLICATION SIGN -->
+<!ENTITY curren "&#x00A4;"> <!-- CURRENCY SIGN -->
+<!ENTITY pound "&#x00A3;"> <!-- POUND SIGN -->
+<!ENTITY dollar "&#x0024;"> <!-- DOLLAR SIGN -->
+<!ENTITY cent "&#x00A2;"> <!-- CENT SIGN -->
+<!ENTITY yen "&#x00A5;"> <!-- YEN SIGN -->
+<!ENTITY num "&#x0023;"> <!-- NUMBER SIGN -->
+<!ENTITY percnt "&#x0025;"> <!-- PERCENT SIGN -->
+<!ENTITY amp "&#38;#38;"> <!-- AMPERSAND -->
+<!ENTITY ast "&#x002A;"> <!-- ASTERISK -->
+<!ENTITY commat "&#x0040;"> <!-- COMMERCIAL AT -->
+<!ENTITY lsqb "&#x005B;"> <!-- LEFT SQUARE BRACKET -->
+<!ENTITY bsol "&#x005C;"> <!-- REVERSE SOLIDUS -->
+<!ENTITY rsqb "&#x005D;"> <!-- RIGHT SQUARE BRACKET -->
+<!ENTITY lcub "&#x007B;"> <!-- LEFT CURLY BRACKET -->
+<!ENTITY horbar "&#x2015;"> <!-- HORIZONTAL BAR -->
+<!ENTITY verbar "&#x007C;"> <!-- VERTICAL LINE -->
+<!ENTITY rcub "&#x007D;"> <!-- RIGHT CURLY BRACKET -->
+<!ENTITY micro "&#x00B5;"> <!-- MICRO SIGN -->
+<!ENTITY ohm "&#x2126;"> <!-- OHM SIGN -->
+<!ENTITY deg "&#x00B0;"> <!-- DEGREE SIGN -->
+<!ENTITY ordm "&#x00BA;"> <!-- MASCULINE ORDINAL INDICATOR -->
+<!ENTITY ordf "&#x00AA;"> <!-- FEMININE ORDINAL INDICATOR -->
+<!ENTITY sect "&#x00A7;"> <!-- SECTION SIGN -->
+<!ENTITY para "&#x00B6;"> <!-- PILCROW SIGN -->
+<!ENTITY middot "&#x00B7;"> <!-- MIDDLE DOT -->
+<!ENTITY larr "&#x2190;"> <!-- LEFTWARDS ARROW -->
+<!ENTITY rarr "&#x2192;"> <!-- RIGHTWARDS ARROW -->
+<!ENTITY uarr "&#x2191;"> <!-- UPWARDS ARROW -->
+<!ENTITY darr "&#x2193;"> <!-- DOWNWARDS ARROW -->
+<!ENTITY copy "&#x00A9;"> <!-- COPYRIGHT SIGN -->
+<!ENTITY reg "&#x00AE;"> <!-- REG TRADE MARK SIGN -->
+<!ENTITY trade "&#x2122;"> <!-- TRADE MARK SIGN -->
+<!ENTITY brvbar "&#x00A6;"> <!-- BROKEN BAR -->
+<!ENTITY not "&#x00AC;"> <!-- NOT SIGN -->
+<!ENTITY sung "&#x2669;"> <!-- -->
+<!ENTITY excl "&#x0021;"> <!-- EXCLAMATION MARK -->
+<!ENTITY iexcl "&#x00A1;"> <!-- INVERTED EXCLAMATION MARK -->
+<!ENTITY quot "&#x0022;"> <!-- QUOTATION MARK -->
+<!ENTITY apos "&#x0027;"> <!-- APOSTROPHE -->
+<!ENTITY lpar "&#x0028;"> <!-- LEFT PARENTHESIS -->
+<!ENTITY rpar "&#x0029;"> <!-- RIGHT PARENTHESIS -->
+<!ENTITY comma "&#x002C;"> <!-- COMMA -->
+<!ENTITY lowbar "&#x005F;"> <!-- LOW LINE -->
+<!ENTITY hyphen "&#x002D;"> <!-- HYPHEN-MINUS -->
+<!ENTITY period "&#x002E;"> <!-- FULL STOP -->
+<!ENTITY sol "&#x002F;"> <!-- SOLIDUS -->
+<!ENTITY colon "&#x003A;"> <!-- COLON -->
+<!ENTITY semi "&#x003B;"> <!-- SEMICOLON -->
+<!ENTITY quest "&#x003F;"> <!-- QUESTION MARK -->
+<!ENTITY iquest "&#x00BF;"> <!-- INVERTED QUESTION MARK -->
+<!ENTITY laquo "&#x00AB;"> <!-- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK -->
+<!ENTITY raquo "&#x00BB;"> <!-- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -->
+<!ENTITY lsquo "&#x2018;"> <!-- -->
+<!ENTITY rsquo "&#x2019;"> <!-- RIGHT SINGLE QUOTATION MARK -->
+<!ENTITY ldquo "&#x201C;"> <!-- -->
+<!ENTITY rdquo "&#x201D;"> <!-- RIGHT DOUBLE QUOTATION MARK -->
+<!ENTITY nbsp "&#x00A0;"> <!-- NO-BREAK SPACE -->
+<!ENTITY shy "&#x00AD;"> <!-- SOFT HYPHEN -->
+
+<!-- End of ISO Numeric and Special Graphic Entities V0.3 ................. -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-pub.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-pub.ent
new file mode 100644
index 000000000..979d178a4
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-pub.ent
@@ -0,0 +1,127 @@
+<!-- ...................................................................... -->
+<!-- ISO Publishing Entities V0.3 ......................................... -->
+<!-- File iso-pub.ent ..................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-pub.ent,v 1.1 2008/05/27 19:26:08 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-pub.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES Publishing//EN//XML
+-->
+
+<!ENTITY emsp "&#x2003;"> <!-- EM SPACE -->
+<!ENTITY ensp "&#x2002;"> <!-- EN SPACE -->
+<!ENTITY emsp13 "&#x2004;"> <!-- THREE-PER-EM SPACE -->
+<!ENTITY emsp14 "&#x2005;"> <!-- FOUR-PER-EM SPACE -->
+<!ENTITY numsp "&#x2007;"> <!-- FIGURE SPACE -->
+<!ENTITY puncsp "&#x2008;"> <!-- PUNCTUATION SPACE -->
+<!ENTITY thinsp "&#x2009;"> <!-- THIN SPACE -->
+<!ENTITY hairsp "&#x200A;"> <!-- HAIR SPACE -->
+<!ENTITY mdash "&#x2014;"> <!-- EM DASH -->
+<!ENTITY ndash "&#x2013;"> <!-- EN DASH -->
+<!ENTITY dash "&#x2010;"> <!-- HYPHEN -->
+<!ENTITY blank "&#x2423;"> <!-- OPEN BOX -->
+<!ENTITY hellip "&#x2026;"> <!-- HORIZONTAL ELLIPSIS -->
+<!ENTITY nldr "&#x2025;"> <!-- TWO DOT LEADER -->
+<!ENTITY frac13 "&#x2153;"> <!-- VULGAR FRACTION ONE THIRD -->
+<!ENTITY frac23 "&#x2154;"> <!-- VULGAR FRACTION TWO THIRDS -->
+<!ENTITY frac15 "&#x2155;"> <!-- VULGAR FRACTION ONE FIFTH -->
+<!ENTITY frac25 "&#x2156;"> <!-- VULGAR FRACTION TWO FIFTHS -->
+<!ENTITY frac35 "&#x2157;"> <!-- VULGAR FRACTION THREE FIFTHS -->
+<!ENTITY frac45 "&#x2158;"> <!-- VULGAR FRACTION FOUR FIFTHS -->
+<!ENTITY frac16 "&#x2159;"> <!-- VULGAR FRACTION ONE SIXTH -->
+<!ENTITY frac56 "&#x215A;"> <!-- VULGAR FRACTION FIVE SIXTHS -->
+<!ENTITY incare "&#x2105;"> <!-- CARE OF -->
+<!ENTITY block "&#x2588;"> <!-- FULL BLOCK -->
+<!ENTITY uhblk "&#x2580;"> <!-- UPPER HALF BLOCK -->
+<!ENTITY lhblk "&#x2584;"> <!-- LOWER HALF BLOCK -->
+<!ENTITY blk14 "&#x2591;"> <!-- LIGHT SHADE -->
+<!ENTITY blk12 "&#x2592;"> <!-- MEDIUM SHADE -->
+<!ENTITY blk34 "&#x2593;"> <!-- DARK SHADE -->
+<!ENTITY marker "&#x25AE;"> <!-- BLACK VERTICAL RECTANGLE -->
+<!ENTITY cir "&#x25CB;"> <!-- WHITE CIRCLE -->
+<!ENTITY squ "&#x25A1;"> <!-- WHITE SQUARE -->
+<!ENTITY rect "&#x25AD;"> <!-- WHITE RECTANGLE -->
+<!ENTITY utri "&#x25B5;"> <!-- WHITE UP-POINTING TRIANGLE -->
+<!ENTITY dtri "&#x25BF;"> <!-- WHITE DOWN-POINTING TRIANGLE -->
+<!ENTITY star "&#x22C6;"> <!-- STAR OPERATOR -->
+<!ENTITY bull "&#x2022;"> <!-- BULLET -->
+<!ENTITY squf "&#x25AA;"> <!-- -->
+<!ENTITY utrif "&#x25B4;"> <!-- BLACK UP-POINTING TRIANGLE -->
+<!ENTITY dtrif "&#x25BE;"> <!-- BLACK DOWN-POINTING TRIANGLE -->
+<!ENTITY ltrif "&#x25C2;"> <!-- BLACK LEFT-POINTING TRIANGLE -->
+<!ENTITY rtrif "&#x25B8;"> <!-- BLACK RIGHT-POINTING TRIANGLE -->
+<!ENTITY clubs "&#x2663;"> <!-- BLACK CLUB SUIT -->
+<!ENTITY diams "&#x2666;"> <!-- BLACK DIAMOND SUIT -->
+<!ENTITY hearts "&#x2665;"> <!-- BLACK HEART SUIT -->
+<!ENTITY spades "&#x2660;"> <!-- BLACK SPADE SUIT -->
+<!ENTITY malt "&#x2720;"> <!-- MALTESE CROSS -->
+<!ENTITY dagger "&#x2020;"> <!-- DAGGER -->
+<!ENTITY Dagger "&#x2021;"> <!-- DOUBLE DAGGER -->
+<!ENTITY check "&#x2713;"> <!-- CHECK MARK -->
+<!ENTITY cross "&#x2717;"> <!-- BALLOT X -->
+<!ENTITY sharp "&#x266F;"> <!-- MUSIC SHARP SIGN -->
+<!ENTITY flat "&#x266D;"> <!-- MUSIC FLAT SIGN -->
+<!ENTITY male "&#x2642;"> <!-- MALE SIGN -->
+<!ENTITY female "&#x2640;"> <!-- -->
+<!ENTITY phone "&#x260E;"> <!-- TELEPHONE SIGN -->
+<!ENTITY telrec "&#x2315;"> <!-- TELEPHONE RECORDER -->
+<!ENTITY copysr "&#x2117;"> <!-- SOUND RECORDING COPYRIGHT -->
+<!ENTITY caret "&#x2041;"> <!-- CARET -->
+<!ENTITY lsquor "&#x201A;"> <!-- SINGLE LOW-9 QUOTATION MARK -->
+<!ENTITY ldquor "&#x201E;"> <!-- DOUBLE LOW-9 QUOTATION MARK -->
+<!ENTITY fflig "&#xFB00;"> <!-- -->
+<!ENTITY filig "&#xFB01;"> <!-- -->
+<!-- fjlig Unknown unicode character -->
+<!ENTITY ffilig "&#xFB03;"> <!-- -->
+<!ENTITY ffllig "&#xFB04;"> <!-- -->
+<!ENTITY fllig "&#xFB02;"> <!-- -->
+<!ENTITY mldr "&#x2026;"> <!-- HORIZONTAL ELLIPSIS -->
+<!ENTITY rdquor "&#x201C;"> <!-- -->
+<!ENTITY rsquor "&#x2018;"> <!-- -->
+<!ENTITY vellip "&#x22EE;"> <!-- -->
+<!ENTITY hybull "&#x2043;"> <!-- HYPHEN BULLET -->
+<!ENTITY loz "&#x25CA;"> <!-- LOZENGE -->
+<!ENTITY lozf "&#x2726;"> <!-- -->
+<!ENTITY ltri "&#x25C3;"> <!-- WHITE LEFT-POINTING TRIANGLE -->
+<!ENTITY rtri "&#x25B9;"> <!-- WHITE RIGHT-POINTING TRIANGLE -->
+<!ENTITY starf "&#x2605;"> <!-- BLACK STAR -->
+<!ENTITY natur "&#x266E;"> <!-- MUSIC NATURAL SIGN -->
+<!ENTITY rx "&#x211E;"> <!-- PRESCRIPTION TAKE -->
+<!ENTITY sext "&#x2736;"> <!-- SIX POINTED BLACK STAR -->
+<!ENTITY target "&#x2316;"> <!-- POSITION INDICATOR -->
+<!ENTITY dlcrop "&#x230D;"> <!-- BOTTOM LEFT CROP -->
+<!ENTITY drcrop "&#x230C;"> <!-- BOTTOM RIGHT CROP -->
+<!ENTITY ulcrop "&#x230F;"> <!-- TOP LEFT CROP -->
+<!ENTITY urcrop "&#x230E;"> <!-- TOP RIGHT CROP -->
+
+<!-- End of ISO Publishing Entities V0.3 .................................. -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-tech.ent b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-tech.ent
new file mode 100644
index 000000000..b0aaac49c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-tech.ent
@@ -0,0 +1,104 @@
+<!-- ...................................................................... -->
+<!-- ISO General Technical Entities V0.3 .................................. -->
+<!-- File iso-tech.ent .................................................... -->
+
+<!-- Copyright (C) 2001, 2002 Organization for the Advancement of Structured
+ Information Standards (OASIS).
+
+ $Id: iso-tech.ent,v 1.1 2008/05/27 19:26:08 jsumali Exp $
+
+ Permission to use, copy, modify and distribute this entity set
+ and its accompanying documentation for any purpose and without
+ fee is hereby granted in perpetuity, provided that the above
+ copyright notice and this paragraph appear in all copies. The
+ copyright holders make no representation about the suitability of
+ the entities for any purpose. It is provided "as is" without
+ expressed or implied warranty.
+
+ Please direct all questions, bug reports, or suggestions for
+ changes to the docbook@lists.oasis-open.org mailing list. For more
+ information, see http://www.oasis-open.org/docbook/.
+
+ Derived, in part, from:
+
+ * iso-tech.gml
+
+ Copyright (C) 1986 International Organization for Standardization
+ Permission to copy in any form is granted for use with
+ conforming SGML systems and applications as defined in
+ ISO 8879, provided this notice is included in all copies.
+
+ * http://www.tug.org/applications/jadetex/unicode.xml
+
+ * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
+
+ Please use the following formal public identifier to identify it:
+
+ ISO 8879:1986//ENTITIES General Technical//EN//XML
+-->
+
+<!ENTITY aleph "&#x2135;"> <!-- ALEF SYMBOL -->
+<!ENTITY and "&#x2227;"> <!-- -->
+<!ENTITY ang90 "&#x221F;"> <!-- RIGHT ANGLE -->
+<!ENTITY angsph "&#x2222;"> <!-- -->
+<!ENTITY ap "&#x2248;"> <!-- -->
+<!ENTITY becaus "&#x2235;"> <!-- BECAUSE -->
+<!ENTITY bottom "&#x22A5;"> <!-- -->
+<!ENTITY cap "&#x2229;"> <!-- -->
+<!ENTITY cong "&#x2245;"> <!-- -->
+<!ENTITY conint "&#x222E;"> <!-- -->
+<!ENTITY cup "&#x222A;"> <!-- -->
+<!ENTITY equiv "&#x2261;"> <!-- -->
+<!ENTITY exist "&#x2203;"> <!-- -->
+<!ENTITY forall "&#x2200;"> <!-- -->
+<!ENTITY fnof "&#x0192;"> <!-- LATIN SMALL LETTER F WITH HOOK -->
+<!ENTITY ge "&#x2265;"> <!-- GREATER-THAN OR EQUAL TO -->
+<!ENTITY iff "&#x21D4;"> <!-- LEFT RIGHT DOUBLE ARROW -->
+<!ENTITY infin "&#x221E;"> <!-- -->
+<!ENTITY int "&#x222B;"> <!-- -->
+<!ENTITY isin "&#x220A;"> <!-- -->
+<!ENTITY lang "&#x3008;"> <!-- -->
+<!ENTITY lArr "&#x21D0;"> <!-- LEFTWARDS ARROW -->
+<!ENTITY le "&#x2264;"> <!-- -->
+<!ENTITY minus "&#x2212;"> <!-- MINUS SIGN -->
+<!ENTITY mnplus "&#x2213;"> <!-- -->
+<!ENTITY nabla "&#x2207;"> <!-- NABLA -->
+<!ENTITY ne "&#x2260;"> <!-- -->
+<!ENTITY ni "&#x220D;"> <!-- -->
+<!ENTITY or "&#x2228;"> <!-- -->
+<!ENTITY par "&#x2225;"> <!-- PARALLEL TO -->
+<!ENTITY part "&#x2202;"> <!-- -->
+<!ENTITY permil "&#x2030;"> <!-- PER MILLE SIGN -->
+<!ENTITY perp "&#x22A5;"> <!-- -->
+<!ENTITY prime "&#x2032;"> <!-- PRIME -->
+<!ENTITY Prime "&#x2033;"> <!-- DOUBLE PRIME -->
+<!ENTITY prop "&#x221D;"> <!-- -->
+<!ENTITY radic "&#x221A;"> <!-- -->
+<!ENTITY rang "&#x3009;"> <!-- -->
+<!ENTITY rArr "&#x21D2;"> <!-- RIGHTWARDS ARROW -->
+<!ENTITY sim "&#x223C;"> <!-- -->
+<!ENTITY sime "&#x2243;"> <!-- -->
+<!ENTITY square "&#x25A1;"> <!-- WHITE SQUARE -->
+<!ENTITY sub "&#x2282;"> <!-- -->
+<!ENTITY sube "&#x2286;"> <!-- -->
+<!ENTITY sup "&#x2283;"> <!-- -->
+<!ENTITY supe "&#x2287;"> <!-- -->
+<!ENTITY there4 "&#x2234;"> <!-- -->
+<!ENTITY Verbar "&#x2016;"> <!-- DOUBLE VERTICAL LINE -->
+<!ENTITY angst "&#x212B;"> <!-- ANGSTROM SIGN -->
+<!ENTITY bernou "&#x212C;"> <!-- SCRIPT CAPITAL B -->
+<!ENTITY compfn "&#x2218;"> <!-- RING OPERATOR -->
+<!ENTITY Dot "&#x00A8;"> <!-- -->
+<!ENTITY DotDot "&#x20DC;"> <!-- COMBINING FOUR DOTS ABOVE -->
+<!ENTITY hamilt "&#x210B;"> <!-- SCRIPT CAPITAL H -->
+<!ENTITY lagran "&#x2112;"> <!-- SCRIPT CAPITAL L -->
+<!ENTITY lowast "&#x2217;"> <!-- ASTERISK OPERATOR -->
+<!ENTITY notin "&#x2209;"> <!-- -->
+<!ENTITY order "&#x2134;"> <!-- SCRIPT SMALL O -->
+<!ENTITY phmmat "&#x2133;"> <!-- SCRIPT CAPITAL M -->
+<!ENTITY tdot "&#x20DB;"> <!-- COMBINING THREE DOTS ABOVE -->
+<!ENTITY tprime "&#x2034;"> <!-- TRIPLE PRIME -->
+<!ENTITY wedgeq "&#x2259;"> <!-- ESTIMATES -->
+
+<!-- End of ISO General Technical Entities V0.3 ........................... -->
+<!-- ...................................................................... -->
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc-alphaindex.dtd b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc-alphaindex.dtd
new file mode 100644
index 000000000..5597d7bbe
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc-alphaindex.dtd
@@ -0,0 +1,35 @@
+<!-- gjdoc-alphabetical.dtd
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. -->
+
+<!--
+ NOTE: This is NOT a complete DTD usable for verifying XML files
+ generated by XmlDoclet. This file is currently only used to include
+ OASIS' standard entity sets.
+-->
+
+<!ENTITY % dbcent.module "INCLUDE">
+<![%dbcent.module;[
+<!ENTITY euro "&#x20AC;"> <!-- Euro sign, U+20AC -->
+<!ENTITY % dbcent PUBLIC
+"-//OASIS//ENTITIES DocBook XML Character Entities V4.1.2//EN"
+"dbcentx.mod">
+%dbcent;
+]]>
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc.dtd b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc.dtd
new file mode 100644
index 000000000..6d02bd86c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc.dtd
@@ -0,0 +1,35 @@
+<!-- gjdoc.dtd
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. -->
+
+<!--
+ NOTE: This is NOT a complete DTD usable for verifying XML files
+ generated by XmlDoclet. This file is currently only used to include
+ OASIS' standard entity sets.
+-->
+
+<!ENTITY % dbcent.module "INCLUDE">
+<![%dbcent.module;[
+<!ENTITY euro "&#x20AC;"> <!-- Euro sign, U+20AC -->
+<!ENTITY % dbcent PUBLIC
+"-//OASIS//ENTITIES DocBook XML Character Entities V4.1.2//EN"
+"dbcentx.mod">
+%dbcent;
+]]>
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/HtmlDoclet.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/HtmlDoclet.properties
new file mode 100644
index 000000000..37ffad45b
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/HtmlDoclet.properties
@@ -0,0 +1,32 @@
+# gjdochtml-vanilla.css
+# Copyright (C) 2004 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+# Defines localized strings for HtmlDoclet (US-english/fallback)
+#
+
+usagetype.class-derived-from = Classes derived from {0}
+usagetype.class-implementing = Classes implementing {0}
+usagetype.field-of-type = Fields of type {0}
+usagetype.method-with-return-type = Methods with return type {0}
+usagetype.method-with-parameter-type = Methods with parameter type {0}
+usagetype.method-with-thrown-type = Methods which throw type {0}
+usagetype.constructor-with-parameter-type = Constructors with parameter type {0}
+usagetype.constructor-with-thrown-type = Constructors which throw type {0}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdoc.js b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdoc.js
new file mode 100644
index 000000000..91f8ba2ac
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdoc.js
@@ -0,0 +1,115 @@
+/* gjdoc.js
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/**
+ * Sets a new stylesheet for a single frame.
+ */
+function setStyleSheetForFrame(title, frame_name)
+{
+ var i, num, a, main;
+ f = eval("top.frames." + frame_name);
+ for(i=0; (a = f.document.getElementsByTagName("link")[i]); i++) {
+ if(a.getAttribute("rel").indexOf("style") != -1
+ && a.getAttribute("title")) {
+ a.disabled = true;
+ a.disabled = (a.getAttribute("title") != title);
+ }
+ }
+}
+
+/**
+ * Sets a new stylesheet for a single document.
+ */
+function setStyleSheetForDocument(title)
+{
+ var i, num, a, main;
+ for(i=0; (a = top.document.getElementsByTagName("link")[i]); i++) {
+ if(a.getAttribute("rel").indexOf("style") != -1
+ && a.getAttribute("title")) {
+ a.disabled = true;
+ a.disabled = (a.getAttribute("title") != title);
+ }
+ }
+}
+
+/**
+ * Sets a new stylesheets for all frames.
+ */
+function setStyleSheet(title)
+{
+ var i, num, a, main;
+ num = top.frames.length;
+ if (num > 0) {
+ for (i=0; i<num; i++) {
+ setStyleSheetForFrame(title, top.frames[i].name);
+ }
+ }
+ else {
+ setStyleSheetForDocument(title);
+ }
+ top.selectedSheet = title;
+ return false;
+}
+
+/**
+ * Returns the title of the set of stylesheets that is active in the
+ * given frame.
+ */
+function getActiveStylesheetTitle(frame)
+{
+ for(i=0; (a = frame.document.getElementsByTagName("link")[i]); i++) {
+ if(a.getAttribute("rel").indexOf("style") != -1
+ && a.getAttribute("title")) {
+ if (!a.disabled) {
+ return a.getAttribute("title");
+ }
+ }
+ }
+ return "";
+}
+
+/**
+ * Invoked when a page in the main content frame has been loaded.
+ */
+function contentPageLoaded(title)
+{
+ if (title) {
+ top.document.title = title;
+ }
+ /** 20050204: removed since there is only one stylesheet at the time
+ if (top.frames.length > 0) {
+ setStyleSheet(getActiveStylesheetTitle(top.frames.packages), "content");
+ }
+ else if (top.selectedSheet) {
+ setStyleSheet(top.selectedSheet, "content");
+ }
+ **/
+}
+
+/**
+ * Invoked when a page in one of the two frames on the left hand has
+ * been loaded.
+ */
+function secondaryPageLoaded(frame_name)
+{
+ /** 20050204: removed since there is only one stylesheet at the time
+ setStyleSheet(getActiveStylesheetTitle(top.frames.packages), frame_name);
+ **/
+}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-color1.css b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-color1.css
new file mode 100644
index 000000000..28452fa7b
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-color1.css
@@ -0,0 +1,80 @@
+/* gjdochtml-clean-layout.css
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. */
+
+/* --- GNU Clean Style: Color Scheme #1 --- */
+
+[class~="title"],
+[class="table header"],
+[class="table sub header"],
+[class="section header"],
+[class="serialized package header"],
+[class="serialized class header"]
+{
+ background-color: #E8EAFF;
+}
+
+[class~="navbar"][class~="item"]
+{
+ border-color: #000000;
+ color: #000000;
+}
+
+[class~="navbar"][class~="item"][class~="disabled"]
+{
+ border-color: #aaaaaa;
+ color: #aaaaaa;
+}
+
+[class~="navbar"][class~="item"][class~="active"]
+{
+ color: #000000;
+ background-color: #E8EAFF;
+}
+
+[class~="navbar"][class~="item"][class~="active"]
+{
+ border-color: #222222;
+}
+
+.navbar .header a
+{
+ color: #777777;
+}
+
+a[href] {
+ color: #141EB8;
+}
+
+a[href]:visited {
+ color: #0C126E;
+}
+
+
+/* ---- source highlighting ---- */
+
+.comment { color: #777777; }
+.tag { color: #444444; }
+.keyword { color: #B36B00; }
+.header.type { color: #00248F; }
+.type { color: #0033CC; }
+.literal { color: #809FFF; }
+.variable { color: #007D48; }
+.method { color: #B32400; }
+.line-number { color: #AAAAAA; }
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-layout.css b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-layout.css
new file mode 100644
index 000000000..9d4590973
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-layout.css
@@ -0,0 +1,460 @@
+/* gjdochtml-clean-layout.css
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. */
+
+/* --- GNU Clean Style: Layout --- */
+
+body
+{
+ background: white;
+ color: black;
+}
+
+body.content
+{
+ margin-left: 1.3em;
+ margin-right: 1.3em;
+ margin-top: 0.9em;
+ margin-bottom: 1.3em;
+}
+
+div[class="class title outer"]
+{
+ margin: 0em;
+ margin-bottom: 1em;
+ border: 1px solid;
+ padding: 10pt;
+}
+
+[class="class title-package"]
+{
+ margin: 0em;
+ padding: 0em;
+}
+
+[class="class title-class"]
+{
+ margin: 0em;
+ margin-top: 0.2em;
+ padding: 0em;
+}
+
+[class="table header"],
+[class="table sub header"]
+{
+ margin: 0em;
+ padding: 0.25em;
+}
+
+[class="section header"]
+{
+ margin: 0em;
+ padding: 0.25em;
+ border: 1px solid;
+}
+
+.serialized.package.header
+{
+ margin: 0em;
+ padding: 0.25em;
+ border: 1px solid;
+ margin-bottom: 1em;
+}
+
+
+.serialized.class.header
+{
+ margin: 0em;
+ padding: 0.25em;
+ padding-left: 3.25em;
+ border: 1px solid;
+ text-indent: -3em;
+ font-weight: normal;
+ font-size: 1.2em;
+}
+
+.serialized.section.header
+{
+ font-size: 1.15em;
+}
+
+div.serialized.section
+{
+ padding-left: 1em;
+}
+
+.summary td,
+.summary .inherited
+{
+ padding: 0.25em;
+}
+
+table[border]
+{
+ border-spacing: 0em;
+ border-collapse: collapse;
+}
+
+table[border] td
+{
+ border-spacing: 0em;
+ border-collapse: collapse;
+}
+
+hr
+{
+ border-top: 1px solid;
+ border-bottom: 0px;
+ border-left: 0px;
+ border-right: 0px;
+}
+
+.class.summary .left
+{
+ width: 10%;
+}
+
+.class.summary td.left
+{
+ text-align: right;
+}
+
+.class.summary .left .synopsis
+{
+ font-size: small;
+}
+
+
+[class="package summary left"]
+{
+ width: 20%;
+}
+
+ul.inheritance
+{
+ margin-left: 1.8em;
+ padding-left: 0em;
+ marker-offset: 0em !important;
+ list-style-type: none;
+ list-style-image: none;
+}
+
+li.inheritance
+{
+ margin: 0em !important;
+ margin-top: 0.1em !important;
+ padding: 0em !important;
+ marker-offset: 0em !important;
+}
+
+ul.inheritance > li.inheritance:before
+{
+ display: marker;
+ width: 12px;
+ margin: 0em !important;
+ padding: 0em !important;
+ marker-offset: 0em !important;
+ content: url(inherit.png);
+ vertical-align: center !important;
+}
+
+[class="inheritance 0"] > li.inheritance:before
+{
+ display: none;
+}
+
+ul [class="inheritance 0"]
+{
+ margin-left: 12px !important;
+ padding-left: 0em;
+ list-style-type: none !important;
+ list-style-image: none !important;
+}
+
+.inheritance-tree
+{
+ position: relative;
+ left: -24px;
+}
+
+.synopsis.outer
+{
+ padding: 0em;
+ margin-bottom: 0.3em;
+}
+
+.synopsis.outer > *
+{
+ margin: 0em;
+ padding: 0em;
+ line-height: 1.0em;
+}
+
+div.navbar.div
+{
+ padding: 0em;
+ margin: 0em;
+ position: relative;
+ left: -0.2em;
+}
+
+.navbar.div,
+.navbar.div tr,
+.navbar.div td
+{
+ margin: 0em;
+ padding: 0em;
+ border-spacing: 0em;
+ border-collapse: collapse;
+}
+
+table.navbar.div
+{
+ width: 100%;
+}
+
+table.navbar.div td
+{
+ line-height: 1.9em;
+ text-align: top;
+}
+
+.navbar.item
+{
+ /* float: left; */
+ border: 1px solid;
+ /* width: 7.5em; */
+ text-align: center;
+ margin: 0.05em;
+ padding-top: 0.2em;
+ padding-bottom: 0.3em;
+ padding-left: 0.5em;
+ padding-right: 0.5em;
+ font-size: 0.75em;
+ margin-bottom: 0.5em;
+}
+
+.navbar.item.active
+{
+ /* font-weight: bold; */
+ border: 1px solid;
+}
+
+[class~="title"]
+{
+ border: 1px solid;
+ padding: 0.3em;
+ margin-top: 0em;
+}
+
+.table.container,
+.table.container dd
+{
+ padding: 0em;
+ margin: 0em;
+}
+
+.overview.summary
+{
+ padding: 0em;
+ margin: 0em;
+}
+
+.summary
+{
+ margin-bottom: 1.2em;
+}
+
+table.navbar.top
+{
+ margin-bottom: 1em !important;
+}
+
+.package.description
+{
+ margin-top: 0.0em;
+ margin-bottom: 1.0em;
+}
+
+.class.description
+{
+ margin-top: 1em;
+ margin-bottom: 0.8em;
+}
+
+[class="overview description top"]
+{
+ margin-top: 0.0em;
+ margin-bottom: 1.0em;
+}
+
+[class="overview description full"]
+{
+ margin-top: 1.0em;
+ margin-bottom: 0.0em;
+}
+
+.class.summary .right .list
+{
+ margin: 0em;
+ padding: 0em;
+}
+
+.class.summary .right .list .synopsis
+{
+ margin: 0em;
+ padding: 0em;
+}
+
+.classes .menu-subtitle
+{
+ padding: 0em;
+ margin-top: 0.5em;
+ margin-bottom: 0em;
+}
+
+.menu-title
+{
+ padding: 0em;
+ margin-top: 0.8em;
+ margin-bottom: 0.2em;
+}
+
+.menu-entry
+{
+ font-size: 0.8em;
+}
+
+.class.summary .right
+{
+ vertical-align: top;
+}
+
+.class.summary .right .list
+{
+ vertical-align: top;
+}
+
+.navi
+{
+ padding-top: 0.5em;
+ font-size: x-small;
+}
+
+.navbar .header
+{
+ vertical-align: top;
+}
+
+.navbar .header span
+{
+ border: none;
+ white-space: nowrap;
+ padding-top: 0.2em;
+ padding-bottom: 0.3em;
+ padding-left: 0.5em;
+}
+
+.navbar .header a
+{
+ font-weight: bold;
+ font-size: 11pt;
+}
+
+h1
+{
+ font-size: 1.5em;
+}
+
+h2
+{
+ font-size: 1.3em;
+}
+
+h3
+{
+ font-size: 1.1em;
+}
+
+.summary .right .synopsis
+{
+ padding-left: 5.25em !important;
+ text-indent: -5em !important;
+}
+
+.summary .right .description
+{
+ text-indent: 1em !important;
+ padding-top: 0.25em !important;
+ padding-bottom: 0.1em !important;
+ padding-left: 0.25em !important;
+}
+
+td.usage.summary
+{
+ vertical-align: top;
+}
+
+.index .entry .description
+{
+ padding-left: 3em;
+}
+
+.index .entry .key
+{
+ padding-left: 5.25em;
+ text-indent: -5em;
+}
+
+.dep-list .summary .description
+{
+ padding-top: 0.1em;
+ padding-left: 3em;
+}
+
+.dep-toc .header
+{
+ padding-bottom: 0em;
+ margin-bottom: 0.2em;
+}
+
+.dep-toc .list
+{
+ margin-top: 0em;
+ margin-bottom: 1.5em;
+ padding-top: 0em;
+ padding-bottom: 0em;
+ padding-left: 2em;
+}
+
+ul.tree li.node
+{
+ list-style-type: disc;
+}
+
+ul.tree ul
+{
+ margin-left: 0em;
+ padding-left: 1.8em;
+}
+
+li.level
+{
+ list-style-type: none;
+}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-vanilla.css b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-vanilla.css
new file mode 100644
index 000000000..503207b65
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-vanilla.css
@@ -0,0 +1,21 @@
+/* gjdochtml-vanilla.css
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. */
+
+/* Empty Vanilla Stylesheeet */
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/help.xhtml b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/help.xhtml
new file mode 100644
index 000000000..e1bb453b0
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/help.xhtml
@@ -0,0 +1,25 @@
+<!-- help.xhtml
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is 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 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+ -->
+
+<p>
+ Sorry, no help available.
+</p>
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/inherit.png b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/inherit.png
new file mode 100644
index 000000000..50ca4747c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/inherit.png
Binary files differ
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/xhtml11-target10.dtd b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/xhtml11-target10.dtd
new file mode 100644
index 000000000..0dd73f783
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/xhtml11-target10.dtd
@@ -0,0 +1,54 @@
+<!-- xhtml11-strict-target10.dtd
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. -->
+
+<!-- XHTML 1.1 plus Target 1.0 DTD ................................ -->
+
+<!-- File: xhtml11-target10.dtd
+
+ XHTML 1.1 DTD which loads the optional Target 1.0 Module.
+
+ This file is based on a DTD by Jacques Distler. See
+ http://golem.ph.utexas.edu/~distler/blog/files/zeldman.html
+
+ Public and System Identifiers:
+
+ PUBLIC "-//gnu.org//DTD XHTML 1.1 plus Target 1.0//EN"
+ SYSTEM "http://gnu.org/DTD/xhtml11-target10.dtd"
+
+ The corresponding DOCTYPE declaration:
+
+ <!DOCTYPE html
+ PUBLIC "-//gnu.org//DTD XHTML 1.1 plus Target 1.0//EN"
+ "http://gnu.org/DTD/xhtml11-target10.dtd">
+
+ Original idea: Dave H <dmh@dmh.org.uk>
+ http://www.dmh.org.uk/
+
+-->
+<!ENTITY % XHTML.version
+ "-//gnu.org//DTD XHTML 1.1 plus Target 1.0//EN" >
+<!ENTITY % xhtml11.mod
+ PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
+%xhtml11.mod;
+<!ENTITY % xhtml-target.mod
+ PUBLIC "-//W3C//ELEMENTS XHTML Target 1.0//EN"
+ "http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-target-1.mod" >
+%xhtml-target.mod;
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.2.txt b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.2.txt
new file mode 100644
index 000000000..0e44adf1b
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.2.txt
@@ -0,0 +1,78 @@
+Cloneable
+Comparable
+Runnable
+Boolean
+Byte
+Character
+Character.Subset
+Character.UnicodeBlock
+Class
+ClassLoader
+Compiler
+Double
+Float
+InheritableThreadLocal
+Integer
+Long
+Math
+Number
+Object
+Package
+Process
+Runtime
+RuntimePermission
+SecurityManager
+Short
+String
+StringBuffer
+System
+Thread
+ThreadGroup
+ThreadLocal
+Throwable
+Void
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+ClassCastException
+ClassNotFoundException
+CloneNotSupportedException
+Exception
+IllegalAccessException
+IllegalArgumentException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IndexOutOfBoundsException
+InstantiationException
+InterruptedException
+NegativeArraySizeException
+NoSuchFieldException
+NoSuchMethodException
+NullPointerException
+NumberFormatException
+RuntimeException
+SecurityException
+StringIndexOutOfBoundsException
+UnsupportedOperationException
+AbstractMethodError
+ClassCircularityError
+ClassFormatError
+Error
+ExceptionInInitializerError
+IllegalAccessError
+IncompatibleClassChangeError
+InstantiationError
+InternalError
+LinkageError
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchMethodError
+OutOfMemoryError
+StackOverflowError
+ThreadDeath
+UnknownError
+UnsatisfiedLinkError
+UnsupportedClassVersionError
+VerifyError
+VirtualMachineError
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.3.txt b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.3.txt
new file mode 100644
index 000000000..119423d38
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.3.txt
@@ -0,0 +1,79 @@
+Cloneable
+Comparable
+Runnable
+Boolean
+Byte
+Character
+Character.Subset
+Character.UnicodeBlock
+Class
+ClassLoader
+Compiler
+Double
+Float
+InheritableThreadLocal
+Integer
+Long
+Math
+Number
+Object
+Package
+Process
+Runtime
+RuntimePermission
+SecurityManager
+Short
+StrictMath
+String
+StringBuffer
+System
+Thread
+ThreadGroup
+ThreadLocal
+Throwable
+Void
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+ClassCastException
+ClassNotFoundException
+CloneNotSupportedException
+Exception
+IllegalAccessException
+IllegalArgumentException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IndexOutOfBoundsException
+InstantiationException
+InterruptedException
+NegativeArraySizeException
+NoSuchFieldException
+NoSuchMethodException
+NullPointerException
+NumberFormatException
+RuntimeException
+SecurityException
+StringIndexOutOfBoundsException
+UnsupportedOperationException
+AbstractMethodError
+ClassCircularityError
+ClassFormatError
+Error
+ExceptionInInitializerError
+IllegalAccessError
+IncompatibleClassChangeError
+InstantiationError
+InternalError
+LinkageError
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchMethodError
+OutOfMemoryError
+StackOverflowError
+ThreadDeath
+UnknownError
+UnsatisfiedLinkError
+UnsupportedClassVersionError
+VerifyError
+VirtualMachineError
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.4.txt b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.4.txt
new file mode 100644
index 000000000..81a442d6c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.4.txt
@@ -0,0 +1,82 @@
+CharSequence
+Cloneable
+Comparable
+Runnable
+Boolean
+Byte
+Character
+Character.Subset
+Character.UnicodeBlock
+Class
+ClassLoader
+Compiler
+Double
+Float
+InheritableThreadLocal
+Integer
+Long
+Math
+Number
+Object
+Package
+Process
+Runtime
+RuntimePermission
+SecurityManager
+Short
+StackTraceElement
+StrictMath
+String
+StringBuffer
+System
+Thread
+ThreadGroup
+ThreadLocal
+Throwable
+Void
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+ClassCastException
+ClassNotFoundException
+CloneNotSupportedException
+Exception
+IllegalAccessException
+IllegalArgumentException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IndexOutOfBoundsException
+InstantiationException
+InterruptedException
+NegativeArraySizeException
+NoSuchFieldException
+NoSuchMethodException
+NullPointerException
+NumberFormatException
+RuntimeException
+SecurityException
+StringIndexOutOfBoundsException
+UnsupportedOperationException
+AbstractMethodError
+AssertionError
+ClassCircularityError
+ClassFormatError
+Error
+ExceptionInInitializerError
+IllegalAccessError
+IncompatibleClassChangeError
+InstantiationError
+InternalError
+LinkageError
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchMethodError
+OutOfMemoryError
+StackOverflowError
+ThreadDeath
+UnknownError
+UnsatisfiedLinkError
+UnsupportedClassVersionError
+VerifyError
+VirtualMachineError
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.5.txt b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.5.txt
new file mode 100644
index 000000000..2439f2e38
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.5.txt
@@ -0,0 +1,90 @@
+Appendable
+CharSequence
+Cloneable
+Comparable
+Iterable
+Readable
+Runnable
+Thread.UncaughtExceptionHandler
+Boolean
+Byte
+Character
+Character.Subset
+Character.UnicodeBlock
+Class
+ClassLoader
+Compiler
+Double
+Enum
+Float
+InheritableThreadLocal
+Integer
+Long
+Math
+Number
+Object
+Package
+Process
+ProcessBuilder
+Runtime
+RuntimePermission
+SecurityManager
+Short
+StackTraceElement
+StrictMath
+String
+StringBuffer
+StringBuilder
+System
+Thread
+ThreadGroup
+ThreadLocal
+Throwable
+Void
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+ClassCastException
+ClassNotFoundException
+CloneNotSupportedException
+Exception
+IllegalAccessException
+IllegalArgumentException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IndexOutOfBoundsException
+InstantiationException
+InterruptedException
+NegativeArraySizeException
+NoSuchFieldException
+NoSuchMethodException
+NullPointerException
+NumberFormatException
+RuntimeException
+SecurityException
+StringIndexOutOfBoundsException
+TypeNotPresentException
+UnsupportedOperationException
+AbstractMethodError
+AssertionError
+ClassCircularityError
+ClassFormatError
+Error
+ExceptionInInitializerError
+IllegalAccessError
+IncompatibleClassChangeError
+InstantiationError
+InternalError
+LinkageError
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchMethodError
+OutOfMemoryError
+StackOverflowError
+ThreadDeath
+UnknownError
+UnsatisfiedLinkError
+UnsupportedClassVersionError
+VerifyError
+VirtualMachineError
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-classdoc.rng b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-classdoc.rng
new file mode 100644
index 000000000..085710d17
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-classdoc.rng
@@ -0,0 +1,649 @@
+<?xml version="1.0"?>
+
+<!-- gjdoc-classdoc.rng
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. -->
+
+<grammar
+ xmlns="http://relaxng.org/ns/structure/1.0"
+ xmlns:a="http://relaxng.org/ns/annotation/1.0"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml">
+
+ <include href="gjdoc-common.rng"/>
+
+ <a:documentation>
+ The Relax NG grammar for an classdoc XML document generated by
+ GNU Gjdoc.
+ </a:documentation>
+
+ <start>
+ <a:documentation>
+ The root element for a Gjdoc classdoc XML document.
+ </a:documentation>
+
+ <element name="gjdoc:classdoc">
+ <a:documentation>
+ Corresponds to a Javadoc API com.sun.javadoc.ClassDoc
+ object, the subtree of the full generated documentation
+ corresponding to a particular Java class.
+ </a:documentation>
+
+ <ref name="name-attribute"/>
+ <ref name="qualifiedtypename-attribute"/>
+
+ <optional>
+ <ref name="superclass-element"/>
+ </optional>
+
+ <zeroOrMore>
+ <ref name="implements-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="superimplements-element"/>
+ </zeroOrMore>
+
+ <ref name="ProgramElementDocBody"/>
+
+ <optional>
+ <ref name="isAbstract-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isSerializable-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isExternalizable-element"/>
+ </optional>
+
+ <optional>
+ <ref name="definesSerializableFields-element"/>
+ </optional>
+
+ <zeroOrMore>
+ <ref name="constructordoc-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="methoddoc-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="fielddoc-element"/>
+ </zeroOrMore>
+
+ </element>
+
+ </start>
+
+ <!-- The following patterns are "body" patterns for the element
+ patterns below. Their content corresponds to the abstract
+ superclasses of the classes which are represented by the "element"
+ patterns below. -->
+
+ <define name="DocBody">
+ <a:documentation>
+ Corresponds to the abstract class
+ <code>com.sun.javadoc.Doc</code>, the common base class for
+ all documentation classes.
+ </a:documentation>
+
+ <optional>
+ <ref name="isClass-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isConstructor-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isError-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isException-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isField-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isIncluded-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isInterface-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isMethod-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isOrdinaryClass-element"/>
+ </optional>
+
+ <optional>
+ <ref name="inlineTags-element"/>
+ </optional>
+
+ <optional>
+ <ref name="firstSentenceTags-element"/>
+ </optional>
+
+ <optional>
+ <ref name="tags-element"/>
+ </optional>
+
+ <optional>
+ <ref name="seeTags-element"/>
+ </optional>
+
+ </define>
+
+ <define name="ProgramElementDocBody">
+ <a:documentation>
+ Corresponds to the abstract class
+ <code>com.sun.javadoc.ProgramElementDoc</code>.
+ </a:documentation>
+
+ <!-- ... which is derived from class com.sun.javadoc.Doc -->
+ <ref name="DocBody"/>
+
+ <ref name="containingPackage-element"/>
+
+ <optional>
+ <ref name="containingClass-element"/>
+ </optional>
+
+ <ref name="access-element"/>
+
+ <optional>
+ <ref name="isFinal-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isStatic-element"/>
+ </optional>
+
+ </define>
+
+ <define name="MemberDocBody">
+ <a:documentation>
+ Corresponds to the abstract class
+ <code>com.sun.javadoc.MemberDoc</code>.
+ </a:documentation>
+
+ <!-- ... which is derived from class
+ com.sun.javadoc.ProgramElementDoc -->
+ <ref name="ProgramElementDocBody"/>
+
+ </define>
+
+ <define name="ExecutableMemberDocBody">
+ <a:documentation>
+ Corresponds to the abstract class
+ <code>com.sun.javadoc.ExecutableMemberDoc</code>.
+ </a:documentation>
+
+ <!-- ... which is derived from class
+ com.sun.javadoc.MemberDoc -->
+ <ref name="MemberDocBody"/>
+
+ <zeroOrMore>
+ <ref name="parameter-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="thrownException-element"/>
+ </zeroOrMore>
+
+ <ref name="signature-element"/>
+
+ <optional>
+ <ref name="isNative-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isSynchronized-element"/>
+ </optional>
+
+ </define>
+
+ <define name="ConstructorDocBody">
+ <a:documentation>
+ Corresponds to an object of class
+ <code>com.sun.javadoc.ConstructorDoc</code>.
+ </a:documentation>
+
+ <!-- ... which is derived from class
+ com.sun.javadoc.ExecutableMemberDoc -->
+ <ref name="ExecutableMemberDocBody"/>
+
+ </define>
+
+ <define name="MethodDocBody">
+ <a:documentation>
+ Corresponds to an object of class
+ <code>com.sun.javadoc.MethodDoc</code>.
+ </a:documentation>
+
+ <!-- ... which is derived from class
+ com.sun.javadoc.ExecutableMemberDoc -->
+ <ref name="ExecutableMemberDocBody"/>
+
+ <ref name="returns-element"/>
+ </define>
+
+ <define name="FieldDocBody">
+ <a:documentation>
+ Corresponds to an object of class
+ <code>com.sun.javadoc.FieldDoc</code>.
+ </a:documentation>
+
+ <!-- ... which is derived from class
+ com.sun.javadoc.ProgramElementDoc -->
+ <ref name="ProgramElementDocBody"/>
+
+ <optional>
+ <ref name="isTransient-element"/>
+ </optional>
+
+ <optional>
+ <ref name="isVolatile-element"/>
+ </optional>
+
+ <element name="gjdoc:type">
+ <ref name="typedef-attributes"/>
+ </element>
+
+ </define>
+
+
+ <!-- The following patterns define the elements representing
+ concrete classes in the Javadoc API. -->
+
+ <define name="constructordoc-element">
+ <a:documentation>
+ Specifies a constructor of the class.
+ </a:documentation>
+
+ <element name="gjdoc:constructordoc">
+ <ref name="name-attribute"/>
+ <ref name="ConstructorDocBody"/>
+ </element>
+ </define>
+
+ <define name="methoddoc-element">
+ <a:documentation>
+ Specifies a method of the class.
+ </a:documentation>
+
+ <element name="gjdoc:methoddoc">
+ <ref name="name-attribute"/>
+ <ref name="MethodDocBody"/>
+ </element>
+ </define>
+
+ <define name="fielddoc-element">
+ <a:documentation>
+ Specifies a field of the class.
+ </a:documentation>
+
+ <element name="gjdoc:fielddoc">
+ <ref name="name-attribute"/>
+ <ref name="FieldDocBody"/>
+ </element>
+ </define>
+
+ <!-- The following patterns represent the return value of the
+ corresponding boolean getters of various classes in
+ <code>com.sun.javadoc</code>. The presence of each tag denotes a
+ return value of <code>true</code>, absence denotes a return value
+ of <code>false</code>. -->
+
+ <define name="isAbstract-element">
+ <a:documentation>
+ Presence means <code>ClassDoc.isAbstract()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isAbstract">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isClass-element">
+ <a:documentation>
+ Presence means <code>Doc.isClass()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isClass">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isConstructor-element">
+ <a:documentation>
+ Presence means <code>Doc.isConstructor()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isConstructor">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isError-element">
+ <a:documentation>
+ Presence means <code>Doc.isError()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isError">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isException-element">
+ <a:documentation>
+ Presence means <code>Doc.isException()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isException">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isSerializable-element">
+ <a:documentation>
+ Presence means <code>ClassDoc.isSerializable()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isSerializable">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isExternalizable-element">
+ <a:documentation>
+ Presence means <code>ClassDoc.isExternalizable()</code>
+ returns <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isExternalizable">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isField-element">
+ <a:documentation>
+ Presence means <code>Doc.isField()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isField">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isIncluded-element">
+ <a:documentation>
+ Presence means <code>Doc.isIncluded()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isIncluded">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isInterface-element">
+ <a:documentation>
+ Presence means <code>Doc.isInterface()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isInterface">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isMethod-element">
+ <a:documentation>
+ Presence means <code>Doc.isMethod()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isMethod">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isOrdinaryClass-element">
+ <a:documentation>
+ Presence means <code>Doc.isOrdinaryClass()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isOrdinaryClass">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isFinal-element">
+ <a:documentation>
+ Presence means <code>ProgramElementDoc.isFinal()</code>
+ returns <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isFinal">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isStatic-element">
+ <a:documentation>
+ Presence means <code>ProgramElementDoc.isStatic()</code>
+ returns <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isStatic">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isTransient-element">
+ <a:documentation>
+ Presence means <code>FieldDoc.isTransient()</code>
+ returns <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isTransient">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isVolatile-element">
+ <a:documentation>
+ Presence means <code>FieldDoc.isVolatile()</code>
+ returns <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isVolatile">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isNative-element">
+ <a:documentation>
+ Presence means <code>ExecutableMemberDoc.isNative()</code>
+ returns <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isNative">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="isSynchronized-element">
+ <a:documentation>
+ Presence means
+ <code>ExecutableMemberDoc.isSynchronized()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:isSynchronized">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="definesSerializableFields-element">
+ <a:documentation>
+ Presence means
+ <code>ClassDoc.definesSerializableFields()</code> returns
+ <code>true</code>.
+ </a:documentation>
+
+ <element name="gjdoc:definesSerializableFields">
+ <empty/>
+ </element>
+ </define>
+
+ <define name="access-element">
+ <a:documentation>
+ Corresponds to the access modifier (public, protected,
+ private) specified by a ProgramElementDoc.
+ </a:documentation>
+
+ <element name="gjdoc:access">
+ <attribute name="scope">
+ <a:documentation>
+ This value is determined by calling
+ <code>ProgramElementDoc.isPublic()</code>,
+ <code>ProgramElementDoc.isProtected()</code>,
+ <code>ProgramElementDoc.isPrivate()</code> and
+ <code>ProgramElementDoc.isPackagePrivate()</code>.
+ </a:documentation>
+ <choice>
+ <value>public</value>
+ <value>protected</value>
+ <value>private</value>
+ <value>package</value>
+ </choice>
+ </attribute>
+ </element>
+ </define>
+
+ <define name="containingClass-element">
+ <a:documentation>
+ Corresponds to the type returned by a call to
+ <code>com.sun.javadoc.Classdoc.containingClass()</code>.
+ </a:documentation>
+
+ <element name="gjdoc:containingClass">
+ <a:documentation>
+ The full name of the outer class containing the class, if
+ this class is an inner class.
+ </a:documentation>
+ <ref name="typedef-attributes"/>
+ </element>
+ </define>
+
+ <define name="parameter-element">
+ <a:documentation>
+ Corresponds to an entry in the array returned by a
+ <code>com.sun.javadoc.ExecutableMemberDoc.parameters()</code>.
+ </a:documentation>
+
+ <element name="gjdoc:parameter">
+ <a:documentation>
+ A parameter for a method or constructor call.
+ </a:documentation>
+ <ref name="name-attribute"/>
+ <optional>
+ <ref name="typedef-attributes"/>
+ </optional>
+ </element>
+ </define>
+
+ <define name="thrownException-element">
+ <a:documentation>
+ Corresponds to an entry in the array returned by a
+ <code>com.sun.javadoc.ExecutableMemberDoc.thrownExceptions()</code>.
+ </a:documentation>
+
+ <element name="gjdoc:thrownException">
+ <a:documentation>
+ An exception thrown by a method or constructor.
+ </a:documentation>
+ <ref name="typedef-attributes"/>
+ </element>
+ </define>
+
+
+ <define name="signature-element">
+ <a:documentation>
+ Corresponds to the signature specified by a
+ <code>com.sun.javadoc.MethodDoc</code>.
+ </a:documentation>
+
+ <element name="gjdoc:signature">
+ <a:documentation>
+ The signature of a method or constructor.
+ </a:documentation>
+ <attribute name="full">
+ <a:documentation>
+ The full signature of a method or constructor, as
+ returned by
+ <code>com.sun.javadoc.ExecutableMemberDoc.signature()</code>.
+ </a:documentation>
+ <text/>
+ </attribute>
+ <attribute name="flat">
+ <a:documentation>
+ The "flat" signature of a method or constructor, as
+ returned by
+ <code>com.sun.javadoc.ExecutableMemberDoc.flatSignature()</code>.
+ </a:documentation>
+ <text/>
+ </attribute>
+ </element>
+ </define>
+
+ <define name="returns-element">
+ <a:documentation>
+ Corresponds to the type returned by
+ <code>com.sun.javadoc.MethodDoc.returnType()</code>.
+ </a:documentation>
+
+ <element name="gjdoc:returns">
+ <a:documentation>
+ The type returned by a method.
+ </a:documentation>
+
+ <ref name="typedef-attributes"/>
+ </element>
+ </define>
+</grammar>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-common.rng b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-common.rng
new file mode 100644
index 000000000..85ffc1d91
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-common.rng
@@ -0,0 +1,264 @@
+<?xml version="1.0"?>
+
+<!-- gjdoc-common.rng
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. -->
+
+<grammar
+ xmlns="http://relaxng.org/ns/structure/1.0"
+ xmlns:a="http://relaxng.org/ns/annotation/1.0"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml">
+
+ <a:documentation>
+ A Relax NG grammar with definitions of elements and attributes
+ used by both the XML index file and the XML class files
+ generated by GNU Gjdoc.
+ </a:documentation>
+
+ <define name="firstSentenceTags-element">
+ <a:documentation>
+
+ </a:documentation>
+
+ <element name="gjdoc:firstSentenceTags">
+ <ref name="tags-contents"/>
+ </element>
+ </define>
+
+ <define name="inlineTags-element">
+ <a:documentation>
+
+ </a:documentation>
+
+ <element name="gjdoc:inlineTags">
+ <ref name="tags-contents"/>
+ </element>
+ </define>
+
+ <define name="seeTags-element">
+ <a:documentation>
+
+ </a:documentation>
+
+ <element name="gjdoc:seeTags">
+ <ref name="tags-contents"/>
+ </element>
+ </define>
+
+
+ <define name="tags-element">
+ <a:documentation>
+
+ </a:documentation>
+
+ <element name="gjdoc:tags">
+ <ref name="tags-contents"/>
+ </element>
+ </define>
+
+ <define name="tags-contents">
+ <a:documentation>
+ Specifies mixed content comprised of gjdoc tags,
+ HTML tags, taglet output, and text.
+ </a:documentation>
+
+ <zeroOrMore>
+ <ref name="TagContent"/>
+ </zeroOrMore>
+ </define>
+
+ <define name="implements-element">
+ <element name="gjdoc:implements">
+ <a:documentation>
+ Specifies an interface that the class implements.
+ </a:documentation>
+
+ <ref name="typedef-attributes"/>
+ </element>
+ </define>
+
+
+ <define name="superimplements-element">
+ <element name="gjdoc:superimplements">
+ <a:documentation>
+ Specifies an interface implemented by superclasses
+ (ancestors) of the class. Together with the interfaces
+ specified with tag `implements', this lists all interfaces
+ the class can be cast to.
+ </a:documentation>
+
+ <ref name="typedef-attributes"/>
+ </element>
+ </define>
+
+ <define name="typedef-attributes">
+ <attribute name="typename">
+ <a:documentation>
+ The name of the class, without package prefix. If the
+ class is an inner class, this includes the name of its
+ outer class.
+ </a:documentation>
+
+ <text/>
+ </attribute>
+
+ <ref name="qualifiedtypename-attribute"/>
+
+ <optional>
+ <attribute name="dimension">
+ <a:documentation>
+ The dimension of this typedef, represented by a zero or
+ more repetitions of the string "[]".
+ </a:documentation>
+
+ <text/>
+ </attribute>
+ </optional>
+ </define>
+
+ <define name="name-attribute">
+ <attribute name="name">
+ <a:documentation>
+ The name of some Java Entity (package, class, constructor,
+ method, field.)
+ </a:documentation>
+
+ <text/>
+ </attribute>
+ </define>
+
+ <define name="qualifiedtypename-attribute">
+ <attribute name="qualifiedtypename">
+ <a:documentation>
+ The fully qualified name of the class.
+ </a:documentation>
+
+ <text/>
+ </attribute>
+ </define>
+
+ <define name="superclass-element">
+ <element name="gjdoc:superclass">
+ <a:documentation>
+ Specifies the superclass of the class.
+ </a:documentation>
+
+ <ref name="typedef-attributes"/>
+ </element>
+ </define>
+
+ <define name="tag-element">
+ <element name="gjdoc:tag">
+ <ref name="name-attribute"/>
+ <attribute name="kind">
+ <text/>
+ </attribute>
+ <zeroOrMore>
+ <ref name="TagContent"/>
+ </zeroOrMore>
+ </element>
+ </define>
+
+ <define name="exception-element">
+ <element name="gjdoc:exception">
+ <ref name="typedef-attributes"/>
+ </element>
+ </define>
+
+ <define name="TagContent">
+ <choice>
+ <element>
+ <anyName>
+ <except>
+ <nsName ns="gjdoc"/>
+ <name>gjdoc:tag</name>
+ </except>
+ </anyName>
+ <zeroOrMore>
+ <attribute>
+ <anyName/>
+ </attribute>
+ </zeroOrMore>
+ <zeroOrMore>
+ <choice>
+ <text/>
+ <ref name="TagContent"/>
+ </choice>
+ </zeroOrMore>
+ </element>
+ <ref name="tag-element"/>
+ <ref name="exception-element"/>
+ <ref name="tagletText-element"/>
+ <text/>
+ </choice>
+ </define>
+
+ <define name="containingPackage-element">
+ <element name="gjdoc:containingPackage">
+ <a:documentation>
+ The full name of the package containing the class.
+ </a:documentation>
+ <attribute name="name">
+ <text/>
+ </attribute>
+ </element>
+ </define>
+
+ <define name="tagletText-element">
+ <element name="gjdoc:tagletText">
+ <a:documentation>
+ A string generated by a Taglet.toString() method.
+ </a:documentation>
+ <attribute name="tagName">
+ <a:documentation>
+ The name of the tag this Taglet was assigned to.
+ </a:documentation>
+ <text/>
+ </attribute>
+ </element>
+ </define>
+
+ <define name="isError-element">
+ <element name="gjdoc:isError">
+ <a:documentation>
+ Exists when the described class is a subclass of
+ java.lang.Error.
+ </a:documentation>
+ </element>
+ </define>
+
+ <define name="isException-element">
+ <element name="gjdoc:isException">
+ <a:documentation>
+ Exists when the described class is a subclass of
+ java.lang.Exception.
+ </a:documentation>
+ </element>
+ </define>
+
+ <define name="isInterface-element">
+ <element name="gjdoc:isInterface">
+ <a:documentation>
+ Exists when the described class is an interface.
+ </a:documentation>
+ </element>
+ </define>
+
+</grammar>
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-index.rng b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-index.rng
new file mode 100644
index 000000000..b78855695
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-index.rng
@@ -0,0 +1,176 @@
+<?xml version="1.0"?>
+
+<!-- gjdoc-index.rng
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. -->
+
+<grammar
+ xmlns="http://relaxng.org/ns/structure/1.0"
+ xmlns:a="http://relaxng.org/ns/annotation/1.0"
+ xmlns:gjdoc="http://www.gnu.org/software/cp-tools/gjdocxml">
+
+ <include href="gjdoc-common.rng"/>
+
+ <a:documentation>
+ The Relax NG grammar for the XML index file generated by GNU
+ Gjdoc.
+ </a:documentation>
+
+ <start>
+ <a:documentation>
+ The root element for a Gjdoc index XML document.
+ </a:documentation>
+
+ <element name="gjdoc:rootdoc">
+ <a:documentation>
+ Corresponds to the Javadoc API RootDoc object, the root of
+ the generated documentation.
+ </a:documentation>
+
+ <zeroOrMore>
+ <ref name="specifiedclass-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="specifiedpackage-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="packagedoc-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="classdoc-element"/>
+ </zeroOrMore>
+ </element>
+ </start>
+
+ <define name="containsClass-element">
+ <element name="gjdoc:containsClass">
+ <a:documentation>
+ Corresponds to a class contained in a package or in
+ another class.
+ </a:documentation>
+
+ <ref name="qualifiedtypename-attribute"/>
+ </element>
+ </define>
+
+ <define name="specifiedclass-element">
+ <element name="gjdoc:specifiedclass">
+ <a:documentation>
+ Corresponds to a class named on the Gjdoc command
+ line. This is a class the user explicitly wants
+ documentation generated for.
+ </a:documentation>
+
+ <attribute name="name">
+ <a:documentation>
+ The name of the class as given by the user on the command
+ line. (CHECK)
+ </a:documentation>
+
+ <text/>
+ </attribute>
+ </element>
+ </define>
+
+ <define name="specifiedpackage-element">
+ <element name="gjdoc:specifiedpackage">
+ <a:documentation>
+ Corresponds to a package named on the Gjdoc command
+ line. This is a package the user explicitly wants
+ documentation generated for.
+ </a:documentation>
+
+ <attribute name="name">
+ <a:documentation>
+ The full name of the package.
+ </a:documentation>
+
+ <text/>
+ </attribute>
+ </element>
+ </define>
+
+ <define name="packagedoc-element">
+ <element name="gjdoc:packagedoc">
+ <a:documentation>
+ Corresponds to a package for which XML documentation
+ has been generated. This is not necessarily a package
+ the user requested generation for.
+ </a:documentation>
+
+ <ref name="name-attribute"/>
+ <ref name="firstSentenceTags-element"/>
+
+ <zeroOrMore>
+ <ref name="containsClass-element"/>
+ </zeroOrMore>
+ </element>
+ </define>
+
+ <define name="classdoc-element">
+ <element name="gjdoc:classdoc">
+ <a:documentation>
+ Corresponds to a class for which XML documentation has
+ been generated.
+ </a:documentation>
+
+ <ref name="name-attribute"/>
+ <ref name="qualifiedtypename-attribute"/>
+
+ <optional>
+ <a:documentation>
+ The following is optional because the root class
+ java.lang.Object does not have a superclass. For all
+ other classes, this element should be specified.
+ </a:documentation>
+
+ <ref name="superclass-element"/>
+ </optional>
+
+ <zeroOrMore>
+ <ref name="implements-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="superimplements-element"/>
+ </zeroOrMore>
+
+ <ref name="containingPackage-element"/>
+
+ <zeroOrMore>
+ <ref name="isError-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="isException-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="isInterface-element"/>
+ </zeroOrMore>
+
+ <zeroOrMore>
+ <ref name="containsClass-element"/>
+ </zeroOrMore>
+ </element>
+ </define>
+</grammar>
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/jar/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/jar/messages.properties
new file mode 100644
index 000000000..a456fe243
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/jar/messages.properties
@@ -0,0 +1,72 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Creator.Ignoring=ignoring entry {0}
+Creator.Adding=adding: {0} (in={1,number,integer}) (out={2,number,integer}) (stored {3,number,integer}%)
+Extractor.Created=\ \ created: {0}
+Extractor.Extracted=\ extracted: {0}
+Extractor.Inflated=\ \ inflated: {0}
+Indexer.Indexing=indexing: {0}
+Main.ArchiveAlreadySet=archive file name already set to {0}
+Main.ModeAlreaySet=operation mode already specified
+Main.MustSpecify=must specify one of -t, -c, -u, -x, or -i
+Main.TwoArgsReqd=-C argument requires both directory and filename
+Main.CantHaveBoth=can't specify both -m and -M
+Main.NoFilesWithi=can't specify file arguments when using -i
+Main.NoMAndi=can't specify -M with -i
+Main.AnotherNomAndi=can't specify -m with -i
+Main.Usage=Usage: jar -ctxui [OPTIONS] jar-file [-C DIR FILE] FILE...
+Main.OpMode=Operation mode
+Main.Create=create a new archive
+Main.Extract=extract from archive
+Main.List=list archive contents
+Main.Update=update archive
+Main.Index=compute archive index
+Main.FileArg=FILE
+Main.OpMods=Operation modifiers
+Main.ArchiveName=specify archive file name
+Main.FileArg2=FILE
+Main.NoZip=store only; no ZIP compression
+Main.Verbose=verbose operation
+Main.NoManifest=do not create a manifest file
+Main.ManifestName=specify manifest file
+Main.ManifestArgName=FILE
+Main.FileNameGroup=File name selection
+Main.ChangeDir=change to directory before the next file
+Main.ChangeDirArg=DIR FILE
+Main.InternalError=jar: internal error:
+Main.Stdin=Read file names from stdin
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/jarsigner/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/jarsigner/messages.properties
new file mode 100644
index 000000000..d4088177c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/jarsigner/messages.properties
@@ -0,0 +1,126 @@
+# messages.properties -- English language messages and message formats
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+#
+# for gnu.classpath.tools.jarsigner package
+#
+
+Main.7=jarsigner:
+Main.9=jarsigner error:
+Main.70=JAR file [{0}] is NOT a file object
+Main.72=JAR file [{0}] is NOT readable
+#Main.85=Option '-keystore' is not defined or is an empty string, and 'user.home' is unknown
+Main.85=Unable to locate a valid key store
+Main.92=Enter key store password:
+Main.6=Designated alias [{0}] MUST be known to the key store in use
+Main.2=\
+Usage: jarsigner [OPTION]... FILE ALIAS\n\
+\ \ \ \ \ \ \ \ jarsigner -verify [OPTION]... FILE\n\
+Java ARchive (JAR) file signing and verification tool.\n\
+\n\
+FILE is the .JAR file to sign or to verify.\n\
+\n\
+ALIAS must be a known Alias of a Key Entry in the designated key store. The \
+private key material associated with this Alias is used for signing FILE. if \
+ALIAS is required, but was omitted, "mykey" will be used instead.
+Main.1=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+Main.0=Signing options
+Main.95=Designated alias [{0}] MUST be an Alias of a Key Entry
+Main.97=Enter key password for <{0}>:
+Main.99=Key associated with [{0}] MUST be a private key
+Main.101=Location of the key store to use. The default value is a file-based \
+scheme whose path is the file named ".keystore" in your home directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+Main.102=URL
+Main.104=Type of the key store to use. If omitted, the default value is that \
+of the property "keystore.type" in the security properties file.
+Main.105=STORE_TYPE
+Main.107=Password to unlock the key store. If omitted, you will be prompted \
+to provide a password.
+Main.108=PASSWORD
+Main.110=Password to unlock the Key Entry associated with ALIAS. If omitted, \
+the tool will use the same password protecting the key store. If this fails, \
+you will be prompted to provide a password.
+Main.111=PASSWORD
+Main.113=A literal to construct file names for both the .SF and .DSA signature \
+files --which will be placed in the META-INF directory of the signed JAR. \
+Permissible characters are in the range [a-zA-Z0-9_-].\n\
+If omitted, the first 8 characters of ALIAS will be used. Characters outside \
+that range will be replaced by underscores.
+Main.114=NAME
+Main.116=Name of the signed JAR file. If omitted, the signed JAR will be \
+named the same as FILE; i.e. the input file will be replaced with its signed \
+copy.
+Main.117=FILE
+Main.118=Verification options
+Main.120=Verify an already signed FILE.
+Main.122=Use with -verbose to see more detailed information about the \
+certificates of ALIAS.
+Main.123=Common options
+Main.125=Output more verbose messages during processing.
+Main.127=Include --otherwise do not-- the .SF file in the .DSA generated file.
+Main.129=Include in the .SF generated file --otherwise do not-- a header \
+containing a hash of the whole manifest file.
+Main.131=Fully qualified class name of a Security Provider to add to the JVM \
+in-use.
+Main.132=PROVIDER_CLASS_NAME
+Main.133=Missing FILE argument.
+
+JarSigner.1=\ \ signing:
+JarSigner.2=\ updating:
+JarSigner.8=\ \ \ adding:
+JarSigner.14=Jar signed.
+
+JarVerifier.2=Jar is not signed --no signature files found.
+JarVerifier.3=Jar verification failed.
+JarVerifier.4=Jar partially verified --{0,numer} of {1,number} signers.
+JarVerifier.7=Jar verified --{0,number} signer(s).
+JarVerifier.13=Signature Block missing for {0}
+JarVerifier.14=At least one SignerInfo element MUST be present in a Signature \
+Block (.DSA file)
+JarVerifier.16=Missing EncryptedDigest in Signature Block (.DSA file) first \
+SignerInfo element
+
+SFHelper.1=Helper is NOT finished
+SFHelper.4=.SF file has NOT been generated
+SFHelper.6=Unknown or unsupported private key algorithm
+SFHelper.9=Helper is NOT ready
+SFHelper.0=Warning: The certificate issued by {0}, for {1}, has expired as of {3,date,full} - {3,time,full}.
+SFHelper.10=Helper is NOT started
+SFHelper.11=Warning: The certificate issued by {0}, for {1}, is only valid after {3,date,full} - {3,time,full}.
+SFHelper.14=[unknown]
+SFHelper.17=[unnamed]
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/keytool/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/keytool/messages.properties
new file mode 100644
index 000000000..98f4e6842
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/keytool/messages.properties
@@ -0,0 +1,570 @@
+# messages.properties -- English language messages and message formats
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+#
+# for gnu.classpath.tools.keytool package
+#
+
+Main.6=keytool: {0}
+Main.8=keytool error: {0}
+Main.5=Import a CA's Trusted Certificate.\n\
+[-file FILE] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
+Main.18=Unrecognized command: {0}
+Main.19=Usage: keytool [COMMAND] [-- COMMAND]...\n\
+Manage private keys and public certificates.
+Main.20=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+Main.21=Available commands
+Main.22=Generate a Key Entry, eventually creating a key store.\n\
+[-alias ALIAS] [-keyalg ALGORITHM] [-keysize KEY_SIZE]\n\
+[-sigalg ALGORITHM] [-dname NAME] [-keypass PASSWORD]\n\
+[-validity DAY_COUNT] [-storetype STORE_TYPE]\n\
+[-keystore URL] [-storepass PASSWORD]\n\
+[-provider PROVIDER_CLASS_NAME] [-v].
+Main.23=Add Key Entries and Trusted Certificates.\n\
+[-alias ALIAS] [-file FILE] [-keypass PASSWORD]\n\
+[-noprompt] [-trustcacerts] [-storetype STORE_TYPE]\n\
+[-keystore URL] [-storepass PASSWORD]\n\
+[-provider PROVIDER_CLASS_NAME] [-v].
+Main.24=Generate a self-signed Trusted Certificate.\n\
+[-alias ALIAS] [-sigalg ALGORITHM] [-dname NAME]\n\
+[-validity DAY_COUNT] [-keypass PASSWORD]\n\
+[-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
+Main.25=NOT IMPLEMENTED YET. Import JDK1.1 Identity Database.\n\
+[-file FILE] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
+Main.26=Issue a Certificate Signing Request (CSR).\n\
+[-alias ALIAS] [-sigalg ALGORITHM] [-file FILE]\n\
+[-keypass PASSWORD] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v]\n\
+[-attributes].
+Main.27=Export a Certificate from a key store.\n\
+[-alias ALIAS] [-file FILE] [-storetype STORE_TYPE]\n\
+[-keystore URL] [-storepass PASSWORD]\n\
+[-provider PROVIDER_CLASS_NAME] [-rfc] [-v].
+Main.28=Print one or all Certificates in a key store to STDOUT.\n\
+[-alias ALIAS] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-rfc] [-v].
+Main.29=Print a human-readable form of a Certificate in a FILE.\n\
+[-file FILE] [-v].
+Main.30=Clone a Key Entry in a key store.\n\
+[-alias ALIAS] [-dest ALIAS] [-keypass PASSWORD]\n\
+[-new PASSWORD] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
+Main.31=Change the password protecting a key store.\n\
+[-new PASSWORD] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
+Main.32=Change the password protecting a Key Entry in a key store.\n\
+[-alias ALIAS] [-keypass PASSWORD] [-new PASSWORD]\n\
+[-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
+Main.33=Delete a Key Entry or a Trusted Certificate from a key store.\n\
+[-alias ALIAS] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
+
+Command.19=Failed creating new file at {0}
+Command.20=Unable to find a suitable signature algorithm named {0}, although we found a key-pair generation algorithm named {1}
+Command.21=Enter key password for <{0}>:
+Command.23=A correct key password MUST be provided
+Command.24=Enter key store password:
+#Command.36=Option '-keystore' is undefined, or is an empty string, and 'user.home' is unknown
+Command.36=Unable to locate a valid key store
+Command.40=Provider fully qualified class name:
+Command.42=File object [{0}] exists but is NOT a file
+Command.44=File [{0}] exists but is NOT writable
+Command.46=File object [{0}] MUST be an existing readable file
+Command.48=Signature algorithm is missing and private key is of unknown or unsupported type
+Command.51=Validity period MUST be greater than zero
+Command.52=Unable to get signature algorithm name
+Command.60=Unknown or unsupported signature algorithm: {0}
+Command.63=Saving key store at {0}
+Command.66=Owner: {0}
+Command.67=Issuer: {0}
+Command.68=Serial number: {0,number}
+Command.69=Valid from: {0,date,full} - {0,time,full}
+Command.70=\ \ \ \ \ until: {0,date,full} - {0,time,full}
+Command.71=Certificate fingerprints
+Command.72=\ \ \ \ \ \ MD5: {0}
+Command.73=\ \ SHA-160: {0}
+Command.75=Alias [{0}] MUST be knwon to the key store
+Command.77=Alias [{0}] MUST be associated with a Key Entry
+
+CertReqCmd.27=Certification request stored in {0}
+CertReqCmd.28=Submit this to your CA
+CertReqCmd.25=Usage: keytool -certreq [OPTION]...\n\
+Generate a PKCS#10 Certificate Signing Request (CSR) and write it to a \
+designated output destination.\n\n\
+IMPORTANT: Some documentation claims that the Attributes field, in the CSR is \
+OPTIONAL while RFC-2986 implies the opposite. This implementation considers \
+this field, by default, as OPTIONAL, unless option -attributes is specified.
+CertReqCmd.24=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+CertReqCmd.23=Command options
+CertReqCmd.22=Alias of an entry in the key store on whose behalf the CSR is \
+generated. The value "mykey" (all lower case, without the enclosing quotes) \
+is used when this option is omitted.
+CertReqCmd.21=ALIAS
+CertReqCmd.20=Name of the digital signature algorithm to use for signing the \
+certificate. If omitted, a default value is chosen based on the type of the \
+private key associated with ALIAS. If the key is a "DSA" one, the value for \
+signature algorithm will be "SHA1withDSA". If on the other hand the key is \
+an "RSA" one, then "MD5withRSA" will be the signature algorithm.
+CertReqCmd.19=ALGORITHM
+CertReqCmd.18=Destination of the generated CSR. STDOUT is used if this \
+option is omitted.
+CertReqCmd.17=FILE
+CertReqCmd.16=Password to unlock the Key Entry associated with ALIAS. If \
+omitted, the tool will attempt to unlock the Key Entry using the same password \
+protecting the key store. If this fails, you will be prompted for a password.
+CertReqCmd.14=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+CertReqCmd.13=STORE_TYPE
+CertReqCmd.12=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+CertReqCmd.11=URL
+CertReqCmd.10=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+CertReqCmd.9=PASSWORD
+CertReqCmd.8=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+CertReqCmd.7=PROVIDER_CLASS_NAME
+CertReqCmd.6=Emit more verbose messages.
+CertReqCmd.5=Force the tool to encode a NULL DER value in the CSR as the value \
+of the Attributes field.
+
+DeleteCmd.19=Enter the Alias to delete:
+DeleteCmd.18=Usage: keytool -delete [OPTION]...\n\
+Delete a designated key store entry.
+DeleteCmd.17=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+DeleteCmd.16=Command options
+DeleteCmd.15=Alias of an entry to delete. The value "mykey" (all lower case, \
+without the enclosing quotes) is used when this option is omitted.
+DeleteCmd.14=ALIAS
+DeleteCmd.13=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+DeleteCmd.12=STORE_TYPE
+DeleteCmd.11=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+DeleteCmd.10=URL
+DeleteCmd.20=Alias MUST NOT be null or an empty string
+DeleteCmd.9=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+DeleteCmd.8=PASSWORD
+DeleteCmd.7=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+DeleteCmd.6=PROVIDER_CLASS_NAME
+DeleteCmd.5=Emit more verbose messages.
+
+GenKeyCmd.0=\nYou are about to enter information that will be incorporated into\n\
+your certificate request. This information is what is called a\n\
+Distinguished Name or DN. There are quite a few fields but you\n\
+can use supplied default values, displayed between brackets, by just\n\
+hitting <Enter>, or blank the field by entering the <.> character\n\
+before hitting <Enter>.\n\n
+GenKeyCmd.6=The Sample Company
+GenKeyCmd.7=Sydney
+GenKeyCmd.8=NSW
+GenKeyCmd.9=AU
+GenKeyCmd.10=Common Name (hostname, IP, or your name):
+GenKeyCmd.11=Organization Name (company) [{0}]:
+GenKeyCmd.13=Organizational Unit Name (department, division):
+GenKeyCmd.14=Locality Name (city, district) [{0}]:
+GenKeyCmd.16=State or Province Name (full name) [{0}]:
+GenKeyCmd.18=Country Name (2 letter code) [{0}]:
+GenKeyCmd.54=Key size MUST be greater than zero
+GenKeyCmd.57=Usage: keytool -genkey [OPTION]...\n\
+Generate a new key-pair and save these credentials in the key store as a Key \
+Entry, associated with a designated Alias.
+GenKeyCmd.58=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+GenKeyCmd.59=Command options
+GenKeyCmd.60=Alias of the Key Entry to generate. The value "mykey" (all lower \
+case, without the enclosing quotes) is used when this option is omitted.
+GenKeyCmd.61=ALIAS
+GenKeyCmd.62=Name of the key-pair generation algorithm. The default value is \
+"DSS" (a synonym for the Digital Signature Algorithm also known as DSA).
+GenKeyCmd.63=ALGORITHM
+GenKeyCmd.64=Number of bits of the shared modulus, for both the public and \
+private keys, to use for the new keys. If omitted, 1024 is used.
+GenKeyCmd.65=SIZE
+GenKeyCmd.66=Name of the digital signature algorithm to use for signing the \
+certificate. If omitted, a default value is chosen based on the type of the \
+private key associated with ALIAS. If the key is a "DSA" one, the value for \
+signature algorithm will be "SHA1withDSA". If on the other hand the key is \
+an "RSA" one, then "MD5withRSA" will be the signature algorithm.
+GenKeyCmd.68=The X.500 Distinguished Name of the Subject of the generated \
+certificate. If omitted you will be prompted for one.
+GenKeyCmd.69=NAME
+GenKeyCmd.70=Password to protect the newly created Key Entry. If omitted, \
+you will be prompted to provide a password.
+GenKeyCmd.71=PASSWORD
+GenKeyCmd.72=Number of days the generated certificate is valid for. If \
+omitted, 90 is used.
+GenKeyCmd.73=DAY_COUNT
+GenKeyCmd.74=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+GenKeyCmd.75=STORE_TYPE
+GenKeyCmd.76=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+GenKeyCmd.77=URL
+GenKeyCmd.78=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+GenKeyCmd.80=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+GenKeyCmd.81=PROVIDER_CLASS_NAME
+GenKeyCmd.82=Emit more verbose messages.
+
+StorePasswdCmd.19=Too many failed attempts
+StorePasswdCmd.18=Usage: keytool -storepasswd [OPTION]...\n\
+Change the password protecting a key store.
+StorePasswdCmd.17=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+StorePasswdCmd.16=Command options
+StorePasswdCmd.15=The new, and different, password to protect the key store. \
+If omitted, you will be prompted for one.
+StorePasswdCmd.13=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+StorePasswdCmd.12=STORE_TYPE
+StorePasswdCmd.11=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+StorePasswdCmd.10=URL
+StorePasswdCmd.20=Enter new key store password:
+StorePasswdCmd.21=Password MUST be at least 6 characters.
+StorePasswdCmd.22=New password MUST be different than the old one.
+StorePasswdCmd.23=Re-enter new key store password:
+StorePasswdCmd.24=Passwords MUST be the same in both attempts.
+StorePasswdCmd.9=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+StorePasswdCmd.8=PASSWORD
+StorePasswdCmd.7=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+StorePasswdCmd.6=PROVIDER_CLASS_NAME
+StorePasswdCmd.5=Emit more verbose messages.
+
+KeyPasswdCmd.24=Enter new key password for <{0}>:
+KeyPasswdCmd.28=Re-enter new key password for <{0}>:
+KeyPasswdCmd.23=Usage: keytool -keypasswd [OPTION]...\n\
+Change the password protecting a Key Entry.
+KeyPasswdCmd.22=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+KeyPasswdCmd.21=Command options
+KeyPasswdCmd.20=The Alias which password is to be changed.
+KeyPasswdCmd.19=ALIAS
+KeyPasswdCmd.18=Password to unlock ALIAS. If omitted, the tool will attempt \
+to unlock the Key Entry using the same password protecting the key store. If \
+this fails, you will be prompted for a password.
+KeyPasswdCmd.16=The new, and different, password to protect ALIAS.
+KeyPasswdCmd.14=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+KeyPasswdCmd.13=STORE_TYPE
+KeyPasswdCmd.12=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+KeyPasswdCmd.11=URL
+KeyPasswdCmd.10=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+KeyPasswdCmd.9=PASSWORD
+KeyPasswdCmd.8=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+KeyPasswdCmd.7=PROVIDER_CLASS_NAME
+KeyPasswdCmd.6=Emit more verbose messages.
+
+KeyCloneCmd.23=Destination Alias MUST NOT exist in key store
+KeyCloneCmd.26=Enter destination alias:
+KeyCloneCmd.27=Destination alias MUST NOT be null nor empty
+KeyCloneCmd.28=Enter new key password for <{0}> [{1}]:
+KeyCloneCmd.22=Usage: keytool -keyclone [OPTION]...\n\
+Clone an existing Key Entry and store it under a new (different) Alias \
+protecting its private key material with possibly a new password.
+KeyCloneCmd.21=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+KeyCloneCmd.20=Command options
+KeyCloneCmd.19=Alias of an entry to clone. The value "mykey" (all lower case, \
+without the enclosing quotes) is used when this option is omitted.
+KeyCloneCmd.17=Alias to identify the cloned copy of the Key Entry.
+KeyCloneCmd.16=ALIAS
+KeyCloneCmd.15=Password to unlock the Key Entry associated with the Alias to \
+clone. If omitted, the tool will attempt to unlock the Key Entry using the \
+same password protecting the key store. If this fails, you will be prompted \
+for a password.
+KeyCloneCmd.13=Password to protect the cloned copy of the Key Entry. If \
+omitted, you will be prompted to provide one.
+KeyCloneCmd.11=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+KeyCloneCmd.10=STORE_TYPE
+KeyCloneCmd.9=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+KeyCloneCmd.8=URL
+KeyCloneCmd.7=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+KeyCloneCmd.6=PASSWORD
+KeyCloneCmd.5=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+KeyCloneCmd.4=PROVIDER_CLASS_NAME
+KeyCloneCmd.3=Emit more verbose messages.
+
+ListCmd.21=Key store type: {0}
+ListCmd.22=Key store provider: {0}
+ListCmd.24=Key store contains {0,number} entry(ies)
+ListCmd.20=Usage: keytool -list [OPTION]...\n\
+Print one or all of the key store entries to STDOUT. Usually this command \
+will only print a fingerprint of the certificate, unless either -rfc or -v \
+is specified.
+ListCmd.30=Alias name: {0}
+ListCmd.31=Creation timestamp: {0,date,full} - {0,time,full}
+ListCmd.32=Entry type: trusted-certificate
+ListCmd.33=Entry type: key-entry
+ListCmd.34=Alias [{0}] is unknown to the key store
+ListCmd.38=Certificate chain length: {0,number}
+ListCmd.39=Certificate[1]:
+ListCmd.40=Certificate[{0,number}]:
+ListCmd.42=*******************************************
+ListCmd.43=-----BEGIN CERTIFICATE-----
+ListCmd.44=-----END CERTIFICATE-----
+ListCmd.45=Certificate fingerprint (MD5): {0}
+ListCmd.19=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+ListCmd.18=Command options
+ListCmd.17=Alias of an entry to list. If omitted, all entries are listed.
+ListCmd.16=ALIAS
+ListCmd.15=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+ListCmd.14=STORE_TYPE
+ListCmd.13=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+ListCmd.12=URL
+ListCmd.11=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+ListCmd.10=PASSWORD
+ListCmd.9=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+ListCmd.8=PROVIDER_CLASS_NAME
+ListCmd.7=Output the certificate in human-readable format, even if -rfc is \
+also specified.
+ListCmd.6=Use RFC-1421 specifications when encoding the output.
+
+ImportCmd.34=Failed to establish chain-of-trust from reply
+ImportCmd.37=Unable to find anchor certificate for {0}
+ImportCmd.38=Public keys, in key store and certificate, MUST be of the same type
+ImportCmd.32=Can this certificate be trusted?
+ImportCmd.40=Key entry associated with {0} has an unknown or unsupported public key type {1}
+ImportCmd.41=Public keys, in key store and certificate, MUST be the same
+ImportCmd.29=Certificate was added to the key store
+ImportCmd.28=Certificate was not added to the key store
+ImportCmd.27=Usage: keytool -import [OPTION]...\n\
+Read an X.509 certificate, or a PKCS#7 Certificate Reply from a designated \
+input source and incorporate the certificates into the key store.
+ImportCmd.26=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+ImportCmd.25=Command options
+ImportCmd.24=If ALIAS does not already exist in the key store, the tool treats \
+the certificate in FILE as a new Trusted Certificate.\n\
+If ALIAS exists in the key store, the tool will treat the certificate(s) in \
+FILE as a Certificate Reply (which can be a chain of certificates).
+ImportCmd.23=ALIAS
+ImportCmd.22=Location of the Certificate or Certificate Reply to import.
+ImportCmd.21=FILE
+ImportCmd.20=Password to protect the Key Entry associated with ALIAS. If \
+this option is omitted, and the chain-of-trust for the Certificate Reply has \
+been established, the tool will first attempt to unlock the Key Entry using \
+the same password protecting the key store. If this fails, you will be \
+prompted to provide a password.
+ImportCmd.19=PASSWORD
+ImportCmd.18=Prevent the tool from prompting the user.
+ImportCmd.17=Additionally use a key store, of type "JKS", named "cacerts", \
+and located in lib/security in an installed Java Runtime Environment, when \
+trying to establish chains-of-trust.
+ImportCmd.16=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+ImportCmd.15=STORE_TYPE
+ImportCmd.14=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+ImportCmd.13=URL
+ImportCmd.12=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+ImportCmd.11=PASSWORD
+ImportCmd.10=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+ImportCmd.9=PROVIDER_CLASS_NAME
+ImportCmd.8=Emit more verbose messages.
+ImportCmd.7=Was unable to build a certificate-chain. Only {0,number} out of {1,number} certificates were processed
+
+ExportCmd.17=Usage: keytool -export [OPTION]...\n\
+Export a certificate stored in the key store to a designated output \
+destination, either in binary format or in RFC-1421 compliant encoding.
+ExportCmd.18=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+ExportCmd.19=Command options
+ExportCmd.20=Alias of an entry to export. The value "mykey" (all lower case, \
+without the enclosing quotes) is used when this option is omitted.
+ExportCmd.21=ALIAS
+ExportCmd.22=Destination of the exported certificate. STDOUT is used if this \
+option is omitted.
+ExportCmd.23=FILE
+ExportCmd.24=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+ExportCmd.25=STORE_TYPE
+ExportCmd.26=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+ExportCmd.27=URL
+ExportCmd.28=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+ExportCmd.29=PASSWORD
+ExportCmd.30=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+ExportCmd.31=PROVIDER_CLASS_NAME
+ExportCmd.32=Use RFC-1421 specifications when encoding the output.
+ExportCmd.33=Output the certificate in binary DER encoding, which is the \
+default format. If -rfc is also present, this option is ignored.
+
+IdentityDBCmd.7=Usage: keytool -identitydb [OPTION]...\n\
+NOT IMPLEMENTED YET. Import a JDK 1.1 style Identity Database.
+IdentityDBCmd.8=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+IdentityDBCmd.9=Command options
+IdentityDBCmd.10=Location of the Identity Database to import. If omitted, \
+STDIN is used.
+IdentityDBCmd.11=FILE
+IdentityDBCmd.12=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+IdentityDBCmd.13=STORE_TYPE
+IdentityDBCmd.14=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+IdentityDBCmd.15=URL
+IdentityDBCmd.16=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+IdentityDBCmd.17=PASSWORD
+IdentityDBCmd.18=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+IdentityDBCmd.19=PROVIDER_CLASS_NAME
+IdentityDBCmd.20=Emit more verbose messages.
+
+PrintCertCmd.5=Usage: keytool -printcert [OPTION]...\n\
+Read a certificate from FILE and print it to STDOUT in a human-readable form.
+PrintCertCmd.6=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+PrintCertCmd.7=Command options
+PrintCertCmd.8=Location of the certificate to print. If omitted, STDIN is used.
+PrintCertCmd.9=FILE
+PrintCertCmd.10=Emit more verbose messages.
+
+SelfCertCmd.14=Usage: keytool -selfcert [OPTION]...\n\
+Generate a self-signed X.509 version 1 certificate.\n\n\
+The newly generated certificate will form a chain of one element which will \
+replace the previous chain associated with ALIAS.
+SelfCertCmd.15=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+SelfCertCmd.16=Command options
+SelfCertCmd.17=Alias of the Key Entry to select. The value "mykey" (all lower \
+case, without the enclosing quotes) is used when this option is omitted.
+SelfCertCmd.18=ALIAS
+SelfCertCmd.19=Name of the digital signature algorithm to use for signing the \
+certificate. If omitted, a default value is chosen based on the type of the \
+private key associated with ALIAS. If the key is a "DSA" one, the value for \
+signature algorithm will be "SHA1withDSA". If on the other hand the key is \
+an "RSA" one, then "MD5withRSA" will be the signature algorithm.
+SelfCertCmd.20=ALGORITHM
+SelfCertCmd.21=The X.500 Distinguished Name of the Subject of the generated \
+certificate. If omitted the Distinguished Name of the base certificate in \
+the chain associated with ALIAS is used instead.
+SelfCertCmd.22=NAME
+SelfCertCmd.23=Password to unlock the Key Entry associated with ALIAS. If \
+omitted, the tool will attempt to unlock the Key Entry using the same password \
+protecting the key store. If this fails, you will be prompted for a password.
+SelfCertCmd.24=PASSWORD
+SelfCertCmd.25=Number of days the generated certificate is valid for. If \
+omitted, 90 is used.
+SelfCertCmd.26=DAY_COUNT
+SelfCertCmd.27=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+SelfCertCmd.28=STORE_TYPE
+SelfCertCmd.29=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+SelfCertCmd.30=URL
+SelfCertCmd.31=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+SelfCertCmd.32=PASSWORD
+SelfCertCmd.33=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+SelfCertCmd.34=PROVIDER_CLASS_NAME
+SelfCertCmd.35=Emit more verbose messages.
+
+CACertCmd.0=Alias [{0}] is already present in key store
+CACertCmd.1=Certificate in file "{0}" was added to the key store under the alias "{1}"
+CACertCmd.2=Usage: keytool -cacert [OPTION]...\n\
+Import a trusted CA certificate.
+CACertCmd.3=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+CACertCmd.4=Command options
+CACertCmd.5=Location of the trusted CA certificate to import.
+CACertCmd.6=FILE
+CACertCmd.7=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+CACertCmd.8=STORE_TYPE
+CACertCmd.9=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+CACertCmd.10=URL
+CACertCmd.11=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+CACertCmd.12=PASSWORD
+CACertCmd.13=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+CACertCmd.14=PROVIDER_CLASS_NAME
+CACertCmd.15=Emit more verbose messages.
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/native2ascii/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/native2ascii/messages.properties
new file mode 100644
index 000000000..f04d184f2
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/native2ascii/messages.properties
@@ -0,0 +1,44 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Native2ASCII.TooManyFiles=too many files specified
+Native2ASCII.Usage=Usage: native2ascii [OPTIONS]... [INPUTFILE [OUTPUTFILE]]
+Native2ASCII.EncodingHelp=encoding to use
+Native2ASCII.EncodingArgName=NAME
+Native2ASCII.EncodingSpecified=encoding already specified
+Native2ASCII.ReverseHelp=convert from encoding to native
+
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/orbd/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/orbd/messages.properties
new file mode 100644
index 000000000..b427d102b
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/orbd/messages.properties
@@ -0,0 +1,46 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: orbd [OPTIONS]
+Main.ORBInitialPort=port on which persistent naming service is to be started
+Main.Port=PORT
+Main.IOR=file in which to store persistent naming service's IOR reference
+Main.IORFile=FILE
+Main.Restart=restart persistent naming service, clearing persistent naming database
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.InternalError=orbd: internal error:
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/messages.properties
new file mode 100644
index 000000000..7be7cb0c7
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/messages.properties
@@ -0,0 +1,61 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage:rmic [OPTIONS] CLASSNAME...
+Main.NoWarn:show no warnings
+Main.NoWrite:check for errors and do not write any files
+Main.Verbose:show verbose output
+Main.DirOpt:write generated files to given directory
+Main.DirArg:DIRECTORY
+Main.ClasspathOpt:where to find input classes
+Main.ClasspathArg:PATH
+Main.BootclasspathOpt:where to find classes used to run rmic (ignored)
+Main.BootclasspathArg:PATH
+Main.ExtdirsOpt:where to find extension classes used to run rmic (ignored)
+Main.ExtdirsArg:PATH
+Main.IIOP:generate stubs and ties for IIOP
+Main.Always:always overwrite generated files (ignored)
+Main.AlwaysGenerate:same as -always
+Main.NoLocalStubs:do not create same-process stubs (ignored)
+Main.POA:generate servant-based ties
+Main.Keep:keep generated stub, skeleton and tie sources
+Main.KeepGenerated:same as -keep
+Main.v11:generate JDK 1.1 protocol stubs and skeletons
+Main.v12:generate JDK 1.2 JRMP stubs (default)
+Main.vcompat:generate JDK 1.1 protocol and JDK 1.2 JRMP stubs
+Main.DebugInfo:include debugging information in generated classes
+Main.InternalError:rmic: internal error:
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/ImplTie.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/ImplTie.jav
new file mode 100644
index 000000000..aff606b90
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/ImplTie.jav
@@ -0,0 +1,152 @@
+package #package;
+
+#imports
+import java.rmi.Remote;
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+
+import org.omg.CORBA_2_3.portable.ObjectImpl;
+import org.omg.CORBA_2_3.portable.InputStream;
+
+// This Tie type is obsolete. Use the POA - based tie (key -poa).
+
+/**
+ * This class accepts remote calls to the served GIOP object and delegates them
+ * to the enclosed implementing class. Being derived from the ObjectImpl,
+ * it directly implements the GIOP Object.
+ *
+ * It is normally generated with grmic -impl
+ */
+public class _#nameImpl_Tie extends ObjectImpl implements Tie
+{
+ /**
+ * All decoded remote calls are forwarded to this target.
+ */
+ #implName target;
+
+ /**
+ * The array of repository ids, supported by this GIOP Object
+ */
+ private static final String[] type_ids =
+ {
+#idList
+ };
+
+ /**
+ * Get an array of all interfaces (repository ids),
+ * supported by this Object.
+ *
+ * @return the array of Ids.
+ */
+ public String[] _ids()
+ {
+ return type_ids;
+ }
+
+ /**
+ * Set the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @param a_target the forwarding target
+ *
+ * @throws ClassCastException if the target is not an instance of
+ * #implName
+ */
+ public void setTarget(Remote a_target)
+ {
+ this.target = (#implName) a_target;
+ }
+
+ /**
+ * Get the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @return the target, an instance of
+ * #implName
+ */
+ public Remote getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Return the actual GIOP object that would handle this request.
+ *
+ * @return <code>this</code>, always.
+ */
+ public org.omg.CORBA.Object thisObject()
+ {
+ return this;
+ }
+
+ /**
+ * Deactivates this object, disconnecting it from the orb.
+ */
+ public void deactivate()
+ {
+ _orb().disconnect(this);
+ _set_delegate(null);
+ target = null;
+ }
+
+ /**
+ * Get the {@link ORB} where this {@link Servant} is connected.
+ *
+ * @return the ORB
+ */
+ public ORB orb()
+ {
+ return _orb();
+ }
+
+ /**
+ * Connect this servant to the given ORB.
+ */
+ public void orb(ORB orb)
+ {
+ orb.connect(this);
+ }
+
+/**
+ * This method is invoked by ORB in response to the remote call. It redirects
+ * the call to one of the methods in the target.
+ *
+ * @param method the name of the method to call.
+ * @param parameter_stream the input stream, from where the parameters must be
+ * read.
+ * @param reply the response hander, providing methods to return the result.
+ *
+ * @return the output stream, created by the response handler
+ *
+ * @throws SystemException if one occurs during method invocation.
+ */
+ public OutputStream _invoke(String method,
+ org.omg.CORBA.portable.InputStream parameter_stream,
+ ResponseHandler reply)
+ {
+ try
+ {
+ InputStream in =(InputStream) parameter_stream;
+
+#tie_methods
+
+ throw new BAD_OPERATION("No such method: '"+method+"'");
+ }
+ catch (SystemException ex)
+ {
+ throw ex;
+ }
+ catch (Throwable ex)
+ {
+ throw new UnknownException(ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub.jav
new file mode 100644
index 000000000..371e12d44
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub.jav
@@ -0,0 +1,47 @@
+package #package;
+
+#imports
+import java.rmi.UnexpectedException;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.RemarshalException;
+
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+/**
+ * This class delegates its method calls to the remote GIOP object.
+ * It is normally generated with grmic.
+ */
+public class _#name_Stub extends Stub
+ implements #interfaces
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The array of repository ids, supported by this GIOP Object
+ */
+ private static final String[] type_ids =
+ {
+#idList
+ };
+
+ /**
+ * Return the array of repository ids, supported by this GIOP Object.
+ *
+ * @return the array of Ids.
+ */
+ public String[] _ids()
+ {
+ return type_ids;
+ }
+
+#stub_methods
+} \ No newline at end of file
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethod.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethod.jav
new file mode 100644
index 000000000..17636deb6
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethod.jav
@@ -0,0 +1,33 @@
+ /** @inheritDoc */
+ public #return_type #method_name(#argument_list) #throws
+ {
+ try
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out =
+ (OutputStream) _request("#giop_method_name", true);
+#argument_write
+ in = _invoke(out);
+ #read_return
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new UnexpectedException(in.read_string());
+ }
+ catch (RemarshalException ex)
+ {
+ return #method_name(#argument_names);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav
new file mode 100644
index 000000000..0125a02b0
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav
@@ -0,0 +1,32 @@
+ /** @inheritDoc */
+ public #return_type #method_name(#argument_list) #throws
+ {
+ try
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out =
+ (OutputStream) _request("#giop_method_name", true);
+#argument_write
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new UnexpectedException(in.read_string());
+ }
+ catch (RemarshalException ex)
+ {
+ #method_name(#argument_names);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12.jav
new file mode 100644
index 000000000..1c55a0597
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12.jav
@@ -0,0 +1,62 @@
+package #package;
+
+#imports
+import java.lang.reflect.Method;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.UnexpectedException;
+
+/**
+ * This class delegates its method calls to the remote RMI object, referenced
+ * by {@link RemoteRef}.
+ *
+ * It is normally generated with rmic.
+ */
+public final class #name_Stub
+ extends RemoteStub
+ implements #interfaces
+{
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 2;
+
+ /**
+ * The explaining message for {@ling UnexpectedException}.
+ */
+ private static final String exception_message =
+ "undeclared checked exception";
+
+ /* All remote methods, invoked by this stub: */
+#stub_method_declarations
+ #zeroSizeObjecArray
+ static
+ {
+ #zeroSizeClassArray
+ try
+ {
+#stub_method_initializations
+ }
+ catch (NoSuchMethodException nex)
+ {
+ NoSuchMethodError err = new NoSuchMethodError(
+ "#name_Stub class initialization failed");
+ err.initCause(nex);
+ throw err;
+ }
+ }
+
+ /**
+ * Create the instance for _#name_Stub that forwards method calls to the
+ * remote object.
+ *
+ * @para the reference to the remote object.
+ */
+ public #name_Stub(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /* Methods */
+#stub_methods
+}
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12Method.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12Method.jav
new file mode 100644
index 000000000..9aaf8f5ad
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12Method.jav
@@ -0,0 +1,26 @@
+ /** @inheritDoc */
+ public #return_type #method_name(#argument_list) #throws
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_#method_name,
+ #object_arg_list,
+ #method_hash);
+ #return_statement
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+ \ No newline at end of file
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav
new file mode 100644
index 000000000..860a93c84
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav
@@ -0,0 +1,25 @@
+ /** @inheritDoc */
+ public void #method_name(#argument_list) #throws
+ {
+ try
+ {
+ ref.invoke(this, met_#method_name,
+ #object_arg_list,
+ #method_hash);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+ \ No newline at end of file
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Tie.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Tie.jav
new file mode 100644
index 000000000..797ae1401
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Tie.jav
@@ -0,0 +1,184 @@
+package #package;
+
+#imports
+import java.rmi.Remote;
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAPackage.WrongPolicy;
+import org.omg.PortableServer.POAPackage.ObjectNotActive;
+import org.omg.PortableServer.POAPackage.ServantNotActive;
+
+import org.omg.CORBA_2_3.portable.InputStream;
+
+/**
+ * This class accepts remote calls to the served GIOP object and delegates them
+ * to the enclosed implementing class. Being servant, it must be connected to
+ * the ORB Poa.
+ * It is normally generated with grmic -poa
+ */
+public class _#nameImpl_Tie extends Servant implements Tie
+{
+ /**
+ * All decoded remote calls are forwarded to this target.
+ */
+ #implName target;
+
+ /**
+ * The array of repository ids, supported by this GIOP Object
+ */
+ private static final String[] type_ids =
+ {
+#idList
+ };
+
+ /**
+ * Get an array of all interfaces, supported by this
+ * {@link Servant}.
+ *
+ * @param poa unused
+ * @param objectId unused
+ *
+ * @return the array of Ids.
+ */
+ public String[] _all_interfaces(POA poa,
+ byte[] objectId
+ )
+ {
+ return type_ids;
+ }
+
+
+ /**
+ * Set the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @param a_target the forwarding target
+ *
+ * @throws ClassCastException if the target is not an instance of
+ * #implName
+ */
+ public void setTarget(Remote a_target)
+ {
+ this.target = (#implName) a_target;
+ }
+
+ /**
+ * Get the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @return the target, an instance of
+ * #implName
+ */
+ public Remote getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Return the actual GIOP object that would handle this request.
+ *
+ * @return the GIOP object.
+ */
+ public org.omg.CORBA.Object thisObject()
+ {
+ return _this_object();
+ }
+
+ /**
+ * Deactivate this {@link Servant}. The WrongPolicy, ObjectNotActive
+ * and ServantNotActive exceptions, if thrown during deactivation, are
+ * catched and silently ignored.
+ */
+ public void deactivate()
+ {
+ try
+ {
+ _poa().deactivate_object(_poa().servant_to_id(this));
+ }
+ catch (WrongPolicy exception)
+ {
+ }
+ catch (ObjectNotActive exception)
+ {
+ }
+ catch (ServantNotActive exception)
+ {
+ }
+ }
+
+ /**
+ * Get the {@link ORB} where this {@link Servant} is connected.
+ *
+ * @return the ORB
+ */
+ public ORB orb()
+ {
+ return _orb();
+ }
+
+ /**
+ * Connect this servant to the given ORB. It is recommended to connect
+ * servant to the ORBs root or other POA rather than using this method.
+ */
+ public void orb(ORB orb)
+ {
+ try
+ {
+ ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
+ }
+ catch (ClassCastException e)
+ {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "POA Servant requires an instance of org.omg.CORBA_2_3.ORB"
+ );
+ }
+ }
+
+/**
+ * This method is invoked by ORB in response to the remote call. It redirects
+ * the call to one of the methods in the target.
+ *
+ * @param method the name of the method to call.
+ * @param parameter_stream the input stream, from where the parameters must be
+ * read.
+ * @param reply the response hander, providing methods to return the result.
+ *
+ * @return the output stream, created by the response handler
+ *
+ * @throws SystemException if one occurs during method invocation.
+ */
+ public OutputStream _invoke(String method,
+ org.omg.CORBA.portable.InputStream parameter_stream,
+ ResponseHandler reply
+ ) throws SystemException
+ {
+ try
+ {
+ InputStream in =(InputStream) parameter_stream;
+ switch (method.charAt(#hashCharPos))
+ {
+#tie_methods
+ default: break;
+ }
+
+ throw new BAD_OPERATION("No such method: '"+method+"'");
+ }
+ catch (SystemException ex)
+ {
+ throw ex;
+ }
+ catch (Throwable ex)
+ {
+ throw new UnknownException(ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethod.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethod.jav
new file mode 100644
index 000000000..493f0009b
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethod.jav
@@ -0,0 +1,11 @@
+ #hashCodeLabel
+ // #method_name
+ if (method.equals("#giop_method_name"))
+ {
+#read_and_define_args
+ OutputStream out = reply.createReply();
+ #return_type result =
+ target.#method_name(#argument_names);
+ #write_result
+ return out;
+ }
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav
new file mode 100644
index 000000000..3db17da7c
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav
@@ -0,0 +1,9 @@
+ #hashCodeLabel
+ // #method_name
+ if (method.equals("#giop_method_name"))
+ {
+#read_and_define_args
+ OutputStream out = reply.createReply();
+ target.#method_name(#argument_names);
+ return out;
+ }
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmid/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/rmid/messages.properties
new file mode 100644
index 000000000..234cea12a
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmid/messages.properties
@@ -0,0 +1,50 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: rmid [OPTIONS]
+Main.ControlGroup=Activation process control
+Main.PortOption=port on which activation system is to be started
+Main.Port=PORT
+Main.Restart=restart activation system, clearing persistent naming database, if any
+Main.Stop=stop activation system
+Main.PersistenceGroup=Persistence
+Main.Persistent=make activation system persistent
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.DebugGroup=Debugging
+Main.Verbose=log binding events to standard out
+Main.InternalError=rmid: internal error:
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/rmiregistry/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/rmiregistry/messages.properties
new file mode 100644
index 000000000..46f7cfdb7
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/rmiregistry/messages.properties
@@ -0,0 +1,48 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: rmiregistry [OPTIONS] [PORT]
+Main.ControlGroup=Registry process control
+Main.Restart=restart RMI naming service, clearing persistent naming database, if any
+Main.Stop=stop RMI naming service
+Main.PersistenceGroup=Persistence
+Main.Persistent=make RMI naming service persistent
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.DebugGroup=Debugging
+Main.Verbose=log binding events to standard out
+Main.InternalError=rmiregistry: internal error:
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/serialver/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/serialver/messages.properties
new file mode 100644
index 000000000..8900795d4
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/serialver/messages.properties
@@ -0,0 +1,44 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+SerialVer.NoClassesSpecd=no classes specified
+SerialVer.HelpHeader=serialver [OPTIONS]... CLASS...\n\nPrint the serialVersionUID of the specified classes
+SerialVer.5=classpath
+SerialVer.ClasspathHelp=class path to use to find classes
+SerialVer.ClassNotSerial=serialver: class {0} is not serializable
+SerialVer.ClassNotFound=serialver: class {0} not found
+SerialVer.DupClasspath=classpath already specified
diff --git a/libjava/classpath/tools/resource/gnu/classpath/tools/tnameserv/messages.properties b/libjava/classpath/tools/resource/gnu/classpath/tools/tnameserv/messages.properties
new file mode 100644
index 000000000..3861e24ba
--- /dev/null
+++ b/libjava/classpath/tools/resource/gnu/classpath/tools/tnameserv/messages.properties
@@ -0,0 +1,43 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: tnameserv [OPTIONS]
+Main.ORBInitialPort=port on which naming service is to be started
+Main.Port=PORT
+Main.IOR=file in which to store naming service's IOR reference
+Main.IORFile=FILE
+Main.InternalError=tnameserv: internal error:
diff --git a/libjava/classpath/tools/resource/sun/rmi/rmic/messages.properties b/libjava/classpath/tools/resource/sun/rmi/rmic/messages.properties
new file mode 100644
index 000000000..4c897fd5e
--- /dev/null
+++ b/libjava/classpath/tools/resource/sun/rmi/rmic/messages.properties
@@ -0,0 +1,38 @@
+# messages.properties -- English language messages
+# Copyright (C) 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is 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 2, or (at your option)
+# any later version.
+#
+# GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.InternalError:sun.rmi.rmic: failed to run rmic main method
diff --git a/libjava/classpath/tools/sun/rmi/rmic/Main.java b/libjava/classpath/tools/sun/rmi/rmic/Main.java
new file mode 100644
index 000000000..7acc65696
--- /dev/null
+++ b/libjava/classpath/tools/sun/rmi/rmic/Main.java
@@ -0,0 +1,60 @@
+/* Main.java -- implement sun.rmi.rmic.Main
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package sun.rmi.rmic;
+
+import java.io.OutputStream;
+
+public class Main
+{
+ // Ant calls this. What to do with stream and string?
+ public Main(OutputStream stream, String string) {}
+
+ public boolean compile(String[] args)
+ {
+ try
+ {
+ gnu.classpath.tools.rmic.Main.main(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError"));
+ e.printStackTrace();
+ }
+ return true;
+ }
+}
diff --git a/libjava/classpath/tools/sun/rmi/rmic/Messages.java b/libjava/classpath/tools/sun/rmi/rmic/Messages.java
new file mode 100644
index 000000000..80f5513a8
--- /dev/null
+++ b/libjava/classpath/tools/sun/rmi/rmic/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for sun.rmi.rmic
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package sun.rmi.rmic;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "sun.rmi.rmic.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/libjava/classpath/tools/toolwrapper.c b/libjava/classpath/tools/toolwrapper.c
new file mode 100644
index 000000000..806fb2bd3
--- /dev/null
+++ b/libjava/classpath/tools/toolwrapper.c
@@ -0,0 +1,264 @@
+/* toolwrapper.c -- a native tool wrapper for VMs that support the JNI
+ invocation interface
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is 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 2, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <jni.h>
+#include <ltdl.h>
+#include <string.h>
+#include <stdlib.h>
+#include "config.h"
+
+#ifndef JNI_VERSION_1_2
+# error JNI version 1.2 or greater required
+#endif
+
+#ifndef MAINCLASS
+#define MAINCLASS "Main"
+#endif
+
+union env_union
+{
+ void *void_env;
+ JNIEnv *jni_env;
+};
+
+/* Typedef for JNI_CreateJavaVM dlopen call. */
+typedef jint createVM (JavaVM **, void **, void *);
+
+int
+main (int argc, const char** argv)
+{
+ union env_union tmp;
+ JNIEnv* env;
+ JavaVM* jvm;
+ JavaVMInitArgs vm_args;
+ jint result;
+ jclass class_id;
+ jmethodID method_id;
+ jstring str;
+ jclass string_class_id;
+ jobjectArray args_array;
+ char** non_vm_argv;
+ int non_vm_argc;
+ int i;
+ int classpath_found = 0;
+ /* Variables for JNI_CreateJavaVM dlopen call. */
+ lt_dlhandle libjvm_handle = NULL;
+ createVM* libjvm_create = NULL;
+ int libjvm_error = 0;
+
+ env = NULL;
+ jvm = NULL;
+
+ vm_args.nOptions = 0;
+ vm_args.options = NULL;
+
+ non_vm_argc = 0;
+ non_vm_argv = NULL;
+
+ if (argc > 1)
+ {
+ for (i = 1; i < argc; i++)
+ {
+ if (!strncmp (argv[i], "-J", 2))
+ {
+ if (!strncmp (argv[i], "-J-Djava.class.path=", 20))
+ classpath_found = 1;
+
+ /* A virtual machine option. */
+ vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+
+ if (vm_args.options == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
+ goto destroy;
+ }
+
+ if (strlen (argv[i]) == 2)
+ {
+ fprintf (stderr, TOOLNAME ": the -J option must not be followed by a space.\n");
+ goto destroy;
+ }
+ else
+ vm_args.options[vm_args.nOptions++].optionString = strdup (argv[i] + 2);
+ }
+ else
+ {
+ non_vm_argv = (char**) realloc (non_vm_argv, (non_vm_argc + 1) * sizeof (char*));
+ if (non_vm_argv == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
+ goto destroy;
+ }
+ non_vm_argv[non_vm_argc++] = strdup (argv[i]);
+ }
+ }
+ }
+
+ if (!classpath_found)
+ {
+ /* Set the invocation classpath. */
+ vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+
+ if (vm_args.options == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
+ goto destroy;
+ }
+
+ vm_args.options[vm_args.nOptions++].optionString = "-Xbootclasspath/p:" TOOLS_ZIP;
+ }
+
+ /* Terminate vm_args.options with a NULL element. */
+ vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+ if (vm_args.options == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
+ goto destroy;
+ }
+ vm_args.options[vm_args.nOptions].optionString = NULL;
+
+ /* Terminate non_vm_argv with a NULL element. */
+ non_vm_argv = (char**) realloc (non_vm_argv, (non_vm_argc + 1) * sizeof (char*));
+ if (non_vm_argv == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
+ goto destroy;
+ }
+ non_vm_argv[non_vm_argc] = NULL;
+
+ vm_args.version = JNI_VERSION_1_2;
+ vm_args.ignoreUnrecognized = JNI_TRUE;
+
+ /* dlopen libjvm.so */
+ libjvm_error = lt_dlinit ();
+ if (libjvm_error)
+ {
+ fprintf (stderr, TOOLNAME ": lt_dlinit failed.\n");
+ goto destroy;
+ }
+
+ libjvm_handle = lt_dlopenext (LIBJVM);
+ if (!libjvm_handle)
+ {
+ fprintf (stderr, TOOLNAME ": failed to open " LIBJVM "\n");
+ goto destroy;
+ }
+ libjvm_create = (createVM*) lt_dlsym (libjvm_handle, "JNI_CreateJavaVM");
+ if (!libjvm_create)
+ {
+ fprintf (stderr, TOOLNAME ": failed to load JNI_CreateJavaVM symbol from " LIBJVM "\n");
+ goto destroy;
+ }
+ result = (*libjvm_create) (&jvm, &tmp.void_env, &vm_args);
+
+ if (result < 0)
+ {
+ fprintf (stderr, TOOLNAME ": couldn't create virtual machine\n");
+ goto destroy;
+ }
+
+ env = tmp.jni_env;
+
+ string_class_id = (*env)->FindClass (env, "java/lang/String");
+ if (string_class_id == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": FindClass failed.\n");
+ goto destroy;
+ }
+
+ args_array = (*env)->NewObjectArray (env, non_vm_argc, string_class_id, NULL);
+ if (args_array == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": NewObjectArray failed.\n");
+ goto destroy;
+ }
+
+ for (i = 0; i < non_vm_argc; i++)
+ {
+ str = (*env)->NewStringUTF (env, non_vm_argv[i]);
+ if (str == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": NewStringUTF failed.\n");
+ goto destroy;
+ }
+
+ (*env)->SetObjectArrayElement (env, args_array, i, str);
+ }
+
+ class_id
+ = (*env)->FindClass (env,
+ "gnu/classpath/tools/" TOOLPACKAGE "/" MAINCLASS);
+ if (class_id == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": FindClass failed.\n");
+ goto destroy;
+ }
+
+ method_id = (*env)->GetStaticMethodID (env, class_id, "main", "([Ljava/lang/String;)V");
+
+ if (method_id == NULL)
+ {
+ fprintf (stderr, TOOLNAME ": GetStaticMethodID failed.\n");
+ goto destroy;
+ }
+
+ (*env)->CallStaticVoidMethod (env, class_id, method_id, args_array);
+
+ destroy:
+
+ if (env != NULL)
+ {
+ if ((*env)->ExceptionOccurred (env))
+ (*env)->ExceptionDescribe (env);
+
+ if (jvm != NULL)
+ (*jvm)->DestroyJavaVM (jvm);
+ }
+
+ /* libltdl cleanup */
+ if (libjvm_handle)
+ {
+ if (lt_dlclose (libjvm_handle) != 0)
+ fprintf (stderr, TOOLNAME ": failed to close " LIBJVM "\n");
+ }
+
+ if (lt_dlexit () != 0)
+ fprintf (stderr, TOOLNAME ": lt_dlexit failed.\n");
+
+ return 1;
+}