From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libjava/classpath/tools/.cvsignore | 19 + libjava/classpath/tools/Makefile.am | 415 +++ libjava/classpath/tools/Makefile.in | 1402 +++++++ libjava/classpath/tools/README | 58 + libjava/classpath/tools/appletviewer.in | 46 + .../asm/org/objectweb/asm/AnnotationVisitor.class | Bin 0 -> 481 bytes .../asm/org/objectweb/asm/AnnotationWriter.class | Bin 0 -> 5344 bytes .../tools/asm/org/objectweb/asm/Attribute.class | Bin 0 -> 2624 bytes .../tools/asm/org/objectweb/asm/ByteVector.class | Bin 0 -> 3259 bytes .../tools/asm/org/objectweb/asm/ClassAdapter.class | Bin 0 -> 2432 bytes .../tools/asm/org/objectweb/asm/ClassReader.class | Bin 0 -> 22143 bytes .../tools/asm/org/objectweb/asm/ClassVisitor.class | Bin 0 -> 894 bytes .../tools/asm/org/objectweb/asm/ClassWriter.class | Bin 0 -> 14071 bytes .../tools/asm/org/objectweb/asm/Edge.class | Bin 0 -> 360 bytes .../tools/asm/org/objectweb/asm/FieldVisitor.class | Bin 0 -> 295 bytes .../tools/asm/org/objectweb/asm/FieldWriter.class | Bin 0 -> 3658 bytes .../tools/asm/org/objectweb/asm/Handler.class | Bin 0 -> 428 bytes .../tools/asm/org/objectweb/asm/Item.class | Bin 0 -> 2190 bytes .../tools/asm/org/objectweb/asm/Label.class | Bin 0 -> 2561 bytes .../asm/org/objectweb/asm/MethodAdapter.class | Bin 0 -> 4363 bytes .../asm/org/objectweb/asm/MethodVisitor.class | Bin 0 -> 1464 bytes .../tools/asm/org/objectweb/asm/MethodWriter.class | Bin 0 -> 20587 bytes .../tools/asm/org/objectweb/asm/Opcodes.class | Bin 0 -> 5782 bytes .../tools/asm/org/objectweb/asm/Type.class | Bin 0 -> 7900 bytes .../objectweb/asm/attrs/StackMapAttribute.class | Bin 0 -> 6499 bytes .../org/objectweb/asm/attrs/StackMapFrame.class | Bin 0 -> 1113 bytes .../asm/attrs/StackMapTableAttribute.class | Bin 0 -> 9987 bytes .../asm/org/objectweb/asm/attrs/StackMapType.class | Bin 0 -> 2422 bytes .../org/objectweb/asm/commons/AdviceAdapter.class | Bin 0 -> 7758 bytes .../org/objectweb/asm/commons/EmptyVisitor.class | Bin 0 -> 5591 bytes .../objectweb/asm/commons/GeneratorAdapter.class | Bin 0 -> 18394 bytes .../asm/commons/LocalVariablesSorter.class | Bin 0 -> 2561 bytes .../asm/org/objectweb/asm/commons/Method.class | Bin 0 -> 3964 bytes .../asm/commons/SerialVersionUIDAdder$Item.class | Bin 0 -> 946 bytes .../asm/commons/SerialVersionUIDAdder.class | Bin 0 -> 5030 bytes .../objectweb/asm/commons/StaticInitMerger.class | Bin 0 -> 2143 bytes .../asm/commons/TableSwitchGenerator.class | Bin 0 -> 234 bytes .../optimizer/AnnotationConstantsCollector.class | Bin 0 -> 3362 bytes .../asm/optimizer/ClassConstantsCollector.class | Bin 0 -> 4492 bytes .../objectweb/asm/optimizer/ClassOptimizer.class | Bin 0 -> 4264 bytes .../asm/org/objectweb/asm/optimizer/Constant.class | Bin 0 -> 3227 bytes .../org/objectweb/asm/optimizer/ConstantPool.class | Bin 0 -> 4508 bytes .../asm/optimizer/FieldConstantsCollector.class | Bin 0 -> 1555 bytes .../org/objectweb/asm/optimizer/JarOptimizer.class | Bin 0 -> 2470 bytes .../asm/optimizer/MethodConstantsCollector.class | Bin 0 -> 4251 bytes .../objectweb/asm/optimizer/MethodOptimizer.class | Bin 0 -> 2637 bytes .../org/objectweb/asm/optimizer/NameMapping.class | Bin 0 -> 2504 bytes .../optimizer/Shrinker$ConstantComparator.class | Bin 0 -> 2004 bytes .../asm/org/objectweb/asm/optimizer/Shrinker.class | Bin 0 -> 4058 bytes .../objectweb/asm/signature/SignatureReader.class | Bin 0 -> 2803 bytes .../objectweb/asm/signature/SignatureVisitor.class | Bin 0 -> 808 bytes .../objectweb/asm/signature/SignatureWriter.class | Bin 0 -> 2981 bytes .../org/objectweb/asm/tree/AbstractInsnNode.class | Bin 0 -> 994 bytes .../org/objectweb/asm/tree/AnnotationNode.class | Bin 0 -> 2730 bytes .../asm/org/objectweb/asm/tree/ClassNode.class | Bin 0 -> 4545 bytes .../asm/org/objectweb/asm/tree/FieldInsnNode.class | Bin 0 -> 996 bytes .../asm/org/objectweb/asm/tree/FieldNode.class | Bin 0 -> 1958 bytes .../asm/org/objectweb/asm/tree/IincInsnNode.class | Bin 0 -> 749 bytes .../org/objectweb/asm/tree/InnerClassNode.class | Bin 0 -> 836 bytes .../asm/org/objectweb/asm/tree/InsnNode.class | Bin 0 -> 994 bytes .../asm/org/objectweb/asm/tree/IntInsnNode.class | Bin 0 -> 819 bytes .../asm/org/objectweb/asm/tree/JumpInsnNode.class | Bin 0 -> 874 bytes .../asm/org/objectweb/asm/tree/LabelNode.class | Bin 0 -> 736 bytes .../asm/org/objectweb/asm/tree/LdcInsnNode.class | Bin 0 -> 729 bytes .../org/objectweb/asm/tree/LineNumberNode.class | Bin 0 -> 709 bytes .../org/objectweb/asm/tree/LocalVariableNode.class | Bin 0 -> 1021 bytes .../objectweb/asm/tree/LookupSwitchInsnNode.class | Bin 0 -> 1626 bytes .../asm/org/objectweb/asm/tree/MemberNode.class | Bin 0 -> 1241 bytes .../org/objectweb/asm/tree/MethodInsnNode.class | Bin 0 -> 1000 bytes .../asm/org/objectweb/asm/tree/MethodNode$1.class | Bin 0 -> 803 bytes .../asm/org/objectweb/asm/tree/MethodNode.class | Bin 0 -> 8654 bytes .../asm/tree/MultiANewArrayInsnNode.class | Bin 0 -> 828 bytes .../objectweb/asm/tree/TableSwitchInsnNode.class | Bin 0 -> 1372 bytes .../org/objectweb/asm/tree/TryCatchBlockNode.class | Bin 0 -> 904 bytes .../asm/org/objectweb/asm/tree/TypeInsnNode.class | Bin 0 -> 858 bytes .../asm/org/objectweb/asm/tree/VarInsnNode.class | Bin 0 -> 815 bytes .../org/objectweb/asm/tree/analysis/Analyzer.class | Bin 0 -> 8867 bytes .../asm/tree/analysis/AnalyzerException.class | Bin 0 -> 1243 bytes .../asm/tree/analysis/BasicInterpreter.class | Bin 0 -> 5974 bytes .../objectweb/asm/tree/analysis/BasicValue.class | Bin 0 -> 1962 bytes .../asm/tree/analysis/BasicVerifier.class | Bin 0 -> 7836 bytes .../asm/tree/analysis/DataflowInterpreter.class | Bin 0 -> 4302 bytes .../asm/tree/analysis/DataflowValue.class | Bin 0 -> 1356 bytes .../org/objectweb/asm/tree/analysis/Frame.class | Bin 0 -> 10023 bytes .../org/objectweb/asm/tree/analysis/IntMap.class | Bin 0 -> 1230 bytes .../objectweb/asm/tree/analysis/Interpreter.class | Bin 0 -> 1312 bytes .../asm/tree/analysis/SimpleVerifier.class | Bin 0 -> 4833 bytes .../org/objectweb/asm/tree/analysis/SmallSet.class | Bin 0 -> 1641 bytes .../objectweb/asm/tree/analysis/Subroutine.class | Bin 0 -> 1836 bytes .../org/objectweb/asm/tree/analysis/Value.class | Bin 0 -> 147 bytes .../asm/util/ASMifierAbstractVisitor.class | Bin 0 -> 4875 bytes .../asm/util/ASMifierAnnotationVisitor.class | Bin 0 -> 2587 bytes .../objectweb/asm/util/ASMifierClassVisitor.class | Bin 0 -> 9817 bytes .../objectweb/asm/util/ASMifierFieldVisitor.class | Bin 0 -> 437 bytes .../objectweb/asm/util/ASMifierMethodVisitor.class | Bin 0 -> 7739 bytes .../org/objectweb/asm/util/AbstractVisitor.class | Bin 0 -> 3823 bytes .../asm/util/CheckAnnotationAdapter.class | Bin 0 -> 2766 bytes .../org/objectweb/asm/util/CheckClassAdapter.class | Bin 0 -> 9732 bytes .../org/objectweb/asm/util/CheckFieldAdapter.class | Bin 0 -> 1588 bytes .../objectweb/asm/util/CheckMethodAdapter.class | Bin 0 -> 13225 bytes .../objectweb/asm/util/TraceAbstractVisitor.class | Bin 0 -> 2593 bytes .../asm/util/TraceAnnotationVisitor.class | Bin 0 -> 5991 bytes .../org/objectweb/asm/util/TraceClassVisitor.class | Bin 0 -> 9174 bytes .../org/objectweb/asm/util/TraceFieldVisitor.class | Bin 0 -> 1141 bytes .../objectweb/asm/util/TraceMethodVisitor.class | Bin 0 -> 10058 bytes .../objectweb/asm/util/TraceSignatureVisitor.class | Bin 0 -> 4781 bytes .../asm/util/attrs/ASMStackMapAttribute.class | Bin 0 -> 5535 bytes .../asm/util/attrs/ASMStackMapTableAttribute.class | Bin 0 -> 5483 bytes .../org/objectweb/asm/util/attrs/ASMifiable.class | Bin 0 -> 210 bytes .../org/objectweb/asm/util/attrs/Traceable.class | Bin 0 -> 189 bytes .../ASMContentHandler$AnnotationDefaultRule.class | Bin 0 -> 1414 bytes ...ASMContentHandler$AnnotationParameterRule.class | Bin 0 -> 1864 bytes .../asm/xml/ASMContentHandler$AnnotationRule.class | Bin 0 -> 1905 bytes ...tentHandler$AnnotationValueAnnotationRule.class | Bin 0 -> 1591 bytes ...SMContentHandler$AnnotationValueArrayRule.class | Bin 0 -> 1512 bytes ...ASMContentHandler$AnnotationValueEnumRule.class | Bin 0 -> 1373 bytes .../ASMContentHandler$AnnotationValueRule.class | Bin 0 -> 1408 bytes .../asm/xml/ASMContentHandler$ClassRule.class | Bin 0 -> 1854 bytes .../asm/xml/ASMContentHandler$ExceptionRule.class | Bin 0 -> 1279 bytes .../asm/xml/ASMContentHandler$ExceptionsRule.class | Bin 0 -> 1814 bytes .../asm/xml/ASMContentHandler$FieldRule.class | Bin 0 -> 1866 bytes .../asm/xml/ASMContentHandler$InnerClassRule.class | Bin 0 -> 1448 bytes .../asm/xml/ASMContentHandler$InterfaceRule.class | Bin 0 -> 1279 bytes .../asm/xml/ASMContentHandler$InterfacesRule.class | Bin 0 -> 1879 bytes .../asm/xml/ASMContentHandler$LabelRule.class | Bin 0 -> 1283 bytes .../asm/xml/ASMContentHandler$LineNumberRule.class | Bin 0 -> 1472 bytes .../asm/xml/ASMContentHandler$LocalVarRule.class | Bin 0 -> 1724 bytes .../ASMContentHandler$LookupSwitchLabelRule.class | Bin 0 -> 1469 bytes .../xml/ASMContentHandler$LookupSwitchRule.class | Bin 0 -> 2483 bytes .../asm/xml/ASMContentHandler$MaxRule.class | Bin 0 -> 1327 bytes .../asm/xml/ASMContentHandler$MethodRule.class | Bin 0 -> 1719 bytes .../asm/xml/ASMContentHandler$Opcode.class | Bin 0 -> 525 bytes .../asm/xml/ASMContentHandler$OpcodeGroup.class | Bin 0 -> 594 bytes .../asm/xml/ASMContentHandler$OpcodesRule.class | Bin 0 -> 3114 bytes .../asm/xml/ASMContentHandler$OuterClassRule.class | Bin 0 -> 1346 bytes .../objectweb/asm/xml/ASMContentHandler$Rule.class | Bin 0 -> 4970 bytes .../asm/xml/ASMContentHandler$RuleSet.class | Bin 0 -> 2077 bytes .../asm/xml/ASMContentHandler$SourceRule.class | Bin 0 -> 1269 bytes .../ASMContentHandler$TableSwitchLabelRule.class | Bin 0 -> 1376 bytes .../xml/ASMContentHandler$TableSwitchRule.class | Bin 0 -> 2406 bytes .../asm/xml/ASMContentHandler$TryCatchRule.class | Bin 0 -> 1541 bytes .../org/objectweb/asm/xml/ASMContentHandler.class | Bin 0 -> 16825 bytes .../xml/Processor$ASMContentHandlerFactory.class | Bin 0 -> 871 bytes .../asm/xml/Processor$ContentHandlerFactory.class | Bin 0 -> 299 bytes .../objectweb/asm/xml/Processor$EntryElement.class | Bin 0 -> 367 bytes .../asm/xml/Processor$InputSlicingHandler.class | Bin 0 -> 2395 bytes .../asm/xml/Processor$OutputSlicingHandler.class | Bin 0 -> 3132 bytes .../asm/xml/Processor$ProtectedInputStream.class | Bin 0 -> 1130 bytes .../objectweb/asm/xml/Processor$SAXWriter.class | Bin 0 -> 4521 bytes .../asm/xml/Processor$SAXWriterFactory.class | Bin 0 -> 867 bytes .../asm/xml/Processor$SingleDocElement.class | Bin 0 -> 930 bytes .../xml/Processor$SubdocumentHandlerFactory.class | Bin 0 -> 781 bytes .../xml/Processor$TransformerHandlerFactory.class | Bin 0 -> 1756 bytes .../asm/xml/Processor$ZipEntryElement.class | Bin 0 -> 1163 bytes .../asm/org/objectweb/asm/xml/Processor.class | Bin 0 -> 11122 bytes .../asm/org/objectweb/asm/xml/SAXAdapter.class | Bin 0 -> 1848 bytes .../objectweb/asm/xml/SAXAnnotationAdapter.class | Bin 0 -> 4628 bytes .../org/objectweb/asm/xml/SAXClassAdapter.class | Bin 0 -> 6837 bytes .../asm/org/objectweb/asm/xml/SAXCodeAdapter.class | Bin 0 -> 7552 bytes .../org/objectweb/asm/xml/SAXFieldAdapter.class | Bin 0 -> 1719 bytes .../tools/classes/com/sun/javadoc/ClassDoc.class | Bin 0 -> 1087 bytes .../classes/com/sun/javadoc/ConstructorDoc.class | Bin 0 -> 215 bytes .../tools/classes/com/sun/javadoc/Doc.class | Bin 0 -> 741 bytes .../classes/com/sun/javadoc/DocErrorReporter.class | Bin 0 -> 219 bytes .../tools/classes/com/sun/javadoc/Doclet.class | Bin 0 -> 750 bytes .../com/sun/javadoc/ExecutableMemberDoc.class | Bin 0 -> 504 bytes .../tools/classes/com/sun/javadoc/FieldDoc.class | Bin 0 -> 405 bytes .../tools/classes/com/sun/javadoc/MemberDoc.class | Bin 0 -> 184 bytes .../tools/classes/com/sun/javadoc/MethodDoc.class | Bin 0 -> 290 bytes .../tools/classes/com/sun/javadoc/PackageDoc.class | Bin 0 -> 351 bytes .../tools/classes/com/sun/javadoc/ParamTag.class | Bin 0 -> 214 bytes .../tools/classes/com/sun/javadoc/Parameter.class | Bin 0 -> 261 bytes .../com/sun/javadoc/ProgramElementDoc.class | Bin 0 -> 508 bytes .../tools/classes/com/sun/javadoc/RootDoc.class | Bin 0 -> 504 bytes .../tools/classes/com/sun/javadoc/SeeTag.class | Bin 0 -> 413 bytes .../classes/com/sun/javadoc/SerialFieldTag.class | Bin 0 -> 363 bytes .../classes/com/sun/javadoc/SourcePosition.class | Bin 0 -> 239 bytes .../tools/classes/com/sun/javadoc/Tag.class | Bin 0 -> 294 bytes .../tools/classes/com/sun/javadoc/ThrowsTag.class | Bin 0 -> 267 bytes .../tools/classes/com/sun/javadoc/Type.class | Bin 0 -> 382 bytes .../classes/com/sun/javadoc/TypeVariable.class | Bin 0 -> 250 bytes .../classes/com/sun/tools/doclets/Taglet.class | Bin 0 -> 419 bytes .../tools/classes/com/sun/tools/javac/Main.class | Bin 0 -> 3764 bytes .../classes/com/sun/tools/javac/Messages.class | Bin 0 -> 1130 bytes .../tools/classes/com/sun/tools/javadoc/Main.class | Bin 0 -> 453 bytes .../tools/classes/com/sun/tools/javah/Main.class | Bin 0 -> 692 bytes .../FileSystemClassLoader$FileStreamInfo.class | Bin 0 -> 1086 bytes .../FileSystemClassLoader$JarStreamInfo.class | Bin 0 -> 1741 bytes .../tools/FileSystemClassLoader$StreamInfo.class | Bin 0 -> 446 bytes .../classpath/tools/FileSystemClassLoader.class | Bin 0 -> 6253 bytes .../classes/gnu/classpath/tools/IOToolkit.class | Bin 0 -> 3753 bytes .../gnu/classpath/tools/MalformedInputEvent.class | Bin 0 -> 1267 bytes .../classpath/tools/MalformedInputListener.class | Bin 0 -> 228 bytes .../tools/NotifyingInputStreamReader.class | Bin 0 -> 5878 bytes .../gnu/classpath/tools/StringToolkit.class | Bin 0 -> 1124 bytes .../tools/appletviewer/AppletClassLoader.class | Bin 0 -> 935 bytes .../tools/appletviewer/AppletSecurityManager.class | Bin 0 -> 1193 bytes .../classpath/tools/appletviewer/AppletTag.class | Bin 0 -> 8668 bytes .../tools/appletviewer/CommonAppletContext.class | Bin 0 -> 2750 bytes .../tools/appletviewer/CommonAppletStub.class | Bin 0 -> 1891 bytes .../classpath/tools/appletviewer/ErrorApplet.class | Bin 0 -> 648 bytes .../gnu/classpath/tools/appletviewer/Main$1.class | Bin 0 -> 828 bytes .../gnu/classpath/tools/appletviewer/Main$10.class | Bin 0 -> 801 bytes .../gnu/classpath/tools/appletviewer/Main$2.class | Bin 0 -> 828 bytes .../gnu/classpath/tools/appletviewer/Main$3.class | Bin 0 -> 828 bytes .../gnu/classpath/tools/appletviewer/Main$4.class | Bin 0 -> 973 bytes .../gnu/classpath/tools/appletviewer/Main$5.class | Bin 0 -> 974 bytes .../gnu/classpath/tools/appletviewer/Main$6.class | Bin 0 -> 915 bytes .../gnu/classpath/tools/appletviewer/Main$7.class | Bin 0 -> 1067 bytes .../gnu/classpath/tools/appletviewer/Main$8.class | Bin 0 -> 831 bytes .../gnu/classpath/tools/appletviewer/Main$9.class | Bin 0 -> 799 bytes .../gnu/classpath/tools/appletviewer/Main.class | Bin 0 -> 8053 bytes .../classpath/tools/appletviewer/Messages.class | Bin 0 -> 1169 bytes .../tools/appletviewer/PluginAppletContext.class | Bin 0 -> 1320 bytes .../tools/appletviewer/PluginAppletViewer.class | Bin 0 -> 3918 bytes .../tools/appletviewer/PluginAppletWindow.class | Bin 0 -> 8194 bytes .../appletviewer/StandaloneAppletContext.class | Bin 0 -> 1397 bytes .../appletviewer/StandaloneAppletViewer.class | Bin 0 -> 4309 bytes .../appletviewer/StandaloneAppletWindow$1.class | Bin 0 -> 1119 bytes .../appletviewer/StandaloneAppletWindow.class | Bin 0 -> 11928 bytes .../classpath/tools/appletviewer/TagParser.class | Bin 0 -> 6630 bytes .../gnu/classpath/tools/common/CallbackUtil.class | Bin 0 -> 2816 bytes .../tools/common/ClasspathToolParser$1.class | Bin 0 -> 1028 bytes .../tools/common/ClasspathToolParser$2.class | Bin 0 -> 983 bytes ...lasspathToolParser$AtFileArgumentCallback.class | Bin 0 -> 1727 bytes .../tools/common/ClasspathToolParser.class | Bin 0 -> 4028 bytes .../gnu/classpath/tools/common/Messages.class | Bin 0 -> 1151 bytes .../tools/common/Persistent$ExitTask.class | Bin 0 -> 532 bytes .../gnu/classpath/tools/common/Persistent.class | Bin 0 -> 570 bytes .../classpath/tools/common/ProviderUtil$1.class | Bin 0 -> 891 bytes .../classpath/tools/common/ProviderUtil$2.class | Bin 0 -> 705 bytes .../gnu/classpath/tools/common/ProviderUtil.class | Bin 0 -> 2879 bytes .../tools/common/SecurityProviderInfo.class | Bin 0 -> 1215 bytes .../doclets/AbstractDoclet$DocletOptionGroup.class | Bin 0 -> 2075 bytes .../doclets/AbstractDoclet$DocletOptionTag.class | Bin 0 -> 3296 bytes .../AbstractDoclet$DocletOptionTaglet.class | Bin 0 -> 4359 bytes .../AbstractDoclet$DocletOptionTagletPath.class | Bin 0 -> 955 bytes .../tools/doclets/AbstractDoclet$IndexKey.class | Bin 0 -> 1129 bytes .../doclets/AbstractDoclet$InterfaceRelation.class | Bin 0 -> 663 bytes .../tools/doclets/AbstractDoclet$UsageType.class | Bin 0 -> 1848 bytes .../classpath/tools/doclets/AbstractDoclet.class | Bin 0 -> 27182 bytes .../doclets/DocletConfigurationException.class | Bin 0 -> 432 bytes .../gnu/classpath/tools/doclets/DocletOption.class | Bin 0 -> 575 bytes .../tools/doclets/DocletOptionColonSeparated.class | Bin 0 -> 1139 bytes .../classpath/tools/doclets/DocletOptionFile.class | Bin 0 -> 962 bytes .../classpath/tools/doclets/DocletOptionFlag.class | Bin 0 -> 755 bytes .../doclets/DocletOptionPackageWildcard.class | Bin 0 -> 2108 bytes .../tools/doclets/DocletOptionString.class | Bin 0 -> 776 bytes .../tools/doclets/InlineTagRenderer.class | Bin 0 -> 258 bytes .../doclets/InvalidPackageWildcardException.class | Bin 0 -> 437 bytes .../gnu/classpath/tools/doclets/PackageGroup.class | Bin 0 -> 698 bytes .../classpath/tools/doclets/PackageMatcher.class | Bin 0 -> 2907 bytes .../classpath/tools/doclets/StandardTaglet.class | Bin 0 -> 1341 bytes .../classpath/tools/doclets/TagletPrinter.class | Bin 0 -> 187 bytes .../tools/doclets/debugdoclet/DebugDoclet.class | Bin 0 -> 4081 bytes .../tools/doclets/htmldoclet/CssClass.class | Bin 0 -> 14612 bytes .../tools/doclets/htmldoclet/ExternalDocSet.class | Bin 0 -> 3836 bytes .../tools/doclets/htmldoclet/HtmlDoclet$1.class | Bin 0 -> 1205 bytes .../tools/doclets/htmldoclet/HtmlDoclet$2.class | Bin 0 -> 1207 bytes .../tools/doclets/htmldoclet/HtmlDoclet$3.class | Bin 0 -> 1401 bytes .../doclets/htmldoclet/HtmlDoclet$TreeNode.class | Bin 0 -> 1088 bytes .../tools/doclets/htmldoclet/HtmlDoclet.class | Bin 0 -> 79930 bytes .../tools/doclets/htmldoclet/HtmlPage.class | Bin 0 -> 12297 bytes .../doclets/htmldoclet/HtmlTagletContext.class | Bin 0 -> 876 bytes .../tools/doclets/xmldoclet/Driver$1.class | Bin 0 -> 935 bytes .../xmldoclet/Driver$NullErrorReporter.class | Bin 0 -> 793 bytes .../tools/doclets/xmldoclet/Driver$UsageType.class | Bin 0 -> 1537 bytes .../classpath/tools/doclets/xmldoclet/Driver.class | Bin 0 -> 52598 bytes .../tools/doclets/xmldoclet/Driver1_4.class | Bin 0 -> 955 bytes .../doclets/xmldoclet/HtmlRepairer$TagInfo.class | Bin 0 -> 1043 bytes .../tools/doclets/xmldoclet/HtmlRepairer.class | Bin 0 -> 10463 bytes .../tools/doclets/xmldoclet/TargetContext.class | Bin 0 -> 1172 bytes .../DocTranslet$DocErrorReporterOutputStream.class | Bin 0 -> 1093 bytes .../xmldoclet/doctranslet/DocTranslet.class | Bin 0 -> 14435 bytes .../DocTransletConfigurationException.class | Bin 0 -> 774 bytes .../doctranslet/DocTransletException.class | Bin 0 -> 1218 bytes .../xmldoclet/doctranslet/DocTransletOptions.class | Bin 0 -> 865 bytes .../xmldoclet/doctranslet/JarClassLoader.class | Bin 0 -> 2127 bytes .../xmldoclet/doctranslet/OutputFileInfo.class | Bin 0 -> 1467 bytes .../tools/getopt/FileArgumentCallback.class | Bin 0 -> 459 bytes .../gnu/classpath/tools/getopt/Messages.class | Bin 0 -> 1151 bytes .../gnu/classpath/tools/getopt/Option.class | Bin 0 -> 2640 bytes .../classpath/tools/getopt/OptionException.class | Bin 0 -> 565 bytes .../gnu/classpath/tools/getopt/OptionGroup.class | Bin 0 -> 3894 bytes .../gnu/classpath/tools/getopt/Parser$1.class | Bin 0 -> 1061 bytes .../gnu/classpath/tools/getopt/Parser$2.class | Bin 0 -> 1119 bytes .../gnu/classpath/tools/getopt/Parser$3.class | Bin 0 -> 904 bytes .../gnu/classpath/tools/getopt/Parser.class | Bin 0 -> 8255 bytes .../classpath/tools/gjdoc/AbstractTagImpl.class | Bin 0 -> 2825 bytes .../tools/gjdoc/ArrayCharacterIterator.class | Bin 0 -> 1762 bytes .../tools/gjdoc/BlockSourceComponent.class | Bin 0 -> 629 bytes .../gnu/classpath/tools/gjdoc/BracketClose.class | Bin 0 -> 862 bytes .../gnu/classpath/tools/gjdoc/ClassComponent.class | Bin 0 -> 2610 bytes .../gnu/classpath/tools/gjdoc/ClassDocImpl.class | Bin 0 -> 25782 bytes .../gnu/classpath/tools/gjdoc/ClassDocProxy.class | Bin 0 -> 7577 bytes .../tools/gjdoc/ClassDocReflectedImpl.class | Bin 0 -> 8685 bytes .../classpath/tools/gjdoc/CommentComponent.class | Bin 0 -> 1517 bytes .../classpath/tools/gjdoc/ConstructorDocImpl.class | Bin 0 -> 757 bytes .../classes/gnu/classpath/tools/gjdoc/Debug.class | Bin 0 -> 1447 bytes .../tools/gjdoc/DirectoryTree$FileNode.class | Bin 0 -> 943 bytes .../gnu/classpath/tools/gjdoc/DirectoryTree.class | Bin 0 -> 1226 bytes .../gnu/classpath/tools/gjdoc/DocImpl.class | Bin 0 -> 19116 bytes .../tools/gjdoc/EmptyStatementComponent.class | Bin 0 -> 612 bytes .../gnu/classpath/tools/gjdoc/ErrorReporter.class | Bin 0 -> 1660 bytes .../tools/gjdoc/ExecutableMemberDocImpl.class | Bin 0 -> 9289 bytes .../gnu/classpath/tools/gjdoc/FieldComponent.class | Bin 0 -> 3110 bytes .../gnu/classpath/tools/gjdoc/FieldDocImpl.class | Bin 0 -> 8266 bytes .../classpath/tools/gjdoc/FunctionComponent.class | Bin 0 -> 2992 bytes .../classpath/tools/gjdoc/GjdocPackageDoc.class | Bin 0 -> 217 bytes .../gnu/classpath/tools/gjdoc/GjdocRootDoc.class | Bin 0 -> 184 bytes .../tools/gjdoc/IgnoredFileParseException.class | Bin 0 -> 357 bytes .../classpath/tools/gjdoc/ImportComponent.class | Bin 0 -> 1226 bytes .../classpath/tools/gjdoc/InheritDocTagImpl.class | Bin 0 -> 1838 bytes .../gnu/classpath/tools/gjdoc/JavadocWrapper.class | Bin 0 -> 960 bytes .../gnu/classpath/tools/gjdoc/LinkTagImpl.class | Bin 0 -> 918 bytes .../classes/gnu/classpath/tools/gjdoc/Main$1.class | Bin 0 -> 825 bytes .../gnu/classpath/tools/gjdoc/Main$10.class | Bin 0 -> 1221 bytes .../gnu/classpath/tools/gjdoc/Main$11.class | Bin 0 -> 1728 bytes .../gnu/classpath/tools/gjdoc/Main$12.class | Bin 0 -> 1799 bytes .../gnu/classpath/tools/gjdoc/Main$13.class | Bin 0 -> 1800 bytes .../gnu/classpath/tools/gjdoc/Main$14.class | Bin 0 -> 1002 bytes .../gnu/classpath/tools/gjdoc/Main$15.class | Bin 0 -> 924 bytes .../gnu/classpath/tools/gjdoc/Main$16.class | Bin 0 -> 1715 bytes .../gnu/classpath/tools/gjdoc/Main$17.class | Bin 0 -> 828 bytes .../gnu/classpath/tools/gjdoc/Main$18.class | Bin 0 -> 809 bytes .../gnu/classpath/tools/gjdoc/Main$19.class | Bin 0 -> 809 bytes .../classes/gnu/classpath/tools/gjdoc/Main$2.class | Bin 0 -> 767 bytes .../gnu/classpath/tools/gjdoc/Main$20.class | Bin 0 -> 1382 bytes .../gnu/classpath/tools/gjdoc/Main$21.class | Bin 0 -> 1401 bytes .../gnu/classpath/tools/gjdoc/Main$22.class | Bin 0 -> 809 bytes .../gnu/classpath/tools/gjdoc/Main$23.class | Bin 0 -> 809 bytes .../gnu/classpath/tools/gjdoc/Main$24.class | Bin 0 -> 809 bytes .../gnu/classpath/tools/gjdoc/Main$25.class | Bin 0 -> 809 bytes .../classes/gnu/classpath/tools/gjdoc/Main$3.class | Bin 0 -> 767 bytes .../classes/gnu/classpath/tools/gjdoc/Main$4.class | Bin 0 -> 767 bytes .../classes/gnu/classpath/tools/gjdoc/Main$5.class | Bin 0 -> 767 bytes .../classes/gnu/classpath/tools/gjdoc/Main$6.class | Bin 0 -> 806 bytes .../classes/gnu/classpath/tools/gjdoc/Main$7.class | Bin 0 -> 825 bytes .../classes/gnu/classpath/tools/gjdoc/Main$8.class | Bin 0 -> 825 bytes .../classes/gnu/classpath/tools/gjdoc/Main$9.class | Bin 0 -> 806 bytes .../tools/gjdoc/Main$OptionProcessor.class | Bin 0 -> 727 bytes .../classes/gnu/classpath/tools/gjdoc/Main.class | Bin 0 -> 29338 bytes .../gnu/classpath/tools/gjdoc/MemberDocImpl.class | Bin 0 -> 5337 bytes .../gnu/classpath/tools/gjdoc/MethodDocImpl.class | Bin 0 -> 1247 bytes .../classpath/tools/gjdoc/PackageComponent.class | Bin 0 -> 1142 bytes .../gnu/classpath/tools/gjdoc/PackageDocImpl.class | Bin 0 -> 5798 bytes .../gnu/classpath/tools/gjdoc/ParamTagImpl.class | Bin 0 -> 1368 bytes .../gnu/classpath/tools/gjdoc/ParameterImpl.class | Bin 0 -> 1682 bytes .../gnu/classpath/tools/gjdoc/ParseException.class | Bin 0 -> 463 bytes .../gnu/classpath/tools/gjdoc/Parser$1.class | Bin 0 -> 1669 bytes .../gnu/classpath/tools/gjdoc/Parser$Context.class | Bin 0 -> 1209 bytes .../classes/gnu/classpath/tools/gjdoc/Parser.class | Bin 0 -> 13190 bytes .../tools/gjdoc/ProgramElementDocImpl.class | Bin 0 -> 3566 bytes .../tools/gjdoc/RootDocImpl$ResolvedImport.class | Bin 0 -> 403 bytes .../RootDocImpl$ResolvedImportClassFile.class | Bin 0 -> 3100 bytes .../gjdoc/RootDocImpl$ResolvedImportNotFound.class | Bin 0 -> 1664 bytes .../RootDocImpl$ResolvedImportPackageFile.class | Bin 0 -> 3932 bytes ...RootDocImpl$ResolvedImportReflectionClass.class | Bin 0 -> 1980 bytes ...otDocImpl$ResolvedImportReflectionPackage.class | Bin 0 -> 2039 bytes .../tools/gjdoc/RootDocImpl$ScheduledClass.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/gjdoc/RootDocImpl.class | Bin 0 -> 20655 bytes .../gnu/classpath/tools/gjdoc/SeeTagImpl.class | Bin 0 -> 4114 bytes .../classpath/tools/gjdoc/SerialFieldTagImpl.class | Bin 0 -> 2862 bytes .../tools/gjdoc/SlashSlashCommentComponent.class | Bin 0 -> 556 bytes .../classpath/tools/gjdoc/SourceComponent.class | Bin 0 -> 787 bytes .../classpath/tools/gjdoc/SourcePositionImpl.class | Bin 0 -> 1095 bytes .../tools/gjdoc/StaticBlockComponent.class | Bin 0 -> 1030 bytes .../gnu/classpath/tools/gjdoc/TagContainer.class | Bin 0 -> 247 bytes .../gnu/classpath/tools/gjdoc/TagImpl.class | Bin 0 -> 1350 bytes .../gnu/classpath/tools/gjdoc/TemporaryStore.class | Bin 0 -> 548 bytes .../gnu/classpath/tools/gjdoc/TextTagImpl.class | Bin 0 -> 1026 bytes .../gnu/classpath/tools/gjdoc/ThrowsTagImpl.class | Bin 0 -> 2479 bytes .../classes/gnu/classpath/tools/gjdoc/Timer.class | Bin 0 -> 2568 bytes .../gnu/classpath/tools/gjdoc/TimerDoclet$1.class | Bin 0 -> 900 bytes .../gnu/classpath/tools/gjdoc/TimerDoclet.class | Bin 0 -> 2637 bytes .../gnu/classpath/tools/gjdoc/TypeImpl.class | Bin 0 -> 2694 bytes .../classpath/tools/gjdoc/TypeVariableImpl.class | Bin 0 -> 1292 bytes .../gnu/classpath/tools/gjdoc/ValueTagImpl.class | Bin 0 -> 1032 bytes .../gnu/classpath/tools/gjdoc/Whitespace.class | Bin 0 -> 591 bytes .../gnu/classpath/tools/gjdoc/WritableType.class | Bin 0 -> 309 bytes .../tools/gjdoc/expr/AdditionExpression.class | Bin 0 -> 2306 bytes .../classpath/tools/gjdoc/expr/AndExpression.class | Bin 0 -> 756 bytes .../tools/gjdoc/expr/BinaryBitwiseExpression.class | Bin 0 -> 1711 bytes .../gjdoc/expr/BinaryComputationExpression.class | Bin 0 -> 2769 bytes .../gjdoc/expr/BinaryEqualityExpression.class | Bin 0 -> 2071 bytes .../tools/gjdoc/expr/BinaryExpression.class | Bin 0 -> 615 bytes .../tools/gjdoc/expr/BinaryLogicalExpression.class | Bin 0 -> 1593 bytes .../gjdoc/expr/BinaryRelationExpression.class | Bin 0 -> 1928 bytes .../tools/gjdoc/expr/BinaryShiftExpression.class | Bin 0 -> 1691 bytes .../tools/gjdoc/expr/BitShiftRightExpression.class | Bin 0 -> 784 bytes .../gjdoc/expr/CircularExpressionException.class | Bin 0 -> 618 bytes .../tools/gjdoc/expr/ConditionalExpression.class | Bin 0 -> 1670 bytes .../tools/gjdoc/expr/ConstantBoolean.class | Bin 0 -> 1371 bytes .../classpath/tools/gjdoc/expr/ConstantByte.class | Bin 0 -> 1082 bytes .../classpath/tools/gjdoc/expr/ConstantChar.class | Bin 0 -> 1634 bytes .../tools/gjdoc/expr/ConstantDouble.class | Bin 0 -> 1288 bytes .../tools/gjdoc/expr/ConstantExpression.class | Bin 0 -> 787 bytes .../classpath/tools/gjdoc/expr/ConstantFloat.class | Bin 0 -> 1448 bytes .../tools/gjdoc/expr/ConstantInteger.class | Bin 0 -> 1378 bytes .../classpath/tools/gjdoc/expr/ConstantLong.class | Bin 0 -> 1599 bytes .../classpath/tools/gjdoc/expr/ConstantNull.class | Bin 0 -> 829 bytes .../classpath/tools/gjdoc/expr/ConstantShort.class | Bin 0 -> 1088 bytes .../tools/gjdoc/expr/ConstantString.class | Bin 0 -> 1025 bytes .../gnu/classpath/tools/gjdoc/expr/Context.class | Bin 0 -> 818 bytes .../tools/gjdoc/expr/DivisionExpression.class | Bin 0 -> 959 bytes .../tools/gjdoc/expr/EqualExpression.class | Bin 0 -> 1067 bytes .../gnu/classpath/tools/gjdoc/expr/Evaluator.class | Bin 0 -> 3343 bytes .../tools/gjdoc/expr/EvaluatorEnvironment.class | Bin 0 -> 378 bytes .../tools/gjdoc/expr/ExclusiveOrExpression.class | Bin 0 -> 780 bytes .../classpath/tools/gjdoc/expr/Expression.class | Bin 0 -> 333 bytes .../tools/gjdoc/expr/GreaterThanExpression.class | Bin 0 -> 988 bytes .../gjdoc/expr/GreaterThanOrEqualExpression.class | Bin 0 -> 1009 bytes .../tools/gjdoc/expr/IdentifierExpression.class | Bin 0 -> 2874 bytes .../gjdoc/expr/IllegalExpressionException.class | Bin 0 -> 577 bytes .../tools/gjdoc/expr/InclusiveOrExpression.class | Bin 0 -> 773 bytes .../gnu/classpath/tools/gjdoc/expr/JavaLexer.class | Bin 0 -> 27040 bytes .../tools/gjdoc/expr/JavaRecognizer.class | Bin 0 -> 22390 bytes .../tools/gjdoc/expr/JavaTokenTypes.class | Bin 0 -> 3902 bytes .../tools/gjdoc/expr/LessThanExpression.class | Bin 0 -> 979 bytes .../gjdoc/expr/LessThanOrEqualExpression.class | Bin 0 -> 1000 bytes .../tools/gjdoc/expr/LogicalAndExpression.class | Bin 0 -> 693 bytes .../tools/gjdoc/expr/LogicalNotExpression.class | Bin 0 -> 1557 bytes .../tools/gjdoc/expr/LogicalOrExpression.class | Bin 0 -> 683 bytes .../tools/gjdoc/expr/ModuloExpression.class | Bin 0 -> 953 bytes .../gjdoc/expr/MultiplicationExpression.class | Bin 0 -> 977 bytes .../tools/gjdoc/expr/NegateExpression.class | Bin 0 -> 1696 bytes .../tools/gjdoc/expr/NotEqualExpression.class | Bin 0 -> 1071 bytes .../classpath/tools/gjdoc/expr/NotExpression.class | Bin 0 -> 1467 bytes .../tools/gjdoc/expr/ShiftLeftExpression.class | Bin 0 -> 772 bytes .../tools/gjdoc/expr/ShiftRightExpression.class | Bin 0 -> 775 bytes .../tools/gjdoc/expr/SubtractionExpression.class | Bin 0 -> 968 bytes .../gnu/classpath/tools/gjdoc/expr/Type.class | Bin 0 -> 1204 bytes .../tools/gjdoc/expr/TypeCastExpression.class | Bin 0 -> 2687 bytes .../tools/gjdoc/expr/UnaryExpression.class | Bin 0 -> 524 bytes .../gjdoc/expr/UnknownIdentifierException.class | Bin 0 -> 473 bytes .../classes/gnu/classpath/tools/jar/Action.class | Bin 0 -> 393 bytes .../classes/gnu/classpath/tools/jar/Creator.class | Bin 0 -> 7270 bytes .../classes/gnu/classpath/tools/jar/Entry.class | Bin 0 -> 873 bytes .../gnu/classpath/tools/jar/Extractor.class | Bin 0 -> 2938 bytes .../classes/gnu/classpath/tools/jar/Indexer.class | Bin 0 -> 4278 bytes .../classes/gnu/classpath/tools/jar/Lister.class | Bin 0 -> 2941 bytes .../classes/gnu/classpath/tools/jar/Main$1.class | Bin 0 -> 977 bytes .../classes/gnu/classpath/tools/jar/Main$2.class | Bin 0 -> 916 bytes .../classes/gnu/classpath/tools/jar/Main$3.class | Bin 0 -> 912 bytes .../classes/gnu/classpath/tools/jar/Main$4.class | Bin 0 -> 917 bytes .../classes/gnu/classpath/tools/jar/Main$5.class | Bin 0 -> 1027 bytes .../classes/gnu/classpath/tools/jar/Main$6.class | Bin 0 -> 979 bytes .../classes/gnu/classpath/tools/jar/Main$7.class | Bin 0 -> 923 bytes .../gnu/classpath/tools/jar/Main$HandleFile.class | Bin 0 -> 1151 bytes .../gnu/classpath/tools/jar/Main$JarParser.class | Bin 0 -> 1469 bytes .../gnu/classpath/tools/jar/Main$ModeOption.class | Bin 0 -> 1413 bytes .../classes/gnu/classpath/tools/jar/Main.class | Bin 0 -> 5683 bytes .../classes/gnu/classpath/tools/jar/Messages.class | Bin 0 -> 1142 bytes .../classes/gnu/classpath/tools/jar/Updater.class | Bin 0 -> 2785 bytes .../classes/gnu/classpath/tools/jar/WorkSet.class | Bin 0 -> 1708 bytes .../gnu/classpath/tools/jarsigner/HashUtils.class | Bin 0 -> 2530 bytes .../gnu/classpath/tools/jarsigner/JarSigner.class | Bin 0 -> 5541 bytes .../classpath/tools/jarsigner/JarVerifier.class | Bin 0 -> 9461 bytes .../gnu/classpath/tools/jarsigner/Main$1.class | Bin 0 -> 1187 bytes .../gnu/classpath/tools/jarsigner/Main$10.class | Bin 0 -> 1136 bytes .../gnu/classpath/tools/jarsigner/Main$11.class | Bin 0 -> 1138 bytes .../gnu/classpath/tools/jarsigner/Main$12.class | Bin 0 -> 1201 bytes .../gnu/classpath/tools/jarsigner/Main$2.class | Bin 0 -> 1188 bytes .../gnu/classpath/tools/jarsigner/Main$3.class | Bin 0 -> 1192 bytes .../gnu/classpath/tools/jarsigner/Main$4.class | Bin 0 -> 1190 bytes .../gnu/classpath/tools/jarsigner/Main$5.class | Bin 0 -> 1193 bytes .../gnu/classpath/tools/jarsigner/Main$6.class | Bin 0 -> 1199 bytes .../gnu/classpath/tools/jarsigner/Main$7.class | Bin 0 -> 1130 bytes .../gnu/classpath/tools/jarsigner/Main$8.class | Bin 0 -> 1129 bytes .../gnu/classpath/tools/jarsigner/Main$9.class | Bin 0 -> 1131 bytes .../tools/jarsigner/Main$ToolParser.class | Bin 0 -> 3938 bytes .../tools/jarsigner/Main$ToolParserCallback.class | Bin 0 -> 1000 bytes .../gnu/classpath/tools/jarsigner/Main.class | Bin 0 -> 12108 bytes .../gnu/classpath/tools/jarsigner/Messages.class | Bin 0 -> 2707 bytes .../gnu/classpath/tools/jarsigner/SFHelper.class | Bin 0 -> 11445 bytes .../tools/java2xhtml/Java2xhtml$State.class | Bin 0 -> 900 bytes .../classpath/tools/java2xhtml/Java2xhtml.class | Bin 0 -> 26673 bytes .../gnu/classpath/tools/javah/ClassWrapper.class | Bin 0 -> 9260 bytes .../classpath/tools/javah/CniIncludePrinter.class | Bin 0 -> 1929 bytes .../gnu/classpath/tools/javah/CniPrintStream.class | Bin 0 -> 5411 bytes .../gnu/classpath/tools/javah/CniStubPrinter.class | Bin 0 -> 4087 bytes .../gnu/classpath/tools/javah/FieldHelper.class | Bin 0 -> 2118 bytes .../gnu/classpath/tools/javah/GcjhMain$1.class | Bin 0 -> 1195 bytes .../gnu/classpath/tools/javah/GcjhMain$2.class | Bin 0 -> 1195 bytes .../gnu/classpath/tools/javah/GcjhMain$3.class | Bin 0 -> 1195 bytes .../gnu/classpath/tools/javah/GcjhMain$4.class | Bin 0 -> 1195 bytes .../gnu/classpath/tools/javah/GcjhMain$5.class | Bin 0 -> 990 bytes .../gnu/classpath/tools/javah/GcjhMain$6.class | Bin 0 -> 928 bytes .../gnu/classpath/tools/javah/GcjhMain$7.class | Bin 0 -> 928 bytes .../gnu/classpath/tools/javah/GcjhMain$8.class | Bin 0 -> 928 bytes .../gnu/classpath/tools/javah/GcjhMain$9.class | Bin 0 -> 928 bytes .../gnu/classpath/tools/javah/GcjhMain.class | Bin 0 -> 3098 bytes .../gnu/classpath/tools/javah/JniHelper.class | Bin 0 -> 2909 bytes .../classpath/tools/javah/JniIncludePrinter.class | Bin 0 -> 4600 bytes .../gnu/classpath/tools/javah/JniPrintStream.class | Bin 0 -> 3289 bytes .../gnu/classpath/tools/javah/JniStubPrinter.class | Bin 0 -> 3599 bytes .../gnu/classpath/tools/javah/Keywords.class | Bin 0 -> 3638 bytes .../classes/gnu/classpath/tools/javah/Main$1.class | Bin 0 -> 1002 bytes .../gnu/classpath/tools/javah/Main$10.class | Bin 0 -> 941 bytes .../classes/gnu/classpath/tools/javah/Main$2.class | Bin 0 -> 1119 bytes .../classes/gnu/classpath/tools/javah/Main$3.class | Bin 0 -> 1124 bytes .../classes/gnu/classpath/tools/javah/Main$4.class | Bin 0 -> 1007 bytes .../classes/gnu/classpath/tools/javah/Main$5.class | Bin 0 -> 1069 bytes .../classes/gnu/classpath/tools/javah/Main$6.class | Bin 0 -> 939 bytes .../classes/gnu/classpath/tools/javah/Main$7.class | Bin 0 -> 1064 bytes .../classes/gnu/classpath/tools/javah/Main$8.class | Bin 0 -> 1064 bytes .../classes/gnu/classpath/tools/javah/Main$9.class | Bin 0 -> 973 bytes .../classes/gnu/classpath/tools/javah/Main.class | Bin 0 -> 11933 bytes .../gnu/classpath/tools/javah/MethodHelper.class | Bin 0 -> 2993 bytes .../gnu/classpath/tools/javah/PackageWrapper.class | Bin 0 -> 500 bytes .../classpath/tools/javah/PathOptionGroup$1.class | Bin 0 -> 939 bytes .../classpath/tools/javah/PathOptionGroup$2.class | Bin 0 -> 1104 bytes .../classpath/tools/javah/PathOptionGroup$3.class | Bin 0 -> 1104 bytes .../classpath/tools/javah/PathOptionGroup$4.class | Bin 0 -> 1103 bytes .../classpath/tools/javah/PathOptionGroup$5.class | Bin 0 -> 1108 bytes .../classpath/tools/javah/PathOptionGroup$6.class | Bin 0 -> 1107 bytes .../classpath/tools/javah/PathOptionGroup.class | Bin 0 -> 3678 bytes .../gnu/classpath/tools/javah/Printer.class | Bin 0 -> 2159 bytes .../classes/gnu/classpath/tools/javah/Text.class | Bin 0 -> 565 bytes .../gnu/classpath/tools/keytool/CACertCmd$1.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/keytool/CACertCmd$2.class | Bin 0 -> 1030 bytes .../gnu/classpath/tools/keytool/CACertCmd$3.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/CACertCmd$4.class | Bin 0 -> 1034 bytes .../gnu/classpath/tools/keytool/CACertCmd$5.class | Bin 0 -> 1041 bytes .../gnu/classpath/tools/keytool/CACertCmd$6.class | Bin 0 -> 972 bytes .../gnu/classpath/tools/keytool/CACertCmd.class | Bin 0 -> 6606 bytes .../gnu/classpath/tools/keytool/CertReqCmd$1.class | Bin 0 -> 1035 bytes .../classpath/tools/keytool/CertReqCmd$10.class | Bin 0 -> 987 bytes .../gnu/classpath/tools/keytool/CertReqCmd$2.class | Bin 0 -> 1042 bytes .../gnu/classpath/tools/keytool/CertReqCmd$3.class | Bin 0 -> 1045 bytes .../gnu/classpath/tools/keytool/CertReqCmd$4.class | Bin 0 -> 1038 bytes .../gnu/classpath/tools/keytool/CertReqCmd$5.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/keytool/CertReqCmd$6.class | Bin 0 -> 1035 bytes .../gnu/classpath/tools/keytool/CertReqCmd$7.class | Bin 0 -> 1040 bytes .../gnu/classpath/tools/keytool/CertReqCmd$8.class | Bin 0 -> 1047 bytes .../gnu/classpath/tools/keytool/CertReqCmd$9.class | Bin 0 -> 978 bytes .../gnu/classpath/tools/keytool/CertReqCmd.class | Bin 0 -> 10372 bytes .../tools/keytool/Command$ShutdownHook.class | Bin 0 -> 780 bytes .../gnu/classpath/tools/keytool/Command.class | Bin 0 -> 19742 bytes .../gnu/classpath/tools/keytool/DeleteCmd$1.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/DeleteCmd$2.class | Bin 0 -> 1030 bytes .../gnu/classpath/tools/keytool/DeleteCmd$3.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/DeleteCmd$4.class | Bin 0 -> 1034 bytes .../gnu/classpath/tools/keytool/DeleteCmd$5.class | Bin 0 -> 1041 bytes .../gnu/classpath/tools/keytool/DeleteCmd$6.class | Bin 0 -> 972 bytes .../gnu/classpath/tools/keytool/DeleteCmd.class | Bin 0 -> 5720 bytes .../gnu/classpath/tools/keytool/ExportCmd$1.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/ExportCmd$2.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/keytool/ExportCmd$3.class | Bin 0 -> 1030 bytes .../gnu/classpath/tools/keytool/ExportCmd$4.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/ExportCmd$5.class | Bin 0 -> 1034 bytes .../gnu/classpath/tools/keytool/ExportCmd$6.class | Bin 0 -> 1041 bytes .../gnu/classpath/tools/keytool/ExportCmd$7.class | Bin 0 -> 968 bytes .../gnu/classpath/tools/keytool/ExportCmd$8.class | Bin 0 -> 972 bytes .../gnu/classpath/tools/keytool/ExportCmd.class | Bin 0 -> 6735 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$1.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$10.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$11.class | Bin 0 -> 1043 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$12.class | Bin 0 -> 974 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$2.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$3.class | Bin 0 -> 1034 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$4.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$5.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$6.class | Bin 0 -> 1032 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$7.class | Bin 0 -> 1035 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$8.class | Bin 0 -> 1030 bytes .../gnu/classpath/tools/keytool/GenKeyCmd$9.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/GenKeyCmd.class | Bin 0 -> 12086 bytes .../classpath/tools/keytool/IdentityDBCmd$1.class | Bin 0 -> 1059 bytes .../classpath/tools/keytool/IdentityDBCmd$2.class | Bin 0 -> 1054 bytes .../classpath/tools/keytool/IdentityDBCmd$3.class | Bin 0 -> 1053 bytes .../classpath/tools/keytool/IdentityDBCmd$4.class | Bin 0 -> 1058 bytes .../classpath/tools/keytool/IdentityDBCmd$5.class | Bin 0 -> 1065 bytes .../classpath/tools/keytool/IdentityDBCmd$6.class | Bin 0 -> 996 bytes .../classpath/tools/keytool/IdentityDBCmd.class | Bin 0 -> 4563 bytes .../gnu/classpath/tools/keytool/ImportCmd$1.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/ImportCmd$10.class | Bin 0 -> 974 bytes .../gnu/classpath/tools/keytool/ImportCmd$2.class | Bin 0 -> 1036 bytes .../gnu/classpath/tools/keytool/ImportCmd$3.class | Bin 0 -> 1032 bytes .../gnu/classpath/tools/keytool/ImportCmd$4.class | Bin 0 -> 973 bytes .../gnu/classpath/tools/keytool/ImportCmd$5.class | Bin 0 -> 977 bytes .../gnu/classpath/tools/keytool/ImportCmd$6.class | Bin 0 -> 1030 bytes .../gnu/classpath/tools/keytool/ImportCmd$7.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/ImportCmd$8.class | Bin 0 -> 1034 bytes .../gnu/classpath/tools/keytool/ImportCmd$9.class | Bin 0 -> 1041 bytes .../gnu/classpath/tools/keytool/ImportCmd.class | Bin 0 -> 17528 bytes .../classpath/tools/keytool/KeyCloneCmd$1.class | Bin 0 -> 1041 bytes .../classpath/tools/keytool/KeyCloneCmd$2.class | Bin 0 -> 1045 bytes .../classpath/tools/keytool/KeyCloneCmd$3.class | Bin 0 -> 1044 bytes .../classpath/tools/keytool/KeyCloneCmd$4.class | Bin 0 -> 1047 bytes .../classpath/tools/keytool/KeyCloneCmd$5.class | Bin 0 -> 1042 bytes .../classpath/tools/keytool/KeyCloneCmd$6.class | Bin 0 -> 1041 bytes .../classpath/tools/keytool/KeyCloneCmd$7.class | Bin 0 -> 1046 bytes .../classpath/tools/keytool/KeyCloneCmd$8.class | Bin 0 -> 1053 bytes .../classpath/tools/keytool/KeyCloneCmd$9.class | Bin 0 -> 984 bytes .../gnu/classpath/tools/keytool/KeyCloneCmd.class | Bin 0 -> 8733 bytes .../classpath/tools/keytool/KeyPasswdCmd$1.class | Bin 0 -> 1047 bytes .../classpath/tools/keytool/KeyPasswdCmd$2.class | Bin 0 -> 1050 bytes .../classpath/tools/keytool/KeyPasswdCmd$3.class | Bin 0 -> 1053 bytes .../classpath/tools/keytool/KeyPasswdCmd$4.class | Bin 0 -> 1048 bytes .../classpath/tools/keytool/KeyPasswdCmd$5.class | Bin 0 -> 1047 bytes .../classpath/tools/keytool/KeyPasswdCmd$6.class | Bin 0 -> 1052 bytes .../classpath/tools/keytool/KeyPasswdCmd$7.class | Bin 0 -> 1059 bytes .../classpath/tools/keytool/KeyPasswdCmd$8.class | Bin 0 -> 990 bytes .../gnu/classpath/tools/keytool/KeyPasswdCmd.class | Bin 0 -> 8305 bytes .../gnu/classpath/tools/keytool/ListCmd$1.class | Bin 0 -> 1017 bytes .../gnu/classpath/tools/keytool/ListCmd$2.class | Bin 0 -> 1018 bytes .../gnu/classpath/tools/keytool/ListCmd$3.class | Bin 0 -> 1017 bytes .../gnu/classpath/tools/keytool/ListCmd$4.class | Bin 0 -> 1022 bytes .../gnu/classpath/tools/keytool/ListCmd$5.class | Bin 0 -> 1029 bytes .../gnu/classpath/tools/keytool/ListCmd$6.class | Bin 0 -> 960 bytes .../gnu/classpath/tools/keytool/ListCmd$7.class | Bin 0 -> 956 bytes .../gnu/classpath/tools/keytool/ListCmd.class | Bin 0 -> 8706 bytes .../tools/keytool/Main$NoParseOption.class | Bin 0 -> 1130 bytes .../tools/keytool/Main$ShutdownHook.class | Bin 0 -> 756 bytes .../classes/gnu/classpath/tools/keytool/Main.class | Bin 0 -> 8838 bytes .../gnu/classpath/tools/keytool/Messages.class | Bin 0 -> 2614 bytes .../classpath/tools/keytool/PrintCertCmd$1.class | Bin 0 -> 1054 bytes .../classpath/tools/keytool/PrintCertCmd$2.class | Bin 0 -> 990 bytes .../gnu/classpath/tools/keytool/PrintCertCmd.class | Bin 0 -> 3871 bytes .../classpath/tools/keytool/SelfCertCmd$1.class | Bin 0 -> 1041 bytes .../classpath/tools/keytool/SelfCertCmd$10.class | Bin 0 -> 986 bytes .../classpath/tools/keytool/SelfCertCmd$2.class | Bin 0 -> 1048 bytes .../classpath/tools/keytool/SelfCertCmd$3.class | Bin 0 -> 1041 bytes .../classpath/tools/keytool/SelfCertCmd$4.class | Bin 0 -> 1044 bytes .../classpath/tools/keytool/SelfCertCmd$5.class | Bin 0 -> 1047 bytes .../classpath/tools/keytool/SelfCertCmd$6.class | Bin 0 -> 1042 bytes .../classpath/tools/keytool/SelfCertCmd$7.class | Bin 0 -> 1041 bytes .../classpath/tools/keytool/SelfCertCmd$8.class | Bin 0 -> 1046 bytes .../classpath/tools/keytool/SelfCertCmd$9.class | Bin 0 -> 1053 bytes .../gnu/classpath/tools/keytool/SelfCertCmd.class | Bin 0 -> 8750 bytes .../classpath/tools/keytool/StorePasswdCmd$1.class | Bin 0 -> 1065 bytes .../classpath/tools/keytool/StorePasswdCmd$2.class | Bin 0 -> 1060 bytes .../classpath/tools/keytool/StorePasswdCmd$3.class | Bin 0 -> 1059 bytes .../classpath/tools/keytool/StorePasswdCmd$4.class | Bin 0 -> 1064 bytes .../classpath/tools/keytool/StorePasswdCmd$5.class | Bin 0 -> 1071 bytes .../classpath/tools/keytool/StorePasswdCmd$6.class | Bin 0 -> 1002 bytes .../classpath/tools/keytool/StorePasswdCmd.class | Bin 0 -> 7050 bytes .../classpath/tools/native2ascii/Messages.class | Bin 0 -> 1169 bytes .../tools/native2ascii/Native2ASCII$1.class | Bin 0 -> 1264 bytes .../tools/native2ascii/Native2ASCII$2.class | Bin 0 -> 1019 bytes .../tools/native2ascii/Native2ASCII$3.class | Bin 0 -> 1019 bytes .../native2ascii/Native2ASCII$HandleFile.class | Bin 0 -> 1088 bytes .../tools/native2ascii/Native2ASCII.class | Bin 0 -> 4205 bytes .../classes/gnu/classpath/tools/orbd/Main$1.class | Bin 0 -> 1106 bytes .../classes/gnu/classpath/tools/orbd/Main$2.class | Bin 0 -> 1052 bytes .../classes/gnu/classpath/tools/orbd/Main$3.class | Bin 0 -> 1048 bytes .../classes/gnu/classpath/tools/orbd/Main$4.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/orbd/Main$5.class | Bin 0 -> 721 bytes .../classes/gnu/classpath/tools/orbd/Main.class | Bin 0 -> 5476 bytes .../gnu/classpath/tools/orbd/Messages.class | Bin 0 -> 1145 bytes .../classpath/tools/orbd/PersistentContext.class | Bin 0 -> 3047 bytes .../tools/orbd/PersistentContextMap.class | Bin 0 -> 1138 bytes .../classpath/tools/orbd/PersistentMap$Entry.class | Bin 0 -> 2457 bytes .../gnu/classpath/tools/orbd/PersistentMap.class | Bin 0 -> 5547 bytes .../tools/rmic/AbstractMethodGenerator.class | Bin 0 -> 232 bytes .../tools/rmic/ClassRmicCompiler$MethodRef.class | Bin 0 -> 2719 bytes .../classpath/tools/rmic/ClassRmicCompiler.class | Bin 0 -> 30526 bytes .../classpath/tools/rmic/CompilationError.class | Bin 0 -> 624 bytes .../gnu/classpath/tools/rmic/Generator.class | Bin 0 -> 2901 bytes .../classes/gnu/classpath/tools/rmic/GiopIo.class | Bin 0 -> 2777 bytes .../gnu/classpath/tools/rmic/HashFinder.class | Bin 0 -> 1064 bytes .../classes/gnu/classpath/tools/rmic/Main$1.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmic/Main$10.class | Bin 0 -> 971 bytes .../classes/gnu/classpath/tools/rmic/Main$11.class | Bin 0 -> 900 bytes .../classes/gnu/classpath/tools/rmic/Main$12.class | Bin 0 -> 971 bytes .../classes/gnu/classpath/tools/rmic/Main$13.class | Bin 0 -> 971 bytes .../classes/gnu/classpath/tools/rmic/Main$14.class | Bin 0 -> 971 bytes .../classes/gnu/classpath/tools/rmic/Main$15.class | Bin 0 -> 1039 bytes .../classes/gnu/classpath/tools/rmic/Main$16.class | Bin 0 -> 972 bytes .../classes/gnu/classpath/tools/rmic/Main$17.class | Bin 0 -> 1039 bytes .../classes/gnu/classpath/tools/rmic/Main$18.class | Bin 0 -> 900 bytes .../classes/gnu/classpath/tools/rmic/Main$2.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmic/Main$3.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmic/Main$4.class | Bin 0 -> 1048 bytes .../classes/gnu/classpath/tools/rmic/Main$5.class | Bin 0 -> 1048 bytes .../classes/gnu/classpath/tools/rmic/Main$6.class | Bin 0 -> 960 bytes .../classes/gnu/classpath/tools/rmic/Main$7.class | Bin 0 -> 960 bytes .../classes/gnu/classpath/tools/rmic/Main$8.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmic/Main$9.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmic/Main.class | Bin 0 -> 6058 bytes .../gnu/classpath/tools/rmic/Messages.class | Bin 0 -> 1145 bytes .../gnu/classpath/tools/rmic/MethodGenerator.class | Bin 0 -> 5280 bytes .../gnu/classpath/tools/rmic/RMICException.class | Bin 0 -> 555 bytes .../classpath/tools/rmic/RmiMethodGenerator.class | Bin 0 -> 5116 bytes .../gnu/classpath/tools/rmic/RmicBackend.class | Bin 0 -> 271 bytes .../tools/rmic/SourceGiopRmicCompiler.class | Bin 0 -> 12269 bytes .../classpath/tools/rmic/SourceRmicCompiler.class | Bin 0 -> 3894 bytes .../gnu/classpath/tools/rmic/Variables.class | Bin 0 -> 3290 bytes .../gnu/classpath/tools/rmic/WrapUnWrapper.class | Bin 0 -> 1244 bytes .../tools/rmid/ActivationSystemImpl.class | Bin 0 -> 5285 bytes .../tools/rmid/ActivationSystemImpl_Stub.class | Bin 0 -> 8775 bytes .../classes/gnu/classpath/tools/rmid/Main$1.class | Bin 0 -> 1084 bytes .../classes/gnu/classpath/tools/rmid/Main$2.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmid/Main$3.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmid/Main$4.class | Bin 0 -> 969 bytes .../classes/gnu/classpath/tools/rmid/Main$5.class | Bin 0 -> 1048 bytes .../classes/gnu/classpath/tools/rmid/Main$6.class | Bin 0 -> 983 bytes .../classes/gnu/classpath/tools/rmid/Main.class | Bin 0 -> 5921 bytes .../gnu/classpath/tools/rmid/Messages.class | Bin 0 -> 1145 bytes .../PersistentBidiHashTable$AdaptedReader.class | Bin 0 -> 1111 bytes .../PersistentBidiHashTable$WriteToDiskTask.class | Bin 0 -> 755 bytes .../tools/rmid/PersistentBidiHashTable.class | Bin 0 -> 4185 bytes .../gnu/classpath/tools/rmiregistry/Main$1.class | Bin 0 -> 1011 bytes .../gnu/classpath/tools/rmiregistry/Main$2.class | Bin 0 -> 1011 bytes .../gnu/classpath/tools/rmiregistry/Main$3.class | Bin 0 -> 1011 bytes .../gnu/classpath/tools/rmiregistry/Main$4.class | Bin 0 -> 1090 bytes .../gnu/classpath/tools/rmiregistry/Main$5.class | Bin 0 -> 965 bytes .../gnu/classpath/tools/rmiregistry/Main$6.class | Bin 0 -> 883 bytes .../gnu/classpath/tools/rmiregistry/Main.class | Bin 0 -> 5715 bytes .../gnu/classpath/tools/rmiregistry/Messages.class | Bin 0 -> 1166 bytes .../PersistentHashTable$WriteToDiskTask.class | Bin 0 -> 766 bytes .../tools/rmiregistry/PersistentHashTable.class | Bin 0 -> 4109 bytes .../classpath/tools/rmiregistry/RegistryImpl.class | Bin 0 -> 2955 bytes .../tools/rmiregistry/RegistryImpl_Skel.class | Bin 0 -> 4191 bytes .../tools/rmiregistry/RegistryImpl_Stub.class | Bin 0 -> 3829 bytes .../gnu/classpath/tools/serialver/Messages.class | Bin 0 -> 1160 bytes .../classpath/tools/serialver/SerialVer$1.class | Bin 0 -> 1171 bytes .../classpath/tools/serialver/SerialVer$2.class | Bin 0 -> 1197 bytes .../classpath/tools/serialver/SerialVer$3.class | Bin 0 -> 950 bytes .../gnu/classpath/tools/serialver/SerialVer.class | Bin 0 -> 4636 bytes .../taglets/AuthorTaglet$EmailReplacement.class | Bin 0 -> 714 bytes .../gnu/classpath/tools/taglets/AuthorTaglet.class | Bin 0 -> 4878 bytes .../gnu/classpath/tools/taglets/CodeTaglet.class | Bin 0 -> 1529 bytes .../classpath/tools/taglets/CopyrightTaglet.class | Bin 0 -> 2366 bytes .../classpath/tools/taglets/DeprecatedTaglet.class | Bin 0 -> 2371 bytes .../classpath/tools/taglets/GenericTaglet.class | Bin 0 -> 2708 bytes .../tools/taglets/GnuExtendedTaglet.class | Bin 0 -> 381 bytes .../gnu/classpath/tools/taglets/SinceTaglet.class | Bin 0 -> 2962 bytes .../classpath/tools/taglets/TagletContext.class | Bin 0 -> 858 bytes .../gnu/classpath/tools/taglets/ValueTaglet.class | Bin 0 -> 2695 bytes .../classpath/tools/taglets/VersionTaglet.class | Bin 0 -> 2580 bytes .../gnu/classpath/tools/tnameserv/Main$1.class | Bin 0 -> 1136 bytes .../gnu/classpath/tools/tnameserv/Main$2.class | Bin 0 -> 1082 bytes .../gnu/classpath/tools/tnameserv/Main.class | Bin 0 -> 2391 bytes .../gnu/classpath/tools/tnameserv/Messages.class | Bin 0 -> 1160 bytes .../gcj/tools/gc_analyze/BlockMap$PtrMarks.class | Bin 0 -> 612 bytes .../gcj/tools/gc_analyze/BlockMap$SizeKind.class | Bin 0 -> 1004 bytes .../gnu/gcj/tools/gc_analyze/BlockMap.class | Bin 0 -> 5443 bytes .../classes/gnu/gcj/tools/gc_analyze/BytePtr.class | Bin 0 -> 2466 bytes .../gnu/gcj/tools/gc_analyze/ItemList.class | Bin 0 -> 3477 bytes .../tools/gc_analyze/MemoryAnalyze$1$Info.class | Bin 0 -> 510 bytes .../gnu/gcj/tools/gc_analyze/MemoryAnalyze$1.class | Bin 0 -> 1109 bytes .../gnu/gcj/tools/gc_analyze/MemoryAnalyze$2.class | Bin 0 -> 1109 bytes .../gnu/gcj/tools/gc_analyze/MemoryAnalyze$3.class | Bin 0 -> 1073 bytes .../gnu/gcj/tools/gc_analyze/MemoryAnalyze$4.class | Bin 0 -> 1086 bytes .../gc_analyze/MemoryAnalyze$OptionParser.class | Bin 0 -> 2636 bytes .../MemoryAnalyze$SubstringComparator.class | Bin 0 -> 1269 bytes .../gnu/gcj/tools/gc_analyze/MemoryAnalyze.class | Bin 0 -> 10680 bytes .../gnu/gcj/tools/gc_analyze/MemoryMap$Range.class | Bin 0 -> 714 bytes .../gc_analyze/MemoryMap$RangeComparator.class | Bin 0 -> 1080 bytes .../gnu/gcj/tools/gc_analyze/MemoryMap.class | Bin 0 -> 7398 bytes .../tools/gc_analyze/ObjectMap$ObjectItem.class | Bin 0 -> 894 bytes .../gnu/gcj/tools/gc_analyze/ObjectMap.class | Bin 0 -> 4140 bytes .../gnu/gcj/tools/gc_analyze/SymbolLookup.class | Bin 0 -> 2485 bytes .../gnu/gcj/tools/gc_analyze/SymbolTable.class | Bin 0 -> 5783 bytes .../gnu/gcj/tools/gc_analyze/ToolPrefix.class | Bin 0 -> 1051 bytes .../tools/classes/sun/rmi/rmic/Main.class | Bin 0 -> 985 bytes .../tools/classes/sun/rmi/rmic/Messages.class | Bin 0 -> 1109 bytes .../classpath/tools/com/sun/javadoc/ClassDoc.java | 321 ++ .../tools/com/sun/javadoc/ConstructorDoc.java | 56 + libjava/classpath/tools/com/sun/javadoc/Doc.java | 264 ++ .../tools/com/sun/javadoc/DocErrorReporter.java | 76 + .../classpath/tools/com/sun/javadoc/Doclet.java | 98 + .../tools/com/sun/javadoc/ExecutableMemberDoc.java | 137 + .../classpath/tools/com/sun/javadoc/FieldDoc.java | 112 + .../classpath/tools/com/sun/javadoc/MemberDoc.java | 59 + .../classpath/tools/com/sun/javadoc/MethodDoc.java | 79 + .../tools/com/sun/javadoc/PackageDoc.java | 108 + .../classpath/tools/com/sun/javadoc/ParamTag.java | 65 + .../classpath/tools/com/sun/javadoc/Parameter.java | 87 + .../tools/com/sun/javadoc/ProgramElementDoc.java | 169 + .../classpath/tools/com/sun/javadoc/RootDoc.java | 111 + .../classpath/tools/com/sun/javadoc/SeeTag.java | 108 + .../tools/com/sun/javadoc/SerialFieldTag.java | 101 + .../tools/com/sun/javadoc/SourcePosition.java | 68 + libjava/classpath/tools/com/sun/javadoc/Tag.java | 106 + .../classpath/tools/com/sun/javadoc/ThrowsTag.java | 75 + libjava/classpath/tools/com/sun/javadoc/Type.java | 119 + .../tools/com/sun/javadoc/TypeVariable.java | 73 + .../tools/com/sun/tools/doclets/Taglet.java | 63 + .../classpath/tools/com/sun/tools/javac/Main.java | 158 + .../tools/com/sun/tools/javac/Messages.java | 67 + .../tools/com/sun/tools/javadoc/Main.java | 46 + .../classpath/tools/com/sun/tools/javah/Main.java | 58 + .../asm/org/objectweb/asm/AnnotationVisitor.java | 88 + .../asm/org/objectweb/asm/AnnotationWriter.java | 311 ++ .../external/asm/org/objectweb/asm/Attribute.java | 254 ++ .../external/asm/org/objectweb/asm/ByteVector.java | 293 ++ .../asm/org/objectweb/asm/ClassAdapter.java | 121 + .../asm/org/objectweb/asm/ClassReader.java | 1606 ++++++++ .../asm/org/objectweb/asm/ClassVisitor.java | 195 + .../asm/org/objectweb/asm/ClassWriter.java | 1162 ++++++ .../tools/external/asm/org/objectweb/asm/Edge.java | 57 + .../asm/org/objectweb/asm/FieldVisitor.java | 63 + .../asm/org/objectweb/asm/FieldWriter.java | 276 ++ .../external/asm/org/objectweb/asm/Handler.java | 70 + .../tools/external/asm/org/objectweb/asm/Item.java | 252 ++ .../external/asm/org/objectweb/asm/Label.java | 299 ++ .../asm/org/objectweb/asm/MethodAdapter.java | 185 + .../asm/org/objectweb/asm/MethodVisitor.java | 334 ++ .../asm/org/objectweb/asm/MethodWriter.java | 2022 ++++++++++ .../external/asm/org/objectweb/asm/Opcodes.java | 295 ++ .../tools/external/asm/org/objectweb/asm/Type.java | 760 ++++ .../org/objectweb/asm/attrs/StackMapAttribute.java | 378 ++ .../asm/org/objectweb/asm/attrs/StackMapFrame.java | 82 + .../asm/attrs/StackMapTableAttribute.java | 927 +++++ .../asm/org/objectweb/asm/attrs/StackMapType.java | 114 + .../org/objectweb/asm/commons/AdviceAdapter.java | 642 ++++ .../org/objectweb/asm/commons/EmptyVisitor.java | 211 ++ .../objectweb/asm/commons/GeneratorAdapter.java | 1454 ++++++++ .../asm/commons/LocalVariablesSorter.java | 136 + .../asm/org/objectweb/asm/commons/Method.java | 220 ++ .../asm/commons/SerialVersionUIDAdder.java | 490 +++ .../objectweb/asm/commons/StaticInitMerger.java | 99 + .../asm/commons/TableSwitchGenerator.java | 55 + .../optimizer/AnnotationConstantsCollector.java | 150 + .../asm/optimizer/ClassConstantsCollector.java | 212 ++ .../objectweb/asm/optimizer/ClassOptimizer.java | 182 + .../asm/org/objectweb/asm/optimizer/Constant.java | 265 ++ .../org/objectweb/asm/optimizer/ConstantPool.java | 198 + .../asm/optimizer/FieldConstantsCollector.java | 76 + .../org/objectweb/asm/optimizer/JarOptimizer.java | 87 + .../asm/optimizer/MethodConstantsCollector.java | 168 + .../objectweb/asm/optimizer/MethodOptimizer.java | 108 + .../org/objectweb/asm/optimizer/NameMapping.java | 101 + .../asm/org/objectweb/asm/optimizer/Shrinker.java | 168 + .../org/objectweb/asm/optimizer/shrink.properties | 225 ++ .../objectweb/asm/signature/SignatureReader.java | 233 ++ .../objectweb/asm/signature/SignatureVisitor.java | 185 + .../objectweb/asm/signature/SignatureWriter.java | 207 ++ .../org/objectweb/asm/tree/AbstractInsnNode.java | 143 + .../asm/org/objectweb/asm/tree/AnnotationNode.java | 187 + .../asm/org/objectweb/asm/tree/ClassNode.java | 283 ++ .../asm/org/objectweb/asm/tree/FieldInsnNode.java | 97 + .../asm/org/objectweb/asm/tree/FieldNode.java | 123 + .../asm/org/objectweb/asm/tree/IincInsnNode.java | 71 + .../asm/org/objectweb/asm/tree/InnerClassNode.java | 101 + .../asm/org/objectweb/asm/tree/InsnNode.java | 96 + .../asm/org/objectweb/asm/tree/IntInsnNode.java | 75 + .../asm/org/objectweb/asm/tree/JumpInsnNode.java | 84 + .../asm/org/objectweb/asm/tree/LabelNode.java | 54 + .../asm/org/objectweb/asm/tree/LdcInsnNode.java | 68 + .../asm/org/objectweb/asm/tree/LineNumberNode.java | 73 + .../org/objectweb/asm/tree/LocalVariableNode.java | 111 + .../objectweb/asm/tree/LookupSwitchInsnNode.java | 103 + .../asm/org/objectweb/asm/tree/MemberNode.java | 120 + .../asm/org/objectweb/asm/tree/MethodInsnNode.java | 98 + .../asm/org/objectweb/asm/tree/MethodNode.java | 439 +++ .../objectweb/asm/tree/MultiANewArrayInsnNode.java | 71 + .../objectweb/asm/tree/TableSwitchInsnNode.java | 102 + .../org/objectweb/asm/tree/TryCatchBlockNode.java | 93 + .../asm/org/objectweb/asm/tree/TypeInsnNode.java | 78 + .../asm/org/objectweb/asm/tree/VarInsnNode.java | 81 + .../org/objectweb/asm/tree/analysis/Analyzer.java | 416 +++ .../asm/tree/analysis/AnalyzerException.java | 56 + .../asm/tree/analysis/BasicInterpreter.java | 335 ++ .../objectweb/asm/tree/analysis/BasicValue.java | 105 + .../objectweb/asm/tree/analysis/BasicVerifier.java | 428 +++ .../asm/tree/analysis/DataflowInterpreter.java | 174 + .../objectweb/asm/tree/analysis/DataflowValue.java | 92 + .../asm/org/objectweb/asm/tree/analysis/Frame.java | 670 ++++ .../org/objectweb/asm/tree/analysis/IntMap.java | 73 + .../objectweb/asm/tree/analysis/Interpreter.java | 178 + .../asm/tree/analysis/SimpleVerifier.java | 266 ++ .../org/objectweb/asm/tree/analysis/SmallSet.java | 126 + .../objectweb/asm/tree/analysis/Subroutine.java | 96 + .../asm/org/objectweb/asm/tree/analysis/Value.java | 45 + .../asm/util/ASMifierAbstractVisitor.java | 226 ++ .../asm/util/ASMifierAnnotationVisitor.java | 127 + .../objectweb/asm/util/ASMifierClassVisitor.java | 607 +++ .../objectweb/asm/util/ASMifierFieldVisitor.java | 50 + .../objectweb/asm/util/ASMifierMethodVisitor.java | 347 ++ .../org/objectweb/asm/util/AbstractVisitor.java | 201 + .../objectweb/asm/util/CheckAnnotationAdapter.java | 125 + .../org/objectweb/asm/util/CheckClassAdapter.java | 416 +++ .../org/objectweb/asm/util/CheckFieldAdapter.java | 75 + .../org/objectweb/asm/util/CheckMethodAdapter.java | 942 +++++ .../objectweb/asm/util/TraceAbstractVisitor.java | 180 + .../objectweb/asm/util/TraceAnnotationVisitor.java | 272 ++ .../org/objectweb/asm/util/TraceClassVisitor.java | 534 +++ .../org/objectweb/asm/util/TraceFieldVisitor.java | 78 + .../org/objectweb/asm/util/TraceMethodVisitor.java | 486 +++ .../objectweb/asm/util/TraceSignatureVisitor.java | 300 ++ .../asm/util/attrs/ASMStackMapAttribute.java | 223 ++ .../asm/util/attrs/ASMStackMapTableAttribute.java | 214 ++ .../org/objectweb/asm/util/attrs/ASMifiable.java | 53 + .../org/objectweb/asm/util/attrs/Traceable.java | 52 + .../org/objectweb/asm/xml/ASMContentHandler.java | 1215 ++++++ .../asm/org/objectweb/asm/xml/Processor.java | 1048 ++++++ .../asm/org/objectweb/asm/xml/SAXAdapter.java | 91 + .../objectweb/asm/xml/SAXAnnotationAdapter.java | 191 + .../asm/org/objectweb/asm/xml/SAXClassAdapter.java | 351 ++ .../asm/org/objectweb/asm/xml/SAXCodeAdapter.java | 310 ++ .../asm/org/objectweb/asm/xml/SAXFieldAdapter.java | 77 + libjava/classpath/tools/gappletviewer.in | 47 + .../gnu/classpath/tools/gjdoc/expr/JavaLexer.java | 1962 ++++++++++ .../gnu/classpath/tools/gjdoc/expr/JavaLexer.smap | 1280 +++++++ .../classpath/tools/gjdoc/expr/JavaRecognizer.java | 1406 +++++++ .../classpath/tools/gjdoc/expr/JavaRecognizer.smap | 987 +++++ .../classpath/tools/gjdoc/expr/JavaTokenTypes.java | 122 + .../classpath/tools/gjdoc/expr/JavaTokenTypes.txt | 116 + libjava/classpath/tools/gjar.in | 48 + libjava/classpath/tools/gjarsigner.in | 48 + libjava/classpath/tools/gjavah.in | 48 + libjava/classpath/tools/gjdoc.in | 49 + libjava/classpath/tools/gkeytool.in | 48 + libjava/classpath/tools/gnative2ascii.in | 48 + .../gnu/classpath/tools/FileSystemClassLoader.java | 312 ++ .../tools/gnu/classpath/tools/IOToolkit.java | 216 ++ .../gnu/classpath/tools/MalformedInputEvent.java | 110 + .../classpath/tools/MalformedInputListener.java | 56 + .../tools/NotifyingInputStreamReader.java | 423 +++ .../tools/gnu/classpath/tools/StringToolkit.java | 84 + .../tools/appletviewer/AppletClassLoader.java | 81 + .../tools/appletviewer/AppletSecurityManager.java | 95 + .../classpath/tools/appletviewer/AppletTag.java | 489 +++ .../tools/appletviewer/CommonAppletContext.java | 133 + .../tools/appletviewer/CommonAppletStub.java | 139 + .../classpath/tools/appletviewer/ErrorApplet.java | 53 + .../gnu/classpath/tools/appletviewer/Main.java | 323 ++ .../gnu/classpath/tools/appletviewer/Messages.java | 67 + .../tools/appletviewer/PluginAppletContext.java | 72 + .../tools/appletviewer/PluginAppletViewer.java | 178 + .../tools/appletviewer/PluginAppletWindow.java | 448 +++ .../appletviewer/StandaloneAppletContext.java | 76 + .../tools/appletviewer/StandaloneAppletViewer.java | 148 + .../tools/appletviewer/StandaloneAppletWindow.java | 560 +++ .../classpath/tools/appletviewer/TagParser.java | 356 ++ .../gnu/classpath/tools/common/CallbackUtil.java | 145 + .../tools/common/ClasspathToolParser.java | 239 ++ .../tools/gnu/classpath/tools/common/Messages.java | 67 + .../gnu/classpath/tools/common/Persistent.java | 87 + .../gnu/classpath/tools/common/ProviderUtil.java | 163 + .../tools/common/SecurityProviderInfo.java | 99 + .../classpath/tools/doclets/AbstractDoclet.java | 1386 +++++++ .../doclets/DocletConfigurationException.java | 54 + .../gnu/classpath/tools/doclets/DocletOption.java | 56 + .../tools/doclets/DocletOptionColonSeparated.java | 76 + .../classpath/tools/doclets/DocletOptionFile.java | 77 + .../classpath/tools/doclets/DocletOptionFlag.java | 69 + .../tools/doclets/DocletOptionPackageWildcard.java | 124 + .../tools/doclets/DocletOptionString.java | 68 + .../classpath/tools/doclets/InlineTagRenderer.java | 46 + .../doclets/InvalidPackageWildcardException.java | 51 + .../gnu/classpath/tools/doclets/PackageGroup.java | 58 + .../classpath/tools/doclets/PackageMatcher.java | 152 + .../classpath/tools/doclets/StandardTaglet.java | 100 + .../gnu/classpath/tools/doclets/TagletPrinter.java | 46 + .../tools/doclets/debugdoclet/DebugDoclet.java | 174 + .../tools/doclets/htmldoclet/CssClass.java | 300 ++ .../tools/doclets/htmldoclet/ExternalDocSet.java | 187 + .../tools/doclets/htmldoclet/HtmlDoclet.java | 3887 ++++++++++++++++++++ .../tools/doclets/htmldoclet/HtmlPage.java | 535 +++ .../doclets/htmldoclet/HtmlTagletContext.java | 65 + .../classpath/tools/doclets/xmldoclet/Driver.java | 2451 ++++++++++++ .../tools/doclets/xmldoclet/Driver1_4.java | 84 + .../tools/doclets/xmldoclet/HtmlRepairer.java | 690 ++++ .../tools/doclets/xmldoclet/TargetContext.java | 103 + .../doclets/xmldoclet/doctranslet/DocTranslet.java | 460 +++ .../DocTransletConfigurationException.java | 53 + .../doctranslet/DocTransletException.java | 63 + .../xmldoclet/doctranslet/DocTransletOptions.java | 62 + .../xmldoclet/doctranslet/JarClassLoader.java | 91 + .../xmldoclet/doctranslet/OutputFileInfo.java | 66 + .../tools/getopt/FileArgumentCallback.java | 62 + .../tools/gnu/classpath/tools/getopt/Messages.java | 67 + .../tools/gnu/classpath/tools/getopt/Option.java | 266 ++ .../classpath/tools/getopt/OptionException.java | 58 + .../gnu/classpath/tools/getopt/OptionGroup.java | 268 ++ .../tools/gnu/classpath/tools/getopt/Parser.java | 495 +++ .../gnu/classpath/tools/gjdoc/AbstractTagImpl.java | 107 + .../tools/gjdoc/ArrayCharacterIterator.java | 121 + .../gnu/classpath/tools/gjdoc/ClassDocImpl.java | 1260 +++++++ .../gnu/classpath/tools/gjdoc/ClassDocProxy.java | 169 + .../tools/gjdoc/ClassDocReflectedImpl.java | 219 ++ .../classpath/tools/gjdoc/ConstructorDocImpl.java | 59 + .../tools/gnu/classpath/tools/gjdoc/Debug.java | 67 + .../gnu/classpath/tools/gjdoc/DirectoryTree.java | 74 + .../tools/gnu/classpath/tools/gjdoc/DocImpl.java | 1090 ++++++ .../gnu/classpath/tools/gjdoc/ErrorReporter.java | 121 + .../tools/gjdoc/ExecutableMemberDocImpl.java | 427 +++ .../gnu/classpath/tools/gjdoc/FieldDocImpl.java | 409 ++ .../gnu/classpath/tools/gjdoc/GjdocPackageDoc.java | 56 + .../gnu/classpath/tools/gjdoc/GjdocRootDoc.java | 56 + .../classpath/tools/gjdoc/InheritDocTagImpl.java | 103 + .../gnu/classpath/tools/gjdoc/JavadocWrapper.java | 53 + .../gnu/classpath/tools/gjdoc/LinkTagImpl.java | 63 + .../tools/gnu/classpath/tools/gjdoc/Main.java | 1854 ++++++++++ .../gnu/classpath/tools/gjdoc/MemberDocImpl.java | 235 ++ .../gnu/classpath/tools/gjdoc/MethodDocImpl.java | 64 + .../gnu/classpath/tools/gjdoc/PackageDocImpl.java | 223 ++ .../gnu/classpath/tools/gjdoc/ParamTagImpl.java | 81 + .../gnu/classpath/tools/gjdoc/ParameterImpl.java | 69 + .../gnu/classpath/tools/gjdoc/ParseException.java | 51 + .../tools/gnu/classpath/tools/gjdoc/Parser.java | 1064 ++++++ .../tools/gjdoc/ProgramElementDocImpl.java | 177 + .../gnu/classpath/tools/gjdoc/RootDocImpl.java | 1334 +++++++ .../gnu/classpath/tools/gjdoc/SeeTagImpl.java | 215 ++ .../classpath/tools/gjdoc/SerialFieldTagImpl.java | 128 + .../classpath/tools/gjdoc/SourcePositionImpl.java | 77 + .../gnu/classpath/tools/gjdoc/TagContainer.java | 52 + .../tools/gnu/classpath/tools/gjdoc/TagImpl.java | 60 + .../gnu/classpath/tools/gjdoc/TemporaryStore.java | 132 + .../gnu/classpath/tools/gjdoc/TextTagImpl.java | 56 + .../gnu/classpath/tools/gjdoc/ThrowsTagImpl.java | 105 + .../tools/gnu/classpath/tools/gjdoc/Timer.java | 88 + .../gnu/classpath/tools/gjdoc/TimerDoclet.java | 104 + .../tools/gnu/classpath/tools/gjdoc/TypeImpl.java | 109 + .../classpath/tools/gjdoc/TypeVariableImpl.java | 108 + .../gnu/classpath/tools/gjdoc/ValueTagImpl.java | 65 + .../gnu/classpath/tools/gjdoc/WritableType.java | 44 + .../tools/gjdoc/expr/AdditionExpression.java | 86 + .../classpath/tools/gjdoc/expr/AndExpression.java | 57 + .../tools/gjdoc/expr/BinaryBitwiseExpression.java | 68 + .../gjdoc/expr/BinaryComputationExpression.java | 92 + .../tools/gjdoc/expr/BinaryEqualityExpression.java | 89 + .../tools/gjdoc/expr/BinaryExpression.java | 51 + .../tools/gjdoc/expr/BinaryLogicalExpression.java | 64 + .../tools/gjdoc/expr/BinaryRelationExpression.java | 82 + .../tools/gjdoc/expr/BinaryShiftExpression.java | 66 + .../tools/gjdoc/expr/BitShiftRightExpression.java | 57 + .../gjdoc/expr/CircularExpressionException.java | 52 + .../tools/gjdoc/expr/ConditionalExpression.java | 74 + .../tools/gjdoc/expr/ConstantBoolean.java | 84 + .../classpath/tools/gjdoc/expr/ConstantByte.java | 74 + .../classpath/tools/gjdoc/expr/ConstantChar.java | 98 + .../classpath/tools/gjdoc/expr/ConstantDouble.java | 79 + .../tools/gjdoc/expr/ConstantExpression.java | 52 + .../classpath/tools/gjdoc/expr/ConstantFloat.java | 79 + .../tools/gjdoc/expr/ConstantInteger.java | 79 + .../classpath/tools/gjdoc/expr/ConstantLong.java | 84 + .../classpath/tools/gjdoc/expr/ConstantNull.java | 66 + .../classpath/tools/gjdoc/expr/ConstantShort.java | 74 + .../classpath/tools/gjdoc/expr/ConstantString.java | 74 + .../gnu/classpath/tools/gjdoc/expr/Context.java | 62 + .../tools/gjdoc/expr/DivisionExpression.java | 67 + .../tools/gjdoc/expr/EqualExpression.java | 72 + .../gnu/classpath/tools/gjdoc/expr/Evaluator.java | 148 + .../tools/gjdoc/expr/EvaluatorEnvironment.java | 46 + .../tools/gjdoc/expr/ExclusiveOrExpression.java | 57 + .../gnu/classpath/tools/gjdoc/expr/Expression.java | 44 + .../tools/gjdoc/expr/GreaterThanExpression.java | 67 + .../gjdoc/expr/GreaterThanOrEqualExpression.java | 67 + .../tools/gjdoc/expr/IdentifierExpression.java | 89 + .../gjdoc/expr/IllegalExpressionException.java | 52 + .../tools/gjdoc/expr/InclusiveOrExpression.java | 57 + .../tools/gjdoc/expr/LessThanExpression.java | 67 + .../gjdoc/expr/LessThanOrEqualExpression.java | 67 + .../tools/gjdoc/expr/LogicalAndExpression.java | 52 + .../tools/gjdoc/expr/LogicalNotExpression.java | 60 + .../tools/gjdoc/expr/LogicalOrExpression.java | 52 + .../tools/gjdoc/expr/ModuloExpression.java | 67 + .../tools/gjdoc/expr/MultiplicationExpression.java | 67 + .../tools/gjdoc/expr/NegateExpression.java | 66 + .../tools/gjdoc/expr/NotEqualExpression.java | 72 + .../classpath/tools/gjdoc/expr/NotExpression.java | 60 + .../tools/gjdoc/expr/ShiftLeftExpression.java | 57 + .../tools/gjdoc/expr/ShiftRightExpression.java | 57 + .../tools/gjdoc/expr/SubtractionExpression.java | 67 + .../tools/gnu/classpath/tools/gjdoc/expr/Type.java | 60 + .../tools/gjdoc/expr/TypeCastExpression.java | 87 + .../tools/gjdoc/expr/UnaryExpression.java | 49 + .../gjdoc/expr/UnknownIdentifierException.java | 47 + .../classpath/tools/gjdoc/expr/java-expression.g | 471 +++ .../tools/gnu/classpath/tools/jar/Action.java | 51 + .../tools/gnu/classpath/tools/jar/Creator.java | 251 ++ .../tools/gnu/classpath/tools/jar/Entry.java | 70 + .../tools/gnu/classpath/tools/jar/Extractor.java | 127 + .../tools/gnu/classpath/tools/jar/Indexer.java | 142 + .../tools/gnu/classpath/tools/jar/Lister.java | 112 + .../tools/gnu/classpath/tools/jar/Main.java | 293 ++ .../tools/gnu/classpath/tools/jar/Messages.java | 67 + .../tools/gnu/classpath/tools/jar/Updater.java | 98 + .../tools/gnu/classpath/tools/jar/WorkSet.java | 83 + .../gnu/classpath/tools/jarsigner/HashUtils.java | 124 + .../gnu/classpath/tools/jarsigner/JarSigner.java | 173 + .../gnu/classpath/tools/jarsigner/JarVerifier.java | 343 ++ .../tools/gnu/classpath/tools/jarsigner/Main.java | 689 ++++ .../gnu/classpath/tools/jarsigner/Messages.java | 119 + .../gnu/classpath/tools/jarsigner/SFHelper.java | 491 +++ .../gnu/classpath/tools/java2xhtml/Java2xhtml.java | 1354 +++++++ .../gnu/classpath/tools/javah/ClassWrapper.java | 376 ++ .../classpath/tools/javah/CniIncludePrinter.java | 80 + .../gnu/classpath/tools/javah/CniPrintStream.java | 274 ++ .../gnu/classpath/tools/javah/CniStubPrinter.java | 129 + .../gnu/classpath/tools/javah/FieldHelper.java | 99 + .../tools/gnu/classpath/tools/javah/GcjhMain.java | 153 + .../tools/gnu/classpath/tools/javah/JniHelper.java | 120 + .../classpath/tools/javah/JniIncludePrinter.java | 169 + .../gnu/classpath/tools/javah/JniPrintStream.java | 115 + .../gnu/classpath/tools/javah/JniStubPrinter.java | 109 + .../tools/gnu/classpath/tools/javah/Keywords.java | 172 + .../tools/gnu/classpath/tools/javah/Main.java | 468 +++ .../gnu/classpath/tools/javah/MethodHelper.java | 122 + .../gnu/classpath/tools/javah/PackageWrapper.java | 54 + .../gnu/classpath/tools/javah/PathOptionGroup.java | 147 + .../tools/gnu/classpath/tools/javah/Printer.java | 139 + .../tools/gnu/classpath/tools/javah/Text.java | 60 + .../gnu/classpath/tools/keytool/CACertCmd.java | 313 ++ .../gnu/classpath/tools/keytool/CertReqCmd.java | 475 +++ .../tools/gnu/classpath/tools/keytool/Command.java | 1228 +++++++ .../gnu/classpath/tools/keytool/DeleteCmd.java | 280 ++ .../gnu/classpath/tools/keytool/ExportCmd.java | 328 ++ .../gnu/classpath/tools/keytool/GenKeyCmd.java | 602 +++ .../gnu/classpath/tools/keytool/IdentityDBCmd.java | 232 ++ .../gnu/classpath/tools/keytool/ImportCmd.java | 930 +++++ .../gnu/classpath/tools/keytool/KeyCloneCmd.java | 407 ++ .../gnu/classpath/tools/keytool/KeyPasswdCmd.java | 395 ++ .../tools/gnu/classpath/tools/keytool/ListCmd.java | 432 +++ .../tools/gnu/classpath/tools/keytool/Main.java | 329 ++ .../gnu/classpath/tools/keytool/Messages.java | 118 + .../gnu/classpath/tools/keytool/PrintCertCmd.java | 143 + .../gnu/classpath/tools/keytool/SelfCertCmd.java | 440 +++ .../classpath/tools/keytool/StorePasswdCmd.java | 318 ++ .../gnu/classpath/tools/native2ascii/Messages.java | 67 + .../classpath/tools/native2ascii/Native2ASCII.java | 194 + .../tools/gnu/classpath/tools/orbd/Main.java | 226 ++ .../tools/gnu/classpath/tools/orbd/Messages.java | 67 + .../classpath/tools/orbd/PersistentContext.java | 152 + .../classpath/tools/orbd/PersistentContextMap.java | 87 + .../gnu/classpath/tools/orbd/PersistentMap.java | 454 +++ .../tools/rmic/AbstractMethodGenerator.java | 53 + .../classpath/tools/rmic/ClassRmicCompiler.java | 1834 +++++++++ .../gnu/classpath/tools/rmic/CompilationError.java | 69 + .../tools/gnu/classpath/tools/rmic/Generator.java | 145 + .../tools/gnu/classpath/tools/rmic/GiopIo.java | 129 + .../tools/gnu/classpath/tools/rmic/HashFinder.java | 100 + .../tools/gnu/classpath/tools/rmic/Main.java | 293 ++ .../tools/gnu/classpath/tools/rmic/Messages.java | 67 + .../gnu/classpath/tools/rmic/MethodGenerator.java | 302 ++ .../gnu/classpath/tools/rmic/RMICException.java | 70 + .../classpath/tools/rmic/RmiMethodGenerator.java | 297 ++ .../gnu/classpath/tools/rmic/RmicBackend.java | 48 + .../tools/rmic/SourceGiopRmicCompiler.java | 694 ++++ .../classpath/tools/rmic/SourceRmicCompiler.java | 189 + .../tools/gnu/classpath/tools/rmic/Variables.java | 154 + .../gnu/classpath/tools/rmic/WrapUnWrapper.java | 99 + .../classpath/tools/rmid/ActivationSystemImpl.java | 243 ++ .../tools/rmid/ActivationSystemImpl_Stub.java | 556 +++ .../tools/gnu/classpath/tools/rmid/Main.java | 258 ++ .../tools/gnu/classpath/tools/rmid/Messages.java | 67 + .../tools/rmid/PersistentBidiHashTable.java | 269 ++ .../gnu/classpath/tools/rmiregistry/Main.java | 232 ++ .../gnu/classpath/tools/rmiregistry/Messages.java | 67 + .../tools/rmiregistry/PersistentHashTable.java | 262 ++ .../classpath/tools/rmiregistry/RegistryImpl.java | 138 + .../tools/rmiregistry/RegistryImpl_Skel.java | 278 ++ .../tools/rmiregistry/RegistryImpl_Stub.java | 263 ++ .../gnu/classpath/tools/serialver/Messages.java | 68 + .../gnu/classpath/tools/serialver/SerialVer.java | 179 + .../gnu/classpath/tools/taglets/AuthorTaglet.java | 293 ++ .../gnu/classpath/tools/taglets/CodeTaglet.java | 101 + .../classpath/tools/taglets/CopyrightTaglet.java | 123 + .../classpath/tools/taglets/DeprecatedTaglet.java | 132 + .../gnu/classpath/tools/taglets/GenericTaglet.java | 157 + .../classpath/tools/taglets/GnuExtendedTaglet.java | 48 + .../gnu/classpath/tools/taglets/SinceTaglet.java | 161 + .../gnu/classpath/tools/taglets/TagletContext.java | 60 + .../gnu/classpath/tools/taglets/ValueTaglet.java | 130 + .../gnu/classpath/tools/taglets/VersionTaglet.java | 153 + .../tools/gnu/classpath/tools/tnameserv/Main.java | 115 + .../gnu/classpath/tools/tnameserv/Messages.java | 67 + libjava/classpath/tools/gorbd.in | 48 + libjava/classpath/tools/grmic.in | 48 + libjava/classpath/tools/grmid.in | 48 + libjava/classpath/tools/grmiregistry.in | 48 + libjava/classpath/tools/gserialver.in | 48 + libjava/classpath/tools/gtnameserv.in | 48 + libjava/classpath/tools/jarsigner.in | 47 + libjava/classpath/tools/keytool.in | 47 + .../com/sun/tools/javac/messages.properties | 42 + .../tools/appletviewer/messages.properties | 102 + .../gnu/classpath/tools/common/Messages.properties | 40 + .../gnu/classpath/tools/getopt/Messages.properties | 46 + .../tools/gjdoc/doctranslets/gjdoc_common.xsl | 54 + .../tools/gjdoc/doctranslets/html/about.xsl | 83 + .../tools/gjdoc/doctranslets/html/allclasses.xsl | 63 + .../tools/gjdoc/doctranslets/html/allpackages.xsl | 78 + .../tools/gjdoc/doctranslets/html/alphaindex.xsl | 107 + .../gjdoc/doctranslets/html/alphaindex_chunked.xsl | 112 + .../gjdoc/doctranslets/html/classdoc-source.xsl | 61 + .../gjdoc/doctranslets/html/classdoc-uses.xsl | 169 + .../tools/gjdoc/doctranslets/html/classdoc.xsl | 1070 ++++++ .../tools/gjdoc/doctranslets/html/deprecated.xsl | 261 ++ .../tools/gjdoc/doctranslets/html/descriptor.xsl | 58 + .../tools/gjdoc/doctranslets/html/doctranslet.xsl | 115 + .../tools/gjdoc/doctranslets/html/fulltree.xsl | 201 + .../tools/gjdoc/doctranslets/html/gjdoc.xsl | 240 ++ .../tools/gjdoc/doctranslets/html/help.xsl | 93 + .../tools/gjdoc/doctranslets/html/html_common.xsl | 584 +++ .../tools/gjdoc/doctranslets/html/index.xsl | 66 + .../gjdoc/doctranslets/html/index_noframes.xsl | 146 + .../gjdoc/doctranslets/html/packageclasses.xsl | 90 + .../tools/gjdoc/doctranslets/html/packagedoc.xsl | 153 + .../doctranslets/html/res/default_help_en.html | 7 + .../tools/gjdoc/doctranslets/html/res/gjdoc.js | 108 + .../doctranslets/html/res/gjdochtml-clean.css | 382 ++ .../doctranslets/html/res/gjdochtml-fixed.css | 286 ++ .../doctranslets/html/res/gjdochtml-sclara.css | 266 ++ .../gjdoc/doctranslets/html/res/gjdochtml.css | 29 + .../gnu/classpath/tools/gjdoc/dtd/dbcentx.mod | 204 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-amsa.ent | 98 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-amsb.ent | 84 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-amsc.ent | 52 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-amsn.ent | 101 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-amso.ent | 68 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-amsr.ent | 126 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-box.ent | 82 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr1.ent | 109 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr2.ent | 68 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-dia.ent | 56 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-grk1.ent | 91 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-grk2.ent | 62 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-grk3.ent | 85 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-grk4.ent | 85 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-lat1.ent | 104 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-lat2.ent | 163 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-num.ent | 118 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-pub.ent | 127 + .../gnu/classpath/tools/gjdoc/dtd/ent/iso-tech.ent | 104 + .../classpath/tools/gjdoc/dtd/gjdoc-alphaindex.dtd | 35 + .../gnu/classpath/tools/gjdoc/dtd/gjdoc.dtd | 35 + .../tools/gjdoc/htmldoclet/HtmlDoclet.properties | 32 + .../gnu/classpath/tools/gjdoc/htmldoclet/gjdoc.js | 115 + .../gjdoc/htmldoclet/gjdochtml-clean-color1.css | 80 + .../gjdoc/htmldoclet/gjdochtml-clean-layout.css | 460 +++ .../tools/gjdoc/htmldoclet/gjdochtml-vanilla.css | 21 + .../classpath/tools/gjdoc/htmldoclet/help.xhtml | 25 + .../classpath/tools/gjdoc/htmldoclet/inherit.png | Bin 0 -> 199 bytes .../tools/gjdoc/htmldoclet/xhtml11-target10.dtd | 54 + .../tools/gjdoc/java.lang-classes-1.2.txt | 78 + .../tools/gjdoc/java.lang-classes-1.3.txt | 79 + .../tools/gjdoc/java.lang-classes-1.4.txt | 82 + .../tools/gjdoc/java.lang-classes-1.5.txt | 90 + .../classpath/tools/gjdoc/rng/gjdoc-classdoc.rng | 649 ++++ .../gnu/classpath/tools/gjdoc/rng/gjdoc-common.rng | 264 ++ .../gnu/classpath/tools/gjdoc/rng/gjdoc-index.rng | 176 + .../gnu/classpath/tools/jar/messages.properties | 72 + .../classpath/tools/jarsigner/messages.properties | 126 + .../classpath/tools/keytool/messages.properties | 570 +++ .../tools/native2ascii/messages.properties | 44 + .../gnu/classpath/tools/orbd/messages.properties | 46 + .../gnu/classpath/tools/rmic/messages.properties | 61 + .../gnu/classpath/tools/rmic/templates/ImplTie.jav | 152 + .../gnu/classpath/tools/rmic/templates/Stub.jav | 47 + .../classpath/tools/rmic/templates/StubMethod.jav | 33 + .../tools/rmic/templates/StubMethodVoid.jav | 32 + .../gnu/classpath/tools/rmic/templates/Stub_12.jav | 62 + .../tools/rmic/templates/Stub_12Method.jav | 26 + .../tools/rmic/templates/Stub_12MethodVoid.jav | 25 + .../gnu/classpath/tools/rmic/templates/Tie.jav | 184 + .../classpath/tools/rmic/templates/TieMethod.jav | 11 + .../tools/rmic/templates/TieMethodVoid.jav | 9 + .../gnu/classpath/tools/rmid/messages.properties | 50 + .../tools/rmiregistry/messages.properties | 48 + .../classpath/tools/serialver/messages.properties | 44 + .../classpath/tools/tnameserv/messages.properties | 43 + .../resource/sun/rmi/rmic/messages.properties | 38 + libjava/classpath/tools/sun/rmi/rmic/Main.java | 60 + libjava/classpath/tools/sun/rmi/rmic/Messages.java | 67 + libjava/classpath/tools/toolwrapper.c | 264 ++ 1262 files changed, 111026 insertions(+) create mode 100644 libjava/classpath/tools/.cvsignore create mode 100755 libjava/classpath/tools/Makefile.am create mode 100644 libjava/classpath/tools/Makefile.in create mode 100644 libjava/classpath/tools/README create mode 100644 libjava/classpath/tools/appletviewer.in create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/AnnotationVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/AnnotationWriter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/Attribute.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/ByteVector.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/ClassAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/ClassReader.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/ClassVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/ClassWriter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/Edge.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/FieldVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/FieldWriter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/Handler.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/Item.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/Label.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/MethodAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/MethodVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/MethodWriter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/Opcodes.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/Type.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapAttribute.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapFrame.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapTableAttribute.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapType.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/AdviceAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/EmptyVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/GeneratorAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/LocalVariablesSorter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/Method.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder$Item.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/StaticInitMerger.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/commons/TableSwitchGenerator.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassOptimizer.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Constant.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ConstantPool.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/JarOptimizer.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodOptimizer.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/NameMapping.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker$ConstantComparator.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureReader.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureWriter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/AbstractInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/AnnotationNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/ClassNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/IincInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/InnerClassNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/InsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/IntInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/JumpInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/LabelNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/LdcInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/LineNumberNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/LocalVariableNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/MemberNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode$1.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/TableSwitchInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/TryCatchBlockNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/TypeInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/VarInsnNode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Analyzer.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/AnalyzerException.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicValue.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicVerifier.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowValue.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Frame.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/IntMap.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Interpreter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SmallSet.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Subroutine.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Value.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierClassVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierFieldVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierMethodVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/AbstractVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/CheckAnnotationAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/CheckClassAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/CheckFieldAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/CheckMethodAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAbstractVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAnnotationVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/TraceClassVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/TraceFieldVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/TraceMethodVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/TraceSignatureVisitor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMifiable.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/Traceable.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationDefaultRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationParameterRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueAnnotationRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueArrayRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueEnumRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ClassRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionsRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$FieldRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InnerClassRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfaceRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfacesRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LabelRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LineNumberRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LocalVarRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchLabelRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MaxRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MethodRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Opcode.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodeGroup.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodesRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OuterClassRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Rule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$RuleSet.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$SourceRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchLabelRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TryCatchRule.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ASMContentHandlerFactory.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ContentHandlerFactory.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$EntryElement.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$InputSlicingHandler.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$OutputSlicingHandler.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ProtectedInputStream.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriterFactory.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SingleDocElement.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SubdocumentHandlerFactory.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$TransformerHandlerFactory.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ZipEntryElement.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXClassAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXCodeAdapter.class create mode 100644 libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXFieldAdapter.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/ClassDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/ConstructorDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/Doc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/DocErrorReporter.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/Doclet.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/ExecutableMemberDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/FieldDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/MemberDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/MethodDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/PackageDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/ParamTag.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/Parameter.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/ProgramElementDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/RootDoc.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/SeeTag.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/SerialFieldTag.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/SourcePosition.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/Tag.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/ThrowsTag.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/Type.class create mode 100644 libjava/classpath/tools/classes/com/sun/javadoc/TypeVariable.class create mode 100644 libjava/classpath/tools/classes/com/sun/tools/doclets/Taglet.class create mode 100644 libjava/classpath/tools/classes/com/sun/tools/javac/Main.class create mode 100644 libjava/classpath/tools/classes/com/sun/tools/javac/Messages.class create mode 100644 libjava/classpath/tools/classes/com/sun/tools/javadoc/Main.class create mode 100644 libjava/classpath/tools/classes/com/sun/tools/javah/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$FileStreamInfo.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$JarStreamInfo.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$StreamInfo.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/IOToolkit.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputEvent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputListener.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/NotifyingInputStreamReader.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/StringToolkit.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletClassLoader.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletSecurityManager.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletTag.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletContext.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletStub.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/ErrorApplet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletContext.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletViewer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletWindow.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletContext.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/TagParser.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/CallbackUtil.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$AtFileArgumentCallback.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent$ExitTask.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/common/SecurityProviderInfo.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionGroup.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTag.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTagletPath.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$IndexKey.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$InterfaceRelation.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$UsageType.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletConfigurationException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOption.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionColonSeparated.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFile.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFlag.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionString.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InlineTagRenderer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InvalidPackageWildcardException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageGroup.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageMatcher.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/StandardTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/TagletPrinter.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/CssClass.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$TreeNode.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$NullErrorReporter.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$UsageType.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer$TagInfo.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/TargetContext.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet$DocErrorReporterOutputStream.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/FileArgumentCallback.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Option.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionGroup.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/AbstractTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BlockSourceComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BracketClose.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocProxy.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/CommentComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ConstructorDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Debug.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree$FileNode.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/EmptyStatementComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ErrorReporter.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FunctionComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocPackageDoc.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocRootDoc.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/IgnoredFileParseException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ImportComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/InheritDocTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/JavadocWrapper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/LinkTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$11.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$12.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$13.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$14.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$15.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$16.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$17.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$18.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$19.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$20.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$21.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$22.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$23.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$24.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$25.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$OptionProcessor.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MemberDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MethodDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParamTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParameterImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParseException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$Context.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImport.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportClassFile.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportNotFound.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportPackageFile.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionClass.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionPackage.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ScheduledClass.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SeeTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SlashSlashCommentComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourceComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourcePositionImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/StaticBlockComponent.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagContainer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TemporaryStore.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TextTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ThrowsTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Timer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeVariableImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ValueTagImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Whitespace.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/WritableType.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AdditionExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AndExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantByte.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantChar.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantDouble.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantFloat.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantInteger.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantLong.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantNull.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantShort.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantString.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Context.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/DivisionExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EqualExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Evaluator.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Expression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaLexer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ModuloExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NegateExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Type.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnaryExpression.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Action.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Entry.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Extractor.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Indexer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Lister.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$HandleFile.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$JarParser.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$ModeOption.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/Updater.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jar/WorkSet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/HashUtils.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarSigner.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarVerifier.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$11.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$12.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParser.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParserCallback.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/SFHelper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml$State.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniHelper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniPrintStream.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PackageWrapper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/javah/Text.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command$ShutdownHook.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$11.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$12.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$NoParseOption.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$ShutdownHook.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$HandleFile.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContext.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContextMap.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap$Entry.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/AbstractMethodGenerator.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler$MethodRef.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/CompilationError.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Generator.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/GiopIo.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/HashFinder.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$10.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$11.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$12.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$13.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$14.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$15.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$16.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$17.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$18.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$7.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$8.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$9.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/MethodGenerator.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RMICException.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmiMethodGenerator.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmicBackend.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceRmicCompiler.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Variables.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmic/WrapUnWrapper.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$AdaptedReader.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$WriteToDiskTask.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$4.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$5.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$6.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable$WriteToDiskTask.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/serialver/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$3.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet$EmailReplacement.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CodeTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CopyrightTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/DeprecatedTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GenericTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GnuExtendedTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/SinceTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/TagletContext.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/ValueTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/taglets/VersionTaglet.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$1.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$2.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main.class create mode 100644 libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Messages.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$PtrMarks.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$SizeKind.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BytePtr.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ItemList.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1$Info.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$2.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$3.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$4.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$OptionParser.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$SubstringComparator.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$Range.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$RangeComparator.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap$ObjectItem.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolLookup.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolTable.class create mode 100644 libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ToolPrefix.class create mode 100644 libjava/classpath/tools/classes/sun/rmi/rmic/Main.class create mode 100644 libjava/classpath/tools/classes/sun/rmi/rmic/Messages.class create mode 100644 libjava/classpath/tools/com/sun/javadoc/ClassDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/ConstructorDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/Doc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/DocErrorReporter.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/Doclet.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/ExecutableMemberDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/FieldDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/MemberDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/MethodDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/PackageDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/ParamTag.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/Parameter.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/ProgramElementDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/RootDoc.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/SeeTag.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/SerialFieldTag.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/SourcePosition.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/Tag.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/ThrowsTag.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/Type.java create mode 100644 libjava/classpath/tools/com/sun/javadoc/TypeVariable.java create mode 100644 libjava/classpath/tools/com/sun/tools/doclets/Taglet.java create mode 100644 libjava/classpath/tools/com/sun/tools/javac/Main.java create mode 100644 libjava/classpath/tools/com/sun/tools/javac/Messages.java create mode 100644 libjava/classpath/tools/com/sun/tools/javadoc/Main.java create mode 100644 libjava/classpath/tools/com/sun/tools/javah/Main.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/AnnotationWriter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/Attribute.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/ByteVector.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/ClassAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/ClassReader.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/ClassVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/ClassWriter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/Edge.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/FieldVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/FieldWriter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/Handler.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/Item.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/Label.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/MethodAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/MethodVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/MethodWriter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/Opcodes.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/Type.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapAttribute.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapFrame.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapTableAttribute.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/attrs/StackMapType.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/AdviceAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/EmptyVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/GeneratorAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/LocalVariablesSorter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/Method.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/StaticInitMerger.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/commons/TableSwitchGenerator.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ClassOptimizer.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Constant.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/ConstantPool.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/JarOptimizer.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/MethodOptimizer.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/NameMapping.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/Shrinker.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/optimizer/shrink.properties create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureReader.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/signature/SignatureWriter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AbstractInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/AnnotationNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/ClassNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/FieldNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IincInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InnerClassNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/InsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/IntInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/JumpInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LabelNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LdcInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LineNumberNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LocalVariableNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MemberNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MethodNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TableSwitchInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TryCatchBlockNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/TypeInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/VarInsnNode.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Analyzer.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/AnalyzerException.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicValue.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/BasicVerifier.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/DataflowValue.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Frame.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/IntMap.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Interpreter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/SmallSet.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Subroutine.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/tree/analysis/Value.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierClassVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierFieldVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/ASMifierMethodVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/AbstractVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckAnnotationAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckClassAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckFieldAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/CheckMethodAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAbstractVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceAnnotationVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceClassVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceFieldVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceMethodVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/TraceSignatureVisitor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/ASMifiable.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/util/attrs/Traceable.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/xml/Processor.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java create mode 100644 libjava/classpath/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java create mode 100644 libjava/classpath/tools/gappletviewer.in create mode 100644 libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.java create mode 100644 libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaLexer.smap create mode 100644 libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.java create mode 100644 libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.smap create mode 100644 libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.java create mode 100644 libjava/classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.txt create mode 100644 libjava/classpath/tools/gjar.in create mode 100644 libjava/classpath/tools/gjarsigner.in create mode 100644 libjava/classpath/tools/gjavah.in create mode 100644 libjava/classpath/tools/gjdoc.in create mode 100644 libjava/classpath/tools/gkeytool.in create mode 100644 libjava/classpath/tools/gnative2ascii.in create mode 100644 libjava/classpath/tools/gnu/classpath/tools/FileSystemClassLoader.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/IOToolkit.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/MalformedInputEvent.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/MalformedInputListener.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/NotifyingInputStreamReader.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/StringToolkit.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/common/ClasspathToolParser.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/common/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/common/Persistent.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/AbstractDoclet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/DocletConfigurationException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOption.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionColonSeparated.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFile.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionFlag.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/DocletOptionString.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/InlineTagRenderer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/InvalidPackageWildcardException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/PackageGroup.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/PackageMatcher.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/StandardTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/TagletPrinter.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/CssClass.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/AbstractTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocProxy.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ConstructorDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/Debug.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/DirectoryTree.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/DocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/FieldDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocPackageDoc.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/GjdocRootDoc.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/InheritDocTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/JavadocWrapper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/LinkTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/MemberDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/MethodDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/PackageDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParamTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParameterImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ParseException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/Parser.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/RootDocImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/SeeTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/SourcePositionImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagContainer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/TagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/TextTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ThrowsTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/Timer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/TimerDoclet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/TypeVariableImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/ValueTagImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/WritableType.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AdditionExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/AndExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantByte.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantChar.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantDouble.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantFloat.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantInteger.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantLong.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantNull.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantShort.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ConstantString.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Context.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/DivisionExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EqualExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Evaluator.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Expression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ModuloExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NegateExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/NotExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/Type.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnaryExpression.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/gjdoc/expr/java-expression.g create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Action.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/java2xhtml/Java2xhtml.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/GcjhMain.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/JniHelper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/JniPrintStream.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/PackageWrapper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/PathOptionGroup.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/javah/Text.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/orbd/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/orbd/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContext.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentContextMap.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/orbd/PersistentMap.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/CompilationError.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/Generator.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/GiopIo.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/HashFinder.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/MethodGenerator.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/RMICException.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/RmicBackend.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmid/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmid/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmiregistry/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/AuthorTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/CodeTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/GenericTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/GnuExtendedTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/SinceTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/TagletContext.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/ValueTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/taglets/VersionTaglet.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/tnameserv/Main.java create mode 100644 libjava/classpath/tools/gnu/classpath/tools/tnameserv/Messages.java create mode 100644 libjava/classpath/tools/gorbd.in create mode 100644 libjava/classpath/tools/grmic.in create mode 100644 libjava/classpath/tools/grmid.in create mode 100644 libjava/classpath/tools/grmiregistry.in create mode 100644 libjava/classpath/tools/gserialver.in create mode 100644 libjava/classpath/tools/gtnameserv.in create mode 100644 libjava/classpath/tools/jarsigner.in create mode 100644 libjava/classpath/tools/keytool.in create mode 100644 libjava/classpath/tools/resource/com/sun/tools/javac/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/appletviewer/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/common/Messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/getopt/Messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/gjdoc_common.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/about.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allclasses.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/allpackages.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/alphaindex_chunked.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-source.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc-uses.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/classdoc.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/deprecated.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/descriptor.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/doctranslet.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/fulltree.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/gjdoc.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/help.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/html_common.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/index_noframes.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packageclasses.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/packagedoc.xsl create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/default_help_en.html create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdoc.js create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-clean.css create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-fixed.css create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml-sclara.css create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/doctranslets/html/res/gjdochtml.css create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/dbcentx.mod create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsa.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsb.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsc.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsn.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amso.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-amsr.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-box.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr1.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-cyr2.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-dia.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk1.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk2.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk3.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-grk4.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat1.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-lat2.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-num.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-pub.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/ent/iso-tech.ent create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc-alphaindex.dtd create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/dtd/gjdoc.dtd create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/HtmlDoclet.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdoc.js create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-color1.css create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-clean-layout.css create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/gjdochtml-vanilla.css create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/help.xhtml create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/inherit.png create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/xhtml11-target10.dtd create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.2.txt create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.3.txt create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.4.txt create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/java.lang-classes-1.5.txt create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-classdoc.rng create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-common.rng create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/rng/gjdoc-index.rng create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/jar/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/jarsigner/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/keytool/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/native2ascii/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/orbd/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/ImplTie.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethod.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12Method.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/Tie.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethod.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmid/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/rmiregistry/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/serialver/messages.properties create mode 100644 libjava/classpath/tools/resource/gnu/classpath/tools/tnameserv/messages.properties create mode 100644 libjava/classpath/tools/resource/sun/rmi/rmic/messages.properties create mode 100644 libjava/classpath/tools/sun/rmi/rmic/Main.java create mode 100644 libjava/classpath/tools/sun/rmi/rmic/Messages.java create mode 100644 libjava/classpath/tools/toolwrapper.c (limited to 'libjava/classpath/tools') 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 &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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/AnnotationWriter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/Attribute.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/ByteVector.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/ClassAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/ClassReader.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/ClassVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/ClassWriter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/Edge.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/FieldVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/FieldWriter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/Handler.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/Item.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/Label.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/MethodAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/MethodVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/MethodWriter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/Opcodes.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/Type.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapAttribute.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapFrame.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapTableAttribute.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/attrs/StackMapType.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/AdviceAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/EmptyVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/GeneratorAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/LocalVariablesSorter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/Method.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder$Item.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/SerialVersionUIDAdder.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/StaticInitMerger.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/commons/TableSwitchGenerator.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/AnnotationConstantsCollector.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassConstantsCollector.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ClassOptimizer.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Constant.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/ConstantPool.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/FieldConstantsCollector.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/JarOptimizer.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodConstantsCollector.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/MethodOptimizer.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/NameMapping.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker$ConstantComparator.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/optimizer/Shrinker.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureReader.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/signature/SignatureWriter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/AbstractInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/AnnotationNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/ClassNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/FieldNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/IincInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/InnerClassNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/InsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/IntInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/JumpInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LabelNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LdcInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LineNumberNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LocalVariableNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/LookupSwitchInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MemberNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MethodNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/MultiANewArrayInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TableSwitchInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TryCatchBlockNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/TypeInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/VarInsnNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Analyzer.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/AnalyzerException.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicInterpreter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicValue.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/BasicVerifier.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowInterpreter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/DataflowValue.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Frame.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/IntMap.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Interpreter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SimpleVerifier.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/SmallSet.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Subroutine.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/tree/analysis/Value.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAbstractVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierAnnotationVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierClassVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierFieldVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/ASMifierMethodVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/AbstractVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckAnnotationAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckClassAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckFieldAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/CheckMethodAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAbstractVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceAnnotationVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceClassVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceFieldVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceMethodVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/TraceSignatureVisitor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapAttribute.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMStackMapTableAttribute.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/ASMifiable.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/util/attrs/Traceable.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationDefaultRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationParameterRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueAnnotationRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueArrayRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueEnumRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$AnnotationValueRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ClassRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$ExceptionsRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$FieldRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InnerClassRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfaceRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$InterfacesRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LabelRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LineNumberRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LocalVarRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchLabelRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$LookupSwitchRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MaxRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$MethodRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Opcode.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodeGroup.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OpcodesRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$OuterClassRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$Rule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$RuleSet.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$SourceRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchLabelRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TableSwitchRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler$TryCatchRule.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/ASMContentHandler.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ASMContentHandlerFactory.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ContentHandlerFactory.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$EntryElement.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$InputSlicingHandler.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$OutputSlicingHandler.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ProtectedInputStream.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SAXWriterFactory.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SingleDocElement.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$SubdocumentHandlerFactory.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$TransformerHandlerFactory.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor$ZipEntryElement.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/Processor.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXClassAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXCodeAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/asm/org/objectweb/asm/xml/SAXFieldAdapter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/ClassDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/ConstructorDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/Doc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/DocErrorReporter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/Doclet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/ExecutableMemberDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/FieldDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/MemberDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/MethodDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/PackageDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/ParamTag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/Parameter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/ProgramElementDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/RootDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/SeeTag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/SerialFieldTag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/SourcePosition.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/Tag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/ThrowsTag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/Type.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/javadoc/TypeVariable.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/tools/doclets/Taglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/tools/javac/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/tools/javac/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/tools/javadoc/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/com/sun/tools/javah/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$FileStreamInfo.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$JarStreamInfo.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$StreamInfo.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/IOToolkit.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputEvent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputListener.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/NotifyingInputStreamReader.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/StringToolkit.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletClassLoader.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletSecurityManager.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/AppletTag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletContext.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/CommonAppletStub.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/ErrorApplet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletContext.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletViewer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/PluginAppletWindow.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletContext.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/appletviewer/TagParser.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/CallbackUtil.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser$AtFileArgumentCallback.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ClasspathToolParser.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent$ExitTask.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/Persistent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/ProviderUtil.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/common/SecurityProviderInfo.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionGroup.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTagletPath.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$IndexKey.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$InterfaceRelation.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$UsageType.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletConfigurationException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOption.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionColonSeparated.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFile.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFlag.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionString.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InlineTagRenderer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InvalidPackageWildcardException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageGroup.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageMatcher.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/StandardTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/TagletPrinter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/CssClass.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$TreeNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$NullErrorReporter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$UsageType.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer$TagInfo.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/TargetContext.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet$DocErrorReporterOutputStream.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/FileArgumentCallback.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Option.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/OptionGroup.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/getopt/Parser.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/AbstractTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BlockSourceComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BracketClose.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocProxy.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/CommentComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ConstructorDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Debug.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree$FileNode.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/EmptyStatementComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ErrorReporter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FunctionComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocPackageDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/GjdocRootDoc.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/IgnoredFileParseException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ImportComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/InheritDocTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/JavadocWrapper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/LinkTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$11.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$12.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$13.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$14.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$15.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$16.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$17.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$18.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$19.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$20.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$21.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$22.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$23.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$24.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$25.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$OptionProcessor.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MemberDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MethodDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParamTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParameterImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParseException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$Context.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImport.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportClassFile.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportNotFound.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportPackageFile.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionClass.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionPackage.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ScheduledClass.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SeeTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SlashSlashCommentComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourceComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourcePositionImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/StaticBlockComponent.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagContainer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TemporaryStore.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TextTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ThrowsTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Timer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeVariableImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ValueTagImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Whitespace.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/WritableType.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AdditionExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AndExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantByte.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantChar.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantDouble.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantFloat.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantInteger.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantLong.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantNull.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantShort.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantString.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Context.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/DivisionExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EqualExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Evaluator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Expression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaLexer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ModuloExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NegateExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Type.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnaryExpression.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Action.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Entry.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Extractor.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Indexer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Lister.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$HandleFile.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$JarParser.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main$ModeOption.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Updater.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jar/WorkSet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/HashUtils.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarSigner.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/JarVerifier.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$11.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$12.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParser.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main$ToolParserCallback.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/jarsigner/SFHelper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml$State.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniHelper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniPrintStream.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PackageWrapper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Text.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CACertCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/CertReqCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command$ShutdownHook.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Command.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/DeleteCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ExportCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$11.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$12.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/GenKeyCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/IdentityDBCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ImportCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyCloneCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/KeyPasswdCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/ListCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$NoParseOption.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main$ShutdownHook.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/PrintCertCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/SelfCertCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/keytool/StorePasswdCmd.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII$HandleFile.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/native2ascii/Native2ASCII.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContext.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentContextMap.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap$Entry.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/orbd/PersistentMap.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/AbstractMethodGenerator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler$MethodRef.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/CompilationError.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Generator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/GiopIo.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/HashFinder.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$10.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$11.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$12.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$13.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$14.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$15.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$16.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$17.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$18.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$7.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$8.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$9.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/MethodGenerator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RMICException.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmiMethodGenerator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmicBackend.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceRmicCompiler.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Variables.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmic/WrapUnWrapper.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$AdaptedReader.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable$WriteToDiskTask.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmid/PersistentBidiHashTable.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$5.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main$6.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable$WriteToDiskTask.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/PersistentHashTable.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet$EmailReplacement.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CodeTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CopyrightTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/DeprecatedTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GenericTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GnuExtendedTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/SinceTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/TagletContext.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/ValueTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/taglets/VersionTaglet.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/classpath/tools/tnameserv/Messages.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$PtrMarks.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap$SizeKind.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BlockMap.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/BytePtr.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ItemList.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1$Info.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$1.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$2.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$3.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$4.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$OptionParser.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze$SubstringComparator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryAnalyze.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$Range.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap$RangeComparator.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/MemoryMap.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap$ObjectItem.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ObjectMap.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolLookup.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/SymbolTable.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/gnu/gcj/tools/gc_analyze/ToolPrefix.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/sun/rmi/rmic/Main.class 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 Binary files /dev/null and b/libjava/classpath/tools/classes/sun/rmi/rmic/Messages.class 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 true if the class is abstract, false, + * 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 + * java.io.Serializable interface. This includes classes + * which are externalizable. + * + * @return true if the class is serializable, + * false 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 + * java.io.Externalizable interface. + * + * @return true if the class is externalizable, + * false 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 + * serialPersistentField 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 + * serialPersistentFields field. + * + * @return true if this class explicitly defines its + * serializable fields, false 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 ClassDoc object of the class to test against. + * + * @return true if this class is a subclass of the specified + * class, false 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 ClassDoc for the named class. The + * following search order is used: + *

+ *

    + *
  1. Fully qualified class name. + *
  2. Inner classes within this class. + *
  3. In the current package. + *
  4. In the imports for this class. + *
+ * + * @param name The name of the class to find. + * + * @return The requested class, or null 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 Text. Inline "@see" tags are returned as + * type SeeTag. + * + * @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 Text. Inline "@see" + * tags are returned as type SeeTag. + * + * @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 true if this item is a field, false + * otherwise. + */ +public abstract boolean +isField(); + +/*************************************************************************/ + +/** + * This method tests whether or not this item is a method. + * + * @return true if this item is a method, false + * otherwise. + */ +public abstract boolean +isMethod(); + +/*************************************************************************/ + +/** + * This method tests whether or not this item is a constructor. + * + * @return true if this item is a constructor, + * false otherwise. + */ +public abstract boolean +isConstructor(); + +/*************************************************************************/ + +/** + * This method tests whether or not this item is an interface. + * + * @return true if this item is an interface, + * false otherwise. + */ +public abstract boolean +isInterface(); + +/*************************************************************************/ + +/** + * This method tests whether or not this item is an exception. + * + * @return true if this item is an exception, + * false otherwise. + */ +public abstract boolean +isException(); + +/*************************************************************************/ + +/** + * This method tests whether or not this item is an error. + * + * @return true if this item is an error, + * false otherwise. + */ +public abstract boolean +isError(); + +/*************************************************************************/ + +/** + * This method tests whether or not this item is a class. Interfaces + * do not count as classes. + * + * @return true if this item is a class, + * false 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 true if this item is an ordinary class, + * false otherwise. + */ +public abstract boolean +isOrdinaryClass(); + +/*************************************************************************/ + +/** + * This method tests whether or not this item is part of the active set, + * whatever that is. + * + * @return true if this item is part of the active set, + * false 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 start 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 RootDoc instance for this javadoc run. + * + * @return true on success, false 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 true if the options are valid, false + * 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 true if the method is native, false + * otherwise. + */ +public abstract boolean +isNative(); + +/*************************************************************************/ + +/** + * This method tests whether or not this method/constructor is + * synchronized. + * + * @return true if the method is synchronized, + * false 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 + * read(String str, boolean bool) would have the signature + * (java.lang.String, boolean) 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 + * read(String str, boolean bool) would have the signature + * (String, boolean) 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 true if the field is transient, false + * otherwise. + */ +public abstract boolean +isTransient(); + +/*************************************************************************/ + +/** + * This method tests whether or not the field is volatile. + * + * @return true if the field is volatile, false + * 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 true if this member was synthesized by the compiler, + * false 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 true if the method is abstract, false + * 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 null 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 ClassDoc instance for the specified + * class. + * + * @param name The name of the class to return. + * + * @return The requested ClassDoc or null 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 + * String. + * + * @return The name of the type of this parameter. + */ +public abstract String +typeName(); + +/*************************************************************************/ + +/** + * This method returns this parameter as a String that + * contains both the type name and parameter name. + * + * @return This parameter as a String. + */ +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, null will be + * returned. + * + * @returned The class element that contains this item, or null + * 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 true if this element is public, false + * otherwise. + */ +public abstract boolean +isPublic(); + +/*************************************************************************/ + +/** + * This method tests whether or not this element is protected. + * + * @return true if this element is protected, false + * otherwise. + */ +public abstract boolean +isProtected(); + +/*************************************************************************/ + +/** + * This method tests whether or not this element is private. + * + * @return true if this element is private, false + * otherwise. + */ +public abstract boolean +isPrivate(); + +/*************************************************************************/ + +/** + * This method tests whether or not this element is package private. + * + * @return true if this element is package private, + * false otherwise. + */ +public abstract boolean +isPackagePrivate(); + +/*************************************************************************/ + +/** + * This method tests whether or not this element is static. + * + * @return true if this element is static, false + * otherwise. + */ +public abstract boolean +isStatic(); + +/*************************************************************************/ + +/** + * This method tests whether or not this element is final. + * + * @return true if this element is final, false + * 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 ClassDoc instance for the name class + * or interface. + * + * @param name + * The class or interface to look up. + * @return The requested ClassDoc, or null if the specified + * class is not part of this javadoc run. + */ + public abstract ClassDoc classNamed(String name); + + /** ********************************************************************** */ + + /** + * This method returns a PackageDoc instance for the named + * package. + * + * @param name + * The package to look up. + * @return The requested PackageDoc, 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 null 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 ClassDoc instance for the class + * referenced in the tag. + * + * @return A ClassDoc 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 MemberDoc instance for the member + * referenced in the tag. + * + * @return A MemberDoc 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 ClassDoc instance for the type of + * the field. What about primitive types??? + * + * @return A ClassDoc 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 String. What kind of + * string? + * + * @return This tag as a String. + */ +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 Tag'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 ClassDoc. + * + * @return The exception class as a ClassDoc. + */ +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 ClassDoc. This is not + * a valid operation for primitive types. + * + * @return A ClassDoc for this type, or null 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 TypeVariable, if it is an + * instance of the TypeVariable class. Otherwise, + * it returns null. + * + * @return this cast to a TypeVariable 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, + * List<E> has the type variable, E. Type + * variables may have explicit bounds, such as <T extends + * Book>, which specifies that the type is a sub-class of + * Book. + * + * @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 extends 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: (visit | visitEnum | + * visitAnnotation | visitArray)* visitEnd. + * + * @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. + * The nested annotation value must be fully visited before + * calling other methods on this annotation visitor. + */ + 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. All the array values must be visited before calling + * other methods on this annotation visitor. + */ + 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; + + /** + * true if values are named, false 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 true if values are named, false 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 parent 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 null. + */ + Attribute next; + + /** + * Constructs a new empty attribute. + * + * @param type the type of the attribute. + */ + protected Attribute(final String type) { + this.type = type; + } + + /** + * Returns true if this type of attribute is unknown. The default + * implementation of this method always returns true. + * + * @return true if this type of attribute is unknown. + */ + public boolean isUnknown() { + return true; + } + + /** + * Returns true if this type of attribute is a code attribute. + * + * @return true 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 null 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 new + * {@link Attribute} object, of type {@link #type type}, corresponding to + * the len 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 null if the + * attribute to be read is not a code attribute. + * @return a new {@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 null if this attribute is not a code + * attributes. + * @param len the length of the bytecode of the method corresponding to this + * code attribute, or null 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 null if these attributes are not code + * attributes. + * @param len the length of the bytecode of the method corresponding to + * these code attributes, or null 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 null if these attributes are not code + * attributes. + * @param len the length of the bytecode of the method corresponding to + * these code attributes, or null 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 null to put len + * 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. 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. + */ + 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 true 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 true 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 true 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 (not + * including the value name constant pool index). + * @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 null if the + * attribute to be read is not a code attribute. + * @return the attribute that has been read, or null 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. This method is intended for {@link Attribute} sub classes, and is + * normally not needed by class generators or adapters. + * + * @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}. This method is intended for + * {@link Attribute} sub classes, and is normally not needed by class + * generators or adapters. + * + * @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}. This method is + * intended for {@link Attribute} sub classes, and is normally not needed by + * class generators or adapters. + * + * @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}. This method is intended + * for {@link Attribute} sub classes, and is normally not needed by class + * generators or adapters. + * + * @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}. This method is intended for + * {@link Attribute} sub classes, and is normally not needed by class + * generators or adapters. + * + * @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}. This method is intended + * for {@link Attribute} sub classes, and is normally not needed by class + * generators or adapters. + * + * @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}. This method + * is intended for {@link Attribute} sub classes, and is normally not needed + * by class generators or adapters. + * + * @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}. This method is + * intended for {@link Attribute} sub classes, and is normally not needed by + * class generators or adapters. + * + * @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}. This + * method is intended for {@link Attribute} sub classes, and is normally not + * needed by class generators or adapters. + * + * @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: visit [ visitSource ] [ + * visitOuterClass ] ( visitAnnotation | + * visitAttribute )* (visitInnerClass | + * visitField | visitMethod )* visitEnd. + * + * @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 null 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 null, but + * only for the {@link Object} class. + * @param interfaces the internal names of the class's interfaces (see + * {@link Type#getInternalName() getInternalName}). May be + * null. + */ + 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 null. + * @param debug additional debug information to compute the correspondance + * between source and compiled elements of the class. May be + * null. + */ + 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 + * null 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 + * null 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 true 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 null. + * @param innerName the (simple) name of the inner class inside its + * enclosing class. May be null 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 null if the + * field's type does not use generic types. + * @param value the field's initial value. This parameter, which may be + * null 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 int, + * float, long or String fields + * respectively). This parameter is only used for static fields. + * 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 + * null 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 must return a new + * {@link MethodVisitor} instance (or null) 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 null 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 + * null. + * @return an object to visit the byte code of the method, or null + * 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; + + /** + * true 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 true if the maximum stack size and the + * maximum number of local variables must be automatically computed. + * If this flag is true, 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 true if the maximum stack size and the + * maximum number of local variables must be automatically computed. + * If this flag is true, 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 Deprecated. 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: + * + *
  • 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 won't be + * removed.
  • 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 lot 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).
  • + *
+ * + * @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 true if the maximum stack size and the + * maximum number of local variables must be automatically computed. + * If this flag is true, 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. + * This method is intended for {@link Attribute} sub classes, and is + * normally not needed by class generators or adapters. + * + * @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. This + * method is intended for {@link Attribute} sub classes, and is normally not + * needed by class generators or adapters. + * + * @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. + * This method is intended for {@link Attribute} sub classes, and is + * normally not needed by class generators or adapters. + * + * @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. + * This method is intended for {@link Attribute} sub classes, and is + * normally not needed by class generators or adapters. + * + * @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. + * This method is intended for {@link Attribute} sub classes, and is + * normally not needed by class generators or adapters. + * + * @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 true if owner 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. + * This method is intended for {@link Attribute} sub classes, and is + * normally not needed by class generators or adapters. + * + * @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 true if owner 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. This + * method is intended for {@link Attribute} sub classes, and is normally not + * needed by class generators or adapters. + * + * @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 null 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 + * must 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: ( visitAnnotation | + * visitAttribute )* visitEnd. + * + * @author Eric Bruneton + */ +public interface FieldVisitor { + + /** + * Visits an annotation of the field. + * + * @param desc the class descriptor of the annotation class. + * @param visible true 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 null. + */ + private AnnotationWriter anns; + + /** + * The runtime invisible annotations of this field. May be null. + */ + private AnnotationWriter ianns; + + /** + * The non standard attributes of this field. May be null. + */ + 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 null. + * @param value the field's constant value. May be null. + */ + 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 + * null 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 true if the given item if equal to this one, + * false 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; + + /** + * true 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. This method is intended for + * {@link Attribute} sub classes, and is normally not needed by class + * generators or adapters. + * + * @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 true if the reference must be stored in 4 + * bytes, or false 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 true 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: [ visitAnnotationDefault ] ( + * visitAnnotation | visitParameterAnnotation | + * visitAttribute )* [ visitCode ( visitXInsn
| + * visitLabel | visitTryCatchBlock | visitLocalVariable | + * visitLineNumber)* visitMaxs ] visitEnd. In + * addition, the visitXInsn
and visitLabel + * methods must be called in the sequential order of the bytecode instructions + * of the visited code, and the visitLocalVariable and visitLineNumber + * methods must be called after 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 true 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 true 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.
+ * When opcode is BIPUSH, operand value should be between + * Byte.MIN_VALUE and Byte.MAX_VALUE.
+ * When opcode is SIPUSH, operand value should be between + * Short.MIN_VALUE and Short.MAX_VALUE.
+ * 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 + * .class 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. labels[i] is + * the beginning of the handler block for the min + i 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. labels[i] is + * the beginning of the handler block for the keys[i] 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 null 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 + * null 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 start 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 cw.cr. More + * precisely, this field gives the index of the first byte to copied from + * cw.cr.b. + */ + int classReaderOffset; + + /** + * If not zero, indicates that the code of this method must be copied from + * the ClassReader associated to this writer in cw.cr. More + * precisely, this field gives the number of bytes to copied from + * cw.cr.b. + */ + 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 null. + */ + private ByteVector annd; + + /** + * The runtime visible annotations of this method. May be null. + */ + private AnnotationWriter anns; + + /** + * The runtime invisible annotations of this method. May be null. + */ + private AnnotationWriter ianns; + + /** + * The runtime visible parameter annotations of this method. May be + * null. + */ + private AnnotationWriter[] panns; + + /** + * The runtime invisible parameter annotations of this method. May be + * null. + */ + 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. + */ + + /** + * true 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 + * stackSize. + */ + 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 stackSize. + */ + 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 null. + * @param exceptions the internal names of the method's exceptions. May be + * null. + * @param computeMaxs true 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 + * with IFNOTxxx GOTO_W , where IFNOTxxx is the + * "opposite" opcode of IFxxx (i.e., IFNE for IFEQ) and where + * 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 = + * (argSize << 2) | retSize (argSize is therefore equal + * to i >> 2, and retSize to i & 0x03). + */ + 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.

This method must be called after all the method + * that is being built has been visited. 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 last + * byte, plus one (or, in other words, by the index of the first + * byte of the next instruction). + * @param sizes the number of bytes to be added to the above + * instructions. More precisely, for each i < len, + * sizes[i] bytes will be added at the end of the + * instruction designated by indexes[i] or, if + * sizes[i] is negative, the last |sizes[i]| + * bytes of the instruction will be removed (the instruction size + * must not 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 indexes.length and sizes.length. + * @return the indexes 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 instruction with + // IFNOTxxx GOTO_W , where IFNOTxxx + // is the "opposite" opcode of IFxxx (i.e., + // IFNE for IFEQ) and where 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 + // with IFNOTxxx GOTO_W , where IFNOTxxx is + // the "opposite" opcode of IFxxx (i.e., IFNE for IFEQ) + // and where 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.

Note: it is possible + * to have several entries for the same instruction in the indexes + * and sizes: 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 last + * byte, plus one (or, in other words, by the index of the first + * byte of the next instruction). + * @param sizes the number of bytes to be added to the above + * instructions. More precisely, for each i < len, + * sizes[i] bytes will be added at the end of the + * instruction designated by indexes[i] or, if + * sizes[i] is negative, the last |sizes[i]| + * bytes of the instruction will be removed (the instruction size + * must not 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 last + * byte, plus one (or, in other words, by the index of the first + * byte of the next instruction). + * @param sizes the number of bytes to be added to the above + * instructions. More precisely, for each i < len, + * sizes[i] bytes will be added at the end of the + * instruction designated by indexes[i] or, if + * sizes[i] is negative, the last |sizes[i]| + * bytes of the instruction will be removed (the instruction size + * must not 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 void type. See {@link #getSort getSort}. + */ + public final static int VOID = 0; + + /** + * The sort of the boolean type. See {@link #getSort getSort}. + */ + public final static int BOOLEAN = 1; + + /** + * The sort of the char type. See {@link #getSort getSort}. + */ + public final static int CHAR = 2; + + /** + * The sort of the byte type. See {@link #getSort getSort}. + */ + public final static int BYTE = 3; + + /** + * The sort of the short type. See {@link #getSort getSort}. + */ + public final static int SHORT = 4; + + /** + * The sort of the int type. See {@link #getSort getSort}. + */ + public final static int INT = 5; + + /** + * The sort of the float type. See {@link #getSort getSort}. + */ + public final static int FLOAT = 6; + + /** + * The sort of the long type. See {@link #getSort getSort}. + */ + public final static int LONG = 7; + + /** + * The sort of the double 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 void type. + */ + public final static Type VOID_TYPE = new Type(VOID); + + /** + * The boolean type. + */ + public final static Type BOOLEAN_TYPE = new Type(BOOLEAN); + + /** + * The char type. + */ + public final static Type CHAR_TYPE = new Type(CHAR); + + /** + * The byte type. + */ + public final static Type BYTE_TYPE = new Type(BYTE); + + /** + * The short type. + */ + public final static Type SHORT_TYPE = new Type(SHORT); + + /** + * The int type. + */ + public final static Type INT_TYPE = new Type(INT); + + /** + * The float type. + */ + public final static Type FLOAT_TYPE = new Type(FLOAT); + + /** + * The long type. + */ + public final static Type LONG_TYPE = new Type(LONG); + + /** + * The double 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 long and + * double, 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 float and + * opcode 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 true 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.

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.

The format of the stack map in the class + * file is given below. In the following,

  • if the length of the + * method's byte code1 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 + * ulocalvar represents the type u2; otherwise ulocalvar + * represents the type u4.
  • If the maximum size of the operand stack + * is 65535 or less, then ustack represents the type u2; otherwise + * ustack represents the type u4.
+ * + *
+ * stack_map { // attribute StackMap
+ *   u2 attribute_name_index;
+ *   u4 attribute_length
+ *   uoffset number_of_entries;
+ *   stack_map_frame entries[number_of_entries];
+ * }
+ * 
+ * + * Each stack map frame has the following format: + * + *
+ * 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];
+ * }
+ * 
+ * + * 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. + * + *
+ * 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;
+ * }
+ * 
+ * + * @see JSR 139 : Connected + * Limited Device Configuration 1.1 + * + * @author Eugene Kuleshov + */ +public class StackMapAttribute extends Attribute { + + static final int MAX_SIZE = 65535; + + /** + * A List of StackMapFrame 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. + * + * Note that Long and Double types are represented by two entries in locals + * and stack. Second entry should be always of type Top. + * + * @see JSR 139 : Connected + * Limited Device Configuration 1.1 + * + * @see "ClassFileFormat-Java6.fm Page 138 Friday, April 15, 2005 3:22 PM" + * + * @author Eugene Kuleshov + */ +public class StackMapFrame { + + /** + * A Label for frame offset within method bytecode. + */ + public Label label; + + /** + * A List of StackMapType instances that represent locals for + * this frame. + */ + public List locals; + + /** + * A List of StackMapType 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).

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.

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

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.

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 ulocalvar + * represents the type u2; otherwise ulocalvar represents the type u4. If the + * maximum size of the operand stack is 65535 or less, then ustack + * represents the type u2; otherwise ustack represents the type u4. + * + *
+ * stack_map { // attribute StackMapTable
+ *   u2 attribute_name_index;
+ *   u4 attribute_length
+ *   uoffset number_of_entries;
+ *   stack_map_frame entries[number_of_entries];
+ * }
+ * 
+ * + * 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 1 + offset_delta to the offset of the + * previous frame, unless the previous frame is the initial frame of the method, + * in which case the byte code offset is offset_delta.

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

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 offset_delta + 1 for all explicit frames, we guarantee + * the absence of duplicates.

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

The stack_map_frame structure consists of a one-byte tag followed + * by zero or more bytes, giving more information, depending upon the tag.
+ *
A stack map frame may belong to one of several frame types + * + *
+ * union stack_map_frame {
+ *   same_frame;
+ *   same_locals_1_stack_item_frame;
+ *   chop_frame;
+ *   same_frame_extended;
+ *   append_frame;
+ *   full_frame;
+ * }
+ * 
+ * + * 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: + * + *
+ * same_frame {
+ *   u1 frame_type = SAME;  // 0-63
+ * }
+ * 
+ * + * 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: + * + *
+ * same_locals_1_stack_item_frame {
+ *   u1 frame_type = SAME_LOCALS_1_STACK_ITEM;  // 64-127
+ *    verification_type_info stack[1];
+ * }
+ * 
+ * + * Tags in the range [128-247] are reserved for future use.

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.

The form of + * such a frame is then: + * + *
+ * chop_frame {
+ *   u1 frame_type=CHOP;  // 248-250
+ *   uoffset offset_delta;
+ * }
+ * 
+ * + * 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: + * + *
+ * same_frame_extended {
+ *   u1 frame_type = SAME_FRAME_EXTENDED;  // 251
+ *   uoffset offset_delta;
+ * }
+ * 
+ * + * 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.

The + * form of such a frame is then: + * + *
+ * append_frame {
+ *   u1 frame_type =APPEND;  // 252-254
+ *   uoffset offset_delta;
+ *   verification_type_info locals[frame_type -251];
+ * }
+ * 
+ * + * 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.

The frame type full_frame is represented by the tag + * value 255. The form of such a frame is then: + * + *
+ * 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];
+ * }
+ * 
+ * + * 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.

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

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.

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. + * + *
+ * 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;
+ * }
+ * 
+ * + * The Top_variable_info type indicates that the local variable has the + * verification type top (T.) + * + *
+ * Top_variable_info {
+ *   u1 tag = ITEM_Top; // 0
+ * }
+ * 
+ * + * The Integer_variable_info type indicates that the location contains the + * verification type int. + * + *
+ * Integer_variable_info {
+ *   u1 tag = ITEM_Integer; // 1
+ * }
+ * 
+ * + * The Float_variable_info type indicates that the location contains the + * verification type float. + * + *
+ * Float_variable_info {
+ *   u1 tag = ITEM_Float; // 2
+ * }
+ * 
+ * + * The Long_variable_info type indicates that the location contains the + * verification type long. If the location is a local variable, then: + * + *
  • It must not be the local variable with the highest index.
  • + *
  • The next higher numbered local variable contains the verification type + * T.
+ * + * If the location is an operand stack entry, then: + * + *
  • The current location must not be the topmost location of the + * operand stack.
  • the next location closer to the top of the operand + * stack contains the verification type T.
+ * + * This structure gives the contents of two locations in the operand stack or in + * the local variables. + * + *
+ * Long_variable_info {
+ *   u1 tag = ITEM_Long; // 4
+ * }
+ * 
+ * + * The Double_variable_info type indicates that the location contains the + * verification type double. If the location is a local variable, then: + * + *
  • It must not be the local variable with the highest index.
  • + *
  • The next higher numbered local variable contains the verification type + * T.
+ * + * If the location is an operand stack entry, then: + * + *
  • The current location must not be the topmost location of the + * operand stack.
  • the next location closer to the top of the operand + * stack contains the verification type T.
+ * + * This structure gives the contents of two locations in in the operand stack or + * in the local variables. + * + *
+ * Double_variable_info {
+ *   u1 tag = ITEM_Double; // 3
+ * }
+ * 
+ * + * The Null_variable_info type indicates that location contains the verification + * type null. + * + *
+ * Null_variable_info {
+ *   u1 tag = ITEM_Null; // 5
+ * }
+ * 
+ * + * The UninitializedThis_variable_info type indicates that the location contains + * the verification type uninitializedThis. + * + *
+ * UninitializedThis_variable_info {
+ *   u1 tag = ITEM_UninitializedThis; // 6
+ * }
+ * 
+ * + * The Object_variable_info type indicates that the location contains an + * instance of the class referenced by the constant pool entry. + * + *
+ * Object_variable_info {
+ *   u1 tag = ITEM_Object; // 7
+ *   u2 cpool_index;
+ * }
+ * 
+ * + * 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. + * + *
+ * Uninitialized_variable_info {
+ *   u1 tag = ITEM_Uninitialized // 8
+ *   uoffset offset;
+ * }
+ * 
+ * + * @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 List of StackMapFrame 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 StackMapType 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 ("".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 JSR 139 : Connected + * Limited Device Configuration 1.1 + * + * @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 MethodAdapter to dispatch method body instruction + *

+ * The behavior is like this: + *

    + * + *
  1. as long as the INVOKESPECIAL for the object initialization has not been + * reached, every bytecode instruction is dispatched in the ctor code visitor
  2. + * + *
  3. when this one is reached, it is only added in the ctor code visitor and + * a JP invoke is added
  4. + *
  5. after that, only the other code visitor receives the instructions
  6. + * + *
+ * + * @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 = "".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. + *

+ * + * Custom code can use or change all the local variables, + * but should not change state of the stack. + */ + 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: + * + *
+     *   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) {
+     *     ...
+     * 
+ * + *

+ * + * Custom code can use or change all the local variables, + * but should not change state of the stack. + * + * @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 + * + *
+ * public class Example {
+ *     public static void main(String[] args) {
+ *         System.out.println("Hello world!");
+ *     }
+ * }
+ * 
+ * + * can be generated as follows: + * + *
+ * ClassWriter cw = new ClassWriter(true);
+ * cw.visit(V1_1, ACC_PUBLIC, "Example", null, "java/lang/Object", null);
+ *
+ * Method m = Method.getMethod("void <init> ()");
+ * 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("void main (String[])");
+ * mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw);
+ * mg.getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
+ * mg.push("Hello world!");
+ * mg.invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println (String)"));
+ * mg.returnValue();
+ * mg.endMethod();
+ *
+ * cw.visitEnd();
+ * 
+ * + * @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 + * null). + * @param exceptions the exceptions thrown by the adapted method (may be + * null). + * @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 null. + */ + 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("", + 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 true. + */ + 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 true. + */ + 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 true. + */ + 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 true. + */ + 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 true. + */ + 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 true. + */ + 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 true to use a TABLESWITCH instruction, or + * false 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 (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 method 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: + * + *
+ *   ClassWriter cw = new ClassWriter(...);
+ *   ClassVisitor sv = new SerialVersionUIDAdder(cw);
+ *   ClassVisitor ca = new MyClassAdapter(sv);
+ *   new ClassReader(orginalClass).accept(ca, false);
+ * 
+ * + * The SVUID algorithm can be found http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/class.html: + * + *
+ * 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, <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.
+ * 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.
+ * 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] >>> 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;
+ * 
+ * + * @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("")) { + 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("")) { + svuidConstructors.add(new Item(name, mods, desc)); + } else if (!name.equals("")) { + 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 + * isHasSVUID 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, , 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(""); + 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, , 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 DataOutputStream value + * @param dotted a boolean 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("")) { + 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 ClassSignature, MethodTypeSignature, + * or FieldTypeSignature. + */ + 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 ClassSignature (such as the + * signature parameter of the + * {@link org.objectweb.asm.ClassVisitor#visit ClassVisitor.visit} method) + * or a MethodTypeSignature (such as the signature + * 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 FieldTypeSignature, such as the + * signature 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):
  • ClassSignature = ( + * visitFormalTypeParameter + * visitClassBound? + * visitInterfaceBound* )* ( visitSuperClass + * visitInterface* )
  • + *
  • MethodSignature = ( visitFormalTypeParameter + * visitClassBound? + * visitInterfaceBound* )* ( visitParameterType* + * visitReturnType + * visitExceptionType* )
  • TypeSignature = + * visitBaseType | visitTypeVariable | + * visitArrayType | ( + * visitClassType visitTypeArgument* ( + * visitInnerClassType visitTypeArgument* )* + * visitEnd ) )
+ * + * @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 + * void. + */ + 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 null 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 null. + */ + 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 null, + * 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 + * null. + */ + public String sourceFile; + + /** + * Debug information to compute the correspondance between source and + * compiled elements of the class. May be null. + */ + public String sourceDebug; + + /** + * The internal name of the enclosing class of the class. May be + * null. + */ + public String outerClass; + + /** + * The name of the method that contains the class, or null if the + * class is not enclosed in a method. + */ + public String outerMethod; + + /** + * The descriptor of the method that contains the class, or null + * 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 null. + */ + public String signature; + + /** + * The field's initial value. This field, which may be null 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 + * null 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 null. + */ + public String outerName; + + /** + * The (simple) name of the inner class inside its enclosing class. May be + * null 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 null. + * @param innerName the (simple) name of the inner class inside its + * enclosing class. May be null 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 null. + */ + 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 + * null. + * @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. labels[i] is + * the beginning of the handler block for the keys[i] 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 null. + * + * @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 null. + * + * @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 null. + * + * @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 true 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 null. + */ + 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 null. + */ + public Object annotationDefault; + + /** + * The runtime visible parameter annotations of this method. These lists are + * lists of {@link AnnotationNode} objects. May be null. + * + * @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 null. + * + * @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 null + * + * @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 null + * + * @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 null. + * @param exceptions the internal names of the method's exception classes + * (see {@link Type#getInternalName() getInternalName}). May be + * null. + */ + 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. labels[i] is + * the beginning of the handler block for the min + i 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 + * null 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 null 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 null 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 null 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 i + * at line 5 are the txo ISTORE instructions at line 1 and 3: + * + *
+     * 1: i = 0;
+     * 2: if (...) {
+     * 3:   i = 1;
+     * 4: }
+     * 5: return i;
+     * 
+ * + * 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 two slots in local variables, and by one 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 true if this frame has been changed as a result of the + * merge operation, or false 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 true if this frame has been changed as a result of the + * merge operation, or false 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 this), + * exception handler variable and with null type + * for variables reserved by long and double types. + * + * @param type a primitive or reference type, or null 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 equal 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 v, + * this method must return v. + */ + 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 true 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 null. + */ + 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 null. + */ + 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:
  • write the Java source code equivalent to the + * bytecode you want to generate;
  • compile it with javac;
  • + *
  • make a {@link ASMifierClassVisitor} visit this compiled class (see the + * {@link #main main} method);
  • edit the generated source code, if + * necessary.
The source code printed when visiting the + * Hello class is the following:

+ * + *
+ * 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,
+ *                 "Hello",
+ *                 null,
+ *                 "java/lang/Object",
+ *                 null);
+ *
+ *         cw.visitSource("Hello.java", null);
+ *
+ *         {
+ *             mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ *             mv.visitVarInsn(ALOAD, 0);
+ *             mv.visitMethodInsn(INVOKESPECIAL,
+ *                     "java/lang/Object",
+ *                     "<init>",
+ *                     "()V");
+ *             mv.visitInsn(RETURN);
+ *             mv.visitMaxs(1, 1);
+ *             mv.visitEnd();
+ *         }
+ *         {
+ *             mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC,
+ *                     "main",
+ *                     "([Ljava/lang/String;)V",
+ *                     null,
+ *                     null);
+ *             mv.visitFieldInsn(GETSTATIC,
+ *                     "java/lang/System",
+ *                     "out",
+ *                     "Ljava/io/PrintStream;");
+ *             mv.visitLdcInsn("hello");
+ *             mv.visitMethodInsn(INVOKEVIRTUAL,
+ *                     "java/io/PrintStream",
+ *                     "println",
+ *                     "(Ljava/lang/String;)V");
+ *             mv.visitInsn(RETURN);
+ *             mv.visitMaxs(2, 1);
+ *             mv.visitEnd();
+ *         }
+ *         cw.visitEnd();
+ *
+ *         return cw.toByteArray();
+ *     }
+ * }
+ *
+ * 
+ * + *
where Hello is defined by:

+ * + *
+ * public class Hello {
+ *
+ *     public static void main(String[] args) {
+ *         System.out.println("hello");
+ *     }
+ * }
+ * 
+ * + *
+ * + * @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.

Usage: ASMifierClassVisitor [-debug] <fully qualified + * class name or class file name> + * + * @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] " + + ""); + 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 null. + */ + 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 + * must 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 operand parameter of the + * {@link org.objectweb.asm.MethodVisitor#visitIntInsn} method when + * opcode is NEWARRAY. + */ + 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 + * only on its arguments, but does not check the sequence + * of method calls. For example, the invalid sequence + * visitField(ACC_PUBLIC, "i", "I", null) visitField(ACC_PUBLIC, + * "i", "D", null) + * will not be detected by this class adapter. + * + * @author Eric Bruneton + */ +public class CheckClassAdapter extends ClassAdapter { + + /** + * true if the visit method has been called. + */ + private boolean start; + + /** + * true if the visitSource method has been called. + */ + private boolean source; + + /** + * true if the visitOuterClass method has been called. + */ + private boolean outer; + + /** + * true if the visitEnd method has been called. + */ + private boolean end; + + /** + * Checks a given class.

Usage: CheckClassAdapter <fully qualified + * class name or class file name> + * + * @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 " + + ""); + 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 ClassReader 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 only on its arguments - + * such as the fact that the given opcode is correct for a given visit method), + * but does not check the sequence of instructions. For example, + * in a method whose signature is void m (), the invalid instruction + * IRETURN, or the invalid sequence IADD L2I will not be detected by + * this code adapter. + * + * @author Eric Bruneton + */ +public class CheckMethodAdapter extends MethodAdapter { + + /** + * true if the visitCode method has been called. + */ + private boolean startCode; + + /** + * true if the visitMaxs method has been called. + */ + private boolean endCode; + + /** + * true 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 name.length() if name is not + * null. + * @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 + * '<init>' or '<clinit>'. + * + * @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("") || name.equals("")) { + return; + } + if (!Character.isJavaIdentifierStart(name.charAt(0))) { + throw new IllegalArgumentException("Invalid " + + msg + + " (must be a '', '' 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 '' or '' 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 name.length() if name is not + * null. + * @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 true if V 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 true if V 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 true 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 true 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 + * null. + */ + 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 null. + */ + 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.

The trace printed when + * visiting the Hello class is the following:

+ * + *
+ * // class version 49.0 (49)
+ * // access flags 33
+ * public class Hello {
+ *
+ *  // compiled from: Hello.java
+ *
+ *   // access flags 1
+ *   public <init> ()V
+ *     ALOAD 0
+ *     INVOKESPECIAL java/lang/Object <init> ()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 "hello"
+ *     INVOKEVIRTUAL java/io/PrintStream println (Ljava/lang/String;)V
+ *     RETURN
+ *     MAXSTACK = 2
+ *     MAXLOCALS = 1
+ * }
+ * 
+ * + *
where Hello is defined by:

+ * + *
+ * public class Hello {
+ *
+ *     public static void main(String[] args) {
+ *         System.out.println("hello");
+ *     }
+ * }
+ * 
+ * + *
+ * + * @author Eric Bruneton + * @author Eugene Kuleshov + */ +public class TraceClassVisitor extends TraceAbstractVisitor implements + ClassVisitor +{ + + /** + * The {@link ClassVisitor} to which this visitor delegates calls. May be + * null. + */ + 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.

+ * Usage: TraceClassVisitor [-debug] <fully qualified class name or class + * file name > + * + * @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] " + + ""); + 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 null. + * @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 + * null. + */ + 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 + * null. + */ + 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 null. + */ + 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 + // 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 = ""; + + /** + * true 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 true 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 null. + * + * @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 null. + * + * @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 null. + * + * @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.

In order to use a concrete XSLT engine, + * system property javax.xml.transform.TransformerFactory must be set + * to one of the following values. + * + *

+ * + * + * + * + * + * + * + * + * + * + *
jd.xsltjd.xml.xslt.trax.TransformerFactoryImpl
Saxon net.sf.saxon.TransformerFactoryImpl
Caucho com.caucho.xsl.Xsl
Xalan interpeter org.apache.xalan.processor.TransformerFactory
Xalan xsltc org.apache.xalan.xsltc.trax.TransformerFactoryImpl
+ * + * @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 ] [-out ] [-xslt ]"); + System.err.println(" when -in or -out is omitted sysin and sysout would be used"); + System.err.println(" and - 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}. + * + *
This implementation does not support namespaces, entity + * definitions (uncluding DTD), CDATA and text elements.
+ */ + 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 SAXWriter. + * + * @param w writer + * @param optimizeEmptyElements if set to true, 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("\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("\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("&"); + break; + + case '<': + sb.append("<"); + break; + + case '>': + sb.append(">"); + break; + + case '\"': + sb.append("""); + 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.

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.

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 true 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 ClassLoader 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= 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 + * NotifyingInputStreamReader 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 + * NotifyingInputStreamReader. + */ + public int getLineNumber() + { + return lineNumber; + } + + /** + * Return the 0-based column number where the malformed input + * begins in the stream read by the + * NotifyingInputStreamReader. + */ + public int getColumnNumber() + { + return columnNumber; + } + + /** + * Return the length (in bytes) of the malformed input encountered + * by the NotifyingInputStreamReader. Note that a + * consecutive run of malformed input isn't necessarily reported + * as a whole; depending on the Charset and + * implementation details of CharsetDecoder, 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 NotifyingInputStreamReader 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. + * + *

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.

+ * + *

Background: The default + * InputStreamReader implementation will ignore + * malformed input, silently replacing it with the default + * replacement string (usually the question mark). Alternatively, you + * can configure a CharsetDecoder for the default + * InputStreamReader 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 + * InputStreamReader to gracefully handle malformed data + * but notify the client code about such + * problems. NotifyingInputStreamReader fills this + * gap.

+ * + * @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 + * file.encoding. If this property isn't set, + * ISO-8859-1 is used as a fallback. + * + *

This method should use {@link Charset.defaultCharset()} + * instead, but this isn't implemented in Classpath at the + * moment.

+ * + * @param in the InputStream 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 InputStream to read from. + * @param charsetName the canonical name or an alias of a + * Charset. + * + * @throws IllegalCharsetNameException if there is no + * Charset with the given canonical name or alias. + * + * @throws UnsupportedCharsetException if there is no support for + * the specified Charset 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 InputStream to read from. + * @param charset the Charset 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. + * + * Note: the + * NotifyingInputStreamReader will not exhibit the + * advertised behaviour if you changed the action to take on + * malformed input in the specified + * CharsetDecoder. 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 InputStream to read from. + * @param charset the CharsetDecoder 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 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 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 MalformedInputListener which should be + * notified when malformed input is encountered. + */ + public void addMalformedInputListener(MalformedInputListener listener) + { + this.listeners.add(listener); + } + + /** + * Unregister a previously registered + * MalformedInputListener 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 haystack with all occurrences of + * needle replaced by replacement. + * + * @param haystack the string to replace occurrences of needle in + * @param needle the substring to replace + * @param replacement the substring to replace needle with + * + * @return haystack with all occurrences of + * needle replaced by replacement. + */ + 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 AppletLoader 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 Class 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 <> 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 APPLET 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 ContainerEvent 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 ContainerEvent 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 ComponentEvent 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 ComponentEvent 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 ComponentEvent 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 ComponentEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 InputMethodEvent 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 InputMethodEvent 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 + * getChangeFlags() 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 = + ""; + + // Handle parameters. + Iterator pairs = parameters.iterator(); + while (pairs.hasNext()) + { + StringTokenizer paramTokenizer = + new StringTokenizer((String) pairs.next(), ","); + tagString += + ""; + } + + tagString += ""; + + 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 ContainerEvent 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 ContainerEvent 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 ComponentEvent 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 ComponentEvent 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 ComponentEvent 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 ComponentEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 MouseEvent 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 InputMethodEvent 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 InputMethodEvent 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 + * getChangeFlags() 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 Helper class containing general purpose utlity methods dealing with + * callback handlers and their Security Provider. + */ +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 console; + * i.e. System.in and System.out. + *

+ * If no Security Provider 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. + *

+ * 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 returned. + * + * @return a {@link CallbackHandler} of the designated type, or + * null 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 fileResult = new ArrayList(); + + 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 @ + * 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 Helper class containing general purpose utlity methods dealing with + * installing and removing Security Providers 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 Security Providers already + * present at runtime, only if it is not already installed. + *

+ * IMPORTANT: 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 + * Security Provider 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 Security Providers already present at runtime, only + * if it is not already installed. + *

+ * IMPORTANT: This method overrides the security check usually carried + * out by the security manager when inserting a new {@link Provider}. + * + * @param provider a non-null Security Provider 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 -1 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 Security Provider. + *

+ * IMPORTANT: 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 Security Provider and its + * position in the list of installed Security Providers in the underlying + * JVM runtime. + */ +public class SecurityProviderInfo +{ + final private Provider provider; + final private int position; + private transient String str; + + /** + * Constructs an instance of SecurityProviderInfo. + *

+ * Used by {@link ProviderUtil} to indicate the result of adding a provider, + * given its class name. + * + * @param provider the possibly null {@link Provider}. + * @param position the position of provider in the list of + * Security Providers in the underlying JVM runtime. -1 + * if that provider (a) is null, 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 null {@link Provider} instance. */ + public Provider getProvider() + { + return this.provider; + } + + /** + * @return the position of the {@link Provider}, or -1 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 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:Xaoptcmf:\"."); + } + 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 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; iAbstractDoclet members or members of + * AbstractDoclet 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; i0) { out.print(", "); } + out.print(thrownExceptions[k].qualifiedTypeName()); + } + out.println(); + } + + printSub2Header("Fields"); + + FieldDoc[] fields = classes[i].fields(); + + for (int j=0; jdiv and span 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 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("<Unnamed>"); + } + 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"); + if (null == rootNode) { + rootNode = new TreeNode(null); + treeMap.put("", 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"); + 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("<unnamed package>"); + } + 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 0) { + output.print(packageDoc.name()); + } + else { + output.print("<Unnamed>"); + } + 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 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 0) { + deprecatedConstructors.add(constructors[j]); + } + } + MethodDoc[] methods = classDoc.methods(); + for (int j=0; j 0) { + deprecatedMethods.add(methods[j]); + } + } + FieldDoc[] fields = classDoc.fields(); + for (int j=0; j 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 0) { + output.beginDiv(CssClass.CLASS_SYNOPSIS_IMPLEMENTS); + if (!classDoc.isInterface()) { + output.print("implements "); + } + else { + output.print("extends "); + } + for (int i=0; i0) { + 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 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 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; i0) { + 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 0) { + synopsis.append("\n throws "); + for (int j=0; j 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 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 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 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 0) { + output.print(", "); + } + printType(output, parameters[j].type()); + output.print(" "); + 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 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 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 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 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 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(""); + if (!plainFont) { + result.append(""); + } + result.append(label); + if (!plainFont) { + result.append(""); + } + result.append(""); + } + else { + if (!plainFont) { + result.append(""); + } + result.append(label); + if (!plainFont) { + result.append(""); + } + } + + 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("

"); + result.append("
"); + result.append("See Also:"); + result.append("
"); + + boolean oneLine = true; + + if (oneLine) { + result.append("
"); + } + + for (int i = 0; i < tags.length; ++i) { + if (oneLine) { + if (i > 0) { + result.append(", "); + } + } + else { + result.append("
"); + } + result.append(renderSeeTag((SeeTag)tags[i], context, false)); + if (!oneLine) { + result.append("
"); + } + } + + if ((doc instanceof ClassDoc) + && (((ClassDoc)doc).isSerializable() || ((ClassDoc)doc).isExternalizable())) { + if (tags.length > 0) { + result.append(", "); + } + HtmlPage output = ((HtmlTagletContext)context).getOutput(); + result.append("Serialized Form"); + } + + if (oneLine) { + result.append(""); + } + result.append("
"); + 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 = "<"; + 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 += ">"; + } + return parameters; + } + + private String transformReferencedMemberName(String referencedMemberName, + boolean javadocCompatibility) + { + if (!javadocCompatibility) { + StringBuffer result = new StringBuffer(); + for (int i=0; i"; + + public HtmlPage(File file, String pathToRoot, String encoding, String baseUrl, File rootDir) + throws IOException + { + this(file, pathToRoot, encoding, baseUrl, rootDir, ""); + } + + 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'); + } + + 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'); + } + + 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"); + } + + + public void endElement(String 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("\n"); + print(docType); + print(""); + 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(""); + 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"); + result.append(content); + result.append(""); + 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 /dev/null. + */ + 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 null. + */ + 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 + * indentStep 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 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 0) { + printOpenTag(2, "serializableFields"); + + FieldDoc[] sfields = classDoc.serializableFields(); + for (int i=0, ilim=sfields.length; i 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"); + } + //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"); + } + 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= 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:Xaoptcmf:\"."); + } + } + } + + // 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, ""); + println(""); + 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, ""); + + 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, ""); + ClassDoc[] specifiedClasses = rootDoc.specifiedClasses(); + for (int i=0, ilim=specifiedClasses.length; i"); + PackageDoc[] specifiedPackages = rootDoc.specifiedPackages(); + for (int i=0, ilim=specifiedPackages.length; i"); + { + 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, ""); + PackageDoc[] packages = rootDoc.specifiedPackages(); + for (int i=0, ilim=packages.length; i"); + ClassDoc[] sumclasses = rootDoc.classes(); + for (int i=0, ilim=sumclasses.length; i"); + 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(""); + println(""); + + 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; irm -Rf directory + * + * @return true on success + */ + private static boolean deleteRecursive(File directory) { + + boolean success = true; + + File[] files = directory.listFiles(); + + for (int i=0, ilim=files.length; i"); + } + + /** + * 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, ""); + } + else { + print(level, ""); + } + } + + 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 < with &lt;, + * > with &gt; and + * & with &amp;. + * + * @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, + "<", "<" + ), + ">", ">" + ), + "&", "&" + ); + } + + /** + * Replaces all occurences of string needle within string + * haystack by string replacement. + * + * @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 needle 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=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= 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 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, ""); + println(""); + 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; i0) { + 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"); + } + */ + + 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, ""+fieldDoc.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 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 '' 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=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("<"+tag+">"); + return; + } + + tagName = tagName.toLowerCase(); + + if (_isLeadingTag && "p".equals(tagName) && !isEndTag && throwAwayLeadingPara) { + return; + } + + if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) { + // throw away

and
+ if (isEndTag) { + return; + } + // make sure every

is a

and every
is a
+ 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 '"); + output.append(""); + } + 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=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 '......'); + if (!tagStack.isEmpty() && tagStack.peek().equals(tagName)) { + printWarning("Inserting "); + output.append(""); + 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(""); + printWarning("Inserting "); + } + return true; + } + } + return false; + } + + private void flush() { + + // close all pending tags + while (!tagStack.isEmpty()) { + String tagName = (String)tagStack.pop(); + printWarning("Inserting "); + output.append(""); + } + } + + /** + * 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; i0) { + haveText(buf.toString()); + buf.setLength(0); + } + } + else if ('>'==c) { + // assume this is a greater-than sign + buf.append(">"); + } + 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("&"); + 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("&"); + buf.append(">"); + state = STATE_INITIAL; + } + else if ('&'==c) { + buf.append("&"); + buf.append("&"); + state = STATE_INITIAL; + } + else if (-1==c) { + buf.append("&"); + 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=0) { + //continue; + + // new: assume this is a less-sign + haveText("<"+c); + state = STATE_INITIAL; + } + else if ('/'==c) { + buf.append((char)c); + state = STATE_TAG; + } + else if ('<'==c) { + // assume this is a less-sign + haveText("<<"); + state = STATE_INITIAL; + } + else if ('>'==c) { + // assume this is a less-sign + haveText("<>"); + 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("<"+(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 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= 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}. + *

+ * The text to print may contain \n 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 leftMargin + 2 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. + *

+ * 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}. + *

+ * The text to print may contain \n 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 leftMargin + 2 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}. + *

+ * The text to print may contain \n 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. + *

+ * 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}. + *

+ * The text to print may contain \n 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. + *

+ * 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 --help option. + *

+ * 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=beginIndex && currentIndexbeginIndex)?endIndex-1:endIndex)]; + } + + // Increments the iterator's index by one and returns the character at the new index. + public char next() { + 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') + { + --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=0) { + for (int i=ndx; 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 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= 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; + } + + /** + *

+ * Parses the type variables declared in the class definition. + * The syntax is: + *

+ *

+ *

+ *
TypeParameters:
+ *
< TypeParameter { , TypeParameter }
+ *
TypeParameter:
+ *
Identifier { extends Bound + * }
+ *
Bound:
+ *
Type{& Type }
+ *
+ * + * @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 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=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 text, + * starting at startIndex and stopping at + * endIndex. + * + * @param text the text to be searched + * @param startIndex index in text at which to start + * @param endIndex index in text at which to stop + * + * @return the index of the character following the end-of-sentence + * marker, endIndex 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; irawDocStart) { + + 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=(i0) { + addTag(tags, "text", bufToString(), i0) { + AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i0) { + AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i0) { + AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i")) { + newTag = new TextTagImpl(txt.substring(3)); + } + else if (txt.endsWith("

")) { + 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; iDocErrorReporter
: writes + * to System.err. + */ +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 true, no notices will be emitted. + */ + private boolean quiet = false; + + /* + * When true, 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=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]!='(' && ndx0) { + 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=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; i0) { + 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 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; iinheritDoc
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; + + /** + * false during Phase I: preparation of the documentation data. + * true 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 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 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 Doclet class to use for generating output\n" + + " -docletpath Specifies the search path for the doclet and\n" + + " dependencies\n" + + " -source Provide source compatibility with specified\n" + + " release (1.4 to handle assertion)\n" + + " -sourcepath Where to look for source files\n" + + " -s Alias for -sourcepath\n" + + " -subpackages List of subpackages to recursively load\n" + + " -exclude 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 Locale to be used, e.g. en_US or en_US_WIN\n" + + " -encoding Source file encoding name\n" + + " -breakiterator Compute first sentence with BreakIterator\n" + + " -classpath 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 Browser window title\n" + + " -doctitle Title near the top of the overview summary file\n" + + " (HTML allowed)\n" + + " -title Title for this set of API documentation\n" + + " (deprecated, -doctitle should be used instead)\n" + + " -header Text to include in the top navigation bar\n" + + " (HTML allowed)\n" + + " -footer Text to include in the bottom navigation bar\n" + + " (HTML allowed)\n" + + " -bottom Text to include at the bottom of each output file\n" + + " (HTML allowed)\n" + + " -link Link to external generated documentation at URL\n" + + " -linkoffline \n" + + " Link to external generated documentation for\n" + + " the specified package-list\n" + + " -linksource Creates an HTML version of each source file\n" + + " -group \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 Path to an alternate help file\n" + + " -stylesheetfile Path to an alternate CSS stylesheet\n" + + " -addstylesheet Path to an additional CSS stylesheet\n" + + " -serialwarn Complain about missing '@serial' tags [ignored]\n" + + " -charset Specifies the HTML charset\n" + + " -docencoding \n" + + " Specifies the encoding of the generated HTML files\n" + + " -tag :Xaoptcmf:\"\"\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 \n" + + " Excludes 'doc-files' subdirectories with a give name\n" + + " -noqualifier all|\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 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 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" + + " .\n" + + " -indentstep How many spaces to indent each tag level in\n" + + " generated XML code.\n" + + " -xsltdriver Specifies the XSLT driver to use for transformation.\n" + + " By default, xsltproc is used.\n" + + " -postprocess 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 Specify handling of mail addresses in @author tags.\n" + + " no-replace do not replace mail addresses (default).\n" + + " mailto-name replace by Real Name.\n" + + " name-mailto-address replace by Real Name (abc@foo.com).\n" + + " name-mangled-address replace by Real Name (abc AT foo DOT com).\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=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=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= 0) { + parser.setBoilerplateComment(boilerplateComment); + } + } + + return endIndex; + } + } + + class SlashSlashCommentComponent extends SourceComponent { + + int match(char[] source, int index) { + if (index+1=0) { + + for (index+=7; index=0) { + + for (index+=7; index=0; ++index) + ; + + if (index0) { + 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))) && endIndex0) + 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; i0) { + 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=0) { + //Debug.log(1,componentTypes[i].getClass().getName()+" ("+match+"/"+source.length+")"); + break; + } + } + + if (iClassDocImpl + */ + 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 + * null 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 = ""; + } + 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; i0) { + + // 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 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 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(""); + if (end == -1) + end = html.indexOf(""); + 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= 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 + * + * Consider the following problem: + *
+ *   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
+ *     }
+ *  }
+ *  
+ * + * In method bar(), the array cannot be garbage + * collected because the local variable hugeArray in + * method foo() still holds a reference to the array. + *

+ * + * When calling bar(new long[1000000]); in + * arr the array can be collected in + * bar(), but that way it can't be initialized in + * foo(). A local variable is needed for + * initialization, but the variable can't be cleared before it is + * passed to bar()!

+ * + * TemporaryStore is the solution for this + * dilemma. The modified method foo() which uses a + * TemporaryStore object would look like this: + * + *

+ *     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());
+ *     }
+ *  
+ * + * When control flow is transferred to bar(), + * foo() will hold no more references to the array + * and so it can be garbage collected in bar(). + * + */ +public class TemporaryStore { + + private Object storedObject; + + /** + * Temporarily store the given object for passing it to a + * different method.

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

+ * + * 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= 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 null if the expression evaluates to + * null. + * + * @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 writtenItems = new HashSet(); + // 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 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 getAllEntries(Main parameters) + { + ArrayList allEntries = new ArrayList(); + 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 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 entries = new LinkedHashSet(); + 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 entries = new ArrayList(); + + /** 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 allItems; + + private void initSet(ArrayList entries) + { + if (entries == null || entries.isEmpty()) + return; + allItems = new HashSet(); + 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 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 gjarsigner 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 gjarsigner 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 entryHashes = new HashMap(); + + 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 sfFiles = new ArrayList(); + 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 true if the designated file-name (usually a key-store + * alias name) has been successfully checked as the signer of the + * corresponding .SF file. Returns false 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 + * alias name) was found to be trusted; i.e. his/her signature + * block in the corresponding .DSA file was successfully + * verified using his/her public key. + *

+ * This method, uses the contents of the corresponding .SF 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 true if all the entries in the corresponding + * .SF file have the same hash values as their + * alter-ego in the manifest 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 entries = new HashMap(); + 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 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 true if our computation of the manifest's hash + * matches the given value; false 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 true if our computation of the JAR entry's hash + * matches the given value; false 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 jarsigner tool. + *

+ * The jarsigner tool is used to sign and verify JAR (Java ARchive) + * files. + *

+ * 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 fileAndAlias = new ArrayList(); + + 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 start() method of the concrete handler. + *

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

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

+ * 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 is set but 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. + *

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

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

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

+ * 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 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 = 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 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 .SF file to the designated JAR + * output stream. Line-endings are platform-independent and consist of the + * 2-codepoint sequence 0x0D and 0x0A. + * + * @param jar the JAR output stream to write a .SF 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. + *

+ * The ContentInfo ASN.1 syntax is as described in the "PKCS#7 Cryptographic + * Message Syntax Standard" (RSA Labs) specifications: + *

+   * ContentInfo ::= SEQUENCE {
+   *   contentType     ContentType,
+   *   content     [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
+   * }
+   *
+   * ContentType ::= OBJECT IDENTIFIER
+   * 
+ *

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

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

+ * Finally the SignerInfo is a per-signer structure. Its ASN.1 syntax looks + * like so: + *

+   * 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
+   * 
+ * + * @param jar the JAR output stream to write a .DSA file to. + * @param signerKey the private key to sign with. + * @param certificates the possibly null signer certificate chain. + * @param internalSF if true 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 digestAlgorithms = new HashSet(); + List digestAlgorithm = new ArrayList(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 signerInfos = new HashSet(); + 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(); + 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 (false) or not (true). + */ + 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.) + *

+ * 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("\r\n"); + if (isXHTML_1_1) + { + bufferOut.append("\r\n"); + bufferOut.append("\r\n"); + } + else + { + bufferOut.append("\r\n"); + bufferOut.append("\r\n"); + } + bufferOut.append(" \r\n"); + bufferOut.append(" \r\n"); + bufferOut.append(" " + sourceFileName + "\r\n"); + bufferOut.append(" \r\n"); + bufferOut.append(" \r\n"); + if (hasInternalStyleSheet) + { + bufferOut.append(" \r\n"); + } + + if (hasExternalStyleSheet) + { + bufferOut.append(" \r\n"); + } + bufferOut.append(" \r\n"); + bufferOut.append(" \r\n"); + } + if (hasTitle) + { + bufferOut.append("

\r\n"); + bufferOut.append(" " + sourceFileName + "\r\n"); + bufferOut.append("
\r\n"); + bufferOut.append("
\r\n"); + } + if (hasLegend) + { + bufferOut.append("
\r\n"); + bufferOut.append(" Legend\r\n"); + bufferOut.append("
\r\n"); + bufferOut.append("
\r\n"); + bufferOut.append("
\r\n"); + bufferOut.append(" "); + bufferOut.append("keyword\r\n"); + bufferOut.append(" "); + bufferOut.append("method\r\n"); + bufferOut.append(" variable" + + "\r\n"); + bufferOut.append(" " + + "singleLineComment\r\n"); + bufferOut.append(" " + + "traditionalComment\r\n"); + bufferOut.append(" " + + "javadocComment\r\n"); + bufferOut.append(" javadocTag" + + "\r\n"); + bufferOut.append(" " + + "importName\r\n"); + bufferOut.append(" " + + "packageName\r\n"); + bufferOut.append(" " + + "primitiveType\r\n"); + bufferOut.append(" " + + "nonPrimitiveType\r\n"); + bufferOut.append(" " + + "constructor\r\n"); + bufferOut.append(" " + + "constant\r\n"); + bufferOut.append(" " + + "doubleQuote\r\n"); + bufferOut.append(" " + + "singleQuote\r\n"); + bufferOut.append(" " + + "numericLiteral\r\n"); + bufferOut.append(" " + + "primitiveLiteral\r\n"); + bufferOut.append("
\r\n"); + bufferOut.append("
\r\n"); + bufferOut.append("
\r\n"); + } + bufferOut.append("
\r\n"); + if (hasLineModulusCodeBlocks) + { + bufferOut.append("
\r\n");
+        }
+        else
+        {
+            bufferOut.append("
\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()),
+                                                 "");
+                        }
+                        bufferOut.append("
\r\n"); + bufferOut.append("
"); + bufferOut.append("\r\n
\r\n");
+                        if (State.TRADITIONAL_COMMENT == presentState)
+                        {
+                            bufferOut.append("");
+                        }
+                        if (State.JAVADOC == presentState)
+                        {
+                            bufferOut.append("");
+                        }
+                    }
+                    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("");
+
+                if (hasLineNumbers)
+                {
+                    if ((lineModulus > 0) && (codeLineNumber%lineModulus == 0))
+                    {
+                        bufferOut.append("");
+                        bufferOut.append(codeLineNumber);
+                        bufferOut.append(": ");
+                        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), "");
+                                bufferOut.insert((bufferOut.length() -
+                                                  (" ").length()), "");
+                            }
+                            spaceLength = 0;
+                        }
+                    }
+                    else
+                    {
+                        // line numbers are in lineNumberColor
+                        bufferOut.append("");
+                        bufferOut.append(codeLineNumber);
+                        bufferOut.append(": ");
+                    }
+                }
+                isNewLine = false;
+
+                bufferOut.append("");
+            }
+            // 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,
+                                     "");
+                    bufferOut.append("");
+                    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,
+                                         "");
+                        bufferOut.append("");
+                        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,
+                                     "");
+                    bufferOut.append("");
+                    presentState = State.TEXT;
+                }
+                else if (State.PACKAGE_NAME == presentState)
+                {
+                    // package identifier
+                    bufferOut.insert(bufferOut.length() -
+                                     qualifiedIdentifierLength,
+                                     "");
+                    bufferOut.append("");
+                    presentState = State.TEXT;
+                }
+                else if (State.TEXT == presentState)
+                {
+                    if (keywordCollection.contains(identifier))
+                    {
+                        // identifier is a keyword
+                        bufferOut.insert(bufferOut.length() -
+                                         qualifiedIdentifierLength,
+                                         "");
+                        bufferOut.append("");
+                        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,
+                                         "");
+                        bufferOut.append("");
+                    }
+                    else if ((identifier.equals(identifier.toUpperCase())) &&
+                             (!(Character.isDigit(identifier.charAt(0)))))
+                    {
+                        // identifier is a constant
+                        bufferOut.insert(bufferOut.length() -
+                                         qualifiedIdentifierLength,
+                                         "");
+                        bufferOut.append("");
+                    }
+                    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,
+                                             "");
+                            bufferOut.append("");
+                        }
+                        else
+                        {
+                            // identifier is a non-primitive type
+                            bufferOut.insert(bufferOut.length() -
+                                             qualifiedIdentifierLength,
+                                             "");
+                            bufferOut.append("");
+                        }
+                    }
+                    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,
+                                             "");
+                            bufferOut.append("");
+                        }
+                        else if (bufferIn.charAt(saveIndex) == ',')
+                        {
+                            // comma seperated variables
+                            bufferOut.insert(bufferOut.length() -
+                                             qualifiedIdentifierLength,
+                                             "");
+                            bufferOut.append("");
+                        }
+                        else
+                        {
+                            // a variable
+                            // take care of cases such as array[index].variable
+                            if (bufferIn.charAt(presentIndex -
+                                                (qualifiedIdentifierLength
+                                                 + 1)) == '.')
+                            {
+                                qualifiedIdentifierLength++;
+                            }
+                            bufferOut.insert(bufferOut.length() -
+                                             qualifiedIdentifierLength,
+                                             "");
+                            bufferOut.append("");
+                        }
+                    }
+                    else
+                    {
+                        if (primitiveLiteralCollection.contains(identifier))
+                        {
+                            // primitiveLiteral (boolean or null)
+                            bufferOut.insert(bufferOut.length() -
+                                             identifierLength, "");
+                            bufferOut.append("");
+                        }
+                        // a numeric literal
+                        else
+                        {
+                            if (((presentIndex -
+                                  (qualifiedIdentifierLength + 1)) > 0) &&
+                                (bufferIn.charAt(presentIndex -
+                                     (qualifiedIdentifierLength + 1)) == '.'))
+                            {
+                                qualifiedIdentifierLength++;
+                            }
+                            bufferOut.insert(bufferOut.length() -
+                                             qualifiedIdentifierLength,
+                                             "");
+                            bufferOut.append("");
+                        }
+                    }
+                }
+                qualifiedIdentifierLength = 0;
+                identifierLength = 0;
+            }
+            // process characters NOT in identifiers
+            switch (presentChar)
+            {
+                case '&': //ampersand
+                    bufferOut.append("&");  // HTMLify character
+                    break;
+                case '<': // less than sign
+                    bufferOut.append("<");   // HTMLify character
+                    break;
+                case '>': // greater than sign
+                    bufferOut.append(">");   // HTMLify character
+                    break;
+                case '\"': // double quote
+                    bufferOut.append("""); // HTMLify character
+                    if (State.TEXT == presentState)
+                    {
+                        presentState = State.DOUBLE_QUOTE;
+                        bufferOut.insert(bufferOut.length()-(""").length(),
+                                         "");
+                    }
+                    else if (State.DOUBLE_QUOTE == presentState)
+                    {
+                        presentState = State.TEXT;
+                        bufferOut.append("");
+                    }
+                    break;
+                case '\'': // single quote
+                    bufferOut.append("\'");
+                    if (State.TEXT == presentState)
+                    {
+                        presentState = State.SINGLE_QUOTE;
+                        bufferOut.insert(bufferOut.length() - ("\'").length(),
+                                         "");
+                    }
+                    else if (State.SINGLE_QUOTE == presentState)
+                    {
+                        presentState = State.TEXT;
+                        bufferOut.append("");
+                    }
+                    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(), "");
+                        }
+                        else
+                        {
+                            presentState = State.TRADITIONAL_COMMENT;
+                            bufferOut.insert(bufferOut.length() -
+                                             ("/*").length(), "");
+                        }
+                    }
+                    break;
+                case '/': // foward slash
+                    bufferOut.append("/");
+                    if (((State.TRADITIONAL_COMMENT == presentState) ||
+                         (State.JAVADOC == presentState)) &&
+                        (bufferIn.charAt(presentIndex - 1) == '*'))
+                    {
+                        bufferOut.append("");
+                        presentState = State.TEXT;
+                    }
+                    if ((State.TEXT == presentState) &&
+                        (presentIndex > 0)  &&
+                        (bufferIn.charAt(presentIndex - 1) == '/'))
+                    {
+                        bufferOut.insert(bufferOut.length() - ("//").length(),
+                                         "");
+                        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("");
+                        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("");
+                        }
+                        bufferOut.append("\r\n");
+                        bufferOut.append("
\r\n"); + bufferOut.append("
\r\n"); + bufferOut.append("
\r\n");
+                        // restart multi-line spanning states
+                        if (State.TRADITIONAL_COMMENT == presentState)
+                        {
+                            bufferOut.append("");
+                        }
+                        if (State.JAVADOC == presentState)
+                        {
+                            bufferOut.append("");
+                        }
+                    }
+                    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("");
+                    }
+                    break;
+                default:  // everything else
+                    bufferOut.append(presentChar);
+            }
+            qualifiedIdentifierLength = 0;
+        }
+        if (presentState == State.LINE_COMMENT) {
+            bufferOut.append("\r\n");
+        }
+
+        bufferOut.append("
\r\n"); + // end block early if no more source code + if ((lineModulus > 0) && hasLineModulusCodeBlocks && !isNewBlock && + (codeLineNumber%lineModulus != 0)) + { + bufferOut.append("
\r\n"); + } + bufferOut.append(" \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("
\r\n"); + bufferOut.append("
\r\n"); + if (hasFooterIcons) + { + if (hasFooterDate) + { + bufferOut.append(" \r\n"); + } + bufferOut.append(" \r\n"); + bufferOut.append(" \"Valid\r\n"); + bufferOut.append(" \r\n"); + bufferOut.append("  \r\n"); + bufferOut.append(" \r\n"); + bufferOut.append(" \"Valid\r\n"); + bufferOut.append(" \r\n"); + } + else + { + bufferOut.append(" This is a valid\r\n"); + bufferOut.append(" XHTML 1.1\r\n"); + } + else + { + bufferOut.append("\">XHTML 1.0\r\n"); + } + bufferOut.append(" with\r\n"); + bufferOut.append(" CSS\r\n"); + bufferOut.append(" document \r\n"); + if (hasFooterDate) + { + bufferOut.append(" \r\n"); + } + } + bufferOut.append("
\r\n"); + } + bufferOut.append(" \r\n"); + bufferOut.append("\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 interfaceClasses; + + // The virtual table for this class. + ArrayList vtable; + + // A set of all the bridge method targets we've found. + HashSet bridgeTargets; + + // A set of all the method names in this class. + HashSet methodNames = new HashSet(); + + // 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 methodNameMap = new HashMap(); + + 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(); + 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(superClass.vtable); + bridgeTargets = new HashSet(superClass.bridgeTargets); + methodNameMap = new HashMap(superClass.methodNameMap); + } + else + { + // Object. + vtable = new ArrayList(); + bridgeTargets = new HashSet(); + methodNameMap = new HashMap(); + } + 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 textList) + { + if (textList == null) + return; + Iterator 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 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 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 allClasses = new HashSet(); + + 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 "); + 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 "); + out.println("#include "); + } + + 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 commands = new ArrayList(); + + 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 "); + } + + 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 methodNameMap = new HashMap(); + + 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 keywords; + static + { + keywords = new HashSet(); + 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 classMap = new HashMap(); + + // Map class names to lists of Text objects. + HashMap> textMap = new HashMap>(); + + 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 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(); + 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 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 null if the option -force was + * specified on the command line and the designated file already + * exists. + * @throws IOException if outFileName 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 klasses, Printer printer) + throws IOException + { + Iterator> i = klasses.entrySet().iterator(); + while (i.hasNext()) + { + Map.Entry 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 klasses = new HashSet(); + 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 i = klasses.iterator(); + HashMap results = new HashMap(); + 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 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 ("".equals(meth.name)) + return; + boolean isInit = "".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 classpath = new ArrayList(); + + ArrayList bootclasspath = new ArrayList(); + + void setPath(ArrayList list, String path) + { + list.clear(); + StringTokenizer st = new StringTokenizer(path, File.pathSeparator); + while (st.hasMoreTokens()) + { + list.add(st.nextToken()); + } + } + + void addExtDirs(ArrayList 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 urls = new ArrayList(); + classpath.addAll(bootclasspath); + Iterator 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 + * -d option was used), or a file (when the -o + * option was used) on the command line. + */ + protected File outputFileObject; + + /** + * Set to true if the field outputFileObject denotes + * a directory; i.e. for each input class file, one JNI header file will be + * generated in that directory. + *

+ * Set to false if the field outputFileObject + * denotes a file; i.e. all generated headers will be written to that file. + */ + protected boolean isDirectory; + + /** + * Set to true if the output file(s) should always be written. + *

+ * When set to false, the contents of the header/stub are only + * written to the file if it does not already exist. + */ + protected boolean force; + + /** + * Set to true 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 -cacert keytol command handler is used to import a CA + * trusted X.509 certificate into a key store. + *

+ * Possible options for this command are: + *

+ *

+ *
-file FILE_NAME
+ *
The fully qualified path of the file containing the trusted CA + * certificate to import. If omitted, the tool will process STDIN. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 brasil.gov.br.cert will result in + * brasil_gov_br 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 -certreq keytool command handler is used to generate a Certificate + * Signing Request (CSR) in PKCS#10 format. + *

+ * The ASN.1 specification of a CSR, as stated in RFC-2986 is as follows: + *

+ *

+ * 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
+ * }
+ * 
+ * IMPORTANT: Some documentation (e.g. RSA examples) claims that the + * attributes field is OPTIONAL while RFC-2986 + * implies the opposite. This implementation considers this field, by default, + * as OPTIONAL, unless the option -attributes is included + * on the command line. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-sigalg ALGORITHM
+ *
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 Alias. If the private key is a DSA one, + * the value for the signature algorithm will be SHA1withDSA. + * If on the other hand the private key is an RSA one, then + * the tool will use MD5withRSA as the signature algorithm. + *

+ * + *
-file FILE_NAME
+ * + *
-keypass PASSWORD
+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output. + *

+ * + *
-attributes
+ *
Use this option to force the tool to encode a NULL DER value in the + * CSR as the value of the Attributes field.
+ *
+ */ +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 NULL 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. + *

+ * 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 startIndex + 1, 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. + *

+ * The general contract of this method is that it is invoked with the + * startIndex argument pointing to the keyword argument that + * uniquelly identifies the command itself; e.g. -genkey or + * -list, etc... + * + * @param args an array of options for this handler and possibly other + * commands and their options. + * @return the remaining un-processed args. + */ + 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. + *

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

+ * The code in this (abstract) class throws a Not implemented yet + * 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. + *

+ * Calls the method with the same name and 5 arguments passing + * false 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 true 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 + * null, 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 gkr 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 + * null, then a default value of mykey + * 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 true an attempt to create a + * keystore at the designated location will be made. If + * false 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 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 null 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 null 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... + *

+ * If the designated algorithm name is null 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 SHA1withDSA, otherwise if it is + * an RSA private key, then the signature algorithm will be + * MD5withRSA. 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 algorithm 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 + * null, a default value of 90 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. + * + *

+   *  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
+   *  }
+   * 
+ * + * @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. + * + *
+   *  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
+   *  }
+   * 
+ * + * IMPORTANT: 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 certificate. + */ + 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 System.out. + * + * @param certificate the certificate to process. + * @throws CertificateEncodingException if an exception occurs while obtaining + * the DER encoded form certificate. + */ + 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. + *

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

+ * 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 -delete keytool command handler is used to delete from the key + * store the entry associated with a designated alias. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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. + *

+ * Unlike in other keytool handlers, the default value (mykey) 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 -export 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. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-file FILE_NAME
+ *
The fully qualified path of the file where the certificate will be + * exported to. If omitted, STDOUT will be used instead. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-rfc
+ *
Use RFC-1421 specifications when encoding the output. + *

+ * + *
-v
+ *
Output the certificate in binary DER encoding. This is the default + * output format of the command if neither -rfc nor + * -v options were detected on the command line. If both this + * option and the -rfc option are detected on the command + * line, the tool will opt for the RFC-1421 style encoding.
+ *
+ */ +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 -genkey 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. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-keyalg ALGORITHM
+ *
Use this option to specify the canonical name of the key-pair + * generation algorithm. The default value for this option is + * DSS (a synonym for the Digital Signature Algorithm also + * known as DSA). + *

+ * + *
-keysize KEY_SIZE
+ *
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 1024 will be used if this option is + * omitted from the command line. + *

+ * + *
-sigalg ALGORITHM
+ *
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 -keyalg option. If the key-pair + * generation algorithm is DSA, the value for the signature + * algorithm will be SHA1withDSA. If on the other hand the + * key-pair generation algorithm is RSA, then the tool will + * use MD5withRSA as the signature algorithm. + *

+ * + *
-dname NAME
+ *
This a mandatory value for this command. If this option is omitted + * the tool will prompt you to enter a Distinguished Name to use as + * both the Owner and Issuer of the generated self-signed + * certificate. + *

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

+ *
CN
+ *
The Common Name; e.g. "host.domain.com"
+ * + *
OU
+ *
The Organizational Unit; e.g. "IT Department"
+ * + *
O
+ *
The Organization Name; e.g. "The Sample Company"
+ * + *
L
+ *
The Locality Name; e.g. "Sydney"
+ * + *
ST
+ *
The State Name; e.g. "New South Wales"
+ * + *
C
+ *
The 2-letter Country identifier; e.g. "AU"
+ *
+ *

+ * When specified with a -dname 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: + *

+ *        CN=host.domain.com, O=The Sample Company, L=Sydney, ST=NSW, C=AU
+ *      
+ * If this option is omitted, the tool will prompt you to enter the + * information through the console. + *

+ * + *
-keypass PASSWORD
+ *
Use this option to specify the password which the tool will use to + * protect the newly created Key Entry. + *

+ * If this option is omitted, you will be prompted to provide a password. + *

+ * + *
-validity DAY_COUNT
+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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; + +/** + * NOT IMPLEMENTED YET + *

+ * The -identitydb 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. + *

+ * Possible options for this command are: + *

+ *

+ *
-file FILE_NAME
+ *
The fully qualified path of the identity file to import. If this + * option is omitted, the tool will process STDIN. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 -import 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. + *

+ * If the Alias 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 Trusted Certificate, already stored in the key + * store. If the -trustcacerts option is present, an additional + * key store, of type JKS named cacerts, and assumed + * to be present in ${JAVA_HOME}/lib/security will also be + * consulted if found --${JAVA_HOME} refers to the location of an + * installed Java Runtime Environment (JRE). If no chain-of-trust can be + * established, and unless the -noprompt option has been specified, + * the certificate is printed to STDOUT and the user is prompted for a + * confirmation. + *

+ * If Alias exists in the key store, the tool will treat the + * certificate(s) read from the input source as a Certificate Reply, + * which can be a chain of certificates, that eventually would replace the chain + * of certificates associated with the Key Entry of that Alias. + * 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 Trusted Certificates already present in the key store. + * Again, if the -trustcacerts option is specified, additional + * Trusted Certificates in the same cacerts key store will + * be considered. If no chain-of-trust can be established, the operation will + * abort. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-file FILE_NAME
+ *
The fully qualified path of the file to read from. If omitted, the + * tool will process STDIN. + *

+ * + *
-keypass PASSWORD
+ *
Use this option to specify the password which the tool will use to + * protect the Key Entry associated with the designated Alias, + * when replacing this Alias' chain of certificates with that found + * in the certificate reply. + *

+ * 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 then be prompted to provide a password. + *

+ * + *
-noprompt
+ *
Use this option to prevent the tool from prompting the user. + *

+ * + *
-trustcacerts
+ *
Use this option to indicate to the tool that a key store, of type + * JKS, named cacerts, and usually located in + * lib/security in an installed Java Runtime Environment + * should be considered when trying to establish chain-of-trusts. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 + * cacerts 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, alias MUST NOT yet exist + * in the key store. + *

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

+ * If the -trustcacerts 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 JKS named cacerts and usually + * located in ${JAVA_HOME}/lib/security, where + * ${JAVA_HOME} is the root folder location of a Java runtime. + *

+ * 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 STDOUT, and the user is prompted to verify it, + * with the option of aborting the import operation. If however the option + * -noprompt 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. + *

+ * When importing a certificate reply, the reply is validated using trusted + * certificates from the key store, and optionally (if the option + * -trustcacerts was detected on the command line) certificates + * found in the key store, of type JKS named cacerts + * located in ${JAVA_HOME}/lib/security, where + * ${JAVA_HOME} 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 Issuer + * of the certificate at position i is the Subject of + * the certificate at position i + 1. + *

+ * This method uses selfSignedCertificate to discover the first + * certificate in the chain. The Trust Anchor of the chain; i.e. the + * self-signed CA certificate, if it exsits, will be discovered/established + * later by an appropriate Certificate Path Validator. + *

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

+ * if promptUser is true, 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 promptUser + * parameter is false 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 true if the validation succeeds; or false + * 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 CertPathParameters 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 -keyclone 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. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-dest ALIAS
+ *
Use this option to specify the new Alias which will be used + * to identify the cloned copy of the Key Entry. + *

+ * + *
-keypass PASSWORD
+ *
Use this option to specify the password which the tool will use to + * unlock the Key Entry associated with the designated Alias. + *

+ * If this option is omitted, the tool will first attempt to unlock the + * Key Entry using the same password protecting the key store. If + * this fails, you will then be prompted to provide a password. + *

+ * + *
-new PASSWORD
+ *
Use this option to specify the password protecting the private key + * material of the newly cloned copy of the Key Entry. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 -keypasswd keytool command handler is used to change the password + * protecting the private key associated to a designated alias. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-keypass PASSWORD
+ *
Use this option to specify the password which the tool will use to + * unlock the Key Entry associated with the designated Alias. + *

+ * If this option is omitted, the tool will first attempt to unlock the + * Key Entry using the same password protecting the key store. If + * this fails, you will then be prompted to provide a password. + *

+ * + *
-new PASSWORD
+ *
The new, and different, password which will be used to protect the + * private key material of the designated Key Entry. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 null 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 -list keytool command handler is used to output one or all key + * store entries. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-rfc
+ *
Use RFC-1421 specifications when encoding the output. + *

+ * + *
-v
+ *
Output the certificate in human-readable format. If both this option + * and the -rfc option are detected on the command line, the + * tool will opt for the human-readable form and will not abort the + * command.
+ *
+ */ +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 + * v (for verbose) and rfc. + *

+ * If both flags are false, only the fingerprint is generated, + * otherwise, if the v flag is set, then a human readable output + * is generated. If rfc is set, then an RFC-1421 like output + * is generated. + *

Note that both v and rfc cannot both be + * true 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 v (for verbose) and rfc. + *

+ * If both flags are false, only a fingerprint is generated, + * otherwise, if the v flag is set, then a human readable output + * is generated. If rfc is set, then an RFC-1421 like output + * is generated. + *

Note that both v and rfc cannot both be + * true 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. + *

+ * Except for the -identitydb command, available for importing + * JDK 1.1 identities 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. + *

+ * 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 -printcert keytool command handler is used to read a certificate + * from a designated file, and print its contents in a human-readable format. + *

+ * Possible options for this command are: + *

+ *

+ *
-file FILE_NAME
+ *
The fully qualified path of the file to read the certificate from. + * If this option is omitted, the tool will process STDIN. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 -selfcert keytool command handler is used to generate a self- + * signed X.509 version 1 certificate using key store credentials stored under a + * designated alias. + *

+ * Possible options for this command are: + *

+ *

+ *
-alias ALIAS
+ *
Every entry, be it a Key Entry or a Trusted + * Certificate, in a key store is uniquely identified by a user-defined + * Alias string. Use this option to specify the Alias to use + * when referring to an entry in the key store. Unless specified otherwise, + * a default value of mykey shall be used when this option is + * omitted from the command line. + *

+ * + *
-sigalg ALGORITHM
+ *
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 Alias. If the private key is a DSA one, + * the value for the signature algorithm will be SHA1withDSA. + * If on the other hand the private key is an RSA one, then + * the tool will use MD5withRSA as the signature algorithm. + *

+ * + *
-dname NAME
+ *
Use this option to specify the Distinguished Name of the + * newly generated self-signed certificate. If this option is omitted, the + * existing Distinguished Name of the base certificate in the chain + * associated with the designated Alias will be used instead. + *

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

+ *
CN
+ *
The Common Name; e.g. "host.domain.com"
+ * + *
OU
+ *
The Organizational Unit; e.g. "IT Department"
+ * + *
O
+ *
The Organization Name; e.g. "The Sample Company"
+ * + *
L
+ *
The Locality Name; e.g. "Sydney"
+ * + *
ST
+ *
The State Name; e.g. "New South Wales"
+ * + *
C
+ *
The 2-letter Country identifier; e.g. "AU"
+ *
+ *

+ * When specified with a -dname 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: + *

+ *        CN=host.domain.com, O=The Sample Company, L=Sydney, ST=NSW, C=AU
+ *      
+ *

+ * + *
-validity DAY_COUNT
+ * + *
-keypass PASSWORD
+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 -storepasswd keytool command handler is used to change the + * password which protects the integrity of the key store. + *

+ * Possible options for this command are: + *

+ *

+ *
-new PASSWORD
+ *
The new, and different, password which will be used to protect the + * designated key store. + *

+ * + *
-storetype STORE_TYPE
+ *
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 + * keystore.type in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + *

+ * + *
-keystore URL
+ *
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 .keystore located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using user.home + * as argument. + *

+ * 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 file:. + *

+ * + *
-storepass PASSWORD
+ *
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. + *

+ * + *
-provider PROVIDER_CLASS_NAME
+ *
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. + *

+ * + *
-v
+ *
Use this option to enable more verbose output.
+ *
+ */ +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 + */ +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 tnameserv and persistent orbd. + * + * @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 ior + 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), + "", + 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), + "", + 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_m.getName()_i = + * m.getDeclaringClass().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, "", + 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), + "", + 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, "", + Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), + null, null); + code.visitVarInsn(Opcodes.ALOAD, 0); + code.visitMethodInsn + (Opcodes.INVOKESPECIAL, superInternalName, "", + 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, "", + 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, "", + 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), + "", + 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), + "", + 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), + "", + 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), + "", + 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, "", + 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, "", + Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null); + init.visitVarInsn(Opcodes.ALOAD, 0); + init.visitMethodInsn + (Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "", + 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 = + 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), + "", + 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), + "", + 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), + "", + 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), + "", + 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 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 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 classes = new ArrayList(); + // The class path to use. + String classpath; + + // FIXME: taken from ClassLoader, should share it. + private static void addFileURL(ArrayList 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 list = new ArrayList(); + 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 "<a + * href="mailto:user@domain.tld">Real Name</a>. + */ + public static final EmailReplacement MAILTO_NAME = new EmailReplacement(); + + /** + * Specifies that author tag text matching "Real Name + * (user@domain.tld)" is converted to "Real Name (<a + * href="mailto:user@domain.tld">user@domain.tld</a>). + */ + 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 = " at "; + private static String dotReplacement = " dot "; + + 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 . (dot). + */ + private static final Pattern dotPattern = Pattern.compile("[.]"); + + /** + * Matches @ (at sign). + */ + private static final Pattern atPattern = Pattern.compile("[@]"); + + /** + * Matches Real Name (user@domain.tld). + */ + 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("
"); + result.append("
"); + if (tags.length == 1) { + result.append(SINGLE_HEADER); + } + else { + result.append(MULTI_HEADER); + } + result.append("
"); + for (int i = 0; i < tags.length; i++) { + result.append("
"); + result.append(replaceEmail(tags[i].text())); + result.append("
"); + } + result.append("
"); + 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 "" + realName + ""; + } + else if (EmailReplacement.NAME_MAILTO_ADDRESS == emailReplacementType) { + return realName + " (" + emailAddress + ")"; + } + 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 @ (at sign) in email + * addresses should be replaced if the email replacement type is + * NAME_MANGLED_ADDRESS. + */ + public static void setAtReplacement(String atReplacement) + { + AuthorTaglet.atReplacement = atReplacement; + } + + /** + * Set the HTML text by which the . (dot) in email + * addresses should be replaced if the email replacement type is + * NAME_MANGLED_ADDRESS. + */ + 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 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 "" + tag.text() + ""; + } + + 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("
"); + for (int i = 0; i < tags.length; i++) { + if (tags[i].text().length() > 0) { + result.append("
Copyright © " + tags[i].text() + "
"); + } + } + result.append("
"); + 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("
"); + result.append(HEADER); + result.append("
"); + result.append("
"); + for (int i = 0; i < tags.length; i++) { + result.append("
"); + result.append(tags[i].text()); + result.append("
"); + } + result.append("
"); + 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("
"); + result.append(header); + result.append("
"); + result.append("
"); + for (int i = 0; i < tags.length; i++) { + result.append("
"); + result.append(tags[i].text()); + result.append("
"); + } + result.append("
"); + 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("
"); + result.append("
"); + result.append(HEADER); + result.append("
"); + for (int i = 0; i < tags.length; ++i) { + if (tags[i].text().length() > 0) { + result.append("
"); + result.append(inlineTagRenderer.renderInlineTags(tags[i].inlineTags(), context)); + result.append("
"); + } + } + result.append("
"); + 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("
"); + result.append("
"); + result.append("
"); + result.append(HEADER); + result.append("
"); + 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("
"); + result.append(""); + 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 tnameserv and persistent orbd. + * + * @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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +

About this API documentation

+ + + + + + + + + + + +
+ + +
+ +
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 @@ + + + + + + + + + + + + + + + + + + + <xsl:value-of select="concat(/gjdoc:rootdoc/gjdoc:title, ' - All Classes')"/> + + + + + + + + + + + +
+
+ + +
+ +
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 @@ + + + + + + + + + + + + + + + + + + + <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"/> + + + + + + All Classes

+ + + + + +
+
+ + +
+
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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Alphabetical Index +

+ +
+ + + + + + + + + + +
+ + +

+

+ +
+ + + + + + + + + + + + + +
+ + + +
+ +
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 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +

+ Alphabetical Index + + - + + +

+ +
+ + + + + + + + + + +
+ + + +

+ +
+ +
+ + + + + + + + + + + + + +
+ + + +
+ +
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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + +

+ Uses in package + +

+ +
+ + +
+ + + + + + + + + + + + + + + + + +
+
+ + + +

+ + + + + Classes in derived from + + + Fields in of type + + + Methods in returning + + + Methods in accepting parameters of type + + + Methods in throwing + + + Constructors in accepting parameters of type + + + Constructors in throwing + + + Unknown ID + + +

+
+ +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +

+ Uses of class + + +

+
+ + + + + + + + + + + + + + + + +
+ + + +
+ +
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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +

Field Details

+ + + + + +
+ + +

Constructor Details

+ + + + + +
+ + +

Method Details

+ + + + + + +
+ + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +

+ + + Interface + + + Class + + + +

+ +
+ + + + + + + + Enclosing Class:
+ + + + +
+ + +

+ + + + All Superinterfaces: + + + All Implemented Interfaces: + + + +
+ + + + + + + + , + + + +

+ + + + + + All Known Direct Subinterfaces:
+ + + + + + + + , + + +
+
+ + + + + + Known Implementing Classes:
+ + + + + + + + , + + +
+
+ + + + + + Known Direct Subclasses:
+ + + + + + + + , + + +
+
+ +


+ +
+ + + + + static + final + + + interface + + + abstract + class + + + +
+ + + + + extends + + + + + + + + +
+
+ + + + + implements + + + + + + + + + + + + , + + + +
+ + + +

+ + +

+ + + +
+
+ + + + +
+ + + + + + +
+ +
+
+ + + +
+
+ + + +
+
+ +
+ + + + + + + + + + + + + +
Field Summary
+ + + + +
+ +
+ + + + + + + + + + + + +
Method Summary
+ + + + +
+ +
+ + + + + + + + + + + + + + +
Constructor Summary
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + +
+ + + + native + + + static + + + final + + + abstract + + + transient + + + volatile + + + synchronized + + + + + + static + + + abstract + + + transient + + + volatile + + + synchronized + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + ) + + + + +
+ + + + Deprecated. + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + +   + + + , + + + + + + + + + +
+ +
+ + + + + + + - + + + + +
+
+
+
+ + + +
See Also:
+ +
+ + +
+ + + +
+
+
+
+
+ + + + + + +
+ +

+ +

+ + + + + + + +

+ +

+ + + + +

+ + + +
+ + +

+ + + + + + + + +


+ + +
+ + + + + + + +
+ +

+ +

+ + + + + + + ( + + ) +

+ + + + +
+ + + +
+
+ +

+ + + + +

Parameters:
+ + + + +
Returns:
+
+
+ + + +
+
+
+ + +
Throws:
+
+ +
+ + + + + + + + + + + - + + + +
+
+
+
+ + + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + images/tree-final-node.png + + + images/tree-node.png + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + * + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+            
+              
+              
+              
+            
+          
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-- + + + + + + + + + + + + + + + +
+
Methods inherited from class
+
+ + , + +
+
+
+ + + + + + + + + + + +
+
Fields inherited from class
+
+ + , + +
+
+
+ +
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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + +
+
+ + + + + + +
+
+ +
+
+ + + +
+
+
+
+ +
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 @@ + + + + + + + + + + + + + + + + + + This file was generated by Gjdoc + on . + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + GNU Gjdoc HTML DocTranslet + + 0.6.1 + + + HTML + + + + index.html + index + index.xsl + HTML Index file + + + + index_noframes.html + index_noframes + index_noframes.xsl + HTML Index file (No Frames) + + + + descriptor.xml + descriptor + descriptor.xsl + HTML Descriptor file + + + + allclasses.html + allclasses + allclasses.xsl + HTML All Classes file + + + + allpackages.html + allpackages + allpackages.xsl + HTML All Packages file + + + + fulltree.html + fulltree + fulltree.xsl + HTML Tree file + + + + + + package + + packagedoc.xsl + HTML Documentation for package + + + + + + + class + + classdoc.xsl + HTML Documentation for + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + . + + (implements + + + + + + + + + + + + + + + + + + + + + + + + , + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + +
  • +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + +

    + + + Full Class Tree + + for + + + + + Class Hierarchy for Package + + +

    + + +
      +
    • + +
    • +
    +
    + + + + + + + + + + + + + + + +
    + + + +
    +
    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 @@ + + + + + + + + + + + + + + + + + + GNU Gjdoc HTML Documentation + + + index.html + index.xsl + HTML Index file + + + + index_noframes.html + index_noframes.xsl + HTML Index file (No Frames) + + + + descriptor.xml + descriptor.xsl + HTML Descriptor file + + + + allclasses.html + allclasses.xsl + HTML All Classes file + + + + + allpackages.html + allpackages.xsl + HTML All Packages file + + + + + + fulltree.html + fulltree.xsl + HTML Tree file + + + + + + + + + alphaindex.html + + alphaindex_chunked.xsl + HTML Alphabetical Index (Overview) + + + + + + + alphaindex_chunked.xsl + + + + + + + + alphaindex.html + alphaindex.xsl + HTML Alphabetical Index + + + + + + + + + + packagedoc.xsl + HTML Documentation for package + + + + + packageclasses.xsl + HTML Class list for package + + + + + + + fulltree.xsl + HTML Hierarchy for package + + + + + + + + + + classdoc.xsl + HTML Documentation for + + + + + src-html/ + + classdoc-source.xsl + HTML Source for + + + + + + class-use/ + + classdoc-uses.xsl + usage information for + + + + + + + + + user.css + + user-supplied CSS stylesheet + + + + + gjdochtml.css + res/gjdochtml.css + CSS base stylesheet + + + gjdochtml-clean.css + res/gjdochtml-clean.css + CSS stylesheet 'Clean' + + + gjdochtml-sclara.css + res/gjdochtml-sclara.css + CSS stylesheet 'Santa Clara' + + + gjdochtml-fixed.css + res/gjdochtml-fixed.css + CSS stylesheet 'Fixed' + + + + + + gjdoc.js + res/gjdoc.js + JavaScript helper file + + + + + help.html + help.xsl + help file + + + + + about.html + about.xsl + about file + + + + + deprecated.html + deprecated.xsl + deprecated list + + + + + serialized.html + serialized.xsl + serialization information + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    + +
    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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + - + + + Package + + + Nested class in class + + + + Nested exception in class + + + + Nested error in class + + + + Nested interface in class + + + + Class in package + + + + Exception in package + + + + Error in package + + + + Interface in package + + + + Method in class + + + + Field in class + + + +
    +
    + + + +
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + &nbsp; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + +
    + +
    + +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + ) + + + + <xsl:value-of select="$v_title"/> + + + + + + + + + + + + + + + + + + + + + + . + + + java.lang. + + + + + + + + + + + + + ( + + + + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + +
    + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +

    +
    + +
    + + + +
    +
    See Also:
    +
    +
    Description
    +
    +
    + + + + +

    + + + + + + + +
    +
    +
    + +

    All Packages

    + + + + +
    +
    +
    + + +
    + + + +
    +
    +
    + + + + + + + + + + + + + + + + +
    +
    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 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + <xsl:value-of select="concat(/gjdoc:rootdoc/gjdoc:title, ' - ', 'Classes in ', $gjdoc.outputfile.info)"/> + + + + + + + + + + + +

    Exceptions

    + + + + +
    + + +

    Errors

    + + + + +
    + + + +
    + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    Package

    + +
    + +
    + + + + + + + + +
    Interface Summary
    +
    + + + + + + + + +
    Class Summary
    +
    + + + + + + + + +
    Exception Summary
    +
    + + + + + + + + +
    Error Summary
    +
    + +

    +

    Package Description

    + +
    + +
    + +
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + No description available. + + + + + +
    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 @@ + +

    Using the API Documentation

    + +

    + Write me. +

    + 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 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 @@ + + + + + + + + + + + + + + +%ISOamsa; +]]> + + + +%ISOamsb; +]]> + + + +%ISOamsc; +]]> + + + +%ISOamsn; +]]> + + + +%ISOamso; +]]> + + + +%ISOamsr; +]]> + + + +%ISObox; +]]> + + + +%ISOcyr1; +]]> + + + +%ISOcyr2; +]]> + + + +%ISOdia; +]]> + + + +%ISOgrk1; +]]> + + + +%ISOgrk2; +]]> + + + +%ISOgrk3; +]]> + + + +%ISOgrk4; +]]> + + + +%ISOlat1; +]]> + + + +%ISOlat2; +]]> + + + +%ISOnum; +]]> + + + +%ISOpub; +]]> + + + +%ISOtech; +]]> + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + +%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 @@ + + + + + + + +%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 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 @@ + + +

    + Sorry, no help available. +

    + 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 Binary files /dev/null and b/libjava/classpath/tools/resource/gnu/classpath/tools/gjdoc/htmldoclet/inherit.png 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.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 @@ + + + + + + + + + + The Relax NG grammar for an classdoc XML document generated by + GNU Gjdoc. + + + + + The root element for a Gjdoc classdoc XML document. + + + + + Corresponds to a Javadoc API com.sun.javadoc.ClassDoc + object, the subtree of the full generated documentation + corresponding to a particular Java class. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Corresponds to the abstract class + com.sun.javadoc.Doc, the common base class for + all documentation classes. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Corresponds to the abstract class + com.sun.javadoc.ProgramElementDoc. + + + + + + + + + + + + + + + + + + + + + + + + + + Corresponds to the abstract class + com.sun.javadoc.MemberDoc. + + + + + + + + + + Corresponds to the abstract class + com.sun.javadoc.ExecutableMemberDoc. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Corresponds to an object of class + com.sun.javadoc.ConstructorDoc. + + + + + + + + + + Corresponds to an object of class + com.sun.javadoc.MethodDoc. + + + + + + + + + + + Corresponds to an object of class + com.sun.javadoc.FieldDoc. + + + + + + + + + + + + + + + + + + + + + + + + + Specifies a constructor of the class. + + + + + + + + + + + Specifies a method of the class. + + + + + + + + + + + Specifies a field of the class. + + + + + + + + + + + + + Presence means ClassDoc.isAbstract() returns + true. + + + + + + + + + + Presence means Doc.isClass() returns + true. + + + + + + + + + + Presence means Doc.isConstructor() returns + true. + + + + + + + + + + Presence means Doc.isError() returns + true. + + + + + + + + + + Presence means Doc.isException() returns + true. + + + + + + + + + + Presence means ClassDoc.isSerializable() returns + true. + + + + + + + + + + Presence means ClassDoc.isExternalizable() + returns true. + + + + + + + + + + Presence means Doc.isField() returns + true. + + + + + + + + + + Presence means Doc.isIncluded() returns + true. + + + + + + + + + + Presence means Doc.isInterface() returns + true. + + + + + + + + + + Presence means Doc.isMethod() returns + true. + + + + + + + + + + Presence means Doc.isOrdinaryClass() returns + true. + + + + + + + + + + Presence means ProgramElementDoc.isFinal() + returns true. + + + + + + + + + + Presence means ProgramElementDoc.isStatic() + returns true. + + + + + + + + + + Presence means FieldDoc.isTransient() + returns true. + + + + + + + + + + Presence means FieldDoc.isVolatile() + returns true. + + + + + + + + + + Presence means ExecutableMemberDoc.isNative() + returns true. + + + + + + + + + + Presence means + ExecutableMemberDoc.isSynchronized() returns + true. + + + + + + + + + + Presence means + ClassDoc.definesSerializableFields() returns + true. + + + + + + + + + + Corresponds to the access modifier (public, protected, + private) specified by a ProgramElementDoc. + + + + + + This value is determined by calling + ProgramElementDoc.isPublic(), + ProgramElementDoc.isProtected(), + ProgramElementDoc.isPrivate() and + ProgramElementDoc.isPackagePrivate(). + + + public + protected + private + package + + + + + + + + Corresponds to the type returned by a call to + com.sun.javadoc.Classdoc.containingClass(). + + + + + The full name of the outer class containing the class, if + this class is an inner class. + + + + + + + + Corresponds to an entry in the array returned by a + com.sun.javadoc.ExecutableMemberDoc.parameters(). + + + + + A parameter for a method or constructor call. + + + + + + + + + + + Corresponds to an entry in the array returned by a + com.sun.javadoc.ExecutableMemberDoc.thrownExceptions(). + + + + + An exception thrown by a method or constructor. + + + + + + + + + Corresponds to the signature specified by a + com.sun.javadoc.MethodDoc. + + + + + The signature of a method or constructor. + + + + The full signature of a method or constructor, as + returned by + com.sun.javadoc.ExecutableMemberDoc.signature(). + + + + + + The "flat" signature of a method or constructor, as + returned by + com.sun.javadoc.ExecutableMemberDoc.flatSignature(). + + + + + + + + + Corresponds to the type returned by + com.sun.javadoc.MethodDoc.returnType(). + + + + + The type returned by a method. + + + + + + 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 @@ + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specifies mixed content comprised of gjdoc tags, + HTML tags, taglet output, and text. + + + + + + + + + + + Specifies an interface that the class implements. + + + + + + + + + + + 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. + + + + + + + + + + The name of the class, without package prefix. If the + class is an inner class, this includes the name of its + outer class. + + + + + + + + + + + The dimension of this typedef, represented by a zero or + more repetitions of the string "[]". + + + + + + + + + + + The name of some Java Entity (package, class, constructor, + method, field.) + + + + + + + + + + The fully qualified name of the class. + + + + + + + + + + Specifies the superclass of the class. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + gjdoc:tag + + + + + + + + + + + + + + + + + + + + + + + + + The full name of the package containing the class. + + + + + + + + + + + A string generated by a Taglet.toString() method. + + + + The name of the tag this Taglet was assigned to. + + + + + + + + + + Exists when the described class is a subclass of + java.lang.Error. + + + + + + + + Exists when the described class is a subclass of + java.lang.Exception. + + + + + + + + Exists when the described class is an interface. + + + + + + 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 @@ + + + + + + + + + + The Relax NG grammar for the XML index file generated by GNU + Gjdoc. + + + + + The root element for a Gjdoc index XML document. + + + + + Corresponds to the Javadoc API RootDoc object, the root of + the generated documentation. + + + + + + + + + + + + + + + + + + + + + + + + Corresponds to a class contained in a package or in + another class. + + + + + + + + + + Corresponds to a class named on the Gjdoc command + line. This is a class the user explicitly wants + documentation generated for. + + + + + The name of the class as given by the user on the command + line. (CHECK) + + + + + + + + + + + Corresponds to a package named on the Gjdoc command + line. This is a package the user explicitly wants + documentation generated for. + + + + + The full name of the package. + + + + + + + + + + + Corresponds to a package for which XML documentation + has been generated. This is not necessarily a package + the user requested generation for. + + + + + + + + + + + + + + + Corresponds to a class for which XML documentation has + been generated. + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 , or blank the field by entering the <.> character\n\ +before hitting .\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 this, 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 +#include +#include +#include +#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; +} -- cgit v1.2.3